New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include!
ing files without .rs
suffix does not work
#10178
Comments
Oh, and for reference, I do have: {"rust-analyzer.cargo.runBuildScripts": true} |
I think this happens because we only add files ending in |
Hmm, I feel odd calling it Looks like the |
I have the same issue, my files end in let expression = include!("../tests/variable.ast"); |
Fascinatingly if I use static GREETING: &str = include!(concat!(env!("OUT_DIR"), "/foobar.inc"));
fn main() {
println!(include!(concat!(env!("OUT_DIR"), "/foobar.inc")));
println!("{}", GREETING);
} This exhibits the failure to load the include file for the With a `build.rs`:use std::io::Write;
use std::path::Path;
fn main() {
let outpath = Path::new(&std::env::var("OUT_DIR").unwrap()).join("foobar.inc");
let mut fh = std::fs::File::create(outpath).unwrap();
fh.write_all("\"Hello world\"".as_bytes()).unwrap();
} |
How would one go about fixing this? I'd be interested. BTW: this should probably be renamed to something more descriptive like "failed to load reported for non-.rs files" |
There is no straightforward fix. We can only include files that are in the virtual file system; we have to limit the set of files in the VFS somehow because loading every file in the workspace would be prohibitively expensive; and we don't know the files that will be included when deciding what to load into the VFS.
|
FWIW I'm seeing this in a multi-crate repository (tagged to a commit that exhibits the issue). It appears that RA may be trying to use the wrong path relative to the crate to load the included file? The project(s) build fine with The path in the error message is (relative to repository root): But the path I would expect is: However, the path in the error message does exist, since the $ cargo build
Compiling libretro-rs-sys v0.1.0 (/home/adam/Repos/libretro-rs/libretro-rs-sys)
Compiling libretro-rs v0.1.3 (/home/adam/Repos/libretro-rs/libretro-rs)
Compiling example v0.1.0 (/home/adam/Repos/libretro-rs/example)
Finished dev [unoptimized + debuginfo] target(s) in 0.93s If this issue is unrelated, I'll make a new issue. |
That is a different issue yes since your file is an |
OUT_DIR
include!
ing files without .rs
suffix does not work
I have a project (https://gitlab.com/subplot/subplot) which has a
build.rs
which writes a file out to be included into the build.The file is written out to
OUT_DIR
(embedded_files.inc
)In my code I have:
In VSCode, I have that line have the following error shown:
However, that file very much does exist, so the error is spurious. Is there a way to get rust-analyzer to find this file and stop complaining?
The text was updated successfully, but these errors were encountered: