Skip to content

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

Merged
bors merged 3 commits into
rust-lang:masterfrom
jseyfried:fix_expanded_mod_path
Mar 4, 2016
Merged

bors merged 3 commits into
rust-lang:masterfrom
jseyfried:fix_expanded_mod_path

Conversation

@jseyfried

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

cc @nikomatsakis @Kimundi @nrc

@jseyfried
jseyfried force-pushed the fix_expanded_mod_path branch from 9379359 to e2aa90e Compare March 2, 2016 23:51
@alexcrichton

Copy link
Copy Markdown
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
Copy Markdown
Contributor

@bors r+

@bors

bors commented Mar 3, 2016

Copy link
Copy Markdown
Collaborator

📌 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

bors commented Mar 4, 2016

Copy link
Copy Markdown
Collaborator

⌛ 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