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

Fix the search paths for macro-expanded non-inline modules #32006

Merged
merged 3 commits into from
Mar 4, 2016

Conversation

jseyfried
Copy link
Contributor

This PR changes the search paths for macro-expanded non-inline modules so that they match ordinary non-inline modules (fixes #31624). This is a [breaking-change].

Right now, the search paths for a macro-expanded non-inline module are computed as if the module were declared in the top level of the file in which the macro was defined.
For example, consider ./foo/mod.rs:

#[macro_use]
mod inconsequential { // moving the macro outside this module wouldn't change anything
    macro_rules! mod_decl {
        ($i:ident) => { mod $i; }
    }
}

and ./lib.rs:

#[macro_use]
mod foo;

mod bar {
    mod_decl!(baz);
    //^ Now, rustc expects `./foo/baz.rs` (or `./foo/baz/mod.rs`)
    //| After this PR, rustc will expect `./bar/baz.rs` (or `./bar/baz/mod.rs`)
}

r? @alexcrichton

@jseyfried
Copy link
Contributor Author

cc @nikomatsakis @Kimundi @nrc

@alexcrichton
Copy link
Member

I ran this through crater and it reported no regressions. Implementation also looks good to me!

Assigning to @nikomatsakis for a second opinion as well (also to ensure this is expected).

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Mar 3, 2016

📌 Commit e2aa90e has been approved by nikomatsakis

bors added a commit that referenced this pull request Mar 4, 2016
This PR changes the search paths for macro-expanded non-inline modules so that they match ordinary non-inline modules (fixes #31624). This is a [breaking-change].

Right now, the search paths for a macro-expanded non-inline module are computed as if the module were declared in the top level of the file in which the macro was defined.
For example, consider `./foo/mod.rs`:
```rust
mod inconsequential { // moving the macro outside this module wouldn't change anything
    macro_rules! mod_decl {
        ($i:ident) => { mod $i; }
    }
}
```
and `./lib.rs`:
```rust
mod foo;

mod bar {
    mod_decl!(baz);
    //^ Now, rustc expects `./foo/baz.rs` (or `./foo/baz/mod.rs`)
    //| After this PR, rustc will expect `./bar/baz.rs` (or `./bar/baz/mod.rs`)
}
```
r? @alexcrichton
@bors
Copy link
Contributor

bors commented Mar 4, 2016

⌛ Testing commit e2aa90e with merge 5b5e521...

@bors bors merged commit e2aa90e into rust-lang:master Mar 4, 2016
bors added a commit to rust-lang/cargo that referenced this pull request Mar 4, 2016
This PR moves the subcommands in `src/bin` into their own directory and ensures future compatibility with the corrected search paths for non-inline modules (see [Rust PR #32006](rust-lang/rust#32006)).
r? @alexcrichton
@jseyfried jseyfried deleted the fix_expanded_mod_path branch March 25, 2016 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

libsyntax: bug in macro expanded non-inline module declarations
4 participants