-
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
Go-to-definition not working for symbols defined outside of file #4402
Comments
Yes, it should work. Do you have |
(So I guess, yes?) |
I have the same issue (variables with type unknown, jump to definition doesn't work) for some crates but not others. How can we debug such issues? I've set RUST_LOG=info and enable server verbose trace and I see nothing in the Server Trace. (Using VS Code on windows). rust-src is installed. Sometimes restarting the server or restarting the IDE solves some issues. |
OK, after restart I see the Server Trace, and I suppose I've ran into #4150 |
@pwaller is this working for you now? We've added some messages for users with |
Since filing the issue, I have used rust-analyzer on multiple machines in this kind of configuration and not hit the problem. I have found that whenever there is an update for rust-analyzer available, it stops working until I update. Oftentimes the notification goes missing before I notice it, resulting in the analyzer being silently broken. I also don't understand why the presence of a new version should cause the old version to stop working, but I have seen this behaviour on a large number of occasions. I mention this now because I wonder if it could be related to the bug I originally filed? I learned to watch out for updates being available and upgrade (which feels non-ideal), but in practice I don't seem to get stuck in the same way now as I did when I was first starting out and filed this issue. @lnicola feel free to close the issue, or keep it open and keep the dialog going, if there is anything else it's useful for me to report back with on this issue. |
This happens because the extension itself is updated automatically but the matching rust-analyzer binary is not yet downloaded. The extension is only guaranteed to work with exactly one rust-analyzer binary version which is stated inside the extension source. |
@bjorn3 thanks for the context - that makes sense, but as a user it seems non-ideal, could the extension present me with an update button which updates both concurrently, rather than allowing the extension to break in this way when I might be relying on it? e.g. I open my editor, the extension updates, I don't use rust and don't notice, then I get on an airplane, where I don't have internet. A workflow which worked just before I got on the airplane now doesn't work, because I got unlucky, and I'm not in a situation where I can easily fix it. Even if the above scenario is contrived, in practice, I'm demoing rust a lot to different people at the moment, and often I have to say "oh darn, it's broken, we have to wait a few minutes while the extension updates and then I have to restart my editor and rust is great I promise! crap, I've lost them." |
Vscode automatically updates the extension when there is a new version. I don't think extensions can prevent this. Only the user can by explicitly installing a specific version. I agree that it is not ideal, but I don't think there is much we can do apart from maybe allowing the extension to use an older rust-analyzer binary and hoping that nothing breaks. |
One suggestion which comes to mind is to have logic in the extension which grabs the latest analyzer binary in advance of when it's needed. So that when vscode updates the extension, the needed binary is already there. It's not a full fix, but would at least mean that it doesn't break for everybody every time. |
The extension and server binary are published at the same time. I'm not sure if Code updates the extension on the fly or on restart, but we generally can't detect that a new server was published. A workaround for you would be to disable updates for the extension (you can do that in Code) and update it manually when you remember and know you're on a stable network connection. Maybe we could also have a toggle to disable protocol extensions; then we could still run a mismatched server. |
Not sure what’s the root cause here is exactly, but weave recently became more forgiving of mismatched versions (by using lsp capabilities), so I thing we can clots this, |
Hi! rust newbie here just trying things out. The first things I'm trying haven't worked and I thought you might like to know. Perhaps there is something obvious wrong with what I'm trying to do, but looking over the docs and issue tracker I can't figure it out quickly.
cargo new
.cargo run
:Go to definition does not work on any symbol, as far as I can tell. For example,
Command
, ornew
,Result
,Ok
, etc. Should I expect this to work?Go-to-symbol works if I define and use a symbol within the file.
Completion doesn't seem to work for symbols outside the file, either.
The text was updated successfully, but these errors were encountered: