X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=clippy_lints%2Fsrc%2Fdefault_trait_access.rs;h=9dc404efd7e0ba17cede72a704892c8a5c11153c;hb=4d60841205d10293d6759df1948acda4c607c7eb;hp=66d94e00d0d3187c9f0b58cc4e96c5ae596fdbcd;hpb=a16edf84ce17095ebeebccb5662441ef1c824905;p=rust.git diff --git a/clippy_lints/src/default_trait_access.rs b/clippy_lints/src/default_trait_access.rs index 66d94e00d0d..9dc404efd7e 100644 --- a/clippy_lints/src/default_trait_access.rs +++ b/clippy_lints/src/default_trait_access.rs @@ -7,16 +7,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -use crate::rustc::hir::*; -use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use crate::rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; -use crate::rustc::ty::TyKind; +use rustc::hir::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::ty; +use rustc::{declare_tool_lint, lint_array}; +use rustc_errors::Applicability; use crate::utils::{any_parent_is_automatically_derived, match_def_path, opt_def_id, paths, span_lint_and_sugg}; - /// **What it does:** Checks for literal calls to `Default::default()`. /// /// **Why is this bad?** It's more clear to the reader to use the name of the type whose default is @@ -72,7 +71,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { // TODO: Work out a way to put "whatever the imported way of referencing // this type in this file" rather than a fully-qualified type. let expr_ty = cx.tables.expr_ty(expr); - if let TyKind::Adt(..) = expr_ty.sty { + if let ty::Adt(..) = expr_ty.sty { let replacement = format!("{}::default()", expr_ty); span_lint_and_sugg( cx, @@ -80,12 +79,14 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { expr.span, &format!("Calling {} is more clear than this expression", replacement), "try", - replacement); + replacement, + Applicability::Unspecified, // First resolve the TODO above + ); } }, QPath::TypeRelative(..) => {}, } } - } + } } }