Skip to content

Commit 99afc6e

Browse files
committed
Auto merge of #6881 - flip1995:rustup, r=flip1995
Rustup changelog: none
2 parents 8222d48 + 9c1dd0c commit 99afc6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+173
-138
lines changed

clippy_lints/src/attrs.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,15 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
276276
}
277277

278278
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
279+
let attrs = cx.tcx.hir().attrs(item.hir_id());
279280
if is_relevant_item(cx, item) {
280-
check_attrs(cx, item.span, item.ident.name, &item.attrs)
281+
check_attrs(cx, item.span, item.ident.name, attrs)
281282
}
282283
match item.kind {
283284
ItemKind::ExternCrate(..) | ItemKind::Use(..) => {
284-
let skip_unused_imports = item.attrs.iter().any(|attr| attr.has_name(sym::macro_use));
285+
let skip_unused_imports = attrs.iter().any(|attr| attr.has_name(sym::macro_use));
285286

286-
for attr in item.attrs {
287+
for attr in attrs {
287288
if in_external_macro(cx.sess(), attr.span) {
288289
return;
289290
}
@@ -353,13 +354,13 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
353354

354355
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
355356
if is_relevant_impl(cx, item) {
356-
check_attrs(cx, item.span, item.ident.name, &item.attrs)
357+
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()))
357358
}
358359
}
359360

360361
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
361362
if is_relevant_trait(cx, item) {
362-
check_attrs(cx, item.span, item.ident.name, &item.attrs)
363+
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()))
363364
}
364365
}
365366
}

clippy_lints/src/cognitive_complexity.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ impl CognitiveComplexity {
7676

7777
if rust_cc > self.limit.limit() {
7878
let fn_span = match kind {
79-
FnKind::ItemFn(ident, _, _, _, _) | FnKind::Method(ident, _, _, _) => ident.span,
80-
FnKind::Closure(_) => {
79+
FnKind::ItemFn(ident, _, _, _) | FnKind::Method(ident, _, _) => ident.span,
80+
FnKind::Closure => {
8181
let header_span = body_span.with_hi(decl.output.span().lo());
8282
let pos = snippet_opt(cx, header_span).and_then(|snip| {
8383
let low_offset = snip.find('|')?;

clippy_lints/src/derive.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
170170
}) = item.kind
171171
{
172172
let ty = cx.tcx.type_of(item.def_id);
173-
let is_automatically_derived = is_automatically_derived(&*item.attrs);
173+
let attrs = cx.tcx.hir().attrs(item.hir_id());
174+
let is_automatically_derived = is_automatically_derived(attrs);
174175

175176
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
176177
check_ord_partial_ord(cx, item.span, trait_ref, ty, is_automatically_derived);

clippy_lints/src/doc.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,14 @@ impl_lint_pass!(DocMarkdown =>
208208
);
209209

210210
impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
211-
fn check_crate(&mut self, cx: &LateContext<'tcx>, krate: &'tcx hir::Crate<'_>) {
212-
check_attrs(cx, &self.valid_idents, &krate.item.attrs);
211+
fn check_crate(&mut self, cx: &LateContext<'tcx>, _: &'tcx hir::Crate<'_>) {
212+
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
213+
check_attrs(cx, &self.valid_idents, attrs);
213214
}
214215

215216
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
216-
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
217+
let attrs = cx.tcx.hir().attrs(item.hir_id());
218+
let headers = check_attrs(cx, &self.valid_idents, attrs);
217219
match item.kind {
218220
hir::ItemKind::Fn(ref sig, _, body_id) => {
219221
if !(is_entrypoint_fn(cx, item.def_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) {
@@ -249,7 +251,8 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
249251
}
250252

251253
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'_>) {
252-
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
254+
let attrs = cx.tcx.hir().attrs(item.hir_id());
255+
let headers = check_attrs(cx, &self.valid_idents, attrs);
253256
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
254257
if !in_external_macro(cx.tcx.sess, item.span) {
255258
lint_for_missing_headers(cx, item.hir_id(), item.span, sig, headers, None, None);
@@ -258,7 +261,8 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
258261
}
259262

260263
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) {
261-
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
264+
let attrs = cx.tcx.hir().attrs(item.hir_id());
265+
let headers = check_attrs(cx, &self.valid_idents, attrs);
262266
if self.in_trait_impl || in_external_macro(cx.tcx.sess, item.span) {
263267
return;
264268
}

clippy_lints/src/entry.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_lint::{LateContext, LateLintPass};
99
use rustc_middle::hir::map::Map;
1010
use rustc_session::{declare_lint_pass, declare_tool_lint};
1111
use rustc_span::source_map::Span;
12+
use rustc_span::sym;
1213

1314
declare_clippy_lint! {
1415
/// **What it does:** Checks for uses of `contains_key` + `insert` on `HashMap`
@@ -111,7 +112,7 @@ fn check_cond<'a>(cx: &LateContext<'_>, check: &'a Expr<'a>) -> Option<(&'static
111112
return if match_type(cx, obj_ty, &paths::BTREEMAP) {
112113
Some(("BTreeMap", map, key))
113114
}
114-
else if is_type_diagnostic_item(cx, obj_ty, sym!(hashmap_type)) {
115+
else if is_type_diagnostic_item(cx, obj_ty, sym::hashmap_type) {
115116
Some(("HashMap", map, key))
116117
}
117118
else {

clippy_lints/src/exhaustive_items.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ impl LateLintPass<'_> for ExhaustiveItems {
7373
if_chain! {
7474
if let ItemKind::Enum(..) | ItemKind::Struct(..) = item.kind;
7575
if cx.access_levels.is_exported(item.hir_id());
76-
if !item.attrs.iter().any(|a| a.has_name(sym::non_exhaustive));
76+
let attrs = cx.tcx.hir().attrs(item.hir_id());
77+
if !attrs.iter().any(|a| a.has_name(sym::non_exhaustive));
7778
then {
7879
let (lint, msg) = if let ItemKind::Struct(ref v, ..) = item.kind {
7980
if v.fields().iter().any(|f| !f.vis.node.is_pub()) {

clippy_lints/src/functions.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
251251
hir_id: hir::HirId,
252252
) {
253253
let unsafety = match kind {
254-
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }, _, _) => unsafety,
255-
intravisit::FnKind::Method(_, sig, _, _) => sig.header.unsafety,
256-
intravisit::FnKind::Closure(_) => return,
254+
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }, _) => unsafety,
255+
intravisit::FnKind::Method(_, sig, _) => sig.header.unsafety,
256+
intravisit::FnKind::Closure => return,
257257
};
258258

259259
// don't warn for implementations, it's not their fault
@@ -267,9 +267,8 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
267267
..
268268
},
269269
_,
270-
_,
271270
)
272-
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }, _, _) => {
271+
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }, _) => {
273272
self.check_arg_number(cx, decl, span.with_hi(decl.output.span().hi()))
274273
},
275274
_ => {},
@@ -281,7 +280,8 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
281280
}
282281

283282
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
284-
let attr = must_use_attr(&item.attrs);
283+
let attrs = cx.tcx.hir().attrs(item.hir_id());
284+
let attr = must_use_attr(attrs);
285285
if let hir::ItemKind::Fn(ref sig, ref _generics, ref body_id) = item.kind {
286286
let is_public = cx.access_levels.is_exported(item.hir_id());
287287
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
@@ -292,7 +292,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
292292
check_needless_must_use(cx, &sig.decl, item.hir_id(), item.span, fn_header_span, attr);
293293
return;
294294
}
295-
if is_public && !is_proc_macro(cx.sess(), &item.attrs) && attr_by_name(&item.attrs, "no_mangle").is_none() {
295+
if is_public && !is_proc_macro(cx.sess(), attrs) && attr_by_name(attrs, "no_mangle").is_none() {
296296
check_must_use_candidate(
297297
cx,
298298
&sig.decl,
@@ -313,12 +313,11 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
313313
if is_public && trait_ref_of_method(cx, item.hir_id()).is_none() {
314314
check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
315315
}
316-
let attr = must_use_attr(&item.attrs);
316+
let attrs = cx.tcx.hir().attrs(item.hir_id());
317+
let attr = must_use_attr(attrs);
317318
if let Some(attr) = attr {
318319
check_needless_must_use(cx, &sig.decl, item.hir_id(), item.span, fn_header_span, attr);
319-
} else if is_public
320-
&& !is_proc_macro(cx.sess(), &item.attrs)
321-
&& trait_ref_of_method(cx, item.hir_id()).is_none()
320+
} else if is_public && !is_proc_macro(cx.sess(), attrs) && trait_ref_of_method(cx, item.hir_id()).is_none()
322321
{
323322
check_must_use_candidate(
324323
cx,
@@ -345,15 +344,16 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
345344
check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
346345
}
347346

348-
let attr = must_use_attr(&item.attrs);
347+
let attrs = cx.tcx.hir().attrs(item.hir_id());
348+
let attr = must_use_attr(attrs);
349349
if let Some(attr) = attr {
350350
check_needless_must_use(cx, &sig.decl, item.hir_id(), item.span, fn_header_span, attr);
351351
}
352352
if let hir::TraitFn::Provided(eid) = *eid {
353353
let body = cx.tcx.hir().body(eid);
354354
Self::check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.hir_id());
355355

356-
if attr.is_none() && is_public && !is_proc_macro(cx.sess(), &item.attrs) {
356+
if attr.is_none() && is_public && !is_proc_macro(cx.sess(), attrs) {
357357
check_must_use_candidate(
358358
cx,
359359
&sig.decl,

clippy_lints/src/future_not_send.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
5858
_: Span,
5959
hir_id: HirId,
6060
) {
61-
if let FnKind::Closure(_) = kind {
61+
if let FnKind::Closure = kind {
6262
return;
6363
}
6464
let ret_ty = utils::return_ty(cx, hir_id);

clippy_lints/src/inline_fn_without_body.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ declare_lint_pass!(InlineFnWithoutBody => [INLINE_FN_WITHOUT_BODY]);
3434
impl<'tcx> LateLintPass<'tcx> for InlineFnWithoutBody {
3535
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
3636
if let TraitItemKind::Fn(_, TraitFn::Required(_)) = item.kind {
37-
check_attrs(cx, item.ident.name, &item.attrs);
37+
let attrs = cx.tcx.hir().attrs(item.hir_id());
38+
check_attrs(cx, item.ident.name, attrs);
3839
}
3940
}
4041
}

clippy_lints/src/loops/empty_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_lint::LateContext;
77
pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, loop_block: &'tcx Block<'_>) {
88
if loop_block.stmts.is_empty() && loop_block.expr.is_none() && !is_in_panic_handler(cx, expr) {
99
let msg = "empty `loop {}` wastes CPU cycles";
10-
let help = if is_no_std_crate(cx.tcx.hir().krate()) {
10+
let help = if is_no_std_crate(cx) {
1111
"you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body"
1212
} else {
1313
"you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body"

clippy_lints/src/loops/explicit_iter_loop.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_errors::Applicability;
44
use rustc_hir::{Expr, Mutability};
55
use rustc_lint::LateContext;
66
use rustc_middle::ty::{self, Ty, TyS};
7-
use rustc_span::symbol::sym;
7+
use rustc_span::sym;
88

99
use crate::utils::{is_type_diagnostic_item, match_type, paths};
1010

@@ -55,9 +55,9 @@ fn is_ref_iterable_type(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
5555
is_iterable_array(ty, cx) ||
5656
is_type_diagnostic_item(cx, ty, sym::vec_type) ||
5757
match_type(cx, ty, &paths::LINKED_LIST) ||
58-
is_type_diagnostic_item(cx, ty, sym!(hashmap_type)) ||
59-
is_type_diagnostic_item(cx, ty, sym!(hashset_type)) ||
60-
is_type_diagnostic_item(cx, ty, sym!(vecdeque_type)) ||
58+
is_type_diagnostic_item(cx, ty, sym::hashmap_type) ||
59+
is_type_diagnostic_item(cx, ty, sym::hashset_type) ||
60+
is_type_diagnostic_item(cx, ty, sym::vecdeque_type) ||
6161
match_type(cx, ty, &paths::BINARY_HEAP) ||
6262
match_type(cx, ty, &paths::BTREEMAP) ||
6363
match_type(cx, ty, &paths::BTREESET)

clippy_lints/src/loops/for_kv_map.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::utils::{is_type_diagnostic_item, match_type, multispan_sugg, paths, s
44
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, Pat, PatKind};
55
use rustc_lint::LateContext;
66
use rustc_middle::ty;
7+
use rustc_span::sym;
78

89
/// Checks for the `FOR_KV_MAP` lint.
910
pub(super) fn check<'tcx>(
@@ -35,7 +36,7 @@ pub(super) fn check<'tcx>(
3536
_ => arg,
3637
};
3738

38-
if is_type_diagnostic_item(cx, ty, sym!(hashmap_type)) || match_type(cx, ty, &paths::BTREEMAP) {
39+
if is_type_diagnostic_item(cx, ty, sym::hashmap_type) || match_type(cx, ty, &paths::BTREEMAP) {
3940
span_lint_and_then(
4041
cx,
4142
FOR_KV_MAP,

clippy_lints/src/loops/manual_memcpy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ struct MinifyingSugg<'a>(Sugg<'a>);
203203

204204
impl<'a> MinifyingSugg<'a> {
205205
fn as_str(&self) -> &str {
206-
let Sugg::NonParen(s) | Sugg::MaybeParen(s) | Sugg::BinOp(_, s) = &self.0;
206+
let (Sugg::NonParen(s) | Sugg::MaybeParen(s) | Sugg::BinOp(_, s)) = &self.0;
207207
s.as_ref()
208208
}
209209

@@ -328,7 +328,7 @@ fn is_slice_like<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'_>) -> bool {
328328
_ => false,
329329
};
330330

331-
is_slice || is_type_diagnostic_item(cx, ty, sym::vec_type) || is_type_diagnostic_item(cx, ty, sym!(vecdeque_type))
331+
is_slice || is_type_diagnostic_item(cx, ty, sym::vec_type) || is_type_diagnostic_item(cx, ty, sym::vecdeque_type)
332332
}
333333

334334
fn fetch_cloned_expr<'tcx>(expr: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> {

clippy_lints/src/loops/needless_collect.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ fn check_needless_collect_direct_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCont
2929
then {
3030
let ty = cx.typeck_results().node_type(ty.hir_id);
3131
if is_type_diagnostic_item(cx, ty, sym::vec_type) ||
32-
is_type_diagnostic_item(cx, ty, sym!(vecdeque_type)) ||
32+
is_type_diagnostic_item(cx, ty, sym::vecdeque_type) ||
3333
match_type(cx, ty, &paths::BTREEMAP) ||
34-
is_type_diagnostic_item(cx, ty, sym!(hashmap_type)) {
34+
is_type_diagnostic_item(cx, ty, sym::hashmap_type) {
3535
if method.ident.name == sym!(len) {
3636
let span = shorten_needless_collect_span(expr);
3737
span_lint_and_sugg(
@@ -99,7 +99,7 @@ fn check_needless_collect_indirect_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCo
9999
if let Some(GenericArg::Type(ref ty)) = generic_args.args.get(0);
100100
if let ty = cx.typeck_results().node_type(ty.hir_id);
101101
if is_type_diagnostic_item(cx, ty, sym::vec_type) ||
102-
is_type_diagnostic_item(cx, ty, sym!(vecdeque_type)) ||
102+
is_type_diagnostic_item(cx, ty, sym::vecdeque_type) ||
103103
match_type(cx, ty, &paths::LINKED_LIST);
104104
if let Some(iter_calls) = detect_iter_and_into_iters(block, *ident);
105105
if iter_calls.len() == 1;

clippy_lints/src/macro_use.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
107107
if_chain! {
108108
if cx.sess().opts.edition >= Edition::Edition2018;
109109
if let hir::ItemKind::Use(path, _kind) = &item.kind;
110-
if let Some(mac_attr) = item
111-
.attrs
110+
let attrs = cx.tcx.hir().attrs(item.hir_id());
111+
if let Some(mac_attr) = attrs
112112
.iter()
113113
.find(|attr| attr.ident().map(|s| s.to_string()) == Some("macro_use".to_string()));
114114
if let Res::Def(DefKind::Mod, id) = path.res;

clippy_lints/src/main_recursion.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ pub struct MainRecursion {
3232
impl_lint_pass!(MainRecursion => [MAIN_RECURSION]);
3333

3434
impl LateLintPass<'_> for MainRecursion {
35-
fn check_crate(&mut self, _: &LateContext<'_>, krate: &Crate<'_>) {
36-
self.has_no_std_attr = is_no_std_crate(krate);
35+
fn check_crate(&mut self, cx: &LateContext<'_>, _: &Crate<'_>) {
36+
self.has_no_std_attr = is_no_std_crate(cx);
3737
}
3838

3939
fn check_expr_post(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {

clippy_lints/src/matches.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1207,11 +1207,11 @@ fn find_matches_sugg(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr
12071207
if b0 != b1;
12081208
let if_guard = &b0_arms[0].guard;
12091209
if if_guard.is_none() || b0_arms.len() == 1;
1210-
if b0_arms[0].attrs.is_empty();
1210+
if cx.tcx.hir().attrs(b0_arms[0].hir_id).is_empty();
12111211
if b0_arms[1..].iter()
12121212
.all(|arm| {
12131213
find_bool_lit(&arm.body.kind, desugared).map_or(false, |b| b == b0) &&
1214-
arm.guard.is_none() && arm.attrs.is_empty()
1214+
arm.guard.is_none() && cx.tcx.hir().attrs(arm.hir_id).is_empty()
12151215
});
12161216
then {
12171217
// The suggestion may be incorrect, because some arms can have `cfg` attributes

clippy_lints/src/methods/iter_count.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ pub(crate) fn lints<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, iter_args: &'
1414
"slice"
1515
} else if is_type_diagnostic_item(cx, ty, sym::vec_type) {
1616
"Vec"
17-
} else if is_type_diagnostic_item(cx, ty, sym!(vecdeque_type)) {
17+
} else if is_type_diagnostic_item(cx, ty, sym::vecdeque_type) {
1818
"VecDeque"
19-
} else if is_type_diagnostic_item(cx, ty, sym!(hashset_type)) {
19+
} else if is_type_diagnostic_item(cx, ty, sym::hashset_type) {
2020
"HashSet"
21-
} else if is_type_diagnostic_item(cx, ty, sym!(hashmap_type)) {
21+
} else if is_type_diagnostic_item(cx, ty, sym::hashmap_type) {
2222
"HashMap"
2323
} else if match_type(cx, ty, &paths::BTREEMAP) {
2424
"BTreeMap"

clippy_lints/src/methods/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc_middle::ty::{self, TraitRef, Ty, TyS};
2626
use rustc_semver::RustcVersion;
2727
use rustc_session::{declare_tool_lint, impl_lint_pass};
2828
use rustc_span::source_map::Span;
29-
use rustc_span::symbol::{sym, SymbolStr};
29+
use rustc_span::symbol::{sym, Symbol, SymbolStr};
3030
use rustc_typeck::hir_ty_to_ty;
3131

3232
use crate::consts::{constant, Constant};
@@ -2675,7 +2675,7 @@ fn lint_iter_nth<'tcx>(
26752675
"slice"
26762676
} else if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&iter_args[0]), sym::vec_type) {
26772677
"Vec"
2678-
} else if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&iter_args[0]), sym!(vecdeque_type)) {
2678+
} else if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&iter_args[0]), sym::vecdeque_type) {
26792679
"VecDeque"
26802680
} else {
26812681
let nth_args = nth_and_iter_args[0];
@@ -2729,10 +2729,10 @@ fn lint_get_unwrap<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, get_args:
27292729
} else if is_type_diagnostic_item(cx, expr_ty, sym::vec_type) {
27302730
needs_ref = get_args_str.parse::<usize>().is_ok();
27312731
"Vec"
2732-
} else if is_type_diagnostic_item(cx, expr_ty, sym!(vecdeque_type)) {
2732+
} else if is_type_diagnostic_item(cx, expr_ty, sym::vecdeque_type) {
27332733
needs_ref = get_args_str.parse::<usize>().is_ok();
27342734
"VecDeque"
2735-
} else if !is_mut && is_type_diagnostic_item(cx, expr_ty, sym!(hashmap_type)) {
2735+
} else if !is_mut && is_type_diagnostic_item(cx, expr_ty, sym::hashmap_type) {
27362736
needs_ref = true;
27372737
"HashMap"
27382738
} else if !is_mut && match_type(cx, expr_ty, &paths::BTREEMAP) {
@@ -3696,7 +3696,7 @@ fn lint_asref(cx: &LateContext<'_>, expr: &hir::Expr<'_>, call_name: &str, as_re
36963696
}
36973697
}
36983698

3699-
fn ty_has_iter_method(cx: &LateContext<'_>, self_ref_ty: Ty<'_>) -> Option<(&'static str, &'static str)> {
3699+
fn ty_has_iter_method(cx: &LateContext<'_>, self_ref_ty: Ty<'_>) -> Option<(Symbol, &'static str)> {
37003700
has_iter_method(cx, self_ref_ty).map(|ty_name| {
37013701
let mutbl = match self_ref_ty.kind() {
37023702
ty::Ref(_, _, mutbl) => mutbl,

0 commit comments

Comments
 (0)