1fc6dbc32b
Add inline const and other possible curly brace expressions to expr_trailing_brace Add tests for `}` before `else` in `let...else` error Change to explicit cases for expressions with optional values when being checked for trailing braces Add tests for more complex cases of `}` before `else` in `let..else` statement Move other possible `}` cases into separate arm and add FIXME for future reference
165 lines
3.1 KiB
Rust
165 lines
3.1 KiB
Rust
#![feature(inline_const)]
|
|
#![feature(yeet_expr)]
|
|
#![allow(incomplete_features)] // Necessary for now, while explicit_tail_calls is incomplete
|
|
#![feature(explicit_tail_calls)]
|
|
|
|
fn a() {
|
|
let foo = {
|
|
1
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn b() {
|
|
let foo = for i in 1..2 {
|
|
break;
|
|
} else {
|
|
//~^ ERROR `for...else` loops are not supported
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn c() {
|
|
let foo = if true {
|
|
1
|
|
} else {
|
|
0
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn d() {
|
|
let foo = loop {
|
|
break;
|
|
} else {
|
|
//~^ ERROR loop...else` loops are not supported
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn e() {
|
|
let foo = match true {
|
|
true => 1,
|
|
false => 0
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
struct X {a: i32}
|
|
fn f() {
|
|
let foo = X {
|
|
a: 1
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn g() {
|
|
let foo = while false {
|
|
break;
|
|
} else {
|
|
//~^ ERROR `while...else` loops are not supported
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn h() {
|
|
let foo = const {
|
|
1
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn i() {
|
|
let foo = &{
|
|
1
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn j() {
|
|
let bar = 0;
|
|
let foo = bar = {
|
|
1
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn k() {
|
|
let foo = 1 + {
|
|
1
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn l() {
|
|
let foo = 1..{
|
|
1
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn m() {
|
|
let foo = return {
|
|
()
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn n() {
|
|
let foo = -{
|
|
1
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn o() -> Result<(), ()> {
|
|
let foo = do yeet {
|
|
()
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return Ok(());
|
|
};
|
|
}
|
|
|
|
fn p() {
|
|
let foo = become {
|
|
()
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn q() {
|
|
let foo = |x: i32| {
|
|
x
|
|
} else {
|
|
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
|
|
return;
|
|
};
|
|
}
|
|
|
|
fn main() {}
|