Skip to content

Commit 1f3676f

Browse files
committed
Merge branch 'master' of https://github.com/rust-lang-nursery/rust-clippy into range-plus-one
2 parents b825578 + c051309 commit 1f3676f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

clippy_lints/src/default_trait_access.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess {
4848
then {
4949
match qpath {
5050
QPath::Resolved(..) => {
51+
if_chain! {
52+
// Detect and ignore <Foo as Default>::default() because these calls do
53+
// explicitly name the type.
54+
if let ExprKind::Call(ref method, ref _args) = expr.node;
55+
if let ExprKind::Path(ref p) = method.node;
56+
if let QPath::Resolved(Some(_ty), _path) = p;
57+
then {
58+
return;
59+
}
60+
}
61+
5162
// TODO: Work out a way to put "whatever the imported way of referencing
5263
// this type in this file" rather than a fully-qualified type.
5364
let expr_ty = cx.tables.expr_ty(expr);

tests/ui/default_trait_access.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ fn main() {
4343

4444
let s18 = TupleStructDerivedDefault::default();
4545

46+
let s19 = <DerivedDefault as Default>::default();
47+
4648
println!(
47-
"[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}]",
49+
"[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}], [{:?}]",
4850
s1,
4951
s2,
5052
s3,
@@ -63,6 +65,7 @@ fn main() {
6365
s16,
6466
s17,
6567
s18,
68+
s19,
6669
);
6770
}
6871

0 commit comments

Comments
 (0)