Add mir lower support for tuple destructing assignment

This commit is contained in:
hkalbasi 2023-08-07 02:12:35 +03:30
parent 9b636e2326
commit b96e4f2f4a
2 changed files with 65 additions and 0 deletions

View file

@ -1203,6 +1203,27 @@ fn destructing_assignment() {
"#,
5,
);
check_number(
r#"
const GOAL: u8 = {
let (mut a, mut b) = (2, 5);
(a, b) = (b, a);
a * 10 + b
};
"#,
52,
);
check_number(
r#"
struct Point { x: i32, y: i32 }
const GOAL: i32 = {
let mut p = Point { x: 5, y: 6 };
(p.x, _) = (p.y, p.x);
p.x * 10 + p.y
};
"#,
66,
);
}
#[test]