mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-17 02:42:54 +00:00
Merge pull request #18908 from jnyfah/error-braces
Fix: Detect missing errors for } braces before else in let...else statements
This commit is contained in:
commit
cd199eacd0
23 changed files with 637 additions and 12 deletions
|
|
@ -134,10 +134,12 @@ pub(super) fn let_stmt(p: &mut Parser<'_>, with_semi: Semicolon) {
|
|||
// test_err let_else_right_curly_brace
|
||||
// fn func() { let Some(_) = {Some(1)} else { panic!("h") };}
|
||||
if let Some(expr) = expr_after_eq {
|
||||
if BlockLike::is_blocklike(expr.kind()) {
|
||||
p.error(
|
||||
"right curly brace `}` before `else` in a `let...else` statement not allowed",
|
||||
)
|
||||
if let Some(token) = expr.last_token(p) {
|
||||
if token == T!['}'] {
|
||||
p.error(
|
||||
"right curly brace `}` before `else` in a `let...else` statement not allowed"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue