Skip to content

ICE with macros in macros and multiple use ... as ... with --edition=2021 #97534

Closed
@steffahn

Description

@steffahn

Code

macro_rules! m {
    () => {
        macro_rules! foo {
            () => {
                
            }
        }
        use foo as bar;
    }
}

m!{}

use bar as baz;

baz!{}

(playground)

Meta

note: rustc 1.63.0-nightly (1fede1753 2022-05-28) running on x86_64-unknown-linux-gnu

Error output

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: expansion entered force mode without producing any errors
  --> src/lib.rs:16:1
   |
16 | baz!{}
   | ^^^^^^
   |
   = note: delayed at compiler/rustc_expand/src/expand.rs:415:34

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1368:13
stack backtrace:
   0:     0x7f6f85cabfad - std::backtrace_rs::backtrace::libunwind::trace::h299cf2fa55cd18e9
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f6f85cabfad - std::backtrace_rs::backtrace::trace_unsynchronized::h9c3e5e09cd2938a9
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f6f85cabfad - std::sys_common::backtrace::_print_fmt::h2f4272fba2a84b08
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f6f85cabfad - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9cc2e6942da231a2
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f6f85d07e3c - core::fmt::write::h74a5682239bd79fa
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/core/src/fmt/mod.rs:1196:17
   5:     0x7f6f85c9d741 - std::io::Write::write_fmt::hdfbb1a9b5737a83f
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/std/src/io/mod.rs:1654:15
   6:     0x7f6f85caec95 - std::sys_common::backtrace::_print::h50a7f15c42b03867
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f6f85caec95 - std::sys_common::backtrace::print::h02ebeceda33368d4
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f6f85caec95 - std::panicking::default_hook::{{closure}}::h0887a34b8cc3534d
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/std/src/panicking.rs:295:22
   9:     0x7f6f85cae9b6 - std::panicking::default_hook::h0c4795ddf5f68072
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/std/src/panicking.rs:314:9
  10:     0x7f6f8647ddc1 - rustc_driver[2fa83badea7f0cdf]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f6f85caf36a - std::panicking::rust_panic_with_hook::h78546479954c9351
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/std/src/panicking.rs:702:17
  12:     0x7f6f87610241 - std[ffa8b9f11b03dc27]::panicking::begin_panic::<rustc_errors[4e2c3398779f3018]::ExplicitBug>::{closure#0}
  13:     0x7f6f8760fdb6 - std[ffa8b9f11b03dc27]::sys_common::backtrace::__rust_end_short_backtrace::<std[ffa8b9f11b03dc27]::panicking::begin_panic<rustc_errors[4e2c3398779f3018]::ExplicitBug>::{closure#0}, !>
  14:     0x7f6f8762a1a6 - std[ffa8b9f11b03dc27]::panicking::begin_panic::<rustc_errors[4e2c3398779f3018]::ExplicitBug>
  15:     0x7f6f8762e2c6 - std[ffa8b9f11b03dc27]::panic::panic_any::<rustc_errors[4e2c3398779f3018]::ExplicitBug>
  16:     0x7f6f88ea5b81 - <rustc_errors[4e2c3398779f3018]::HandlerInner as core[be5cd14476d8865]::ops::drop::Drop>::drop
  17:     0x7f6f88613ab8 - core[be5cd14476d8865]::ptr::drop_in_place::<rustc_session[df9bd80ce5aaf91e]::parse::ParseSess>
  18:     0x7f6f88616503 - <alloc[3d41ab90ce221d7c]::rc::Rc<rustc_session[df9bd80ce5aaf91e]::session::Session> as core[be5cd14476d8865]::ops::drop::Drop>::drop
  19:     0x7f6f8860dc3d - core[be5cd14476d8865]::ptr::drop_in_place::<rustc_interface[dd8e8ad2dcac8021]::interface::Compiler>
  20:     0x7f6f8860d675 - rustc_span[dae761737fa53508]::with_source_map::<core[be5cd14476d8865]::result::Result<(), rustc_errors[4e2c3398779f3018]::ErrorGuaranteed>, rustc_interface[dd8e8ad2dcac8021]::interface::create_compiler_and_run<core[be5cd14476d8865]::result::Result<(), rustc_errors[4e2c3398779f3018]::ErrorGuaranteed>, rustc_driver[2fa83badea7f0cdf]::run_compiler::{closure#1}>::{closure#1}>
  21:     0x7f6f885eb397 - <scoped_tls[6e45a7225ea89339]::ScopedKey<rustc_span[dae761737fa53508]::SessionGlobals>>::set::<rustc_interface[dd8e8ad2dcac8021]::interface::run_compiler<core[be5cd14476d8865]::result::Result<(), rustc_errors[4e2c3398779f3018]::ErrorGuaranteed>, rustc_driver[2fa83badea7f0cdf]::run_compiler::{closure#1}>::{closure#0}, core[be5cd14476d8865]::result::Result<(), rustc_errors[4e2c3398779f3018]::ErrorGuaranteed>>
  22:     0x7f6f8860039f - std[ffa8b9f11b03dc27]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[dd8e8ad2dcac8021]::util::run_in_thread_pool_with_globals<rustc_interface[dd8e8ad2dcac8021]::interface::run_compiler<core[be5cd14476d8865]::result::Result<(), rustc_errors[4e2c3398779f3018]::ErrorGuaranteed>, rustc_driver[2fa83badea7f0cdf]::run_compiler::{closure#1}>::{closure#0}, core[be5cd14476d8865]::result::Result<(), rustc_errors[4e2c3398779f3018]::ErrorGuaranteed>>::{closure#0}, core[be5cd14476d8865]::result::Result<(), rustc_errors[4e2c3398779f3018]::ErrorGuaranteed>>
  23:     0x7f6f886004d9 - <<std[ffa8b9f11b03dc27]::thread::Builder>::spawn_unchecked_<rustc_interface[dd8e8ad2dcac8021]::util::run_in_thread_pool_with_globals<rustc_interface[dd8e8ad2dcac8021]::interface::run_compiler<core[be5cd14476d8865]::result::Result<(), rustc_errors[4e2c3398779f3018]::ErrorGuaranteed>, rustc_driver[2fa83badea7f0cdf]::run_compiler::{closure#1}>::{closure#0}, core[be5cd14476d8865]::result::Result<(), rustc_errors[4e2c3398779f3018]::ErrorGuaranteed>>::{closure#0}, core[be5cd14476d8865]::result::Result<(), rustc_errors[4e2c3398779f3018]::ErrorGuaranteed>>::{closure#1} as core[be5cd14476d8865]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x7f6f85cb9283 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hecccfcb66db01976
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/alloc/src/boxed.rs:1872:9
  25:     0x7f6f85cb9283 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfb7a821851f8fe74
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/alloc/src/boxed.rs:1872:9
  26:     0x7f6f85cb9283 - std::sys::unix::thread::Thread::new::thread_start::h2ecf741a356f4523
                               at /rustc/1fede1753c33f4ce0660ad9b8edbd618d9733daf/library/std/src/sys/unix/thread.rs:108:17
  27:     0x7f6f85bdf609 - start_thread
  28:     0x7f6f85b02133 - clone
  29:                0x0 - <unknown>

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.63.0-nightly (1fede1753 2022-05-28) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
end of query stack
error: could not compile `playground`
Backtrace

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: expansion entered force mode without producing any errors
  --> src/lib.rs:16:1
   |
16 | baz!{}
   | ^^^^^^
   |
   = note: delayed at compiler/rustc_expand/src/expand.rs:415:34

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1368:13
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   3: core::ptr::drop_in_place::<rustc_session::parse::ParseSess>
   4: <alloc::rc::Rc<rustc_session::session::Session> as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place::<rustc_interface::interface::Compiler>
   6: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
   7: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.63.0-nightly (1fede1753 2022-05-28) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
end of query stack
error: could not compile `playground`

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions