mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Improve error handling for top-level let
statements
This commit addresses the issue of excessive and unrelated errors generated by top-level `let` statements. Now, only a single error is produced, indicating that `let` statements are invalid at the top level.
This commit is contained in:
parent
c9d189d137
commit
e076192dd8
5 changed files with 86 additions and 44 deletions
|
@ -376,6 +376,16 @@ fn error_block(p: &mut Parser<'_>, message: &str) {
|
|||
m.complete(p, ERROR);
|
||||
}
|
||||
|
||||
// test_err top_level_let
|
||||
// let ref foo: fn() = 1 + 3;
|
||||
fn error_let_stmt(p: &mut Parser<'_>, message: &str) {
|
||||
assert!(p.at(T![let]));
|
||||
let m = p.start();
|
||||
p.error(message);
|
||||
expressions::let_stmt(p, expressions::Semicolon::Optional);
|
||||
m.complete(p, ERROR);
|
||||
}
|
||||
|
||||
/// The `parser` passed this is required to at least consume one token if it returns `true`.
|
||||
/// If the `parser` returns false, parsing will stop.
|
||||
fn delimited(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue