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

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

Closed
steffahn opened this issue May 29, 2022 · 2 comments · Fixed by #108729
Closed

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

steffahn opened this issue May 29, 2022 · 2 comments · Fixed by #108729
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@steffahn
Copy link
Member

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`

@steffahn steffahn added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 29, 2022
@steffahn
Copy link
Member Author

steffahn commented May 29, 2022

Ah, the nested macro is unnecessary! This ICEs, too

macro_rules! foo {
    () => {};
}

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

m! {}

use bar as baz;

baz! {}

@matthiaskrgr
Copy link
Member

Note: this only seems to reproduce with --edition=2021

@matthiaskrgr matthiaskrgr changed the title ICE with macros in macros and multiple use ... as ... ICE with macros in macros and multiple use ... as ... with --edition=2021 May 30, 2022
matthiaskrgr added a commit to matthiaskrgr/glacier that referenced this issue May 30, 2022
matthiaskrgr added a commit to matthiaskrgr/glacier that referenced this issue May 30, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 30, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 20, 2023
…enkov

fix: modify the condition that `resolve_imports` stops

close rust-lang#97534
@bors bors closed this as completed in ee330a3 Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants