`include!` not working with rust-analyzer

When using include!("foo.def") in a project, rust-analyzer reports "failed to load file foo.def". include_str! works fine (though obviously gives a type error since I'm not expecting a string here). cargo build compiles the project successfully, so it's definitely something with r-a. Any idea what's going on? Does r-a just not support include!?

Simple reproduction:

  • cargo new --lib foo
  • add src/foo.def file containing [1, 2, 3]
  • replace src/lib.rs with
    pub const ARRAY: [usize; 3] = include!("foo.def");
    
  • open project in vs code with rust-analyzer (version v0.3.2037)
  • observe red squiggly!

Looks like this issue (or technically the one linked at the end).

1 Like

Thanks! That was indeed the issue. Not sure why that thread didn't come up when I googled this before...