diff options
| author | Takayuki Nakata <f.seasons017@gmail.com> | 2020-09-08 22:45:27 +0900 |
|---|---|---|
| committer | Takayuki Nakata <f.seasons017@gmail.com> | 2020-09-08 22:45:27 +0900 |
| commit | 2c9f82e7d22a5cd3f704ed0b932a17fa53f1145b (patch) | |
| tree | a1665c8d395fe4cb966b68b754132a362f3c1c75 | |
| parent | 5d085ad011a602e004e7d33fa0b9074c7dab36fc (diff) | |
| download | rust-2c9f82e7d22a5cd3f704ed0b932a17fa53f1145b.tar.gz rust-2c9f82e7d22a5cd3f704ed0b932a17fa53f1145b.zip | |
Add some tests to `same_item_push`
Add tests in which the variable is initialized with a match expression and function call
| -rw-r--r-- | tests/ui/same_item_push.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/same_item_push.rs b/tests/ui/same_item_push.rs index bd4792c4a76..7ca829854db 100644 --- a/tests/ui/same_item_push.rs +++ b/tests/ui/same_item_push.rs @@ -11,6 +11,10 @@ fn increment(x: u8) -> u8 { x + 1 } +fn fun() -> usize { + 42 +} + fn main() { // Test for basic case let mut spaces = Vec::with_capacity(10); @@ -124,4 +128,21 @@ fn main() { for _ in 0..20 { vec17.push(item); } + + let mut vec18 = Vec::new(); + let item = 42; + let item = fun(); + for _ in 0..20 { + vec18.push(item); + } + + let mut vec19 = Vec::new(); + let key = 1; + for _ in 0..20 { + let item = match key { + 1 => 10, + _ => 0, + }; + vec19.push(item); + } } |
