Hints work in main.rs, but not other files. Why?

This is in src/main.rs

No hint

Note: This problem is resolved once query_string is imported to main.rs. Why doesn't rust-analyser read files within the src folder?

You don't say what tooling you're using, but, assuming you're in VS Code with the rust-analyzer extension, what you're describing is as expected. Rust-analyzer works over projects, not directories, where a 'project' is typically a Cargo project (though you can configure it to use other build systems).

To be included in a Cargo project a rust file needs to follow the Cargo conventions or be explicitly brought into the module tree with mod. Random rust files in the same dirs are not (as far as I understand) part of the project, so are not analysed by the language server (which is what provides completions to the editor).

1 Like

It was VSCode
Thank you! This works. Now I need to research deeper into the Cargo conventions.