Skip to content

ICE: type variables should not be hashed? #123953

Open
@matthiaskrgr

Description

@matthiaskrgr

snippet:

pub trait A {}
pub trait B: A {}

pub trait Mirror {
    type Assoc: ?Sized;
}
impl<T: ?Sized> Mirror for A {
    type Assoc = T;
}

pub fn foo<'a>(x: &'a <dyn A + 'static as Mirror>::Assoc) -> &'a <dyn B + 'static as Mirror>::Assoc {
    static
}

Version information

rustc 1.79.0-nightly (29b120740 2024-04-14)
binary: rustc
commit-hash: 29b120740b55aaf2f75e659ba34c4e30977e5fed
commit-date: 2024-04-14
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zincremental-verify-ich=yes -Cincremental=<dir> -Cdebuginfo=2

Program output

error: expected identifier, found `}`
  --> /tmp/icemaker_global_tempdir.vwQKa8bWL0Ay/rustc_testrunner_tmpdir_reporting.fL12BrT1pnde/mvce.rs:13:1
   |
13 | }
   | ^ expected identifier

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.vwQKa8bWL0Ay/rustc_testrunner_tmpdir_reporting.fL12BrT1pnde/mvce.rs:13:2
   |
13 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.vwQKa8bWL0Ay/rustc_testrunner_tmpdir_reporting.fL12BrT1pnde/mvce.rs`

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.vwQKa8bWL0Ay/rustc_testrunner_tmpdir_reporting.fL12BrT1pnde/mvce.rs:7:28
  |
7 | impl<T: ?Sized> Mirror for A {
  |                            ^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` on by default
help: if this is an object-safe trait, use `dyn`
  |
7 | impl<T: ?Sized> Mirror for dyn A {
  |                            +++
help: alternatively use a blanket implementation to implement `Mirror` for all types that also implement `A`
  |
7 | impl<T: ?Sized, U: A> Mirror for U {
  |               ++++++             ~

error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
 --> /tmp/icemaker_global_tempdir.vwQKa8bWL0Ay/rustc_testrunner_tmpdir_reporting.fL12BrT1pnde/mvce.rs:7:6
  |
7 | impl<T: ?Sized> Mirror for A {
  |      ^ unconstrained type parameter

error[E0277]: the trait bound `(dyn B + 'static): Mirror` is not satisfied
  --> /tmp/icemaker_global_tempdir.vwQKa8bWL0Ay/rustc_testrunner_tmpdir_reporting.fL12BrT1pnde/mvce.rs:11:62
   |
11 | pub fn foo<'a>(x: &'a <dyn A + 'static as Mirror>::Assoc) -> &'a <dyn B + 'static as Mirror>::Assoc {
   |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Mirror` is not implemented for `(dyn B + 'static)`
   |
   = help: the trait `Mirror` is implemented for `(dyn A + 'static)`

error[E0277]: the trait bound `(dyn B + 'static): Mirror` is not satisfied
  --> /tmp/icemaker_global_tempdir.vwQKa8bWL0Ay/rustc_testrunner_tmpdir_reporting.fL12BrT1pnde/mvce.rs:11:101
   |
11 |   pub fn foo<'a>(x: &'a <dyn A + 'static as Mirror>::Assoc) -> &'a <dyn B + 'static as Mirror>::Assoc {
   |  _____________________________________________________________________________________________________^
12 | |     static
13 | | }
   | |_^ the trait `Mirror` is not implemented for `(dyn B + 'static)`
   |
   = help: the trait `Mirror` is implemented for `(dyn A + 'static)`

thread 'rustc' panicked at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/compiler/rustc_type_ir/src/ty_kind.rs:709:17:
type variables should not be hashed: ?0t
stack backtrace:
   0:     0x71b7480b6cd5 - std::backtrace_rs::backtrace::libunwind::trace::h53271ac0753cf55e
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x71b7480b6cd5 - std::backtrace_rs::backtrace::trace_unsynchronized::h69024d0ed74410f1
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x71b7480b6cd5 - std::sys_common::backtrace::_print_fmt::h1260662ae5cf245c
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x71b7480b6cd5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h364005bab7842cc8
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x71b748105fbb - core::fmt::rt::Argument::fmt::ha2c788a2abe0d825
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/core/src/fmt/rt.rs:165:63
   5:     0x71b748105fbb - core::fmt::write::h54cd3decdbcdebc8
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/core/src/fmt/mod.rs:1157:21
   6:     0x71b7480ab85f - std::io::Write::write_fmt::h4b84255e56f703b1
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/io/mod.rs:1832:15
   7:     0x71b7480b6aae - std::sys_common::backtrace::_print::hb23c9aa181f7f786
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x71b7480b6aae - std::sys_common::backtrace::print::h7c2868c5903babcd
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x71b7480b9429 - std::panicking::default_hook::{{closure}}::h67cd91a3362f6bd2
  10:     0x71b7480b916d - std::panicking::default_hook::h863722b1089490b2
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/panicking.rs:291:9
  11:     0x71b744a78a1c - std[b6640f56223542f]::panicking::update_hook::<alloc[761692029390c70a]::boxed::Box<rustc_driver_impl[1eded89cf714ec14]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x71b7480b9b2c - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h520ed6384e121f6e
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/alloc/src/boxed.rs:2032:9
  13:     0x71b7480b9b2c - std::panicking::rust_panic_with_hook::h76677ece9796b2ab
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/panicking.rs:792:13
  14:     0x71b7480b98d6 - std::panicking::begin_panic_handler::{{closure}}::h0b1380178bfeecce
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/panicking.rs:657:13
  15:     0x71b7480b7199 - std::sys_common::backtrace::__rust_end_short_backtrace::he036971bc710a6c2
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x71b7480b9607 - rust_begin_unwind
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/panicking.rs:645:5
  17:     0x71b748102466 - core::panicking::panic_fmt::hed7cf21e6e33bf06
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/core/src/panicking.rs:72:14
  18:     0x71b746256d62 - <rustc_type_ir[9e0a03ec8de9cfba]::ty_info::WithCachedTypeInfo<rustc_type_ir[9e0a03ec8de9cfba]::ty_kind::TyKind<rustc_middle[f5c2acecf7d1e61]::ty::context::TyCtxt>> as rustc_data_structures[75eb361af5794fb5]::stable_hasher::HashStable<rustc_query_system[fadd9b9860a96126]::ich::hcx::StableHashingContext>>::hash_stable
  19:     0x71b746254aeb - <rustc_type_ir[9e0a03ec8de9cfba]::ty_info::WithCachedTypeInfo<rustc_type_ir[9e0a03ec8de9cfba]::ty_kind::TyKind<rustc_middle[f5c2acecf7d1e61]::ty::context::TyCtxt>> as rustc_data_structures[75eb361af5794fb5]::stable_hasher::HashStable<rustc_query_system[fadd9b9860a96126]::ich::hcx::StableHashingContext>>::hash_stable
  20:     0x71b745f59bc8 - rustc_query_system[fadd9b9860a96126]::query::plumbing::try_execute_query::<rustc_query_impl[89b1cc2b228f800b]::DynamicConfig<rustc_query_system[fadd9b9860a96126]::query::caches::DefaultCache<rustc_middle[f5c2acecf7d1e61]::ty::ParamEnvAnd<rustc_middle[f5c2acecf7d1e61]::ty::generic_args::GenericArg>, rustc_middle[f5c2acecf7d1e61]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[89b1cc2b228f800b]::plumbing::QueryCtxt, true>
  21:     0x71b745f5939e - rustc_query_impl[89b1cc2b228f800b]::query_impl::try_normalize_generic_arg_after_erasing_regions::get_query_incr::__rust_end_short_backtrace
  22:     0x71b7461e2095 - <rustc_middle[f5c2acecf7d1e61]::ty::normalize_erasing_regions::TryNormalizeAfterErasingRegionsFolder as rustc_type_ir[9e0a03ec8de9cfba]::fold::FallibleTypeFolder<rustc_middle[f5c2acecf7d1e61]::ty::context::TyCtxt>>::try_fold_ty
  23:     0x71b7436ae697 - <rustc_mir_transform[696b6d9cac9f4fe9]::reveal_all::RevealAll as rustc_middle[f5c2acecf7d1e61]::mir::MirPass>::run_pass
  24:     0x71b745e0188d - rustc_mir_transform[696b6d9cac9f4fe9]::pass_manager::run_passes_inner
  25:     0x71b74664a002 - rustc_mir_transform[696b6d9cac9f4fe9]::mir_drops_elaborated_and_const_checked
  26:     0x71b74664993d - rustc_query_impl[89b1cc2b228f800b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[89b1cc2b228f800b]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f5c2acecf7d1e61]::query::erase::Erased<[u8; 8usize]>>
  27:     0x71b745fd0f52 - rustc_query_system[fadd9b9860a96126]::query::plumbing::try_execute_query::<rustc_query_impl[89b1cc2b228f800b]::DynamicConfig<rustc_query_system[fadd9b9860a96126]::query::caches::VecCache<rustc_span[67999189de00f189]::def_id::LocalDefId, rustc_middle[f5c2acecf7d1e61]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[89b1cc2b228f800b]::plumbing::QueryCtxt, true>
  28:     0x71b74636cbd3 - rustc_query_impl[89b1cc2b228f800b]::query_impl::mir_drops_elaborated_and_const_checked::get_query_incr::__rust_end_short_backtrace
  29:     0x71b7466ca5d3 - rustc_interface[7cece484144cab9d]::passes::analysis
  30:     0x71b7466c93d5 - rustc_query_impl[89b1cc2b228f800b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[89b1cc2b228f800b]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f5c2acecf7d1e61]::query::erase::Erased<[u8; 1usize]>>
  31:     0x71b746bd604a - rustc_query_system[fadd9b9860a96126]::query::plumbing::try_execute_query::<rustc_query_impl[89b1cc2b228f800b]::DynamicConfig<rustc_query_system[fadd9b9860a96126]::query::caches::SingleCache<rustc_middle[f5c2acecf7d1e61]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[89b1cc2b228f800b]::plumbing::QueryCtxt, true>
  32:     0x71b746bd5c5c - rustc_query_impl[89b1cc2b228f800b]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  33:     0x71b746a7d213 - rustc_interface[7cece484144cab9d]::interface::run_compiler::<core[67782cd00b4ae476]::result::Result<(), rustc_span[67999189de00f189]::ErrorGuaranteed>, rustc_driver_impl[1eded89cf714ec14]::run_compiler::{closure#0}>::{closure#0}
  34:     0x71b746b5225d - std[b6640f56223542f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7cece484144cab9d]::util::run_in_thread_with_globals<rustc_interface[7cece484144cab9d]::util::run_in_thread_pool_with_globals<rustc_interface[7cece484144cab9d]::interface::run_compiler<core[67782cd00b4ae476]::result::Result<(), rustc_span[67999189de00f189]::ErrorGuaranteed>, rustc_driver_impl[1eded89cf714ec14]::run_compiler::{closure#0}>::{closure#0}, core[67782cd00b4ae476]::result::Result<(), rustc_span[67999189de00f189]::ErrorGuaranteed>>::{closure#0}, core[67782cd00b4ae476]::result::Result<(), rustc_span[67999189de00f189]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[67782cd00b4ae476]::result::Result<(), rustc_span[67999189de00f189]::ErrorGuaranteed>>
  35:     0x71b746b5206a - <<std[b6640f56223542f]::thread::Builder>::spawn_unchecked_<rustc_interface[7cece484144cab9d]::util::run_in_thread_with_globals<rustc_interface[7cece484144cab9d]::util::run_in_thread_pool_with_globals<rustc_interface[7cece484144cab9d]::interface::run_compiler<core[67782cd00b4ae476]::result::Result<(), rustc_span[67999189de00f189]::ErrorGuaranteed>, rustc_driver_impl[1eded89cf714ec14]::run_compiler::{closure#0}>::{closure#0}, core[67782cd00b4ae476]::result::Result<(), rustc_span[67999189de00f189]::ErrorGuaranteed>>::{closure#0}, core[67782cd00b4ae476]::result::Result<(), rustc_span[67999189de00f189]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[67782cd00b4ae476]::result::Result<(), rustc_span[67999189de00f189]::ErrorGuaranteed>>::{closure#2} as core[67782cd00b4ae476]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x71b7480c3a1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h44537915e24e94b0
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/alloc/src/boxed.rs:2018:9
  37:     0x71b7480c3a1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h23d4047ab6dcc0a1
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/alloc/src/boxed.rs:2018:9
  38:     0x71b7480c3a1b - std::sys::pal::unix::thread::Thread::new::thread_start::h3b8c7af00c7c77e5
                               at /rustc/29b120740b55aaf2f75e659ba34c4e30977e5fed/library/std/src/sys/pal/unix/thread.rs:108:17
  39:     0x71b7418a955a - <unknown>
  40:     0x71b741926a3c - <unknown>
  41:                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 make sure that you have updated to the latest nightly

note: rustc 1.79.0-nightly (29b120740 2024-04-14) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2

query stack during panic:
#0 [try_normalize_generic_arg_after_erasing_regions] normalizing `&<dyn A as Mirror>::Assoc`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `foo`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors; 1 warning emitted

Some errors have detailed explanations: E0207, E0277, E0601.
For more information about an error, try `rustc --explain E0207`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-incr-compArea: Incremental compilationC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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