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 with #[derive(Default)] on enum with repeated variant names #105101

Closed
jruderman opened this issue Nov 30, 2022 · 2 comments · Fixed by #105106
Closed

ICE with #[derive(Default)] on enum with repeated variant names #105101

jruderman opened this issue Nov 30, 2022 · 2 comments · Fixed by #105106
Assignees
Labels
C-bug Category: This is a bug. 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

@jruderman
Copy link
Contributor

jruderman commented Nov 30, 2022

Found with a modified fuzz-rustc

Code

#[derive(Default)]
enum E {
    #[default] A,
    #[default] A,
}

Error output

thread 'rustc' panicked at 'assertion failed: !suggestion.is_empty()', compiler/rustc_errors/src/diagnostic.rs:628

Backtrace
stack backtrace:
   0:        0x10816c2a6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1901ec5c10c2d477
   1:        0x1081cae2a - core::fmt::write::h453ba3b763f16dfb
   2:        0x10815e64c - std::io::Write::write_fmt::h35935f9cf41659e0
   3:        0x10816c08a - std::sys_common::backtrace::print::h48cb2ddd4d16ad05
   4:        0x10816f3d3 - std::panicking::default_hook::{{closure}}::hf85401495f021b7c
   5:        0x10816f128 - std::panicking::default_hook::hcc698ed67aaec0db
   6:        0x1130055fd - rustc_driver[c6bc39476a4ff69]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x10816fbb7 - std::panicking::rust_panic_with_hook::h4686e220b4123e59
   8:        0x10816f923 - std::panicking::begin_panic_handler::{{closure}}::h159a2fe35d7f418a
   9:        0x10816c748 - std::sys_common::backtrace::__rust_end_short_backtrace::h0017da2a305ee472
  10:        0x10816f62d - _rust_begin_unwind
  11:        0x1081f73f3 - core::panicking::panic_fmt::h000b48597e446791
  12:        0x1081f74c7 - core::panicking::panic::h5888dcc54e62095c
  13:        0x115e67b7c - <rustc_errors[5974999511236221]::diagnostic::Diagnostic>::tool_only_multipart_suggestion::<&alloc[374a688e4a400e73]::string::String>
  14:        0x115e734d6 - rustc_builtin_macros[63bbcae8fe3c402e]::deriving::default::expand_deriving_default::{closure#0}
  15:        0x115f15b54 - <rustc_builtin_macros[63bbcae8fe3c402e]::deriving::generic::MethodDef>::expand_static_enum_method_body
  16:        0x115ef6213 - <core[e7c8723dd1d9fd02]::iter::adapters::map::Map<core[e7c8723dd1d9fd02]::slice::iter::Iter<rustc_builtin_macros[63bbcae8fe3c402e]::deriving::generic::MethodDef>, <rustc_builtin_macros[63bbcae8fe3c402e]::deriving::generic::TraitDef>::expand_enum_def::{closure#1}> as core[e7c8723dd1d9fd02]::iter::traits::iterator::Iterator>::fold::<(), core[e7c8723dd1d9fd02]::iter::traits::iterator::Iterator::for_each::call<rustc_ast[2482a7f97692ab8f]::ptr::P<rustc_ast[2482a7f97692ab8f]::ast::Item<rustc_ast[2482a7f97692ab8f]::ast::AssocItemKind>>, <alloc[374a688e4a400e73]::vec::Vec<rustc_ast[2482a7f97692ab8f]::ptr::P<rustc_ast[2482a7f97692ab8f]::ast::Item<rustc_ast[2482a7f97692ab8f]::ast::AssocItemKind>>>>::extend_trusted<core[e7c8723dd1d9fd02]::iter::adapters::map::Map<core[e7c8723dd1d9fd02]::slice::iter::Iter<rustc_builtin_macros[63bbcae8fe3c402e]::deriving::generic::MethodDef>, <rustc_builtin_macros[63bbcae8fe3c402e]::deriving::generic::TraitDef>::expand_enum_def::{closure#1}>>::{closure#0}>::{closure#0}>
  17:        0x115e3617c - <alloc[374a688e4a400e73]::vec::Vec<rustc_ast[2482a7f97692ab8f]::ptr::P<rustc_ast[2482a7f97692ab8f]::ast::Item<rustc_ast[2482a7f97692ab8f]::ast::AssocItemKind>>> as alloc[374a688e4a400e73]::vec::spec_from_iter::SpecFromIter<rustc_ast[2482a7f97692ab8f]::ptr::P<rustc_ast[2482a7f97692ab8f]::ast::Item<rustc_ast[2482a7f97692ab8f]::ast::AssocItemKind>>, core[e7c8723dd1d9fd02]::iter::adapters::map::Map<core[e7c8723dd1d9fd02]::slice::iter::Iter<rustc_builtin_macros[63bbcae8fe3c402e]::deriving::generic::MethodDef>, <rustc_builtin_macros[63bbcae8fe3c402e]::deriving::generic::TraitDef>::expand_enum_def::{closure#1}>>>::from_iter
  18:        0x115f1019e - <rustc_builtin_macros[63bbcae8fe3c402e]::deriving::generic::TraitDef>::expand_ext
  19:        0x115e6fff1 - rustc_builtin_macros[63bbcae8fe3c402e]::deriving::default::expand_deriving_default
  20:        0x115ec3964 - <rustc_builtin_macros[63bbcae8fe3c402e]::deriving::BuiltinDerive as rustc_expand[f485642205b044c8]::base::MultiItemModifier>::expand
  21:        0x1171491ed - <rustc_expand[f485642205b044c8]::expand::MacroExpander>::fully_expand_fragment
  22:        0x1171479a3 - <rustc_expand[f485642205b044c8]::expand::MacroExpander>::expand_crate
  23:        0x1130878aa - <rustc_session[bf9d936332845243]::session::Session>::time::<core[e7c8723dd1d9fd02]::result::Result<rustc_ast[2482a7f97692ab8f]::ast::Crate, rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_interface[6b0baa6f0acee236]::passes::configure_and_expand::{closure#1}>
  24:        0x1130ca643 - rustc_interface[6b0baa6f0acee236]::passes::configure_and_expand
  25:        0x1130d23f6 - <rustc_interface[6b0baa6f0acee236]::queries::Queries>::expansion
  26:        0x112fdda67 - <rustc_interface[6b0baa6f0acee236]::interface::Compiler>::enter::<rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}::{closure#2}, core[e7c8723dd1d9fd02]::result::Result<core[e7c8723dd1d9fd02]::option::Option<rustc_interface[6b0baa6f0acee236]::queries::Linker>, rustc_errors[5974999511236221]::ErrorGuaranteed>>
  27:        0x112f79d5d - rustc_span[db835ecaf6c42563]::with_source_map::<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  28:        0x112fd0a9d - <scoped_tls[9dceb67bf45baec5]::ScopedKey<rustc_span[db835ecaf6c42563]::SessionGlobals>>::set::<rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>
  29:        0x112f9fffa - std[e853a6d0ec043b70]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[6b0baa6f0acee236]::util::run_in_thread_pool_with_globals<rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>
  30:        0x112f802a5 - <<std[e853a6d0ec043b70]::thread::Builder>::spawn_unchecked_<rustc_interface[6b0baa6f0acee236]::util::run_in_thread_pool_with_globals<rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>::{closure#1} as core[e7c8723dd1d9fd02]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:        0x108178e87 - std::sys::unix::thread::Thread::new::thread_start::hb253bfeab5e611e1
  32:     0x7ff8083354e1 - __pthread_start

error: internal compiler error: unexpected panic

note: 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.67.0-nightly (1eb62b123 2022-11-27) running on x86_64-apple-darwin

Regression

First ICEd in nightly-2021-07-29, likely from #86735 (@jhpratt), which added #[derive(Default)] support for enums.

Version

rustc 1.67.0-nightly (1eb62b123 2022-11-27)
binary: rustc
commit-hash: 1eb62b1235fd77200e6bd967d70e83c0f2497233
commit-date: 2022-11-27
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4
@jruderman jruderman added C-bug Category: This is a bug. 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. labels Nov 30, 2022
@jhpratt
Copy link
Member

jhpratt commented Nov 30, 2022

@rustbot claim

rust-cloud-vms bot pushed a commit to jhpratt/rust that referenced this issue Nov 30, 2022
@jhpratt
Copy link
Member

jhpratt commented Nov 30, 2022

PR is up at #105106

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 1, 2022
Fix ICE from rust-lang#105101

Fixes rust-lang#105101

Rather than comparing idents, compare spans, which should be unique to each variant.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Dec 1, 2022
Fix ICE from rust-lang#105101

Fixes rust-lang#105101

Rather than comparing idents, compare spans, which should be unique to each variant.
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 1, 2022
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#105078 (Fix `expr_to_spanned_string` ICE)
 - rust-lang#105087 (Extract llvm datalayout parsing out of spec module)
 - rust-lang#105088 (rustdoc: remove redundant CSS `div.desc { display: block }`)
 - rust-lang#105106 (Fix ICE from rust-lang#105101)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in ee9eaa6 Dec 1, 2022
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. 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.

2 participants