Skip to content
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

Importing modules from inside include! no longer works #70185

Closed
jdm opened this issue Mar 20, 2020 · 6 comments
Closed

Importing modules from inside include! no longer works #70185

jdm opened this issue Mar 20, 2020 · 6 comments
Assignees
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jdm
Copy link
Contributor

jdm commented Mar 20, 2020

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

I suspect either #68941 or #66131.

@jdm jdm added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. C-bug Category: This is a bug. labels Mar 20, 2020
@SimonSapin
Copy link
Contributor

Regression range: f509b26...f4c675c

Merge commits in that range:

@jonas-schievink jonas-schievink added A-parser Area: The parsing of Rust source code to an AST I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 20, 2020
@jonas-schievink
Copy link
Contributor

probably cause: #69838

cc @Centril

@Centril Centril assigned Centril and unassigned Centril Mar 20, 2020
@jdm
Copy link
Contributor Author

jdm commented Mar 20, 2020

Looks like this should be fixed by #70184?

@Centril
Copy link
Contributor

Centril commented Mar 20, 2020

@jdm Yeah that should fix it.

@Centril Centril added P-high High priority A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-frontend Area: Compiler frontend (errors, parsing and HIR) and removed I-nominated A-parser Area: The parsing of Rust source code to an AST labels Mar 20, 2020
@Centril
Copy link
Contributor

Centril commented Mar 21, 2020

#70184 has landed now. @jdm can you confirm on the next nightly whether the issue was fixed for y'all?

@SimonSapin
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants