Skip to content

Commit 619add3

Browse files
authored
Rollup merge of #104035 - m-ou-se:weird-expr-closure-match, r=compiler-errors
Add 'closure match' test to weird-exprs.rs. Having fun with patterns that look like closures.
2 parents 13e62be + 84fe2ee commit 619add3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test/ui/weird-exprs.rs

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![allow(unreachable_code)]
99
#![allow(unused_braces, unused_must_use, unused_parens)]
1010
#![allow(uncommon_codepoints, confusable_idents)]
11+
#![allow(unreachable_patterns)]
1112

1213
#![recursion_limit = "256"]
1314

@@ -194,6 +195,15 @@ fn bathroom_stall() {
194195
assert_eq!(i, 13);
195196
}
196197

198+
fn closure_matching() {
199+
let x = |_| Some(1);
200+
let (|x| x) = match x(..) {
201+
|_| Some(2) => |_| Some(3),
202+
|_| _ => unreachable!(),
203+
};
204+
assert!(matches!(x(..), |_| Some(4)));
205+
}
206+
197207
pub fn main() {
198208
strange();
199209
funny();
@@ -216,4 +226,5 @@ pub fn main() {
216226
𝚌𝚘𝚗𝚝𝚒𝚗𝚞𝚎();
217227
function();
218228
bathroom_stall();
229+
closure_matching();
219230
}

0 commit comments

Comments
 (0)