ICE: `region variables should not be hashed`
Opened this issue · 2 comments
cushionbadak commented
Code
#![feature(associated_const_equality)]
trait Trait<'a> {
const K: &'a ();
}
fn main() -> Trait<'r, K = { &() }> {
let x = Ok(42);
if true {
x?
}
Ok(())
}A mutant of tests/ui/suggestions/try-operator-dont-suggest-semicolon.rs
Meta
rustc --version --verbose:
rustc 1.93.0-nightly (c90bcb957 2025-11-06)
binary: rustc
commit-hash: c90bcb9571b7aab0d8beaa2ce8a998ffaf079d38
commit-date: 2025-11-06
host: x86_64-apple-darwin
release: 1.93.0-nightly
LLVM version: 21.1.3
Error output
Command: rustc
error[E0261]: use of undeclared lifetime name `'r`
--> 02.rs:7:20
|
7 | fn main() -> Trait<'r, K = { &() }> {
| ^^ undeclared lifetime
|
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the bound lifetime-generic with a new `'r` lifetime
|
7 | fn main() -> for<'r> Trait<'r, K = { &() }> {
| +++++++
help: consider introducing lifetime `'r` here
|
7 | fn main<'r>() -> Trait<'r, K = { &() }> {
| ++++
warning: trait objects without an explicit `dyn` are deprecated
--> 02.rs:7:14
|
7 | fn main() -> Trait<'r, K = { &() }> {
| ^^^^^^^^^^^^^^^^^^^^^^
|
= 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/edition-guide/rust-2021/warnings-promoted-to-error.html>
= note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default
help: if this is a dyn-compatible trait, use `dyn`
|
7 | fn main() -> dyn Trait<'r, K = { &() }> {
| +++
thread 'rustc' (5492753) panicked at /rustc-dev/c90bcb9571b7aab0d8beaa2ce8a998ffaf079d38/compiler/rustc_type_ir/src/region_kind.rs:240:17:
region variables should not be hashed: '?0
Backtrace
thread 'rustc' (5492753) panicked at /rustc-dev/c90bcb9571b7aab0d8beaa2ce8a998ffaf079d38/compiler/rustc_type_ir/src/region_kind.rs:240:17:
region variables should not be hashed: '?0
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: <rustc_middle::ty::region::Region as rustc_data_structures::stable_hasher::HashStable<rustc_query_system::ich::hcx::StableHashingContext>>::hash_stable
3: <rustc_type_ir::ty_kind::TyKind<rustc_middle::ty::context::TyCtxt> as rustc_data_structures::stable_hasher::HashStable<rustc_query_system::ich::hcx::StableHashingContext>>::hash_stable
4: <rustc_type_ir::ty_info::WithCachedTypeInfo<rustc_type_ir::ty_kind::TyKind<rustc_middle::ty::context::TyCtxt>> as rustc_data_structures::stable_hasher::HashStable<rustc_query_system::ich::hcx::StableHashingContext>>::hash_stable
5: <rustc_middle::ty::context::TyCtxt>::feed_anon_const_type
6: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_poly_trait_ref
7: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_trait_object_ty::{closure#0}
8: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty::{closure#0}
9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::suggest_missing_break_or_return_expr
10: <rustc_hir_typeck::coercion::CoerceMany<&rustc_hir::hir::Expr>>::report_return_mismatched_types
11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
17: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_or_body_tail
18: rustc_hir_typeck::check::check_fn
19: rustc_hir_typeck::typeck_with_inspect::{closure#0}
20: rustc_hir_typeck::typeck
[... omitted 1 frame ...]
21: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}
22: rustc_hir_analysis::check_crate
23: rustc_interface::passes::analysis
[... omitted 1 frame ...]
24: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
25: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: please attach the file at `/Users/jb/Library/CloudStorage/Dropbox/Desk/2503_rustc_ice/20251106 ice 보고용/rustc-ice-2025-11-07T04_18_08-52917.txt` to your bug report
query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on crate `02`
end of query stack
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0261`.
Notes
-
ICE location:
compiler/rustc_type_ir/src/region_kind.rs line-240
rust/compiler/rustc_type_ir/src/region_kind.rs
Lines 233 to 241 in c90bcb9
-
Duplication Check
- I searched for ICE issues with "region variables should not be hashed", (Github issue page with query)
- issue-112397 is opened with identical ICE location report, but none of the code in that issue cause ICE in current compiler version.
@rustbot label +F-associated_const_equality
cyrgani commented
somewhat smaller (without ?):
trait Trait<'a> {
const K: &'a ();
}
fn foo() -> dyn Trait<'r, K = { &() }> {
{
match 42 {
42 => 42,
_ => return (),
}
}
9
}cushionbadak commented
cargo-bisect-rustc --start=2022-01-01 --end=2025-11-07 --regress ice --preserve --script rustc -- 148620.rs
********************************************************************************
Regression in nightly-2022-04-18
********************************************************************************
fetching https://static.rust-lang.org/dist/2022-04-17/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2022-04-17: 40 B / 40 B [================================================================================================================================================] 100.00 % 851.07 KB/s converted 2022-04-17 to 878c7833f6c1ff10e2fd89074e5bd4ef5ff15936
fetching https://static.rust-lang.org/dist/2022-04-18/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2022-04-18: 40 B / 40 B [================================================================================================================================================] 100.00 % 706.94 KB/s converted 2022-04-18 to ec77f252434a532fdb5699ae4f21a3072d211edd
looking for regression commit between 2022-04-17 and 2022-04-18
fetching (via remote github) commits from max(878c7833f6c1ff10e2fd89074e5bd4ef5ff15936, 2022-04-15) to ec77f252434a532fdb5699ae4f21a3072d211edd
ending github query because we found starting sha: 878c7833f6c1ff10e2fd89074e5bd4ef5ff15936
get_commits_between returning commits, len: 10
commit[0] 2022-04-16: Auto merge of #96123 - Dylan-DPC:rollup-qjog6n1, r=Dylan-DPC
commit[1] 2022-04-16: Auto merge of #95899 - petrochenkov:modchild2, r=cjgillot
commit[2] 2022-04-17: Auto merge of #96134 - Dylan-DPC:rollup-ejug3yq, r=Dylan-DPC
commit[3] 2022-04-17: Auto merge of #96002 - nnethercote:speed-up-Vec-clear-2, r=m-ou-se
commit[4] 2022-04-17: Auto merge of #96010 - eduardosm:Unique-on-top-of-NonNull, r=m-ou-se,tmiasko
commit[5] 2022-04-17: Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillot
commit[6] 2022-04-17: Auto merge of #96016 - Aaron1011:hash-name-cleanup, r=cjgillot
commit[7] 2022-04-17: Auto merge of #95779 - cjgillot:ast-lifetimes-undeclared, r=petrochenkov
commit[8] 2022-04-17: Auto merge of #96091 - GuillaumeGomez:duplicated-blanket-impls, r=notriddle
commit[9] 2022-04-17: Auto merge of #96139 - erikdesjardins:revertinl2, r=Mark-Simulacrum
ERROR: no CI builds available between 878c7833f6c1ff10e2fd89074e5bd4ef5ff15936 and ec77f252434a532fdb5699ae4f21a3072d211edd within last 167 days