Description
When using a build script to generate code I tried to include it in a submodule in the following way:
#[path = concat!(env!("OUT_DIR"), "/generated.rs")]
pub mod generated;
However this results in error[E0583]: file not found for module generated
. The error does not display the actual path it tried to access.
The closes related issue I could find are #18849 and rust-lang/rfcs#1516 (related rust-lang/cargo#824). However all of these talk about the compile error being a parse error, while I'm getting an error about file not being found.
For reference, here's the build script: (abridged, I apologize if this doesn't compile but you get the idea)
use std::{env, fs};
use std::path::PathBuf;
fn main() {
let out_dir = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR not set"));
let mut file = fs::File::create(&out_dir.join("/generated.cs")).expect("Failed to create generated.rs");
let _ = writeln!(file, "pub const FOO: i32 = 42;");
}
The include!
macro works mostly but has one annoying problem that top-level inner attributes causes a compile error: #18810
The unexpected and reason why I don't think this is a duplicate issue is that the compile error has changed. From the error rust reports it appears I've made a simple typo in the path
when in fact this feature is simply not supported.