I get "unresolved imports" on vscode however compiler is fine with it

So in one of my rust files I am doing this:

However vscode thinks this is an error, but I can still compile it fine and it will still execute just fine, so I am not too sure why vscode thinks this is an error, is there a way to tell vscode this is not an error, or maybe tell rust-analyzer to ignore this two lines of code maybe or something?

This seems to be a known issue with Rust Analyzer when working with paths outside your current project root.

Check the GitHub issue for a suggested way to ignore the error.

Alternatively, don't try to move against the flow. It's expected that all the necessary files for the crate are stored under the crate root, and if you don't follow this expectation, something can always break.

If you have a set of common functions you use across multiple projects, you could out them all in a crate and then depend on this crate in the Cargo.toml of your projects.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.