Skip to content

ICE: region variables should not be hashed: #122864

Closed
@cushionbadak

Description

@cushionbadak

Code

(reduced)

struct NoDerive(i32);

impl PartialEq for NoDerive {  }

#[derive(PartialEq)]
struct WrapParam<'a, T>(&'a &'a T);

const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(& & NoDerive(0));

fn main() {
    match WRAP_DOUBLY_INDIRECT_PARAM {
        WRAP_DOUBLY_INDIRECT_PARAM => { }
        _ => { }
    }
}

(original)

// This is part of a set of tests exploring the different ways a
// structural-match ADT might try to hold a
// non-structural-match in hidden manner that lets matches
// through that we had intended to reject.
//
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
#![warn(indirect_structural_match)]
//@ run-pass

struct NoDerive(#[allow(dead_code)] i32);

//~| ERROR cannot find attribute `w` in this scope
impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }

impl Eq for NoDerive { }

#[derive(PartialEq, Eq)]
struct WrapParam<'a, T>(&'a &'a T);

const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(& & NoDerive(0));

fn main() {
    match WRAP_DOUBLY_INDIRECT_PARAM {
        WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
        //~^ WARN must be annotated with `#[derive(PartialEq)]`
        //~| WARN this was previously accepted
        _ => { println!("WRAP_DOUBLY_INDIRECT_PARAM correctly did not match itself"); }
    }
}

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (0ad927c0c 2024-03-21)
binary: rustc
commit-hash: 0ad927c0c07b65fc0dae37105e09c877c87c296a
commit-date: 2024-03-21
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Error output

error[E0046]: not all trait items implemented, missing: `eq`
 --> reduced_03D683BAA43FDC5659149719B7678C979D2BBD231E786D32B542F42EE920BD91.rs:3:1
  |
3 | impl PartialEq for NoDerive {  }
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `eq` in implementation
  |
  = help: implement the missing item: `fn eq(&self, _: &NoDerive) -> bool { todo!() }`

warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
  --> reduced_03D683BAA43FDC5659149719B7678C979D2BBD231E786D32B542F42EE920BD91.rs:12:9
   |
12 |         WRAP_DOUBLY_INDIRECT_PARAM => { }
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
   = note: the traits must be derived, manual `impl`s are not sufficient
   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
   = note: `#[warn(indirect_structural_match)]` on by default

Backtrace

thread 'rustc' panicked at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/compiler/rustc_type_ir/src/region_kind.rs:287:17:
region variables should not be hashed: '?11
stack backtrace:
   0:     0x7f56059cffa5 - std::backtrace_rs::backtrace::libunwind::trace::h679d01c861932e9e
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f56059cffa5 - std::backtrace_rs::backtrace::trace_unsynchronized::h844ab42216481d11
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f56059cffa5 - std::sys_common::backtrace::_print_fmt::hded996a88eb0ebe5
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f56059cffa5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5cbf4ae00ce2987b
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f5605a20feb - core::fmt::rt::Argument::fmt::h63860774c6cb96d8
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/core/src/fmt/rt.rs:142:9
   5:     0x7f5605a20feb - core::fmt::write::h50de0697b18b6c58
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/core/src/fmt/mod.rs:1153:17
   6:     0x7f56059c4d3f - std::io::Write::write_fmt::hfc015a285764248e
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/io/mod.rs:1843:15
   7:     0x7f56059cfd7e - std::sys_common::backtrace::_print::heb3c50b6ebbd2629
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f56059cfd7e - std::sys_common::backtrace::print::h16dc64233af0ecc0
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f56059d29f9 - std::panicking::default_hook::{{closure}}::he761602674a90188
  10:     0x7f56059d2763 - std::panicking::default_hook::hf0f68f006b5fc67a
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/panicking.rs:292:9
  11:     0x7f56023ce28e - std[a6d3664d074e4e2d]::panicking::update_hook::<alloc[e5204ed3b0e852a7]::boxed::Box<rustc_driver_impl[177aae33245cb812]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f56059d3150 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h910de5d7d29c18e7
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/alloc/src/boxed.rs:2029:9
  13:     0x7f56059d3150 - std::panicking::rust_panic_with_hook::h2cb61026c897c737
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/panicking.rs:783:13
  14:     0x7f56059d2ea6 - std::panicking::begin_panic_handler::{{closure}}::h35ea0cac59ee57dc
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/panicking.rs:657:13
  15:     0x7f56059d0469 - std::sys_common::backtrace::__rust_end_short_backtrace::h1d98a7fbca552aa0
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f56059d2bd7 - rust_begin_unwind
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/panicking.rs:645:5
  17:     0x7f5605a1d486 - core::panicking::panic_fmt::h0834a34108b44488
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/core/src/panicking.rs:72:14
  18:     0x7f5603c5b743 - <rustc_middle[3c0f42ae630e8f10]::ty::generic_args::GenericArg as rustc_data_structures[638fdda6c09fd028]::stable_hasher::HashStable<rustc_query_system[e7e333fc838440db]::ich::hcx::StableHashingContext>>::hash_stable
  19:     0x7f56039ef245 - <rustc_type_ir[615ccdf32c2e66a7]::ty_info::WithCachedTypeInfo<rustc_type_ir[615ccdf32c2e66a7]::ty_kind::TyKind<rustc_middle[3c0f42ae630e8f10]::ty::context::TyCtxt>> as rustc_data_structures[638fdda6c09fd028]::stable_hasher::HashStable<rustc_query_system[e7e333fc838440db]::ich::hcx::StableHashingContext>>::hash_stable
  20:     0x7f5603a00e4c - <rustc_type_ir[615ccdf32c2e66a7]::ty_info::WithCachedTypeInfo<rustc_middle[3c0f42ae630e8f10]::ty::consts::ConstData> as rustc_data_structures[638fdda6c09fd028]::stable_hasher::HashStable<rustc_query_system[e7e333fc838440db]::ich::hcx::StableHashingContext>>::hash_stable
  21:     0x7f5602c0bb9b - rustc_query_impl[3d32d7d6f9825ea7]::plumbing::query_key_hash_verify::<rustc_query_impl[3d32d7d6f9825ea7]::DynamicConfig<rustc_query_system[e7e333fc838440db]::query::caches::DefaultCache<rustc_middle[3c0f42ae630e8f10]::ty::consts::Const, rustc_middle[3c0f42ae630e8f10]::query::erase::Erased<[u8; 24usize]>>, false, false, false>>::{closure#0}
  22:     0x7f5604717733 - <rustc_query_system[e7e333fc838440db]::query::caches::DefaultCache<rustc_middle[3c0f42ae630e8f10]::ty::consts::Const, rustc_middle[3c0f42ae630e8f10]::query::erase::Erased<[u8; 24usize]>> as rustc_query_system[e7e333fc838440db]::query::caches::QueryCache>::iter
  23:     0x7f560471759f - rustc_query_impl[3d32d7d6f9825ea7]::query_impl::destructure_const::query_key_hash_verify
  24:     0x7f560448c385 - rustc_interface[773e0c8b9ac0b15a]::interface::run_compiler::<core[f542d2235e74f536]::result::Result<(), rustc_span[3935dbab7cef6955]::ErrorGuaranteed>, rustc_driver_impl[177aae33245cb812]::run_compiler::{closure#0}>::{closure#0}
  25:     0x7f5604555987 - std[a6d3664d074e4e2d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[773e0c8b9ac0b15a]::util::run_in_thread_with_globals<rustc_interface[773e0c8b9ac0b15a]::util::run_in_thread_pool_with_globals<rustc_interface[773e0c8b9ac0b15a]::interface::run_compiler<core[f542d2235e74f536]::result::Result<(), rustc_span[3935dbab7cef6955]::ErrorGuaranteed>, rustc_driver_impl[177aae33245cb812]::run_compiler::{closure#0}>::{closure#0}, core[f542d2235e74f536]::result::Result<(), rustc_span[3935dbab7cef6955]::ErrorGuaranteed>>::{closure#0}, core[f542d2235e74f536]::result::Result<(), rustc_span[3935dbab7cef6955]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f542d2235e74f536]::result::Result<(), rustc_span[3935dbab7cef6955]::ErrorGuaranteed>>
  26:     0x7f56045557b4 - <<std[a6d3664d074e4e2d]::thread::Builder>::spawn_unchecked_<rustc_interface[773e0c8b9ac0b15a]::util::run_in_thread_with_globals<rustc_interface[773e0c8b9ac0b15a]::util::run_in_thread_pool_with_globals<rustc_interface[773e0c8b9ac0b15a]::interface::run_compiler<core[f542d2235e74f536]::result::Result<(), rustc_span[3935dbab7cef6955]::ErrorGuaranteed>, rustc_driver_impl[177aae33245cb812]::run_compiler::{closure#0}>::{closure#0}, core[f542d2235e74f536]::result::Result<(), rustc_span[3935dbab7cef6955]::ErrorGuaranteed>>::{closure#0}, core[f542d2235e74f536]::result::Result<(), rustc_span[3935dbab7cef6955]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f542d2235e74f536]::result::Result<(), rustc_span[3935dbab7cef6955]::ErrorGuaranteed>>::{closure#1} as core[f542d2235e74f536]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7f56059dc919 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1c605e92c63edbd9
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/alloc/src/boxed.rs:2015:9
  28:     0x7f56059dc919 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h17dff47eba1ee89b
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/alloc/src/boxed.rs:2015:9
  29:     0x7f56059dc919 - std::sys::pal::unix::thread::Thread::new::thread_start::h9a9d47ad2c64592d
                               at /rustc/0ad927c0c07b65fc0dae37105e09c877c87c296a/library/std/src/sys/pal/unix/thread.rs:108:17
  30:     0x7f55ff26bac3 - <unknown>
  31:     0x7f55ff2fd850 - <unknown>
  32:                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 `/home/jb/workspace/placeholder/rustc-ice-2024-03-22T08_27_43-31361.txt` to your bug report

note: compiler flags: -Z incremental-verify-ich=yes -Z dump-mir=all

query stack during panic:
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0046`.

Activity

added
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.
on Mar 22, 2024
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Mar 22, 2024
matthiaskrgr

matthiaskrgr commented on Mar 22, 2024

@matthiaskrgr
Member

duplicate of #112397

removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Mar 23, 2024
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

        Participants

        @matthiaskrgr@cushionbadak@jieyouxu@rustbot

        Issue actions

          ICE: `region variables should not be hashed:` · Issue #122864 · rust-lang/rust