Skip to content

Commit be7e3ce

Browse files
committed
add failing test
1 parent 32a216e commit be7e3ce

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tests/ui/unnecessary_operation.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,12 @@ fn issue15173_original<MsU>(handler: impl FnOnce() -> MsU + Clone + 'static) {
163163
None
164164
}) as Box<dyn Fn(i32) -> Option<i32>>;
165165
}
166+
167+
// don't lint if any of the fields has an ambiguous type when used by themselves
168+
fn issue15381() {
169+
struct DescriptorSet {
170+
slots: Vec<u32>,
171+
}
172+
173+
DescriptorSet { slots: Vec::new() };
174+
}

tests/ui/unnecessary_operation.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,11 @@ error: unnecessary operation
127127
LL | [42, 55][get_usize()];
128128
| ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42, 55].len() > get_usize());`
129129

130-
error: aborting due to 20 previous errors
130+
error: unnecessary operation
131+
--> tests/ui/unnecessary_operation.rs:173:5
132+
|
133+
LL | DescriptorSet { slots: Vec::new() };
134+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `Vec::new();`
135+
136+
error: aborting due to 21 previous errors
131137

0 commit comments

Comments
 (0)