Skip to content

Commit 715e457

Browse files
committed
revert blocklike changes
1 parent 39a1bb9 commit 715e457

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/tools/rust-analyzer/crates/parser/src/grammar.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,8 @@ impl BlockLike {
204204
self == BlockLike::Block
205205
}
206206

207-
fn is_blocklike(expr: &CompletedMarker, p: &Parser<'_>) -> bool {
208-
matches!(expr.kind(), BLOCK_EXPR | IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR)
209-
|| (expr.last_token(p) == Some(T!['}']) && !matches!(expr.kind(), CLOSURE_EXPR))
207+
fn is_blocklike(kind: SyntaxKind) -> bool {
208+
matches!(kind, BLOCK_EXPR | IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR)
210209
}
211210
}
212211

src/tools/rust-analyzer/crates/parser/src/grammar/expressions.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ pub(super) fn let_stmt(p: &mut Parser<'_>, with_semi: Semicolon) {
134134
// test_err let_else_right_curly_brace
135135
// fn func() { let Some(_) = {Some(1)} else { panic!("h") };}
136136
if let Some(expr) = expr_after_eq {
137-
if BlockLike::is_blocklike(&expr, p) {
138-
p.error(
139-
"right curly brace `}` before `else` in a `let...else` statement not allowed",
140-
)
137+
if let Some(token) = expr.last_token(p) {
138+
if token == T!['}'] {
139+
p.error(
140+
"right curly brace `}` before `else` in a `let...else` statement not allowed"
141+
)
142+
}
141143
}
142144
}
143145

src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub(super) fn atom_expr(
198198
}
199199
};
200200
let blocklike =
201-
if BlockLike::is_blocklike(&done, p) { BlockLike::Block } else { BlockLike::NotBlock };
201+
if BlockLike::is_blocklike(done.kind()) { BlockLike::Block } else { BlockLike::NotBlock };
202202
Some((done, blocklike))
203203
}
204204

0 commit comments

Comments
 (0)