]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/default_trait_access.rs
Merge pull request #2985 from phansch/riir_update_lints
[rust.git] / clippy_lints / src / default_trait_access.rs
index cb79883372a0a7a37d2e942ea67940ba8339e85b..e7c90f041889a591627fc3053f295428397ec167 100644 (file)
@@ -48,6 +48,17 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
             then {
                 match qpath {
                     QPath::Resolved(..) => {
+                        if_chain! {
+                            // Detect and ignore <Foo as Default>::default() because these calls do
+                            // explicitly name the type.
+                            if let ExprKind::Call(ref method, ref _args) = expr.node;
+                            if let ExprKind::Path(ref p) = method.node;
+                            if let QPath::Resolved(Some(_ty), _path) = p;
+                            then {
+                                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);