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>(
382
382
}
383
383
} ,
384
384
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
+ }
385
390
if let ExprKind :: Path ( ref qpath) = callee. kind {
386
391
if cx. typeck_results ( ) . type_dependent_def ( expr. hir_id ) . is_some ( ) {
387
392
// 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() {
8
8
slots : Vec < u32 > ,
9
9
}
10
10
11
+ // the repro
11
12
DescriptorSet { slots : Vec :: new ( ) } ;
12
13
//~^ 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
13
28
}
Original file line number Diff line number Diff line change 1
1
error: unnecessary operation
2
- --> tests/ui/unnecessary_operation_unfixable.rs:11 :5
2
+ --> tests/ui/unnecessary_operation_unfixable.rs:12 :5
3
3
|
4
4
LL | DescriptorSet { slots: Vec::new() };
5
5
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `Vec::new();`
6
6
|
7
7
= note: `-D clippy::unnecessary-operation` implied by `-D warnings`
8
8
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_operation)]`
9
9
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
11
29
You can’t perform that action at this time.
0 commit comments