Skip to content

ICE: None when deriving Debug of struct containing unreachable!()聽#114636

Description

@matthiaskrgr

Code

#[derive(Debug)]
pub struct Lazy {
    unreachable!()
}

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (03a119b0b 2023-08-07)
binary: rustc
commit-hash: 03a119b0b0e310d22d94399b24ed030056050f13
commit-date: 2023-08-07
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Error output

error: unexpected token: `!`
 --> treereduce.out:3:16
  |
3 |     unreachable!()
  |                ^ unexpected token after this
  |
  = note: macros cannot expand to struct fields
Backtrace

thread 'rustc' panicked at compiler/rustc_builtin_macros/src/deriving/debug.rs:114:63:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7f2adf96441c - std::backtrace_rs::backtrace::libunwind::trace::hae002a1235f5943b
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f2adf96441c - std::backtrace_rs::backtrace::trace_unsynchronized::h5c6bd4f7426dfc23
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f2adf96441c - std::sys_common::backtrace::_print_fmt::h5d3e21cf396f0686
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f2adf96441c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4df6398b8c79682d
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f2adf9c991c - core::fmt::rt::Argument::fmt::he622d38b82b28b38
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/core/src/fmt/rt.rs:138:9
   5:     0x7f2adf9c991c - core::fmt::write::h766f202e494d1c46
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f2adf956dee - std::io::Write::write_fmt::h4acbb73e5adc92cf
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/io/mod.rs:1714:15
   7:     0x7f2adf964204 - std::sys_common::backtrace::_print::hb0b7b4c1fd1959e0
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f2adf964204 - std::sys_common::backtrace::print::hb16047524a0efcb6
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f2adf9672fa - std::panicking::panic_hook_with_disk_dump::{{closure}}::hbfc807576ec72365
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/panicking.rs:278:22
  10:     0x7f2adf966fe7 - std::panicking::panic_hook_with_disk_dump::h90afe991ab863313
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/panicking.rs:312:9
  11:     0x7f2ae2b45369 - <rustc_driver_impl[da10067d57af8d1d]::install_ice_hook::{closure#0} as core[708e8bb138b9c609]::ops::function::FnOnce<(&core[708e8bb138b9c609]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7f2adf967ba0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h33b0dab6d17bb58f
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/alloc/src/boxed.rs:2021:9
  13:     0x7f2adf967ba0 - std::panicking::rust_panic_with_hook::hb42f613f3941ffdf
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/panicking.rs:733:13
  14:     0x7f2adf9678e1 - std::panicking::begin_panic_handler::{{closure}}::hd271dbc42f32a15e
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/panicking.rs:619:13
  15:     0x7f2adf964946 - std::sys_common::backtrace::__rust_end_short_backtrace::h89f31826ebe8fc58
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7f2adf967672 - rust_begin_unwind
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/panicking.rs:617:5
  17:     0x7f2adf9c5d23 - core::panicking::panic_fmt::h78ec2879fa0b4e5b
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/core/src/panicking.rs:67:14
  18:     0x7f2adf9c5db3 - core::panicking::panic::h3c0f5f829255f8a2
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/core/src/panicking.rs:117:5
  19:     0x7f2ae1f6fa50 - rustc_builtin_macros[e6a957b1f71a82b9]::deriving::debug::expand_deriving_debug::{closure#0}
  20:     0x7f2ae1f5e1cb - <rustc_builtin_macros[e6a957b1f71a82b9]::deriving::generic::MethodDef>::expand_struct_method_body
  21:     0x7f2ae1f5de43 - <core[708e8bb138b9c609]::iter::adapters::map::Map<core[708e8bb138b9c609]::slice::iter::Iter<rustc_builtin_macros[e6a957b1f71a82b9]::deriving::generic::MethodDef>, <rustc_builtin_macros[e6a957b1f71a82b9]::deriving::generic::TraitDef>::expand_struct_def::{closure#1}> as core[708e8bb138b9c609]::iter::traits::iterator::Iterator>::fold::<(), core[708e8bb138b9c609]::iter::traits::iterator::Iterator::for_each::call<rustc_ast[8d85310b5d27e92d]::ptr::P<rustc_ast[8d85310b5d27e92d]::ast::Item<rustc_ast[8d85310b5d27e92d]::ast::AssocItemKind>>, <alloc[f6d94832d5e777bc]::vec::Vec<rustc_ast[8d85310b5d27e92d]::ptr::P<rustc_ast[8d85310b5d27e92d]::ast::Item<rustc_ast[8d85310b5d27e92d]::ast::AssocItemKind>>>>::extend_trusted<core[708e8bb138b9c609]::iter::adapters::map::Map<core[708e8bb138b9c609]::slice::iter::Iter<rustc_builtin_macros[e6a957b1f71a82b9]::deriving::generic::MethodDef>, <rustc_builtin_macros[e6a957b1f71a82b9]::deriving::generic::TraitDef>::expand_struct_def::{closure#1}>>::{closure#0}>::{closure#0}>
  22:     0x7f2ae1f5d678 - <alloc[f6d94832d5e777bc]::vec::Vec<rustc_ast[8d85310b5d27e92d]::ptr::P<rustc_ast[8d85310b5d27e92d]::ast::Item<rustc_ast[8d85310b5d27e92d]::ast::AssocItemKind>>> as alloc[f6d94832d5e777bc]::vec::spec_from_iter::SpecFromIter<rustc_ast[8d85310b5d27e92d]::ptr::P<rustc_ast[8d85310b5d27e92d]::ast::Item<rustc_ast[8d85310b5d27e92d]::ast::AssocItemKind>>, core[708e8bb138b9c609]::iter::adapters::map::Map<core[708e8bb138b9c609]::slice::iter::Iter<rustc_builtin_macros[e6a957b1f71a82b9]::deriving::generic::MethodDef>, <rustc_builtin_macros[e6a957b1f71a82b9]::deriving::generic::TraitDef>::expand_struct_def::{closure#1}>>>::from_iter
  23:     0x7f2ae1f5d4d7 - <rustc_builtin_macros[e6a957b1f71a82b9]::deriving::generic::TraitDef>::expand_struct_def
  24:     0x7f2ae1f58f60 - <rustc_builtin_macros[e6a957b1f71a82b9]::deriving::generic::TraitDef>::expand_ext
  25:     0x7f2ae23a6f3c - rustc_builtin_macros[e6a957b1f71a82b9]::deriving::debug::expand_deriving_debug
  26:     0x7f2ae23a7dc7 - <rustc_builtin_macros[e6a957b1f71a82b9]::deriving::BuiltinDerive as rustc_expand[2ff8e59ac252b7df]::base::MultiItemModifier>::expand
  27:     0x7f2ae1cb0310 - <rustc_expand[2ff8e59ac252b7df]::expand::MacroExpander>::fully_expand_fragment
  28:     0x7f2ae1c67567 - <rustc_expand[2ff8e59ac252b7df]::expand::MacroExpander>::expand_crate
  29:     0x7f2ae1c6683a - <rustc_session[a82e8cd710bc7107]::session::Session>::time::<rustc_ast[8d85310b5d27e92d]::ast::Crate, rustc_interface[a1e77c0e0a807641]::passes::configure_and_expand::{closure#1}>
  30:     0x7f2ae1c62003 - rustc_interface[a1e77c0e0a807641]::passes::resolver_for_lowering
  31:     0x7f2ae206000a - rustc_query_impl[d1ef721d40105293]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d1ef721d40105293]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4f696632061e1cd0]::query::erase::Erased<[u8; 8usize]>>
  32:     0x7f2ae205fff9 - <rustc_query_impl[d1ef721d40105293]::query_impl::resolver_for_lowering::dynamic_query::{closure#2} as core[708e8bb138b9c609]::ops::function::FnOnce<(rustc_middle[4f696632061e1cd0]::ty::context::TyCtxt, ())>>::call_once
  33:     0x7f2ae1fce2bc - rustc_query_system[f2faba017c73cca]::query::plumbing::try_execute_query::<rustc_query_impl[d1ef721d40105293]::DynamicConfig<rustc_query_system[f2faba017c73cca]::query::caches::SingleCache<rustc_middle[4f696632061e1cd0]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[d1ef721d40105293]::plumbing::QueryCtxt, false>
  34:     0x7f2ae24c4775 - rustc_query_impl[d1ef721d40105293]::query_impl::resolver_for_lowering::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f2ae21c84a5 - <rustc_middle[4f696632061e1cd0]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[da10067d57af8d1d]::run_compiler::{closure#1}::{closure#2}::{closure#4}, &rustc_data_structures[7ee79dbb60cc3bb8]::steal::Steal<(rustc_middle[4f696632061e1cd0]::ty::ResolverAstLowering, alloc[f6d94832d5e777bc]::rc::Rc<rustc_ast[8d85310b5d27e92d]::ast::Crate>)>>
  36:     0x7f2ae1e16723 - rustc_span[1a026db0fbf8373b]::set_source_map::<core[708e8bb138b9c609]::result::Result<(), rustc_span[1a026db0fbf8373b]::ErrorGuaranteed>, rustc_interface[a1e77c0e0a807641]::interface::run_compiler<core[708e8bb138b9c609]::result::Result<(), rustc_span[1a026db0fbf8373b]::ErrorGuaranteed>, rustc_driver_impl[da10067d57af8d1d]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  37:     0x7f2ae1e10cc0 - std[b9a874157477860e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a1e77c0e0a807641]::util::run_in_thread_pool_with_globals<rustc_interface[a1e77c0e0a807641]::interface::run_compiler<core[708e8bb138b9c609]::result::Result<(), rustc_span[1a026db0fbf8373b]::ErrorGuaranteed>, rustc_driver_impl[da10067d57af8d1d]::run_compiler::{closure#1}>::{closure#0}, core[708e8bb138b9c609]::result::Result<(), rustc_span[1a026db0fbf8373b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[708e8bb138b9c609]::result::Result<(), rustc_span[1a026db0fbf8373b]::ErrorGuaranteed>>
  38:     0x7f2ae23be565 - <<std[b9a874157477860e]::thread::Builder>::spawn_unchecked_<rustc_interface[a1e77c0e0a807641]::util::run_in_thread_pool_with_globals<rustc_interface[a1e77c0e0a807641]::interface::run_compiler<core[708e8bb138b9c609]::result::Result<(), rustc_span[1a026db0fbf8373b]::ErrorGuaranteed>, rustc_driver_impl[da10067d57af8d1d]::run_compiler::{closure#1}>::{closure#0}, core[708e8bb138b9c609]::result::Result<(), rustc_span[1a026db0fbf8373b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[708e8bb138b9c609]::result::Result<(), rustc_span[1a026db0fbf8373b]::ErrorGuaranteed>>::{closure#1} as core[708e8bb138b9c609]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7f2adf972225 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1e7c61bdab097da8
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/alloc/src/boxed.rs:2007:9
  40:     0x7f2adf972225 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfdf756610eac66a4
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/alloc/src/boxed.rs:2007:9
  41:     0x7f2adf972225 - std::sys::unix::thread::Thread::new::thread_start::h65a83d8fc5842941
                               at /rustc/f525bb4e2afac6d2491a86c178aa98e3f3931130/library/std/src/sys/unix/thread.rs:108:17
  42:     0x7f2adf6cb44b - <unknown>
  43:     0x7f2adf74ee40 - <unknown>
  44:                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 attach the file at `/tmp/im/rustc-ice-2023-08-08T19:12:40.973402629Z-3356979.txt` to your bug report

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack
error: aborting due to previous error

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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