diff options
| author | Takayuki Nakata <f.seasons017@gmail.com> | 2020-09-08 22:45:27 +0900 |
|---|---|---|
| committer | flip1995 <hello@philkrones.com> | 2020-09-10 18:05:04 +0200 |
| commit | 14faebe20ea82392f393c3ff5efaab7250e51989 (patch) | |
| tree | 45cbabf0904f09baaa2c3a2622d3c2bc154203bb | |
| parent | b80576fba633e1fc214c9f6900d7ca3424bda6d0 (diff) | |
| download | rust-14faebe20ea82392f393c3ff5efaab7250e51989.tar.gz rust-14faebe20ea82392f393c3ff5efaab7250e51989.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); + } } |
