diff --git a/clippy_lints/src/default_trait_access.rs b/clippy_lints/src/default_trait_access.rs index f01e106df..d3598a5bd 100644 --- a/clippy_lints/src/default_trait_access.rs +++ b/clippy_lints/src/default_trait_access.rs @@ -48,6 +48,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess { then { match qpath { QPath::Resolved(..) => { + if let ExprKind::Call(ref method, ref _args) = expr.node { + if format!("{:?}", method).contains(" as Default>") { + return + } + } + + // 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); diff --git a/tests/ui/default_trait_access.rs b/tests/ui/default_trait_access.rs index 675e64246..eba024353 100644 --- a/tests/ui/default_trait_access.rs +++ b/tests/ui/default_trait_access.rs @@ -41,8 +41,10 @@ fn main() { let s18 = TupleStructDerivedDefault::default(); + let s19 = ::default(); + println!( - "[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}]", + "[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}], [{:?}]", s1, s2, s3, @@ -61,6 +63,7 @@ fn main() { s16, s17, s18, + s19, ); }