rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.1k stars 12.55k forks source link

ICE: const-generics-demangling.rs #78233

Closed matthiaskrgr closed 3 years ago

matthiaskrgr commented 3 years ago

reduced from ./src/test/ui/symbol-names/const-generics-demangling.rs

Code

#![feature(min_const_generics, rustc_attrs)]

pub struct Unsigned<const F: u8>;

#[rustc_symbol_name]
impl Unsigned<11> {}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (1eaadebb3 2020-10-21)
binary: rustc
commit-hash: 1eaadebb3dee31669c7649b32747381d11614fae
commit-date: 2020-10-21
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0

Error output

error: internal compiler error: compiler/rustc_symbol_mangling/src/legacy.rs:41:21: finding type for DefId(0:6 ~ const_generics_demangling[317d]::{impl#0}), encountered def-id DefId(0:0 ~ const_generics_demangling[317d]) with no parent

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.49.0-nightly (1eaadebb3 2020-10-21) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [symbol_name] computing the symbol for `Unsigned::<11_u8>`
end of query stack
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
  left: `LLVMing`,
 right: `Codegenning`', /rustc/1eaadebb3dee31669c7649b32747381d11614fae/compiler/rustc_codegen_ssa/src/back/write.rs:1423:21

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.49.0-nightly (1eaadebb3 2020-10-21) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to previous error
Backtrace

``` error: internal compiler error: compiler/rustc_symbol_mangling/src/legacy.rs:41:21: finding type for DefId(0:6 ~ const_generics_demangling[317d]::{impl#0}), encountered def-id DefId(0:0 ~ const_generics_demangling[317d]) with no parent thread 'rustc' panicked at 'Box', compiler/rustc_errors/src/lib.rs:945:9 stack backtrace: 0: 0x7f3c7942da10 - std::backtrace_rs::backtrace::libunwind::trace::h622bab51c72c4e69 at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/std/src/../../backtrace/src/backtrace/libunwind.rs:100:5 1: 0x7f3c7942da10 - std::backtrace_rs::backtrace::trace_unsynchronized::h7e820b882ebd41ee at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f3c7942da10 - std::sys_common::backtrace::_print_fmt::h64d46258114db92f at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/std/src/sys_common/backtrace.rs:67:5 3: 0x7f3c7942da10 - ::fmt::h47111d0c1b5f0da5 at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/std/src/sys_common/backtrace.rs:46:22 4: 0x7f3c7949c94c - core::fmt::write::h1857a60b204f1b6a at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/core/src/fmt/mod.rs:1076:17 5: 0x7f3c7941f632 - std::io::Write::write_fmt::h4604516fed3e5731 at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/std/src/io/mod.rs:1516:15 6: 0x7f3c794329c5 - std::sys_common::backtrace::_print::h785e7a78d5ef272c at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/std/src/sys_common/backtrace.rs:49:5 7: 0x7f3c794329c5 - std::sys_common::backtrace::print::h108047ac5c4555d5 at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/std/src/sys_common/backtrace.rs:36:9 8: 0x7f3c794329c5 - std::panicking::default_hook::{{closure}}::h1d0c271f0d087ebf at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/std/src/panicking.rs:208:50 9: 0x7f3c79432668 - std::panicking::default_hook::h692753e26f11b7b7 at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/std/src/panicking.rs:227:9 10: 0x7f3c7a638898 - rustc_driver::report_ice::h027627aaa525f0b3 11: 0x7f3c79433206 - std::panicking::rust_panic_with_hook::h74ddc20305301cd9 at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/std/src/panicking.rs:581:17 12: 0x7f3c7d5c76dd - std::panicking::begin_panic::{{closure}}::hde64e7753bb51667 13: 0x7f3c7d5c7606 - std::sys_common::backtrace::__rust_end_short_backtrace::h6567ed4099b888c3 14: 0x7f3c7d5c764f - std::panicking::begin_panic::h5911b197bf270d50 15: 0x7f3c7d5fe040 - rustc_errors::HandlerInner::bug::hbb6554bd4fbc8852 16: 0x7f3c7d5fcb20 - rustc_errors::Handler::bug::h4feefeec7bb726ca 17: 0x7f3c7d070af4 - rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}::h22b92ed7b73b8340 18: 0x7f3c7d069acb - rustc_middle::ty::context::tls::with_opt::{{closure}}::h32bfd9cf0b0a9393 19: 0x7f3c7d069a72 - rustc_middle::ty::context::tls::with_opt::h762464f893de2d96 20: 0x7f3c7d070a19 - rustc_middle::util::bug::opt_span_bug_fmt::h05648c19bbf99518 21: 0x7f3c7d07098e - rustc_middle::util::bug::bug_fmt::h5d4f7ed12a8f1d0d 22: 0x7f3c7c12cdd2 - rustc_symbol_mangling::legacy::mangle::{{closure}}::he550c574e35a9647 23: 0x7f3c7c12ccb2 - rustc_symbol_mangling::legacy::mangle::h2fb1aa82ca83118f 24: 0x7f3c7c10eac8 - rustc_symbol_mangling::symbol_name_provider::hb4cbbd663d6a8032 25: 0x7f3c7c144284 - rustc_middle::ty::query:: for rustc_middle::ty::query::queries::symbol_name>::compute::h790eea479c51a441 26: 0x7f3c7c13b224 - rustc_query_system::dep_graph::graph::DepGraph::with_task_impl::hb1d364ffec9766dd 27: 0x7f3c7c15bff8 - rustc_data_structures::stack::ensure_sufficient_stack::h78bedacf1b629dae 28: 0x7f3c7c0f553f - rustc_query_system::query::plumbing::get_query_impl::hae23db8b793ce1d9 29: 0x7f3c7c148f60 - rustc_symbol_mangling::test::SymbolNamesTest::process_attrs::hebc886ab52dfdd0d 30: 0x7f3c7c159192 - rustc_hir::hir::Crate::visit_all_item_likes::h62efe572d73c0a6a 31: 0x7f3c7c14b880 - rustc_middle::dep_graph::::with_deps::h33f88e40c117739a 32: 0x7f3c7c148a9b - rustc_symbol_mangling::test::report_symbol_names::h2a7d9459544458aa 33: 0x7f3c7aa548c3 - rustc_codegen_ssa::base::codegen_crate::h4313da1caeb975f4 34: 0x7f3c7aaa5c15 - ::codegen_crate::h1f72f419f7c76d35 35: 0x7f3c7a83b200 - rustc_session::utils::::time::h8dfa67a2b53454b3 36: 0x7f3c7a87bae1 - rustc_interface::queries::Queries::ongoing_codegen::hdbedbe8cc863565e 37: 0x7f3c7a653e1a - rustc_interface::queries::::enter::hec6b32330aacb990 38: 0x7f3c7a61aca2 - rustc_span::with_source_map::haf40dc27442e4810 39: 0x7f3c7a655f62 - rustc_interface::interface::create_compiler_and_run::he1b8461f8d09ca91 40: 0x7f3c7a63ccca - scoped_tls::ScopedKey::set::h4a8a2485893e8de6 41: 0x7f3c7a65a795 - std::sys_common::backtrace::__rust_begin_short_backtrace::h8668b1999ab0e792 42: 0x7f3c7a5d941e - core::ops::function::FnOnce::call_once{{vtable.shim}}::h36ffd177bfc9cab1 43: 0x7f3c7944220a - as core::ops::function::FnOnce>::call_once::h588ce842808b3fd0 at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/alloc/src/boxed.rs:1042:9 44: 0x7f3c7944220a - as core::ops::function::FnOnce>::call_once::h46bc655f05471a92 at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/alloc/src/boxed.rs:1042:9 45: 0x7f3c7944220a - std::sys::unix::thread::Thread::new::thread_start::hb4b79d379b730058 at /rustc/1eaadebb3dee31669c7649b32747381d11614fae/library/std/src/sys/unix/thread.rs:89:17 46: 0x7f3c7933d3e9 - start_thread 47: 0x7f3c7925a293 - __GI___clone 48: 0x0 - 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.49.0-nightly (1eaadebb3 2020-10-21) running on x86_64-unknown-linux-gnu query stack during panic: #0 [symbol_name] computing the symbol for `Unsigned::<11_u8>` end of query stack error: aborting due to previous error ```

lcnr commented 3 years ago

this affects min_const_generics :thinking: is this blocking stabilization? cc @varkor @eddyb

varkor commented 3 years ago

v0 demangling has support for const generics, but the legacy demangler does not. I was under the impression we did not need to support the legacy demangler, but I shall check.

eddyb commented 3 years ago

Why is #[rustc_symbol_name] applied to an impl? impls don't have symbol names, the ICE is the same one for this:

#![feature(rustc_attrs)]

struct Foo;
#[rustc_symbol_name]
impl Foo {}
varkor commented 3 years ago

Closing as working as expected.