question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code analysis not working when file is not referenced

See original GitHub issue

When 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:closed
  • Created 6 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Kobzolcommented, May 9, 2019

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.

0reactions
Kobzolcommented, Jun 15, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Code Analysis can't find reference, fails with 0 errors or warnings
Included in this project is a referenced DLL. If I remove the reference (and code that uses it), code analysis stops failing. So...
Read more >
Cannot find references and static code analysis not shown on ...
One of them is that in random projects (each developer has the issue with a different project) they are not able to "Find...
Read more >
Code Analysis Policy Errors - Visual Studio - Microsoft Learn
This error is raised when there is an open solution, but some files in the "pending check in" view are not part of...
Read more >
Analyze code issues in design time - ReSharper - JetBrains
ReSharper needs to have a solution model to analyze symbols and references used in each file. Therefore, it cannot analyze files that are...
Read more >
Versions of source generator dependencies - Damir's Corner
0, so the source generators must reference Microsoft.CodeAnalysis.CSharp 4.1.x or older, or they will not work in this version of Visual Studio.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found