Open strohel opened 2 years ago
text.in
doesn't work as rust-analyzer only loads .rs
files when populating the database. During macro expansion it isn't possible to read additional files. Using include!()
as expression with files with the .rs
extension not working should definitively be fixed though.
text.in
doesn't work as rust-analyzer only loads.rs
files when populating the database. During macro expansion it isn't possible to read additional files.
Got it, thanks for the info. Would it be possible to demote the error into a warning or info, saying something like "rust-analyzer cannot read non-.rs files during macro expansion"?
Using
include!()
as expression with files with the.rs
extension not working should definitively be fixed though.
I've updated title, description and the code in example repository to directly showcase this case.
I'm running into the same problem (that rust-analyzer only loads .rs files) I named an include file .inc because it's in the cargo examples directory, and I don't want it to get picked up as an example.
Duplicate of #10178
Duplicate of #10178
That's right, the problem is the same. #10178 has somewhat confusing title: the problem is in fact orthogonal to OUT_DIR and doesn't happen spuriously.
std::include!
has 2 variants depending on how it is used:include!("bindings.rs")
often used in -sys crates.let value = include!("file.in")
used likely much less.The item variant works well, but the expression variant always causes rust-analyzer to emit an error. The only negative effect of the error on rust-analyzer is that it doesn't infer the type of the variable. Specifying the type explicitly works.
Minimal reproduction:
With both
text.in
andtext.rs
being:Gives the following rust-analyzer errors:
Also available at https://github.com/strohel/include-test-case as a complete Cargo crate.
Note that if the included file has
.rs
extension (text.rs
), the errors are slightly different.VSCodium 1.61.2 rust-analyzer v0.2.784 from https://open-vsx.org/extension/matklad/rust-analyzer/0.2.784