Skip to content

ICE: const variables should not be hashed: ?0c #122214

Closed

Description

@matthiaskrgr

Code

#![feature(impl_trait_in_assoc_type, const_precise_live_drops)]

trait Trait {
    type Opaque1;
}

impl<const B: Word> Trait for &'a () {
    type Opaque1 = impl Sized;

    fn constrain(self) -> (Self::Opaque1,) {}
}

Meta

rustc --version --verbose:

rustc 1.78.0-nightly (a655e648a 2024-03-08)
binary: rustc
commit-hash: a655e648a9f94d74263108366b83e677af56e35d
commit-date: 2024-03-08
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Error output

rustc -Cincremental=. file.rs

error[E0261]: use of undeclared lifetime name `'a`
 --> ice.rs:7:32
  |
7 | impl<const B: Word> Trait for &'a () {
  |      -                         ^^ undeclared lifetime
  |      |
  |      help: consider introducing lifetime `'a` here: `'a,`

error[E0407]: method `constrain` is not a member of trait `Trait`
  --> ice.rs:10:5
   |
10 |     fn constrain(self) -> (Self::Opaque1,) {}
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Trait`

error[E0412]: cannot find type `Word` in this scope
 --> ice.rs:7:15
  |
7 | impl<const B: Word> Trait for &'a () {
  |               ^^^^ not found in this scope

error[E0601]: `main` function not found in crate `ice`
  --> ice.rs:11:2
   |
11 | }
   |  ^ consider adding a `main` function to `ice.rs`

error[E0207]: the const parameter `B` is not constrained by the impl trait, self type, or predicates
 --> ice.rs:7:6
  |
7 | impl<const B: Word> Trait for &'a () {
  |      ^^^^^^^^^^^^^ unconstrained const parameter
  |
  = note: expressions using a const parameter must map each value to a distinct output value
  = note: proving the result of expressions other than the parameter are unique is not supported

error[E0308]: mismatched types
  --> ice.rs:10:27
   |
10 |     fn constrain(self) -> (Self::Opaque1,) {}
   |        ---------          ^^^^^^^^^^^^^^^^ expected `(_,)`, found `()`
   |        |
   |        implicitly returns `()` as its body has no tail or `return` expression
   |
   = note:  expected tuple `(_,)`
           found unit type `()`
Backtrace

thread 'rustc' panicked at /rustc/a655e648a9f94d74263108366b83e677af56e35d/compiler/rustc_type_ir/src/const_kind.rs:168:17:
const variables should not be hashed: ?0c
stack backtrace:
   0:     0x7f337cb8ca52 - std::backtrace_rs::backtrace::libunwind::trace::h96388202534bc8b4
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f337cb8ca52 - std::backtrace_rs::backtrace::trace_unsynchronized::hd24fda5ee1171687
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f337cb8ca52 - std::sys_common::backtrace::_print_fmt::h7fc6da6ac76efe1a
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f337cb8ca52 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h20b3a1c18b9ce13e
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f337cbdda5c - core::fmt::rt::Argument::fmt::h715695219e3d5daa
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/core/src/fmt/rt.rs:142:9
   5:     0x7f337cbdda5c - core::fmt::write::hdcbaf4dd41b0e397
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/core/src/fmt/mod.rs:1153:17
   6:     0x7f337cb814cf - std::io::Write::write_fmt::ha86dec8b961be9fe
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/io/mod.rs:1846:15
   7:     0x7f337cb8c824 - std::sys_common::backtrace::_print::he2e628b8a344c918
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f337cb8c824 - std::sys_common::backtrace::print::h2d03e07df3cbc968
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f337cb8f52b - std::panicking::default_hook::{{closure}}::h70d1a774a5c00714
  10:     0x7f337cb8f287 - std::panicking::default_hook::h29bee0cc1d7f8ef9
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/panicking.rs:292:9
  11:     0x7f337fa57fdc - std[b22d021cf1654e3a]::panicking::update_hook::<alloc[24b8088a11102544]::boxed::Box<rustc_driver_impl[b8de2d3efc1fcf4f]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f337cb8fc90 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h40bee4bed6b10263
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/alloc/src/boxed.rs:2030:9
  13:     0x7f337cb8fc90 - std::panicking::rust_panic_with_hook::he3cf6200ea961b48
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/panicking.rs:783:13
  14:     0x7f337cb8f9d2 - std::panicking::begin_panic_handler::{{closure}}::h10c391556907277b
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/panicking.rs:657:13
  15:     0x7f337cb8cf26 - std::sys_common::backtrace::__rust_end_short_backtrace::hcaa45d1b2c613d86
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f337cb8f704 - rust_begin_unwind
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/panicking.rs:645:5
  17:     0x7f337cbd9f75 - core::panicking::panic_fmt::h99fd2851b9dbc03c
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/core/src/panicking.rs:72:14
  18:     0x7f33810afb6c - <rustc_middle[fdfb78edc2009106]::ty::consts::ConstData as rustc_data_structures[412ae8551ed91436]::stable_hasher::HashStable<rustc_query_system[689e62d1a5f987e2]::ich::hcx::StableHashingContext>>::hash_stable
  19:     0x7f33810af503 - <rustc_type_ir[9c7832cd21fb2102]::ty_info::WithCachedTypeInfo<rustc_middle[fdfb78edc2009106]::ty::consts::ConstData> as rustc_data_structures[412ae8551ed91436]::stable_hasher::HashStable<rustc_query_system[689e62d1a5f987e2]::ich::hcx::StableHashingContext>>::hash_stable
  20:     0x7f3380fb1412 - <&rustc_middle[fdfb78edc2009106]::ty::list::List<rustc_middle[fdfb78edc2009106]::ty::generic_args::GenericArg> as rustc_data_structures[412ae8551ed91436]::stable_hasher::HashStable<rustc_query_system[689e62d1a5f987e2]::ich::hcx::StableHashingContext>>::hash_stable
  21:     0x7f3380fb1cd3 - <rustc_type_ir[9c7832cd21fb2102]::ty_info::WithCachedTypeInfo<rustc_type_ir[9c7832cd21fb2102]::ty_kind::TyKind<rustc_middle[fdfb78edc2009106]::ty::context::TyCtxt>> as rustc_data_structures[412ae8551ed91436]::stable_hasher::HashStable<rustc_query_system[689e62d1a5f987e2]::ich::hcx::StableHashingContext>>::hash_stable
  22:     0x7f338174ba5b - rustc_query_system[689e62d1a5f987e2]::query::plumbing::try_execute_query::<rustc_query_impl[efcbf58886c52e8a]::DynamicConfig<rustc_query_system[689e62d1a5f987e2]::query::caches::DefaultCache<rustc_middle[fdfb78edc2009106]::ty::ParamEnvAnd<rustc_middle[fdfb78edc2009106]::ty::generic_args::GenericArg>, rustc_middle[fdfb78edc2009106]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[efcbf58886c52e8a]::plumbing::QueryCtxt, true>
  23:     0x7f338174b1dc - rustc_query_impl[efcbf58886c52e8a]::query_impl::try_normalize_generic_arg_after_erasing_regions::get_query_incr::__rust_end_short_backtrace
  24:     0x7f33812a68d4 - <rustc_middle[fdfb78edc2009106]::ty::normalize_erasing_regions::TryNormalizeAfterErasingRegionsFolder as rustc_type_ir[9c7832cd21fb2102]::fold::FallibleTypeFolder<rustc_middle[fdfb78edc2009106]::ty::context::TyCtxt>>::try_fold_ty
  25:     0x7f3381308328 - <rustc_middle[fdfb78edc2009106]::ty::Ty>::needs_drop
  26:     0x7f33800a0dd1 - <rustc_mir_transform[c65367db1eeb27d3]::remove_uninit_drops::RemoveUninitDrops as rustc_middle[fdfb78edc2009106]::mir::MirPass>::run_pass
  27:     0x7f3380e1341b - rustc_mir_transform[c65367db1eeb27d3]::pass_manager::run_passes_inner
  28:     0x7f33814e7f9f - rustc_mir_transform[c65367db1eeb27d3]::mir_drops_elaborated_and_const_checked
  29:     0x7f33814e72a1 - rustc_query_impl[efcbf58886c52e8a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[efcbf58886c52e8a]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fdfb78edc2009106]::query::erase::Erased<[u8; 8usize]>>
  30:     0x7f338129897d - rustc_query_system[689e62d1a5f987e2]::query::plumbing::try_execute_query::<rustc_query_impl[efcbf58886c52e8a]::DynamicConfig<rustc_query_system[689e62d1a5f987e2]::query::caches::VecCache<rustc_span[708bf0c68405aa3d]::def_id::LocalDefId, rustc_middle[fdfb78edc2009106]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[efcbf58886c52e8a]::plumbing::QueryCtxt, true>
  31:     0x7f3380e427a7 - rustc_query_impl[efcbf58886c52e8a]::query_impl::mir_drops_elaborated_and_const_checked::get_query_incr::__rust_end_short_backtrace
  32:     0x7f33817206d6 - rustc_interface[401370fc7cb5d2e1]::passes::analysis
  33:     0x7f338171fda9 - rustc_query_impl[efcbf58886c52e8a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[efcbf58886c52e8a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fdfb78edc2009106]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7f3381b78be2 - rustc_query_system[689e62d1a5f987e2]::query::plumbing::try_execute_query::<rustc_query_impl[efcbf58886c52e8a]::DynamicConfig<rustc_query_system[689e62d1a5f987e2]::query::caches::SingleCache<rustc_middle[fdfb78edc2009106]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[efcbf58886c52e8a]::plumbing::QueryCtxt, true>
  35:     0x7f3381b787dc - rustc_query_impl[efcbf58886c52e8a]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  36:     0x7f3381b8746f - rustc_interface[401370fc7cb5d2e1]::interface::run_compiler::<core[9bbbf43e76ab1d4d]::result::Result<(), rustc_span[708bf0c68405aa3d]::ErrorGuaranteed>, rustc_driver_impl[b8de2d3efc1fcf4f]::run_compiler::{closure#0}>::{closure#0}
  37:     0x7f3381dbc585 - std[b22d021cf1654e3a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[401370fc7cb5d2e1]::util::run_in_thread_with_globals<rustc_interface[401370fc7cb5d2e1]::util::run_in_thread_pool_with_globals<rustc_interface[401370fc7cb5d2e1]::interface::run_compiler<core[9bbbf43e76ab1d4d]::result::Result<(), rustc_span[708bf0c68405aa3d]::ErrorGuaranteed>, rustc_driver_impl[b8de2d3efc1fcf4f]::run_compiler::{closure#0}>::{closure#0}, core[9bbbf43e76ab1d4d]::result::Result<(), rustc_span[708bf0c68405aa3d]::ErrorGuaranteed>>::{closure#0}, core[9bbbf43e76ab1d4d]::result::Result<(), rustc_span[708bf0c68405aa3d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9bbbf43e76ab1d4d]::result::Result<(), rustc_span[708bf0c68405aa3d]::ErrorGuaranteed>>
  38:     0x7f3381dbc3b2 - <<std[b22d021cf1654e3a]::thread::Builder>::spawn_unchecked_<rustc_interface[401370fc7cb5d2e1]::util::run_in_thread_with_globals<rustc_interface[401370fc7cb5d2e1]::util::run_in_thread_pool_with_globals<rustc_interface[401370fc7cb5d2e1]::interface::run_compiler<core[9bbbf43e76ab1d4d]::result::Result<(), rustc_span[708bf0c68405aa3d]::ErrorGuaranteed>, rustc_driver_impl[b8de2d3efc1fcf4f]::run_compiler::{closure#0}>::{closure#0}, core[9bbbf43e76ab1d4d]::result::Result<(), rustc_span[708bf0c68405aa3d]::ErrorGuaranteed>>::{closure#0}, core[9bbbf43e76ab1d4d]::result::Result<(), rustc_span[708bf0c68405aa3d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9bbbf43e76ab1d4d]::result::Result<(), rustc_span[708bf0c68405aa3d]::ErrorGuaranteed>>::{closure#1} as core[9bbbf43e76ab1d4d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7f337cb99435 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcb78242ba64783e0
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/alloc/src/boxed.rs:2016:9
  40:     0x7f337cb99435 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbcd67c6e19068517
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/alloc/src/boxed.rs:2016:9
  41:     0x7f337cb99435 - std::sys::pal::unix::thread::Thread::new::thread_start::h8e93ba7fecc401fc
                               at /rustc/a655e648a9f94d74263108366b83e677af56e35d/library/std/src/sys/pal/unix/thread.rs:108:17
  42:     0x7f337c98155a - <unknown>
  43:     0x7f337c9fea3c - <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/im3/rustc-ice-2024-03-08T23_03_48-805648.txt` to your bug report

note: compiler flags: -C incremental=[REDACTED]

query stack during panic:
#0 [try_normalize_generic_arg_after_erasing_regions] normalizing `<&() as Trait>::Opaque1`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `<impl at ice.rs:7:1: 7:37>::constrain`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors

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

Activity

  1. 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.
    C-bugCategory: This is a bug.
    on Mar 8, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 8, 2024
  3. matthiaskrgr commented on Mar 9, 2024

    @matthiaskrgr
    MemberAuthor
  4. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 11, 2024
  5. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    A-incr-compArea: Incremental compilation
    on Apr 19, 2024
  6. added 2 commits that reference this issue on Aug 4, 2026
  7. added a commit that references this issue on Aug 5, 2026
  8. jakubadamw commented on Aug 5, 2026

    @jakubadamw
    Contributor

    The test was added in #160407, but I misworded the PR description, so the issue didn’t close automatically.

    @matthiaskrgr could you close this, please?

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

    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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions