X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=clippy_lints%2Fsrc%2Ftypes.rs;h=5696c2be12a8c6bb801d249f68509d48a3794108;hb=cdaa93d6958b30001751b0c20a61478ce15fe061;hp=c210cf82a300967aa0c70ddcbaf1d62513ff9e13;hpb=9672a0400cf5be60e06782f4a1faabade15e8936;p=rust.git diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index c210cf82a30..5696c2be12a 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -18,13 +18,13 @@ use syntax::ast::{FloatTy, IntTy, LitIntType, LitKind, UintTy}; use syntax::errors::DiagnosticBuilder; use syntax::source_map::Span; -use syntax::symbol::sym; +use syntax::symbol::{sym, Symbol}; use crate::consts::{constant, Constant}; use crate::utils::paths; use crate::utils::{ clip, comparisons, differing_macro_contexts, higher, in_constant, int_bits, last_path_segment, match_def_path, - match_path, multispan_sugg, same_tys, sext, snippet, snippet_opt, snippet_with_applicability, + match_path, multispan_sugg, qpath_res, same_tys, sext, snippet, snippet_opt, snippet_with_applicability, snippet_with_macro_callsite, span_help_and_lint, span_lint, span_lint_and_sugg, span_lint_and_then, unsext, }; @@ -218,7 +218,7 @@ fn match_type_parameter(cx: &LateContext<'_, '_>, qpath: &QPath, path: &[&str]) _ => None, }); if let TyKind::Path(ref qpath) = ty.node; - if let Some(did) = cx.tables.qpath_res(qpath, ty.hir_id).opt_def_id(); + if let Some(did) = qpath_res(cx, qpath, ty.hir_id).opt_def_id(); if match_def_path(cx, did, path); then { return true; @@ -240,7 +240,7 @@ fn check_ty(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty, is_local: bool) { match hir_ty.node { TyKind::Path(ref qpath) if !is_local => { let hir_id = hir_ty.hir_id; - let res = cx.tables.qpath_res(qpath, hir_id); + let res = qpath_res(cx, qpath, hir_id); if let Some(def_id) = res.opt_def_id() { if Some(def_id) == cx.tcx.lang_items().owned_box() { if match_type_parameter(cx, qpath, &paths::VEC) { @@ -253,7 +253,7 @@ fn check_ty(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty, is_local: bool) { ); return; // don't recurse into the type } - } else if match_def_path(cx, def_id, &paths::VEC) { + } else if cx.tcx.is_diagnostic_item(Symbol::intern("vec_type"), def_id) { if_chain! { // Get the _ part of Vec<_> if let Some(ref last) = last_path_segment(qpath).args; @@ -263,7 +263,7 @@ fn check_ty(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty, is_local: bool) { }); // ty is now _ at this point if let TyKind::Path(ref ty_qpath) = ty.node; - let res = cx.tables.qpath_res(ty_qpath, ty.hir_id); + let res = qpath_res(cx, ty_qpath, ty.hir_id); if let Some(def_id) = res.opt_def_id(); if Some(def_id) == cx.tcx.lang_items().owned_box(); // At this point, we know ty is Box, now get T @@ -369,7 +369,7 @@ fn check_ty_rptr(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty, is_local: bool, lt: match mut_ty.ty.node { TyKind::Path(ref qpath) => { let hir_id = mut_ty.ty.hir_id; - let def = cx.tables.qpath_res(qpath, hir_id); + let def = qpath_res(cx, qpath, hir_id); if_chain! { if let Some(def_id) = def.opt_def_id(); if Some(def_id) == cx.tcx.lang_items().owned_box(); @@ -765,7 +765,7 @@ fn is_unit_literal(expr: &Expr) -> bool { /// } /// ``` pub CAST_LOSSLESS, - complexity, + pedantic, "casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`" }