-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
live-update diagnostics #3107
Comments
These diagnostics come from running |
thanks for the insight! is this something rust-analyzer could do too? |
Currently rust-analyzer is using stable. These api's however require nightly, so using them is not possible. Using for example LD_PRELOAD it would be possible to change the open syscall, but this is a hack and I don't know if windows has something equivalent. |
@bjorn3 Is there any plan to make the analysis work while typing? |
Related to this, on RLS Notice how it using this https://github.com/rust-lang/rustc-dev-guide/blob/master/src/rustc-driver.md Due to my unfamiliarity with Rust, I couldn't find out whether |
|
@bjorn3 Thanks for the clarification. My attempt was for understanding what is blocking progress on this issue on the
Is there some roadmap and/or tracking issue for having them on stable? (Or maybe they already are?) |
No, there is no roadmap, nor a tracking issue. These are implementation details of the rust compiler. It is highly likely that the api's necessary for this will look fundamentally different in a few years. Either as a result of the ongoing libraryfication of rustc (to make it easier to share code with other tools like rust-analyzer) or as a result of the wish to push back incremental compilation more towards the macro expansion/parsing part of the compilation. |
@bjorn3 Instead of stabilizing the internal If we define this such that we can substitute any data read from the filesystem, then we don't have to build-in any assumptions about how the internal API of the compiler works. For example:
Source directory:
overrides.json {
"version": 0,
"overrides": [
{ "path": "submodule.rs", "override": "/some/tmp/ra/dir/submodule.rs", "mtime": "..." }
]
} |
I think such a remapping can be already achieved using e.g. bind mounts or symbolic links (at least on Linux). |
Is there any reason preventing rust-analyzer from using nightly compiler APIs?
|
There are reasons, yes -- we prefer rust-analyzer to build on stable with normal These problems might be avoidable by implementing a separate custom driver for rustc, but the other reason why no-one is spending effort on this is that it's not the final architecture we intend. The whole reason for rust-analyzer's existence is that the RLS approach of just running the compiler on every change is a dead-end. The current 'cargo watch' / flycheck integration is a stopgap to provide diagnostics that rust-analyzer can't provide natively, but our focus is on librarification of rustc and providing more and more diagnostics natively, ideally by sharing library code with rustc. We're not far off from showing type errors natively (without saving), for example. (Just to be clear, that's not saying that any particular pull requests would be rejected out of hand.) |
Naive question. If rust analyzer knows the types of local variables and the signature of functions, could we have type checking for assigning a value with the wrong type to a variable and passing a value with the wrong type to a function? I've found those two are my most common errors. Willing to contribute |
This already exists as an experimental diagnostic; you can enable it by setting |
@flodiebold, awesome! thanks :) |
This issue should be pinned because it gains the most numbers of 👍️. |
@tats-u This issue does not get updated when we add more diagnostics, so I see no reason to pin it. Achieving parity with rustc's diagnostics is a very big project that's going to take a lot of time. We are incrementally adding more and more diagnostics. Next-gen trait solver (on which work was just started) may finally allow us to enable typecheck diagnostics by default, and borrow check diagnostics will likely require more work or switch to Polonius before enabling by default. These are the bigger ones, but there are many small ones. |
Is it possible to get diagnostics when text is edited, like with a debounce/delay so its not overwhelming?
Right now I have to save in order to see them - which is more of a problem than it may seem since old errors lurk around and pollute the screen
The text was updated successfully, but these errors were encountered: