2015-03-18 09:22:38 -04:00
|
|
|
// Test that we cannot parse a closure with an explicit return type
|
|
|
|
// unless it uses braces.
|
|
|
|
|
2025-03-20 15:46:19 +00:00
|
|
|
fn needs_braces_1() {
|
2016-10-26 02:17:29 +03:00
|
|
|
let x = || -> i32 22;
|
2020-03-05 05:49:30 +01:00
|
|
|
//~^ ERROR expected `{`, found `22`
|
2015-03-18 09:22:38 -04:00
|
|
|
}
|
2025-03-20 15:46:19 +00:00
|
|
|
|
|
|
|
// Check other delimiters too.
|
|
|
|
|
|
|
|
fn needs_braces_2() {
|
|
|
|
let x = || -> (i32, i32) (1, 2);
|
|
|
|
//~^ ERROR expected `{`, found `(`
|
|
|
|
}
|
|
|
|
|
|
|
|
fn needs_braces_3() {
|
|
|
|
let c = || -> [i32; 2] [1, 2];
|
|
|
|
//~^ ERROR expected `{`, found `[`
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|