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: macros: entered unreachable code' #126742

Closed
matthiaskrgr opened this issue Jun 20, 2024 · 2 comments · Fixed by #126837
Closed

ICE: macros: entered unreachable code' #126742

matthiaskrgr opened this issue Jun 20, 2024 · 2 comments · Fixed by #126837
Labels
C-bug Category: This is a bug. F-fn_delegation `#![feature(fn_delegation)]` 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

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

impl Trait for S {
    reuse <()>::* { self_0!(self) }
}

original:

//@ check-pass

#![feature(fn_delegation)]
#![allow(incomplete_features)]

trait Trait {
    fn foo(&self) -> u8 { 0 }
    fn bar(&self) -> u8 { 1 }
}

impl Trait for u8 {}

struct S(u8);

// Macro expansion works inside delegation items.
macro_rules! u8 { () => { u8 } }
macro_rules! self_0 { ($self:ident) => { &$self.0 } }
impl Trait for S {
    reuse <IndirectEvil>::* { self_0!(self) }
}

fn main() {
    let s = S(2);
    s.foo();
    s.bar();
}

Version information

rustc 1.81.0-nightly (1ca578e68 2024-06-20)
binary: rustc
commit-hash: 1ca578e68eb715e772fc0c1b9e6ca7c5b122765a
commit-date: 2024-06-20
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

thread 'rustc' panicked at compiler/rustc_resolve/src/macros.rs:721:43:
internal error: entered unreachable code
stack backtrace:
   0:     0x715b87ae6915 - std::backtrace_rs::backtrace::libunwind::trace::h796e75e96c439f3e
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x715b87ae6915 - std::backtrace_rs::backtrace::trace_unsynchronized::h57b5b13bb46e11ba
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x715b87ae6915 - std::sys::backtrace::_print_fmt::h11ce45f986076e87
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/backtrace.rs:68:5
   3:     0x715b87ae6915 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hcd09ba6a4fc236f1
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/backtrace.rs:44:22
   4:     0x715b87b374bb - core::fmt::rt::Argument::fmt::h914f09f4a1c58d59
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/core/src/fmt/rt.rs:165:63
   5:     0x715b87b374bb - core::fmt::write::hc590b91d463e6a2c
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/core/src/fmt/mod.rs:1168:21
   6:     0x715b87adb5af - std::io::Write::write_fmt::hc69b1d0ded026622
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/io/mod.rs:1835:15
   7:     0x715b87ae66ee - std::sys::backtrace::_print::hc852e4497da27a95
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/backtrace.rs:47:5
   8:     0x715b87ae66ee - std::sys::backtrace::print::hc624de700d5fe576
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/backtrace.rs:34:9
   9:     0x715b87ae9129 - std::panicking::default_hook::{{closure}}::hf8d8481f1d9702fb
  10:     0x715b87ae8ecc - std::panicking::default_hook::he469b58de751f8ee
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/panicking.rs:292:9
  11:     0x715b84147870 - std[eca1b30e63fdea7a]::panicking::update_hook::<alloc[79c37403ec1ba474]::boxed::Box<rustc_driver_impl[93e75e0175b92285]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x715b87ae9a4f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h7fb9108d23a6d563
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/alloc/src/boxed.rs:2076:9
  13:     0x715b87ae9a4f - std::panicking::rust_panic_with_hook::h738066c73a52890f
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/panicking.rs:804:13
  14:     0x715b87ae9643 - std::panicking::begin_panic_handler::{{closure}}::h8534a2aac695431b
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/panicking.rs:663:13
  15:     0x715b87ae6dd9 - std::sys::backtrace::__rust_end_short_backtrace::h3420ee35d28bf807
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/backtrace.rs:171:18
  16:     0x715b87ae9304 - rust_begin_unwind
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/panicking.rs:661:5
  17:     0x715b87b33a73 - core::panicking::panic_fmt::h51cb44e3a97167f8
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/core/src/panicking.rs:74:14
  18:     0x715b87b33afc - core::panicking::panic::h01e4b12779f48d55
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/core/src/panicking.rs:148:5
  19:     0x715b85b0c9fa - <rustc_resolve[163f0c579907b7cb]::Resolver as rustc_expand[232dfa03af1749ae]::base::ResolverExpand>::resolve_macro_invocation
  20:     0x715b81e4e4ed - <rustc_expand[232dfa03af1749ae]::expand::MacroExpander>::fully_expand_fragment
  21:     0x715b86100772 - <rustc_expand[232dfa03af1749ae]::expand::MacroExpander>::expand_crate
  22:     0x715b85b4634a - rustc_interface[7fb7dc76513cf959]::passes::resolver_for_lowering_raw
  23:     0x715b85b4590d - rustc_query_impl[da2d3b64247f93f0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[da2d3b64247f93f0]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a7abdaade2c6424c]::query::erase::Erased<[u8; 16usize]>>
  24:     0x715b85b458ed - <rustc_query_impl[da2d3b64247f93f0]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[daaba097f859fa28]::ops::function::FnOnce<(rustc_middle[a7abdaade2c6424c]::ty::context::TyCtxt, ())>>::call_once
  25:     0x715b86430f51 - rustc_query_system[5e65d9b3abdd3162]::query::plumbing::try_execute_query::<rustc_query_impl[da2d3b64247f93f0]::DynamicConfig<rustc_query_system[5e65d9b3abdd3162]::query::caches::SingleCache<rustc_middle[a7abdaade2c6424c]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[da2d3b64247f93f0]::plumbing::QueryCtxt, false>
  26:     0x715b86430bed - rustc_query_impl[da2d3b64247f93f0]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  27:     0x715b862dd082 - rustc_interface[7fb7dc76513cf959]::interface::run_compiler::<core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>, rustc_driver_impl[93e75e0175b92285]::run_compiler::{closure#0}>::{closure#1}
  28:     0x715b8629dac9 - std[eca1b30e63fdea7a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[7fb7dc76513cf959]::util::run_in_thread_with_globals<rustc_interface[7fb7dc76513cf959]::util::run_in_thread_pool_with_globals<rustc_interface[7fb7dc76513cf959]::interface::run_compiler<core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>, rustc_driver_impl[93e75e0175b92285]::run_compiler::{closure#0}>::{closure#1}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>>::{closure#0}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>>
  29:     0x715b8629d880 - <<std[eca1b30e63fdea7a]::thread::Builder>::spawn_unchecked_<rustc_interface[7fb7dc76513cf959]::util::run_in_thread_with_globals<rustc_interface[7fb7dc76513cf959]::util::run_in_thread_pool_with_globals<rustc_interface[7fb7dc76513cf959]::interface::run_compiler<core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>, rustc_driver_impl[93e75e0175b92285]::run_compiler::{closure#0}>::{closure#1}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>>::{closure#0}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[daaba097f859fa28]::result::Result<(), rustc_span[1efc0ab8e6bb0790]::ErrorGuaranteed>>::{closure#2} as core[daaba097f859fa28]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x715b87af38cb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha1ad2417ff4e2c89
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/alloc/src/boxed.rs:2062:9
  31:     0x715b87af38cb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha5ab2243447620ef
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/alloc/src/boxed.rs:2062:9
  32:     0x715b87af38cb - std::sys::pal::unix::thread::Thread::new::thread_start::he00df2d38aeed7a5
                               at /rustc/1ca578e68eb715e772fc0c1b9e6ca7c5b122765a/library/std/src/sys/pal/unix/thread.rs:108:17
  33:     0x715b80ca6ded - <unknown>
  34:     0x715b80d2a0dc - <unknown>
  35:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: rustc 1.81.0-nightly (1ca578e68 2024-06-20) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack

@rustbot label +F-fn_delegation

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Jun 20, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-fn_delegation `#![feature(fn_delegation)]` labels Jun 20, 2024
@matthiaskrgr
Copy link
Member Author

#124135 ^_^

@petrochenkov
Copy link
Contributor

Fixed in #126837.

compiler-errors added a commit to compiler-errors/rust that referenced this issue Jun 23, 2024
…errors

delegation: Do not crash on qpaths without a trait

Fixes rust-lang#126742
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jun 23, 2024
…errors

delegation: Do not crash on qpaths without a trait

Fixes rust-lang#126742
@bors bors closed this as completed in 2c0311d Jun 23, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 23, 2024
Rollup merge of rust-lang#126837 - petrochenkov:delegfix, r=compiler-errors

delegation: Do not crash on qpaths without a trait

Fixes rust-lang#126742
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 24, 2024
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Jun 24, 2024
delegation: Do not crash on qpaths without a trait

Fixes rust-lang/rust#126742
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. F-fn_delegation `#![feature(fn_delegation)]` 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.

4 participants