]> git.proxmox.com Git - rustc.git/blame - src/test/ui/binding/match-reassign.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / binding / match-reassign.rs
CommitLineData
b7449926 1// run-pass
c34b1796 2// Regression test for #23698: The reassignment checker only cared
b7449926 3// about the last assignment in a match arm body
c34b1796
AL
4
5// Use an extra function to make sure no extra assignments
6// are introduced by macros in the match statement
7fn check_eq(x: i32, y: i32) {
8 assert_eq!(x, y);
9}
10
11#[allow(unused_assignments)]
12fn 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}