Skip to content

module name overlap within macros causes ICE #58417

@ghost

Description

macro_rules! gen_mod {
    ($mod_name:ident) => {
        mod $mod_name {}
        pub use $mod_name;
    }
}
gen_mod! { A }

fn main() {
    println!("Oh no!");
}
   Compiling playground v0.0.1 (/playground)
thread 'main' panicked at 'byte index 31 is out of bounds of `$mod_name`', src/libcore/str/mod.rs:2092:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.32.0 (9fda7c223 2019-01-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

Playground Link

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions