Closed
Description
This code works in the 2020-03-19 nightly:
build.rs:
use std::env;
use std::fs;
use std::path::PathBuf;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let path: PathBuf = [out_dir.clone(), "foo.rs".to_string()].iter().collect();
fs::write(path, "pub mod foo2;").unwrap();
let path: PathBuf = [out_dir, "foo2.rs".to_string()].iter().collect();
fs::write(path, "pub fn foo_fn() {}").unwrap();
}
lib.rs:
mod stuff {
include!(concat!(env!("OUT_DIR"), "/foo.rs"));
}
fn main() {
stuff::foo2::foo_fn();
}
The resulting OUT_DIR looks like:
$ ls target/debug/build/regress-d7c49d33c7449edf/out
foo.rs foo2.rs
With the 2020-03-20 nightly, this crate generates the following output:
error[E0583]: file not found for module `foo2`
--> /Users/joshmatthews/regress/target/debug/build/regress-1976556320d6d1b4/out/foo.rs:1:1
|
1 | pub mod foo2;
| ^^^^^^^^^^^^^
|
= help: to create the module `foo2`, create file "src/stuff/foo2.rs"
error[E0425]: cannot find function `foo_fn` in module `stuff::foo2`
--> src/main.rs:7:18
|
7 | stuff::foo2::foo_fn();
| ^^^^^^ not found in `stuff::foo2`
error: aborting due to 2 previous errors