diff --git a/clippy_lints/src/get_last_with_len.rs b/clippy_lints/src/get_last_with_len.rs index e4bad5ca5c517..c32e0a2290d12 100644 --- a/clippy_lints/src/get_last_with_len.rs +++ b/clippy_lints/src/get_last_with_len.rs @@ -8,7 +8,6 @@ use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Spanned; -use rustc_span::symbol::Symbol; declare_clippy_lint! { /// **What it does:** Checks for using `x.get(x.len() - 1)` instead of @@ -51,12 +50,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen { if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind; // Method name is "get" - if path.ident.name == Symbol::intern("get"); + if path.ident.name == sym!(get); // Argument 0 (the struct we're calling the method on) is a vector if let Some(struct_calling_on) = args.get(0); let struct_ty = cx.tables.expr_ty(struct_calling_on); - if is_type_diagnostic_item(cx, struct_ty, Symbol::intern("vec_type")); + if is_type_diagnostic_item(cx, struct_ty, sym!(vec_type)); // Argument to "get" is a subtraction if let Some(get_index_arg) = args.get(1); @@ -71,7 +70,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen { // LHS of subtraction is "x.len()" if let ExprKind::MethodCall(arg_lhs_path, _, lhs_args) = &lhs.kind; - if arg_lhs_path.ident.name == Symbol::intern("len"); + if arg_lhs_path.ident.name == sym!(len); if let Some(arg_lhs_struct) = lhs_args.get(0); // The two vectors referenced (x in x.get(...) and in x.len()) diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 8e1501956dd06..cc69b6194a4a6 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -28,7 +28,7 @@ use rustc_middle::middle::region; use rustc_middle::ty::{self, Ty}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; -use rustc_span::{BytePos, Symbol}; +use rustc_span::BytePos; use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Place, PlaceBase}; use std::iter::{once, Iterator}; use std::mem; @@ -804,7 +804,7 @@ fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'_>) -> bool { _ => false, }; - is_slice || is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")) || match_type(cx, ty, &paths::VEC_DEQUE) + is_slice || is_type_diagnostic_item(cx, ty, sym!(vec_type)) || match_type(cx, ty, &paths::VEC_DEQUE) } fn get_fixed_offset_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr<'_>, var: HirId) -> Option { @@ -1955,7 +1955,7 @@ fn is_ref_iterable_type(cx: &LateContext<'_, '_>, e: &Expr<'_>) -> bool { // will allow further borrows afterwards let ty = cx.tables.expr_ty(e); is_iterable_array(ty, cx) || - is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")) || + is_type_diagnostic_item(cx, ty, sym!(vec_type)) || match_type(cx, ty, &paths::LINKED_LIST) || match_type(cx, ty, &paths::HASHMAP) || match_type(cx, ty, &paths::HASHSET) || @@ -2465,7 +2465,7 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'a, ' if let Some(GenericArg::Type(ref ty)) = generic_args.args.get(0); then { let ty = cx.tables.node_type(ty.hir_id); - if is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")) || + if is_type_diagnostic_item(cx, ty, sym!(vec_type)) || match_type(cx, ty, &paths::VEC_DEQUE) || match_type(cx, ty, &paths::BTREEMAP) || match_type(cx, ty, &paths::HASHMAP) { diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index a5b74466836c4..8b7bb37bf7dd1 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -19,7 +19,7 @@ use rustc_middle::ty::subst::GenericArgKind; use rustc_middle::ty::{self, Predicate, Ty}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; -use rustc_span::symbol::{sym, Symbol, SymbolStr}; +use rustc_span::symbol::{sym, SymbolStr}; use crate::consts::{constant, Constant}; use crate::utils::usage::mutated_variables; @@ -2111,7 +2111,7 @@ fn lint_iter_cloned_collect<'a, 'tcx>( iter_args: &'tcx [hir::Expr<'_>], ) { if_chain! { - if is_type_diagnostic_item(cx, cx.tables.expr_ty(expr), Symbol::intern("vec_type")); + if is_type_diagnostic_item(cx, cx.tables.expr_ty(expr), sym!(vec_type)); if let Some(slice) = derefs_to_slice(cx, &iter_args[0], cx.tables.expr_ty(&iter_args[0])); if let Some(to_replace) = expr.span.trim_start(slice.span.source_callsite()); @@ -2240,7 +2240,7 @@ fn lint_iter_nth<'a, 'tcx>( let mut_str = if is_mut { "_mut" } else { "" }; let caller_type = if derefs_to_slice(cx, &iter_args[0], cx.tables.expr_ty(&iter_args[0])).is_some() { "slice" - } else if is_type_diagnostic_item(cx, cx.tables.expr_ty(&iter_args[0]), Symbol::intern("vec_type")) { + } else if is_type_diagnostic_item(cx, cx.tables.expr_ty(&iter_args[0]), sym!(vec_type)) { "Vec" } else if match_type(cx, cx.tables.expr_ty(&iter_args[0]), &paths::VEC_DEQUE) { "VecDeque" @@ -2297,7 +2297,7 @@ fn lint_get_unwrap<'a, 'tcx>( let caller_type = if derefs_to_slice(cx, &get_args[0], expr_ty).is_some() { needs_ref = get_args_str.parse::().is_ok(); "slice" - } else if is_type_diagnostic_item(cx, expr_ty, Symbol::intern("vec_type")) { + } else if is_type_diagnostic_item(cx, expr_ty, sym!(vec_type)) { needs_ref = get_args_str.parse::().is_ok(); "Vec" } else if match_type(cx, expr_ty, &paths::VEC_DEQUE) { @@ -2378,7 +2378,7 @@ fn derefs_to_slice<'a, 'tcx>( match ty.kind { ty::Slice(_) => true, ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()), - ty::Adt(..) => is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")), + ty::Adt(..) => is_type_diagnostic_item(cx, ty, sym!(vec_type)), ty::Array(_, size) => { if let Some(size) = size.try_eval_usize(cx.tcx, cx.param_env) { size < 32 diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index b3209030aa475..a76776e45a818 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -13,7 +13,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, TypeFoldable}; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use rustc_span::{Span, Symbol}; +use rustc_span::Span; use rustc_target::spec::abi::Abi; use rustc_trait_selection::traits; use rustc_trait_selection::traits::misc::can_type_implement_copy; @@ -214,7 +214,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { let deref_span = spans_need_deref.get(&canonical_id); if_chain! { - if is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")); + if is_type_diagnostic_item(cx, ty, sym!(vec_type)); if let Some(clone_spans) = get_spans(cx, Some(body.id()), idx, &[("clone", ".to_owned()")]); if let TyKind::Path(QPath::Resolved(_, ref path)) = input.kind; diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index fd07df780e42e..949ad0510d34b 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -15,7 +15,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; -use rustc_span::{MultiSpan, Symbol}; +use rustc_span::MultiSpan; use std::borrow::Cow; declare_clippy_lint! { @@ -153,7 +153,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl<'_>, fn_id: HirId, opt_body_ for (idx, (arg, ty)) in decl.inputs.iter().zip(fn_ty.inputs()).enumerate() { if let ty::Ref(_, ty, Mutability::Not) = ty.kind { - if is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")) { + if is_type_diagnostic_item(cx, ty, sym!(vec_type)) { let mut ty_snippet = None; if_chain! { if let TyKind::Path(QPath::Resolved(_, ref path)) = walk_ptrs_hir_ty(arg).kind; diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index e038c3785d592..94d8296a9bedf 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -9,7 +9,6 @@ use rustc_hir::{Block, Expr, ExprKind, PatKind, QPath, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use rustc_span::Symbol; declare_clippy_lint! { /// **What it does:** Checks for manual swapping. @@ -199,7 +198,7 @@ fn check_for_slice<'a>(cx: &LateContext<'_, '_>, lhs1: &'a Expr<'_>, lhs2: &'a E if matches!(ty.kind, ty::Slice(_)) || matches!(ty.kind, ty::Array(_, _)) - || is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")) + || is_type_diagnostic_item(cx, ty, sym!(vec_type)) || match_type(cx, ty, &paths::VEC_DEQUE) { return Slice::Swappable(lhs1, idx1, idx2); diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 67399fb64683c..28223b8835b62 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -21,7 +21,7 @@ use rustc_middle::ty::{self, InferTy, Ty, TyCtxt, TypeckTables}; use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass}; use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::source_map::Span; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::sym; use rustc_target::abi::LayoutOf; use rustc_target::spec::abi::Abi; use rustc_typeck::hir_ty_to_ty; @@ -384,7 +384,7 @@ impl Types { ); return; // don't recurse into the type } - } else if cx.tcx.is_diagnostic_item(Symbol::intern("vec_type"), def_id) { + } else if cx.tcx.is_diagnostic_item(sym!(vec_type), def_id) { if_chain! { // Get the _ part of Vec<_> if let Some(ref last) = last_path_segment(qpath).args;