Closed
Description
Code
I was trying to verify the assumption about the #[default]
tag in this comment, I ran cargo test
with my changes to the macro and it worked successfully, then I added another #[default]
tag (line 205 in tests/sample.rs) and ran cargo test
again and rustc panicked. This is the exactly what was ran when the panic occurred.
Meta
rustc --version --verbose
:
rustc 1.72.0 (5680fa18f 2023-08-23)
binary: rustc
commit-hash: 5680fa18feaa87f3ff04063800aec256c3d4b4be
commit-date: 2023-08-23
host: aarch64-apple-darwin
release: 1.72.0
LLVM version: 16.0.5
Error output
thread 'rustc' panicked at 'assertion failed: !parts.is_empty()', /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/compiler/rustc_errors/src/diagnostic.rs:622:9
stack backtrace:
0: 0x100cfe3c0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h523fafbfdb8f0857
1: 0x100d52450 - core::fmt::write::hf94a55b5a3abd106
2: 0x100cf3d38 - std::io::Write::write_fmt::hc7c6bf1da111b052
3: 0x100cfe218 - std::sys_common::backtrace::print::h68ede8fb1e716cba
4: 0x100d00d94 - std::panicking::default_hook::{{closure}}::hba2205c2705c60bb
5: 0x100d00b24 - std::panicking::default_hook::h9d927e01472bad1a
6: 0x109245034 - rustc_driver_impl[e09643758e6f6376]::install_ice_hook::{closure#0}
7: 0x100d01514 - std::panicking::rust_panic_with_hook::h8654c51ef9980a29
8: 0x100d012ac - std::panicking::begin_panic_handler::{{closure}}::hd188a636b3b90298
9: 0x100cfe7a0 - std::sys_common::backtrace::__rust_end_short_backtrace::hc331d455ac21f427
10: 0x100d01054 - _rust_begin_unwind
11: 0x100d7d444 - core::panicking::panic_fmt::h4f2054f72ff905b1
12: 0x100d7d4b4 - core::panicking::panic::h4d2ee9cac0d6e9c1
13: 0x10bd8a610 - <rustc_errors[ab8c5e7fbe90f582]::diagnostic::Diagnostic>::multipart_suggestion_with_style::<rustc_error_messages[e77c466ec3cc6779]::SubdiagnosticMessage>
14: 0x10be10838 - <rustc_builtin_macros[56a8028b834a18f7]::errors::MultipleDefaults as rustc_errors[ab8c5e7fbe90f582]::diagnostic_builder::IntoDiagnostic>::into_diagnostic
15: 0x10bda384c - <rustc_session[81931be3b0b4dc13]::parse::ParseSess>::emit_err::<rustc_builtin_macros[56a8028b834a18f7]::errors::MultipleDefaults>
16: 0x10bdff49c - rustc_builtin_macros[56a8028b834a18f7]::deriving::default::expand_deriving_default::{closure#0}
17: 0x10be22e90 - <rustc_builtin_macros[56a8028b834a18f7]::deriving::generic::MethodDef>::expand_static_enum_method_body
18: 0x10bd831b8 - <core[f9d6478373b114c5]::iter::adapters::map::Map<core[f9d6478373b114c5]::slice::iter::Iter<rustc_builtin_macros[56a8028b834a18f7]::deriving::generic::MethodDef>, <rustc_builtin_macros[56a8028b834a18f7]::deriving::generic::TraitDef>::expand_enum_def::{closure#1}> as core[f9d6478373b114c5]::iter::traits::iterator::Iterator>::fold::<(), core[f9d6478373b114c5]::iter::traits::iterator::Iterator::for_each::call<rustc_ast[b522d8ec668849e9]::ptr::P<rustc_ast[b522d8ec668849e9]::ast::Item<rustc_ast[b522d8ec668849e9]::ast::AssocItemKind>>, <alloc[bcdadf72caaa217a]::vec::Vec<rustc_ast[b522d8ec668849e9]::ptr::P<rustc_ast[b522d8ec668849e9]::ast::Item<rustc_ast[b522d8ec668849e9]::ast::AssocItemKind>>>>::extend_trusted<core[f9d6478373b114c5]::iter::adapters::map::Map<core[f9d6478373b114c5]::slice::iter::Iter<rustc_builtin_macros[56a8028b834a18f7]::deriving::generic::MethodDef>, <rustc_builtin_macros[56a8028b834a18f7]::deriving::generic::TraitDef>::expand_enum_def::{closure#1}>>::{closure#0}>::{closure#0}>
19: 0x10bd677d8 - <alloc[bcdadf72caaa217a]::vec::Vec<rustc_ast[b522d8ec668849e9]::ptr::P<rustc_ast[b522d8ec668849e9]::ast::Item<rustc_ast[b522d8ec668849e9]::ast::AssocItemKind>>> as alloc[bcdadf72caaa217a]::vec::spec_from_iter::SpecFromIter<rustc_ast[b522d8ec668849e9]::ptr::P<rustc_ast[b522d8ec668849e9]::ast::Item<rustc_ast[b522d8ec668849e9]::ast::AssocItemKind>>, core[f9d6478373b114c5]::iter::adapters::map::Map<core[f9d6478373b114c5]::slice::iter::Iter<rustc_builtin_macros[56a8028b834a18f7]::deriving::generic::MethodDef>, <rustc_builtin_macros[56a8028b834a18f7]::deriving::generic::TraitDef>::expand_enum_def::{closure#1}>>>::from_iter
20: 0x10be1c5cc - <rustc_builtin_macros[56a8028b834a18f7]::deriving::generic::TraitDef>::expand_ext
21: 0x10bdfe800 - rustc_builtin_macros[56a8028b834a18f7]::deriving::default::expand_deriving_default
22: 0x10bdb1734 - <rustc_builtin_macros[56a8028b834a18f7]::deriving::BuiltinDerive as rustc_expand[8ba1771b01b55d53]::base::MultiItemModifier>::expand
23: 0x10c9fe288 - <rustc_expand[8ba1771b01b55d53]::expand::MacroExpander>::fully_expand_fragment
24: 0x10c9fcc9c - <rustc_expand[8ba1771b01b55d53]::expand::MacroExpander>::expand_crate
25: 0x1093598e0 - <rustc_session[81931be3b0b4dc13]::session::Session>::time::<rustc_ast[b522d8ec668849e9]::ast::Crate, rustc_interface[a43b58d3432b23e3]::passes::configure_and_expand::{closure#1}>
26: 0x1093cc724 - rustc_interface[a43b58d3432b23e3]::passes::resolver_for_lowering
27: 0x10c3dfddc - rustc_query_impl[bcaa985f447c9306]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bcaa985f447c9306]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bded664fc7f58a73]::query::erase::Erased<[u8; 8usize]>>
28: 0x10c534cac - <rustc_query_impl[bcaa985f447c9306]::query_impl::resolver_for_lowering::dynamic_query::{closure#2} as core[f9d6478373b114c5]::ops::function::FnOnce<(rustc_middle[bded664fc7f58a73]::ty::context::TyCtxt, ())>>::call_once
29: 0x10c35b7c4 - rustc_query_system[b4230c255e5b9403]::query::plumbing::try_execute_query::<rustc_query_impl[bcaa985f447c9306]::DynamicConfig<rustc_query_system[b4230c255e5b9403]::query::caches::SingleCache<rustc_middle[bded664fc7f58a73]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[bcaa985f447c9306]::plumbing::QueryCtxt, true>
30: 0x10c4c4160 - rustc_query_impl[bcaa985f447c9306]::query_impl::resolver_for_lowering::get_query_incr::__rust_end_short_backtrace
31: 0x109278aa8 - <rustc_middle[bded664fc7f58a73]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[e09643758e6f6376]::run_compiler::{closure#1}::{closure#2}::{closure#2}, &rustc_data_structures[4c9820f8e66966d8]::steal::Steal<(rustc_middle[bded664fc7f58a73]::ty::ResolverAstLowering, alloc[bcdadf72caaa217a]::rc::Rc<rustc_ast[b522d8ec668849e9]::ast::Crate>)>>
32: 0x109249fd0 - <rustc_interface[a43b58d3432b23e3]::interface::Compiler>::enter::<rustc_driver_impl[e09643758e6f6376]::run_compiler::{closure#1}::{closure#2}, core[f9d6478373b114c5]::result::Result<core[f9d6478373b114c5]::option::Option<rustc_interface[a43b58d3432b23e3]::queries::Linker>, rustc_span[ba98f16c60603a35]::ErrorGuaranteed>>
33: 0x109277a58 - rustc_span[ba98f16c60603a35]::set_source_map::<core[f9d6478373b114c5]::result::Result<(), rustc_span[ba98f16c60603a35]::ErrorGuaranteed>, rustc_interface[a43b58d3432b23e3]::interface::run_compiler<core[f9d6478373b114c5]::result::Result<(), rustc_span[ba98f16c60603a35]::ErrorGuaranteed>, rustc_driver_impl[e09643758e6f6376]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
34: 0x10928a310 - std[5f883c90b3b6ecb9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a43b58d3432b23e3]::util::run_in_thread_pool_with_globals<rustc_interface[a43b58d3432b23e3]::interface::run_compiler<core[f9d6478373b114c5]::result::Result<(), rustc_span[ba98f16c60603a35]::ErrorGuaranteed>, rustc_driver_impl[e09643758e6f6376]::run_compiler::{closure#1}>::{closure#0}, core[f9d6478373b114c5]::result::Result<(), rustc_span[ba98f16c60603a35]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f9d6478373b114c5]::result::Result<(), rustc_span[ba98f16c60603a35]::ErrorGuaranteed>>
35: 0x10928af08 - <<std[5f883c90b3b6ecb9]::thread::Builder>::spawn_unchecked_<rustc_interface[a43b58d3432b23e3]::util::run_in_thread_pool_with_globals<rustc_interface[a43b58d3432b23e3]::interface::run_compiler<core[f9d6478373b114c5]::result::Result<(), rustc_span[ba98f16c60603a35]::ErrorGuaranteed>, rustc_driver_impl[e09643758e6f6376]::run_compiler::{closure#1}>::{closure#0}, core[f9d6478373b114c5]::result::Result<(), rustc_span[ba98f16c60603a35]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f9d6478373b114c5]::result::Result<(), rustc_span[ba98f16c60603a35]::ErrorGuaranteed>>::{closure#1} as core[f9d6478373b114c5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
36: 0x100d09d58 - std::sys::unix::thread::Thread::new::thread_start::h143a83d9ede86d5c
37: 0x1a05d906c - __pthread_deallocate
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.72.0 (5680fa18f 2023-08-23) running on aarch64-apple-darwin
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -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
error: could not compile `primitive_enum` (test "sample")
Backtrace
<backtrace>