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

Exported macros break paths #20701

Closed
lifthrasiir opened this issue Jan 7, 2015 · 4 comments
Closed

Exported macros break paths #20701

lifthrasiir opened this issue Jan 7, 2015 · 4 comments
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-pretty Area: Pretty printing.

Comments

@lifthrasiir
Copy link
Contributor

$ cat t.rs
#[macro_export] macro_rules! foo { () => (mod foo { use super::f; pub fn ff() { f(); } }) }

$ cat s.rs
#[macro_use] extern crate t;
macro_rules! bar { () => (mod bar { use super::f; pub fn ff() { f(); } }) }
fn f() { println!("ffff"); }
foo!();
bar!();

$ rustc t.rs --crate-type lib

$ rustc s.rs --crate-type lib -L.
<t macros>:1:25: 1:30 error: expected identifier, found keyword `super`
<t macros>:1 (  ) => ( mod foo { use super :: f ; pub fn ff (  ) { f (  ) ; } } )
                                     ^~~~~

Macro definitions encoded to the metadata do not preserve the ModName identifier style, thus certain paths break down.

lifthrasiir added a commit to lifthrasiir/rust-encoding that referenced this issue Jan 7, 2015
- Fixed deprecated macro syntaxes per the macro reform.
- Changed the test macro syntax; it was affected by rust-lang/rust#20701
  which prevents the direct use of `self::` or `super::` paths in
  exported macros. This triggers a regeneration of indices.
@kmcallister
Copy link
Contributor

Nice catch. I was afraid something like this would happen...

Really a bug in pretty printing, as it doesn't preserve the ident style. This is what we get for hacking contextual lexer information into the token stream...

@kmcallister kmcallister added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-pretty Area: Pretty printing. labels Jan 7, 2015
vadimcn added a commit to vadimcn/rust that referenced this issue Jan 23, 2015
mbrubeck referenced this issue in servo/android-rs-glue Jan 27, 2015
Fixes a build error in current Rust snapshot
@lifthrasiir
Copy link
Contributor Author

The original example now compiles fine, but then I'm not sure about rust-mobile/android-rs-glue#27. @tomaka, is this issue still relevant?

@tomaka
Copy link
Contributor

tomaka commented Feb 5, 2015

I didn't test myself, but @ozkriff reported that it's fixed.

@alexcrichton
Copy link
Member

Yeah it looks like this has been fixed, yay!

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, ..) A-pretty Area: Pretty printing.
Projects
None yet
Development

No branches or pull requests

4 participants