Skip to content

Commit

Permalink
Rollup merge of #104035 - m-ou-se:weird-expr-closure-match, r=compile…
Browse files Browse the repository at this point in the history
…r-errors

Add 'closure match' test to weird-exprs.rs.

Having fun with patterns that look like closures.
  • Loading branch information
matthiaskrgr committed Nov 6, 2022
2 parents 13e62be + 84fe2ee commit 619add3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/ui/weird-exprs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#![allow(unreachable_code)]
#![allow(unused_braces, unused_must_use, unused_parens)]
#![allow(uncommon_codepoints, confusable_idents)]
#![allow(unreachable_patterns)]

#![recursion_limit = "256"]

Expand Down Expand Up @@ -194,6 +195,15 @@ fn bathroom_stall() {
assert_eq!(i, 13);
}

fn closure_matching() {
let x = |_| Some(1);
let (|x| x) = match x(..) {
|_| Some(2) => |_| Some(3),
|_| _ => unreachable!(),
};
assert!(matches!(x(..), |_| Some(4)));
}

pub fn main() {
strange();
funny();
Expand All @@ -216,4 +226,5 @@ pub fn main() {
𝚌𝚘𝚗𝚝𝚒𝚗𝚞𝚎();
function();
bathroom_stall();
closure_matching();
}

0 comments on commit 619add3

Please sign in to comment.