forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#118880 - GearsDatapacks:issue-118859-fix, r=compiler-errors More expressions correctly are marked to end with curly braces Fixes rust-lang#118859, and replaces the mentioned match statement with an exhaustive list, so that this code doesn't get overlooked in the future
- Loading branch information
Showing
3 changed files
with
428 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
#![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() {} |
Oops, something went wrong.