File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -382,6 +382,11 @@ fn reduce_expression<'a>(
382382 }
383383 } ,
384384 ExprKind :: Call ( callee, args) => {
385+ if args. iter ( ) . any ( |a| !expr_type_is_certain ( cx, a) ) {
386+ // there's a risk that if we take the args out of the context of the
387+ // call/constructor, their types might become ambiguous
388+ * applicability = Applicability :: MaybeIncorrect ;
389+ }
385390 if let ExprKind :: Path ( ref qpath) = callee. kind {
386391 if cx. typeck_results ( ) . type_dependent_def ( expr. hir_id ) . is_some ( ) {
387392 // type-dependent function call like `impl FnOnce for X`
Original file line number Diff line number Diff line change @@ -8,6 +8,21 @@ fn issue15381() {
88 slots : Vec < u32 > ,
99 }
1010
11+ // the repro
1112 DescriptorSet { slots : Vec :: new ( ) } ;
1213 //~^ unnecessary_operation
14+
15+ // other cases
16+ enum E {
17+ Foo { f : Vec < u32 > } ,
18+ Bar ( Vec < u32 > ) ,
19+ }
20+ E :: Foo { f : Vec :: new ( ) } ;
21+ //~^ unnecessary_operation
22+ E :: Bar ( Vec :: new ( ) ) ;
23+ //~^ unnecessary_operation
24+
25+ struct Tuple ( Vec < u32 > ) ;
26+ Tuple ( Vec :: new ( ) ) ;
27+ //~^ unnecessary_operation
1328}
Original file line number Diff line number Diff line change 11error: unnecessary operation
2- --> tests/ui/unnecessary_operation_unfixable.rs:11 :5
2+ --> tests/ui/unnecessary_operation_unfixable.rs:12 :5
33 |
44LL | DescriptorSet { slots: Vec::new() };
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `Vec::new();`
66 |
77 = note: `-D clippy::unnecessary-operation` implied by `-D warnings`
88 = help: to override `-D warnings` add `#[allow(clippy::unnecessary_operation)]`
99
10- error: aborting due to 1 previous error
10+ error: unnecessary operation
11+ --> tests/ui/unnecessary_operation_unfixable.rs:20:5
12+ |
13+ LL | E::Foo { f: Vec::new() };
14+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `Vec::new();`
15+
16+ error: unnecessary operation
17+ --> tests/ui/unnecessary_operation_unfixable.rs:22:5
18+ |
19+ LL | E::Bar(Vec::new());
20+ | ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `Vec::new();`
21+
22+ error: unnecessary operation
23+ --> tests/ui/unnecessary_operation_unfixable.rs:26:5
24+ |
25+ LL | Tuple(Vec::new());
26+ | ^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `Vec::new();`
27+
28+ error: aborting due to 4 previous errors
1129
You can’t perform that action at this time.
0 commit comments