Code analysis not working when file is not referenced
See original GitHub issueWhen editing a file in a project, if the file is not referenced from main (or lib), syntax highlighting works, but code analysis does not.
For example, having
src/mymod/mod.rs:
mod one;
// missing "mod two;"
src/mymod/two.rs
use std::fs;
fn foo() -> Result<String, ()> {
fs::read_dir(...).{cursor_here}
}
When you are in {cursor_here} and press ctrl-space, nothing gets suggested as auto-complete; Pressing ctrl-b over read_dir
returns “declaration not found”; Type hints are not shown for function results; No error is detected for the wrong Result<>
signature, etc.
The desired effect would be to at least have code analysis for crates (both std and the ones in Cargo.toml), as I understand it’s hard to have info about the rest of the application, not knowing where the file is going to end up in the nemaspace.
But also, as a quick fix, having a yellow bar on the top saying “Code analysis is disabled for this file as it’s not linked in the project” (or something similar) would be very useful, as it would also remind the developer to add it. cargo check
ignores the file, and I was puzzled for a while yesterday when it happened: I had no errors or warning from either side. 😃
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
Oh, you’re right, I could swear that I saw that bar before 😃 I’ll try to take a look why it disappears when there’s
Cargo.toml
.Fixed by https://github.com/intellij-rust/intellij-rust/pull/3826.