Closed
Description
Code
A minimal example is slightly involved; the minimal triggering case seems to be that a proc-macro produces code that attempts to impl a trait that isn't visible from the location it ends up.
edit: this turns out not to require macros at all.
Cargo.toml
[package]
name = "bugreport"
edition = "2021"
src/lib.rs
trait PrivateTrait {
/// Without this associated const, there is no crash.
const FOO: usize;
}
src/main.rs
struct LocalType;
/// This should complain that PrivateTrait is not visible. Instead, the compiler panics.
impl bugreport::PrivateTrait for LocalType {
/// Without actually defining the trait's associated const, there is no crash.
const FOO: usize = 1;
}
fn main() {}
Meta
rustc --version --verbose
:
rustc 1.76.0-beta.1 (0e09125c6 2023-12-21)
binary: rustc
commit-hash: 0e09125c6c3c2fd70d7de961bcf0e51575235fad
commit-date: 2023-12-21
host: x86_64-unknown-linux-gnu
release: 1.76.0-beta.1
LLVM version: 17.0.6
This also occurs in nightly (rustc 1.77.0-nightly (fb5ed726f 2023-12-28)
), but not in stable (which provides the correct complaint that PrivateTrait
is not publicly re-exported)
Error output
thread 'rustc' panicked at compiler/rustc_middle/src/ty/mod.rs:432:29:
DefId::expect_local: `DefId(20:0 ~ bugreport[22e0])` isn't local
Backtrace
stack backtrace:
0: 0x7f6adfe306f6 - std::backtrace_rs::backtrace::libunwind::trace::h261606ad26a499c1
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
1: 0x7f6adfe306f6 - std::backtrace_rs::backtrace::trace_unsynchronized::hd183f0625477fb28
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f6adfe306f6 - std::sys_common::backtrace::_print_fmt::hd7f8fef21b4eda67
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7f6adfe306f6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h623d9b51f2f453f1
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f6adfe82f40 - core::fmt::rt::Argument::fmt::h9f417ac76a86f368
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/fmt/rt.rs:142:9
5: 0x7f6adfe82f40 - core::fmt::write::hc9b6faf4ac2aeff7
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/fmt/mod.rs:1120:17
6: 0x7f6adfe2453f - std::io::Write::write_fmt::hfead1eee52c2e65e
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/io/mod.rs:1810:15
7: 0x7f6adfe304d4 - std::sys_common::backtrace::_print::hd5d66399c7df88a2
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7f6adfe304d4 - std::sys_common::backtrace::print::he81ed2da642d37e5
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7f6adfe33267 - std::panicking::default_hook::{{closure}}::h85773f4fa117163d
10: 0x7f6adfe32fc9 - std::panicking::default_hook::h6a1694a91d09b278
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:292:9
11: 0x7f6adce189cc - std[ee6a4c5be0dc2fe4]::panicking::update_hook::<alloc[ca44ae591fa90b46]::boxed::Box<rustc_driver_impl[9db4319ac0e53fa6]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7f6adfe339b6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hcb3fe3b9bb537ba8
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/alloc/src/boxed.rs:2029:9
13: 0x7f6adfe339b6 - std::panicking::rust_panic_with_hook::h0a7ad96e90f7145b
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:783:13
14: 0x7f6adfe33702 - std::panicking::begin_panic_handler::{{closure}}::h7919090525c6485e
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:657:13
15: 0x7f6adfe30bf6 - std::sys_common::backtrace::__rust_end_short_backtrace::hf3289479464f7dfe
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:171:18
16: 0x7f6adfe33460 - rust_begin_unwind
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:645:5
17: 0x7f6adfe7f645 - core::panicking::panic_fmt::hcc9f77c5c132af55
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/panicking.rs:72:14
18: 0x7f6adec784d3 - <rustc_resolve[affe76dba0cece58]::late::LateResolutionVisitor as rustc_ast[4aa1586181236210]::visit::Visitor>::visit_item
19: 0x7f6adee2d7ff - <rustc_resolve[affe76dba0cece58]::Resolver>::resolve_crate::{closure#0}
20: 0x7f6adee2ad1a - <rustc_resolve[affe76dba0cece58]::Resolver>::resolve_crate
21: 0x7f6adeeb6d72 - rustc_interface[510b71011450ca5b]::passes::resolver_for_lowering
22: 0x7f6adeeb5e2b - rustc_query_impl[b697241ad8aeb7f0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b697241ad8aeb7f0]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[feea9eb5351a5817]::query::erase::Erased<[u8; 8usize]>>
23: 0x7f6adef1f8ec - rustc_query_system[f4aa0f8944b24174]::query::plumbing::try_execute_query::<rustc_query_impl[b697241ad8aeb7f0]::DynamicConfig<rustc_query_system[f4aa0f8944b24174]::query::caches::SingleCache<rustc_middle[feea9eb5351a5817]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[b697241ad8aeb7f0]::plumbing::QueryCtxt, true>
24: 0x7f6adef1eff3 - rustc_query_impl[b697241ad8aeb7f0]::query_impl::resolver_for_lowering::get_query_incr::__rust_end_short_backtrace
25: 0x7f6aded0bab3 - rustc_interface[510b71011450ca5b]::interface::run_compiler::<core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>, rustc_driver_impl[9db4319ac0e53fa6]::run_compiler::{closure#0}>::{closure#0}
26: 0x7f6adee3b25b - std[ee6a4c5be0dc2fe4]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[510b71011450ca5b]::util::run_in_thread_with_globals<rustc_interface[510b71011450ca5b]::interface::run_compiler<core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>, rustc_driver_impl[9db4319ac0e53fa6]::run_compiler::{closure#0}>::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>
27: 0x7f6adee3b0b9 - <<std[ee6a4c5be0dc2fe4]::thread::Builder>::spawn_unchecked_<rustc_interface[510b71011450ca5b]::util::run_in_thread_with_globals<rustc_interface[510b71011450ca5b]::interface::run_compiler<core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>, rustc_driver_impl[9db4319ac0e53fa6]::run_compiler::{closure#0}>::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c77087b21480946]::result::Result<(), rustc_span[9e4a1c88ef378122]::ErrorGuaranteed>>::{closure#1} as core[9c77087b21480946]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
28: 0x7f6adfe3d8e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5d7c8f150ab9c84c
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/alloc/src/boxed.rs:2015:9
29: 0x7f6adfe3d8e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h570d5b005c242c15
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/alloc/src/boxed.rs:2015:9
30: 0x7f6adfe3d8e5 - std::sys::unix::thread::Thread::new::thread_start::h36b0a20c0b2361ad
at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys/unix/thread.rs:108:17
31: 0x7f6ad9e97ada - <unknown>
32: 0x7f6ad9f2847c - <unknown>
33: 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: rustc 1.76.0-beta.1 (0e09125c6 2023-12-21) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack