Skip to content

ICE: macros: entered unreachable code' #126742

@matthiaskrgr

Description

@matthiaskrgr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-fn_delegation`#![feature(fn_delegation)]`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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions