Skip to content

Exported macros break paths #20701

Closed
Closed
@lifthrasiir

Description

@lifthrasiir
$ 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-prettyArea: Pretty printing (including `-Z unpretty`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions