]> git.lizzy.rs Git - rust.git/blob - src/test/ui/binding/match-reassign.rs
Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors
[rust.git] / src / test / ui / binding / match-reassign.rs
1 // run-pass
2 // Regression test for #23698: The reassignment checker only cared
3 // about the last assignment in a match arm body
4
5 // Use an extra function to make sure no extra assignments
6 // are introduced by macros in the match statement
7 fn check_eq(x: i32, y: i32) {
8     assert_eq!(x, y);
9 }
10
11 #[allow(unused_assignments)]
12 fn main() {
13     let mut x = Box::new(1);
14     match x {
15         y => {
16             x = Box::new(2);
17             let _tmp = 1; // This assignment used to throw off the reassignment checker
18             check_eq(*y, 1);
19         }
20     }
21 }