handle match scrutinee in closure captures

This commit is contained in:
hkalbasi 2023-05-19 12:00:19 +03:30
parent e8ae2d3976
commit c5ea2d7adc
8 changed files with 137 additions and 10 deletions

View file

@ -182,6 +182,43 @@ fn capture_specific_fields() {
}
}
#[test]
fn match_pattern() {
size_and_align_expr! {
struct X(i64, i32, (u8, i128));
let y: X = X(2, 5, (7, 3));
move |x: i64| {
match y {
_ => x,
}
}
}
size_and_align_expr! {
minicore: copy;
stmts: [
struct X(i64, i32, (u8, i128));
let y: X = X(2, 5, (7, 3));
]
|x: i64| {
match y {
X(_a, _b, _c) => x,
}
}
}
size_and_align_expr! {
minicore: copy;
stmts: [
struct X(i64, i32, (u8, i128));
let y: X = X(2, 5, (7, 3));
]
|x: i64| {
match y {
_y => x,
}
}
}
}
#[test]
fn ellipsis_pattern() {
size_and_align_expr! {