Skip to content

Commit 2c9f82e

Browse files
committed
Add some tests to same_item_push
Add tests in which the variable is initialized with a match expression and function call
1 parent 5d085ad commit 2c9f82e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/ui/same_item_push.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ fn increment(x: u8) -> u8 {
1111
x + 1
1212
}
1313

14+
fn fun() -> usize {
15+
42
16+
}
17+
1418
fn main() {
1519
// Test for basic case
1620
let mut spaces = Vec::with_capacity(10);
@@ -124,4 +128,21 @@ fn main() {
124128
for _ in 0..20 {
125129
vec17.push(item);
126130
}
131+
132+
let mut vec18 = Vec::new();
133+
let item = 42;
134+
let item = fun();
135+
for _ in 0..20 {
136+
vec18.push(item);
137+
}
138+
139+
let mut vec19 = Vec::new();
140+
let key = 1;
141+
for _ in 0..20 {
142+
let item = match key {
143+
1 => 10,
144+
_ => 0,
145+
};
146+
vec19.push(item);
147+
}
127148
}

0 commit comments

Comments
 (0)