-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
A-metadataArea: Crate metadataArea: Crate metadataC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
auto-reduced (treereduce-rust):
use m::S;
mod m {
pub struct S {
,
= Priv1 {}
}
struct Priv1 {
,
}
}
fn main() {
let _ = Option { field: (), field1: m::Priv1 {} };
}
original:
//@ aux-build:struct_field_default.rs
#![feature(default_field_values)]
extern crate struct_field_default as xc;
use m::S;
mod m {
pub struct S {
pub field: () = (),
pub field1: Priv1 = Priv1 {},
pub field2: Priv2 = Priv2,
}
struct Priv1 {
x: i32 = 1, //~ ERROR unions cannot have default field values
pub field2: Priv2 = 2., //~ ERROR unions cannot have default field values
}
struct Priv2;
}
fn main() {
let _ = Option { field: (), field1: m::Priv1 {} };
//~^ ERROR missing field `field2`
//~| ERROR struct `Priv1` is private
let _ = S { field: (), field1: m::Option {}, field2: m::Priv2 };
//~^ ERROR struct `Priv1` is private
//~| ERROR unit struct `Priv2` is private
let _ = xc::B { a: xc::Bar };
//~^ ERROR unit struct `Priv` is private
let _ = xc::C { a: xc::Priv };
//~^ ERROR unit struct `Priv` is private
}
Version information
rustc 1.92.0-nightly (7950f244e 2025-10-04)
binary: rustc
commit-hash: 7950f244e7ef55b61a83d12f4662be643cd182d6
commit-date: 2025-10-04
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.2
Possibly related line of code:
rust/compiler/rustc_metadata/src/rmeta/decoder.rs
Lines 985 to 997 in 7950f24
self.target_modifiers.decode(metadata) | |
} | |
} | |
impl<'a> CrateMetadataRef<'a> { | |
fn missing(self, descr: &str, id: DefIndex) -> ! { | |
bug!("missing `{descr}` for {:?}", self.local_def_id(id)) | |
} | |
fn raw_proc_macro(self, id: DefIndex) -> &'a ProcMacro { | |
// DefIndex's in root.proc_macro_data have a one-to-one correspondence | |
// with items in 'raw_proc_macros'. | |
let pos = self |
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error: expected identifier, found `,`
--> /tmp/icemaker_global_tempdir.DLGFDpOJlEch/rustc_testrunner_tmpdir_reporting.GNsDCWlPcya2/mvce.rs:10:8
|
9 | pub struct S {
| - while parsing this struct
10 | ,
| ^ expected identifier
error: expected identifier, found `,`
--> /tmp/icemaker_global_tempdir.DLGFDpOJlEch/rustc_testrunner_tmpdir_reporting.GNsDCWlPcya2/mvce.rs:14:6
|
13 | struct Priv1 {
| ----- while parsing this struct
14 | ,
| ^ expected identifier
error[E0574]: expected struct, variant or union type, found enum `Option`
--> /tmp/icemaker_global_tempdir.DLGFDpOJlEch/rustc_testrunner_tmpdir_reporting.GNsDCWlPcya2/mvce.rs:20:13
|
20 | let _ = Option { field: (), field1: m::Priv1 {} };
| ^^^^^^ not a struct, variant or union type
error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder.rs:991:9: missing `associated_item_or_field_def_ids` for DefId(2:49400 ~ core[8023]::option::Option)
thread 'rustc' (3205958) panicked at compiler/rustc_metadata/src/rmeta/decoder.rs:991:9:
Box<dyn Any>
stack backtrace:
0: 0x7fc24f3c5d53 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hcd475cec18c09b69
1: 0x7fc24fa01fbc - core::fmt::write::h4d8ebd0343ccd312
2: 0x7fc24f37a753 - std::io::Write::write_fmt::h34ba2d18465e0400
3: 0x7fc24f38bd12 - std::sys::backtrace::BacktraceLock::print::h1d4330a47ea56130
4: 0x7fc24f391d89 - std::panicking::default_hook::{{closure}}::h1f97367f3851ed88
5: 0x7fc24f3918b3 - std::panicking::default_hook::h64460450b4afdc7f
6: 0x7fc24e3a9ad7 - std[400c09161ae222d5]::panicking::update_hook::<alloc[2b9060f48e0d9aaf]::boxed::Box<rustc_driver_impl[3ec9f5f0adfb8655]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7fc24f3921af - std::panicking::panic_with_hook::h96715e645c011ab3
8: 0x7fc24e3e5e81 - std[400c09161ae222d5]::panicking::begin_panic::<rustc_errors[73c8be9f2ede5f2a]::ExplicitBug>::{closure#0}
9: 0x7fc24e3d9826 - std[400c09161ae222d5]::sys::backtrace::__rust_end_short_backtrace::<std[400c09161ae222d5]::panicking::begin_panic<rustc_errors[73c8be9f2ede5f2a]::ExplicitBug>::{closure#0}, !>
10: 0x7fc24e3d7374 - std[400c09161ae222d5]::panicking::begin_panic::<rustc_errors[73c8be9f2ede5f2a]::ExplicitBug>
11: 0x7fc24e3f1201 - <rustc_errors[73c8be9f2ede5f2a]::diagnostic::BugAbort as rustc_errors[73c8be9f2ede5f2a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x7fc24e98effa - rustc_middle[25c9a3426253e5f]::util::bug::opt_span_bug_fmt::<rustc_span[2faf896b90cb36a6]::span_encoding::Span>::{closure#0}
13: 0x7fc24e98f1ba - rustc_middle[25c9a3426253e5f]::ty::context::tls::with_opt::<rustc_middle[25c9a3426253e5f]::util::bug::opt_span_bug_fmt<rustc_span[2faf896b90cb36a6]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x7fc24e97dccb - rustc_middle[25c9a3426253e5f]::ty::context::tls::with_context_opt::<rustc_middle[25c9a3426253e5f]::ty::context::tls::with_opt<rustc_middle[25c9a3426253e5f]::util::bug::opt_span_bug_fmt<rustc_span[2faf896b90cb36a6]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x7fc24cee4380 - rustc_middle[25c9a3426253e5f]::util::bug::bug_fmt
16: 0x7fc24e943dbf - <rustc_metadata[274be0ade411361]::creader::CrateMetadataRef>::missing
17: 0x7fc24fb50bfa - rustc_metadata[274be0ade411361]::rmeta::decoder::cstore_impl::provide_extern::associated_item_def_ids
18: 0x7fc24fb51003 - rustc_query_impl[a4747a6cda07ff6e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a4747a6cda07ff6e]::query_impl::associated_item_def_ids::dynamic_query::{closure#2}::{closure#0}, rustc_middle[25c9a3426253e5f]::query::erase::Erased<[u8; 16usize]>>
19: 0x7fc24fb50fd3 - <rustc_query_impl[a4747a6cda07ff6e]::query_impl::associated_item_def_ids::dynamic_query::{closure#2} as core[802353ff8c0f9994]::ops::function::FnOnce<(rustc_middle[25c9a3426253e5f]::ty::context::TyCtxt, rustc_span[2faf896b90cb36a6]::def_id::DefId)>>::call_once
20: 0x7fc24fb520e1 - rustc_query_system[47860c1c47a99752]::query::plumbing::try_execute_query::<rustc_query_impl[a4747a6cda07ff6e]::DynamicConfig<rustc_query_system[47860c1c47a99752]::query::caches::DefIdCache<rustc_middle[25c9a3426253e5f]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[a4747a6cda07ff6e]::plumbing::QueryCtxt, false>
21: 0x7fc24fb51b68 - rustc_query_impl[a4747a6cda07ff6e]::query_impl::associated_item_def_ids::get_query_non_incr::__rust_end_short_backtrace
22: 0x7fc24ef18446 - <rustc_resolve[cd630e76c23ee77e]::Resolver>::report_privacy_error
23: 0x7fc2500526d9 - <rustc_resolve[cd630e76c23ee77e]::Resolver>::resolve_crate::{closure#0}
24: 0x7fc25004890d - <rustc_resolve[cd630e76c23ee77e]::Resolver>::resolve_crate
25: 0x7fc2504715d5 - rustc_interface[901d656aefb56011]::passes::configure_and_expand
26: 0x7fc250c38c17 - rustc_interface[901d656aefb56011]::passes::resolver_for_lowering_raw
27: 0x7fc250c3895b - rustc_query_impl[a4747a6cda07ff6e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a4747a6cda07ff6e]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[25c9a3426253e5f]::query::erase::Erased<[u8; 16usize]>>
28: 0x7fc250c38949 - <rustc_query_impl[a4747a6cda07ff6e]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[802353ff8c0f9994]::ops::function::FnOnce<(rustc_middle[25c9a3426253e5f]::ty::context::TyCtxt, ())>>::call_once
29: 0x7fc25097021f - rustc_query_system[47860c1c47a99752]::query::plumbing::try_execute_query::<rustc_query_impl[a4747a6cda07ff6e]::DynamicConfig<rustc_query_system[47860c1c47a99752]::query::caches::SingleCache<rustc_middle[25c9a3426253e5f]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[a4747a6cda07ff6e]::plumbing::QueryCtxt, false>
30: 0x7fc25096fd7c - rustc_query_impl[a4747a6cda07ff6e]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
31: 0x7fc250c53c6b - rustc_interface[901d656aefb56011]::passes::create_and_enter_global_ctxt::<core[802353ff8c0f9994]::option::Option<rustc_interface[901d656aefb56011]::queries::Linker>, rustc_driver_impl[3ec9f5f0adfb8655]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
32: 0x7fc250c4b851 - <rustc_interface[901d656aefb56011]::passes::create_and_enter_global_ctxt<core[802353ff8c0f9994]::option::Option<rustc_interface[901d656aefb56011]::queries::Linker>, rustc_driver_impl[3ec9f5f0adfb8655]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[802353ff8c0f9994]::ops::function::FnOnce<(&rustc_session[92e9e7f164e36894]::session::Session, rustc_middle[25c9a3426253e5f]::ty::context::CurrentGcx, alloc[2b9060f48e0d9aaf]::sync::Arc<rustc_data_structures[a2e90113c0257c86]::jobserver::Proxy>, &std[400c09161ae222d5]::sync::once_lock::OnceLock<rustc_middle[25c9a3426253e5f]::ty::context::GlobalCtxt>, &rustc_data_structures[a2e90113c0257c86]::sync::worker_local::WorkerLocal<rustc_middle[25c9a3426253e5f]::arena::Arena>, &rustc_data_structures[a2e90113c0257c86]::sync::worker_local::WorkerLocal<rustc_hir[1ac7aa1513e9fcd4]::Arena>, rustc_driver_impl[3ec9f5f0adfb8655]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
33: 0x7fc250bf6a7e - rustc_interface[901d656aefb56011]::interface::run_compiler::<(), rustc_driver_impl[3ec9f5f0adfb8655]::run_compiler::{closure#0}>::{closure#1}
34: 0x7fc250b0a3c7 - std[400c09161ae222d5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[901d656aefb56011]::util::run_in_thread_with_globals<rustc_interface[901d656aefb56011]::util::run_in_thread_pool_with_globals<rustc_interface[901d656aefb56011]::interface::run_compiler<(), rustc_driver_impl[3ec9f5f0adfb8655]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
35: 0x7fc250b0a0a8 - <<std[400c09161ae222d5]::thread::Builder>::spawn_unchecked_<rustc_interface[901d656aefb56011]::util::run_in_thread_with_globals<rustc_interface[901d656aefb56011]::util::run_in_thread_pool_with_globals<rustc_interface[901d656aefb56011]::interface::run_compiler<(), rustc_driver_impl[3ec9f5f0adfb8655]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[802353ff8c0f9994]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
36: 0x7fc250b107cd - std::sys::thread::unix::Thread::new::thread_start::h09bb9c25144a613d
37: 0x7fc24a4969cb - <unknown>
38: 0x7fc24a51aa0c - <unknown>
39: 0x0 - <unknown>
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.92.0-nightly (7950f244e 2025-10-04) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [associated_item_def_ids] collecting associated items or fields of `core::option::Option`
#1 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0574`.
@rustbot label +F-default_field_values
Metadata
Metadata
Assignees
Labels
A-metadataArea: Crate metadataArea: Crate metadataC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.