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

libsyntax: bug in macro expanded non-inline module declarations #31624

Closed
jseyfried opened this issue Feb 13, 2016 · 0 comments · Fixed by #32006
Closed

libsyntax: bug in macro expanded non-inline module declarations #31624

jseyfried opened this issue Feb 13, 2016 · 0 comments · Fixed by #32006
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

Comments

@jseyfried
Copy link
Contributor

The search paths for a macro-expanded non-inline module declaration are always computed as if the declaration were at the top level of the file in which the macro was defined.

@steveklabnik steveklabnik added A-libs A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Feb 15, 2016
bors added a commit that referenced this issue 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants