-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Odd rust-analyzer syntax error #4829
Comments
Hm, so this looks not like syntax error (the code is fine if I paste it into a new buffer) but rather like an incremental sync problem... Not sure how to debug this though, I am rewriting associated bits rn, so there's a chance that it'll either go away or be swapped with a different error. cc @lnicola just in case |
Just wondering, is there a command to trigger a whole (non-incremental) document synchronization without restarting the lsp server (aka reloading vscode)? |
I think closing and opening the file should usually do it? (maybe VSCode tries to be smarter though...) |
@RalfJung have you seen this lately? |
No I have not seen this in a while... but right now, no matter what I do in that file, rust-analyzer doesn't show any kind of syntax error. So I am not sure how I'd even test this. |
I've been seeing this erroneous "Expected SEMICOLON" multiple times today - first in #4503 (comment) , and then here: The red squiggle under In my case, I'm transforming Golang code into Rust code, so I'll copy a chunk of Golang code and slowly transform it. It seems that rust-analyzer gets unrecoverably confused when the Golang code gets pasted in until I restart Visual Studio. |
I also saw it a few times with |
Adding that this is happening multiple times per hour for me. Restarting Rust Analyzer inside of VS Code seems to only fix it very temporarily, whereas restarting VS Code itself seems to fix it for longer (though in both cases the problem always recurs). I used to think that this happens due to Go code being mixed in with Rust code, but I don't think that's the case any more - I've seen rust-analyzer get in the "stuck" state even without any Go code (though I haven't figured out a good repro yet). If there's any debugging information I can get, please let me know! |
Do you get any panics in the Rust Analyzer output channel then it happens? (Watch out, there's a couple of them) |
Unfortunately I worked through all the translation that I needed to do, so I'm no longer in the situation where I'm seeing this. I'll post back here if it recurs though - how can I view the panics in the Rust Analyzer output channel? |
You open the channel and they'll be there if any of them happened. |
F1, Show Output Window (or something like that), then use the list on the top-right of the output window to switch channels. rust-analyzer has three of them, panics show up only in one of those. They're created lazily, so if you don't have three, they're empty. |
Got it, thanks! Next time I see this I'll pull that up and copy-paste the
output here
…On Sun, Feb 21, 2021 at 2:01 PM Laurențiu Nicola ***@***.***> wrote:
F1, Show Output Window (or something like that), then use the list on the
top-right to switch channels.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4829 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIW3KNK6ACUUIJ3XS2EQ4DTAFJ73ANCNFSM4N2EJT6Q>
.
|
I had this happen again, where rust-analyzer was complaining about a missing semicolon even though the Rust code was fine. I deleted the line I thought caused it, cleared the rust-analyzer output, and re-pasted the line that caused the missing semicolon but no rust-analyzer output popped up. I moved to a different section of the code, and rust-analyzer was complaining about a similarly-strange error: Simply by closing and reopening VS code, the errors fixed themselves: There might have been something in the rust-analyzer output before I cleared it, but I'd taken a brief scroll through it and didn't see anything. Of note: I wasn't working with any Go code this time; it was purely Rust code. |
Just had it happen again, when adding a field to a struct. On recollection, I think the previous comment's instance also had to do with adding a field to a struct. Here's the code: Here's the error: Full rust-analyzer output:
and the exact same code, now without errors, after restarting: |
Do you have anything in the other Output channels? If you can find a way to reproduce this, it would be awesome. |
I unfortunately haven't found a way yet - I'm hoping that if I collect enough data on this issue, a pattern will eventually start to emerge. Next time I see it I'll check the other output channels too |
Do you have non-Latin characters in your code? You could also try setting |
Ah apologies @lnicola , I missed your response! Nope, no non-Latin characters in the code. I've just hit the bug again on a very innocuous change: The only change I made is a) change the response type of the function from This is the entire Rust Analyzer channel output, and it does have panics (though I've had VS Code open for several days, so I'm not sure how far back this goes): While researching how to set the Rust Analyzer Version:
Rust Analyzer Status:
I've also now added the following to my settings.json:
This required reloading rust-analyzer, which made the erroneous error go away. Hopefully the above is useful! |
@mieubrisse no news here unfortunately, but the env variable name is actually |
Your log also has interesting tidbits like:
where the large difference between the file size (1681 bytes) and the requested offset (15194) make it sound like we are trying to look into the wrong file. That can happen with macro-expansion bugs. |
11861: internal: Add "view file text" command to debug sync issues r=jonas-schievink a=jonas-schievink I saw a file sync bug the other day but didn't know how to further debug it. This command might give a clue as to what's wrong and help debug issues like #4829. bors r+ Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
In #11861, I've added a "view file text" command that displays the server's view of the file. In case anyone sees a desync like this happen again, please run that command and post the difference, maybe that tells us a clue about what's wrong. |
I'll close this, it hasn't happened for anyone in a long time, if it re-appears we can re-open this |
Right now, rust-analyzer is complaining about the syntax in this function that is totally fine for
cargo check
:In the
super_statement
line, it saysI presume this has something to do with it getting confused while I was typing, and then not properly recovering when I was done typing... the error appeared while I was adding that
super_statement
line, and it went away after I did "reload window".The text was updated successfully, but these errors were encountered: