Description
Versions
rust-analyzer
: v0.4.1539
rustc
: 1.70.0
Reproducer
Simply write a top-level let statement.
let x = 1;
Explanation
Hovering the let
keyword gives
Syntax Error: expected an itemrust-analyzer syntax-error
expected item, found keywordlet
consider usingconst
orstatic
instead oflet
for global variables
Hovering the whitespace between let
and x
Syntax Error: expected an item rust-analyzer syntax-error
expected item, found keywordlet
consider usingconst
orstatic
instead oflet
for global variables
Syntax Error: expected BANG rust-analyzer syntax-error
Syntax Error: expected{
,[
,(
rust-analyzer syntax-error
Syntax Error: expected SEMICOLON rust-analyzer syntax-error
Hovering x
gives
Syntax Error: expected BANG rust-analyzer syntax-error
Syntax Error: expected{
,[
,(
rust-analyzer syntax-error
Syntax Error: expected SEMICOLON rust-analyzer syntax-error
Likewise, hovering the rest of parts of the statement gives similar yet slightly different messages.
As you can see, some of those messages are surprising.
The red underline squiggles are also a bit surprising:
What I expected
I expected the whole statement to be underlined consistently, and the hover message to only contain the relevant error message (i.e. the one that you get when hovering the let
keyword, see section above).