rust-lang / rust-lang/rust

ICE: incr comp: type variable should not be hashed

Open
#125,885 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-incr-comp C-bug F-transmutability F-type_alias_impl_trait I-ICE T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

original:

#![feature(type_alias_impl_trait,transmutability)]
trait OpaqueTrait {}
trait AnotherTrait {}

type OpaqueType = impl OpaqueTrait;
impl AnotherTrait for OpaqueType {}

impl<T: std::mem::BikeshedIntrinsicFrom<()>> AnotherTrait for T {}

pub fn main() {}

Version information

rustc 1.80.0-nightly (a83cf567b 2024-06-02)
binary: rustc
commit-hash: a83cf567b5949691de67f06895d9fe0404c40d27
commit-date: 2024-06-02
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

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

Program output

error: unconstrained opaque type
 --> f.rs:5:19
  |
5 | type OpaqueType = impl OpaqueTrait;
  |                   ^^^^^^^^^^^^^^^^
  |
  = note: `OpaqueType` must be used in combination with a concrete type within the same module

thread 'rustc' panicked at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/compiler/rustc_type_ir/src/ty_kind.rs:856:17:
type variables should not be hashed: ?0t
stack backtrace:
   0:     0x72809149ecc5 - std::backtrace_rs::backtrace::libunwind::trace::ha04a88842d9880e4
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x72809149ecc5 - std::backtrace_rs::backtrace::trace_unsynchronized::h3df86c3465abd5e1
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x72809149ecc5 - std::sys_common::backtrace::_print_fmt::h8c2e29f86235af4c
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x72809149ecc5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h507a097b66676404
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7280914ef46b - core::fmt::rt::Argument::fmt::ha80e838d07549293
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/core/src/fmt/rt.rs:165:63
   5:     0x7280914ef46b - core::fmt::write::h29bd0f6435b5b5cb
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/core/src/fmt/mod.rs:1168:21
   6:     0x728091493a4f - std::io::Write::write_fmt::hd5651667cec2b52c
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/io/mod.rs:1835:15
   7:     0x72809149ea9e - std::sys_common::backtrace::_print::h3176666daf50c582
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x72809149ea9e - std::sys_common::backtrace::print::ha19f92c0a79a518d
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7280914a14d9 - std::panicking::default_hook::{{closure}}::hbd2fa3f92596c173
  10:     0x7280914a127a - std::panicking::default_hook::h7a545bdac7eec416
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/panicking.rs:298:9
  11:     0x72808db422b0 - std[45eea3d871d24ad6]::panicking::update_hook::<alloc[fc515f74a8f785dc]::boxed::Box<rustc_driver_impl[c42a3492d6f6b9ec]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7280914a1c0b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::haa82c5bf225b1a16
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/alloc/src/boxed.rs:2077:9
  13:     0x7280914a1c0b - std::panicking::rust_panic_with_hook::hcc81e648ee4fa5ca
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/panicking.rs:799:13
  14:     0x7280914a1984 - std::panicking::begin_panic_handler::{{closure}}::hb1ba03674522357e
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/panicking.rs:664:13
  15:     0x72809149f189 - std::sys_common::backtrace::__rust_end_short_backtrace::hd358911377029d52
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7280914a16b7 - rust_begin_unwind
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/panicking.rs:652:5
  17:     0x7280914eba03 - core::panicking::panic_fmt::h91b4e9abcff8b652
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/core/src/panicking.rs:72:14
  18:     0x72808e3ce01b - <rustc_type_ir[ec233038e902676a]::ty_kind::InferTy as rustc_data_structures[fdee94bd90e361f1]::stable_hasher::HashStable<rustc_query_system[d7adc1b68469f11c]::ich::hcx::StableHashingContext>>::hash_stable
  19:     0x72808f1b243c - <rustc_type_ir[ec233038e902676a]::ty_info::WithCachedTypeInfo<rustc_type_ir[ec233038e902676a]::ty_kind::TyKind<rustc_middle[20ab712fb3484bec]::ty::context::TyCtxt>> as rustc_data_structures[fdee94bd90e361f1]::stable_hasher::HashStable<rustc_query_system[d7adc1b68469f11c]::ich::hcx::StableHashingContext>>::hash_stable
  20:     0x72808f1ba7a9 - rustc_query_system[d7adc1b68469f11c]::query::plumbing::try_execute_query::<rustc_query_impl[2e1c19f32770c017]::DynamicConfig<rustc_query_system[d7adc1b68469f11c]::query::caches::DefaultCache<rustc_middle[20ab712fb3484bec]::ty::ParamEnvAnd<rustc_middle[20ab712fb3484bec]::ty::Ty>, rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[2e1c19f32770c017]::plumbing::QueryCtxt, true>
  21:     0x72808f1b9acf - rustc_query_impl[2e1c19f32770c017]::query_impl::layout_of::get_query_incr::__rust_end_short_backtrace
  22:     0x72808e7625ee - rustc_middle[20ab712fb3484bec]::query::plumbing::query_get_at::<rustc_query_system[d7adc1b68469f11c]::query::caches::DefaultCache<rustc_middle[20ab712fb3484bec]::ty::ParamEnvAnd<rustc_middle[20ab712fb3484bec]::ty::Ty>, rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 16usize]>>>
  23:     0x72808e783429 - <rustc_transmute[bc46983496e99752]::maybe_transmutable::MaybeTransmutableQuery<rustc_middle[20ab712fb3484bec]::ty::Ty, rustc_middle[20ab712fb3484bec]::ty::context::TyCtxt>>::answer::{closure#0}
  24:     0x72808e780723 - <rustc_transmute[bc46983496e99752]::rustc::TransmuteTypeEnv>::is_transmutable
  25:     0x72808f91f30c - <rustc_trait_selection[57b953155e7b0930]::traits::select::SelectionContext>::confirm_candidate
  26:     0x72808f3d9e0e - <rustc_trait_selection[57b953155e7b0930]::traits::select::SelectionContext>::evaluate_candidate::{closure#0}::{closure#0}
  27:     0x72808bc44285 - <rustc_trait_selection[57b953155e7b0930]::traits::select::SelectionContext>::candidate_from_obligation_no_cache
  28:     0x72808bc802b6 - <rustc_trait_selection[57b953155e7b0930]::traits::select::SelectionContext>::candidate_from_obligation
  29:     0x72808bc7d41a - <rustc_trait_selection[57b953155e7b0930]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively::{closure#0}::{closure#1}
  30:     0x72808f3dde06 - <rustc_trait_selection[57b953155e7b0930]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  31:     0x72808f3cd3ab - <rustc_infer[8a8ff9df6ed1d3c6]::infer::InferCtxt>::probe::<core[221fd742908fc512]::result::Result<rustc_middle[20ab712fb3484bec]::traits::select::EvaluationResult, rustc_middle[20ab712fb3484bec]::traits::select::OverflowError>, <rustc_trait_selection[57b953155e7b0930]::traits::select::SelectionContext>::evaluation_probe<<rustc_trait_selection[57b953155e7b0930]::traits::select::SelectionContext>::evaluate_root_obligation::{closure#0}>::{closure#0}>
  32:     0x72808f3cc1df - rustc_trait_selection[57b953155e7b0930]::traits::coherence::overlap
  33:     0x72808fd42a66 - <rustc_middle[20ab712fb3484bec]::traits::specialization_graph::Children as rustc_trait_selection[57b953155e7b0930]::traits::specialize::specialization_graph::ChildrenExt>::insert
  34:     0x72808c113178 - <rustc_middle[20ab712fb3484bec]::traits::specialization_graph::Graph as rustc_trait_selection[57b953155e7b0930]::traits::specialize::specialization_graph::GraphExt>::insert
  35:     0x72808f1463e9 - rustc_trait_selection[57b953155e7b0930]::traits::specialize::specialization_graph_provider
  36:     0x72808f145f63 - rustc_query_impl[2e1c19f32770c017]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2e1c19f32770c017]::query_impl::specialization_graph_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 8usize]>>
  37:     0x72808f184965 - rustc_query_system[d7adc1b68469f11c]::query::plumbing::try_execute_query::<rustc_query_impl[2e1c19f32770c017]::DynamicConfig<rustc_query_system[d7adc1b68469f11c]::query::caches::DefIdCache<rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2e1c19f32770c017]::plumbing::QueryCtxt, true>
  38:     0x72808f54e6a3 - rustc_query_impl[2e1c19f32770c017]::query_impl::specialization_graph_of::get_query_incr::__rust_end_short_backtrace
  39:     0x72808f272a2f - rustc_hir_analysis[905f368b2fc9ddf1]::coherence::coherent_trait
  40:     0x72808f27276d - rustc_query_impl[2e1c19f32770c017]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2e1c19f32770c017]::query_impl::coherent_trait::dynamic_query::{closure#2}::{closure#0}, rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 1usize]>>
  41:     0x72808f58627c - rustc_query_system[d7adc1b68469f11c]::query::plumbing::try_execute_query::<rustc_query_impl[2e1c19f32770c017]::DynamicConfig<rustc_query_system[d7adc1b68469f11c]::query::caches::DefIdCache<rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2e1c19f32770c017]::plumbing::QueryCtxt, true>
  42:     0x72808f68922b - rustc_query_impl[2e1c19f32770c017]::query_impl::coherent_trait::get_query_incr::__rust_end_short_backtrace
  43:     0x72808f4b0147 - rustc_hir_analysis[905f368b2fc9ddf1]::check::wfcheck::check_well_formed
  44:     0x72808f4ada51 - rustc_query_impl[2e1c19f32770c017]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2e1c19f32770c017]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 1usize]>>
  45:     0x72808f580b0b - rustc_query_system[d7adc1b68469f11c]::query::plumbing::try_execute_query::<rustc_query_impl[2e1c19f32770c017]::DynamicConfig<rustc_query_system[d7adc1b68469f11c]::query::caches::VecCache<rustc_hir[c6d77eea478f137d]::hir_id::OwnerId, rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2e1c19f32770c017]::plumbing::QueryCtxt, true>
  46:     0x72808f580607 - rustc_query_impl[2e1c19f32770c017]::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
  47:     0x72808f4aae37 - rustc_hir_analysis[905f368b2fc9ddf1]::check::wfcheck::check_mod_type_wf
  48:     0x72808f4aac61 - rustc_query_impl[2e1c19f32770c017]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2e1c19f32770c017]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 1usize]>>
  49:     0x72808faede42 - rustc_query_system[d7adc1b68469f11c]::query::plumbing::try_execute_query::<rustc_query_impl[2e1c19f32770c017]::DynamicConfig<rustc_query_system[d7adc1b68469f11c]::query::caches::DefaultCache<rustc_span[51dc3a994d050bac]::def_id::LocalModDefId, rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2e1c19f32770c017]::plumbing::QueryCtxt, true>
  50:     0x72808faeeab0 - rustc_query_impl[2e1c19f32770c017]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
  51:     0x72808f60d990 - rustc_hir_analysis[905f368b2fc9ddf1]::check_crate
  52:     0x72808f56fd3e - rustc_interface[6bfa9daba1d5b6c2]::passes::analysis
  53:     0x72808f56f89b - rustc_query_impl[2e1c19f32770c017]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2e1c19f32770c017]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 1usize]>>
  54:     0x72808fdb958e - rustc_query_system[d7adc1b68469f11c]::query::plumbing::try_execute_query::<rustc_query_impl[2e1c19f32770c017]::DynamicConfig<rustc_query_system[d7adc1b68469f11c]::query::caches::SingleCache<rustc_middle[20ab712fb3484bec]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2e1c19f32770c017]::plumbing::QueryCtxt, true>
  55:     0x72808fdb91ba - rustc_query_impl[2e1c19f32770c017]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  56:     0x72808fbd1ce0 - rustc_interface[6bfa9daba1d5b6c2]::interface::run_compiler::<core[221fd742908fc512]::result::Result<(), rustc_span[51dc3a994d050bac]::ErrorGuaranteed>, rustc_driver_impl[c42a3492d6f6b9ec]::run_compiler::{closure#0}>::{closure#1}
  57:     0x72808fbbd649 - std[45eea3d871d24ad6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[6bfa9daba1d5b6c2]::util::run_in_thread_with_globals<rustc_interface[6bfa9daba1d5b6c2]::util::run_in_thread_pool_with_globals<rustc_interface[6bfa9daba1d5b6c2]::interface::run_compiler<core[221fd742908fc512]::result::Result<(), rustc_span[51dc3a994d050bac]::ErrorGuaranteed>, rustc_driver_impl[c42a3492d6f6b9ec]::run_compiler::{closure#0}>::{closure#1}, core[221fd742908fc512]::result::Result<(), rustc_span[51dc3a994d050bac]::ErrorGuaranteed>>::{closure#0}, core[221fd742908fc512]::result::Result<(), rustc_span[51dc3a994d050bac]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[221fd742908fc512]::result::Result<(), rustc_span[51dc3a994d050bac]::ErrorGuaranteed>>
  58:     0x72808fbbd400 - <<std[45eea3d871d24ad6]::thread::Builder>::spawn_unchecked_<rustc_interface[6bfa9daba1d5b6c2]::util::run_in_thread_with_globals<rustc_interface[6bfa9daba1d5b6c2]::util::run_in_thread_pool_with_globals<rustc_interface[6bfa9daba1d5b6c2]::interface::run_compiler<core[221fd742908fc512]::result::Result<(), rustc_span[51dc3a994d050bac]::ErrorGuaranteed>, rustc_driver_impl[c42a3492d6f6b9ec]::run_compiler::{closure#0}>::{closure#1}, core[221fd742908fc512]::result::Result<(), rustc_span[51dc3a994d050bac]::ErrorGuaranteed>>::{closure#0}, core[221fd742908fc512]::result::Result<(), rustc_span[51dc3a994d050bac]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[221fd742908fc512]::result::Result<(), rustc_span[51dc3a994d050bac]::ErrorGuaranteed>>::{closure#2} as core[221fd742908fc512]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  59:     0x7280914abbfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h715ce95eefcc4a2c
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/alloc/src/boxed.rs:2063:9
  60:     0x7280914abbfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h502013687618e5e5
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/alloc/src/boxed.rs:2063:9
  61:     0x7280914abbfb - std::sys::pal::unix::thread::Thread::new::thread_start::ha0246e0960ff3ff1
                               at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library/std/src/sys/pal/unix/thread.rs:108:17
  62:     0x7280912481cf - <unknown>
  63:     0x7280912c96ec - <unknown>
  64:                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: please attach the file at `/tmp/icemaker_reports/2024-06-02_11-08-05/rustc-ice-2024-06-02T09_50_12-2441874.txt` to your bug report

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

query stack during panic:
panicked at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/compiler/rustc_type_ir/src/ty_kind.rs:856:17:
thread panicked while processing panic. aborting.
[1]    2441874 IOT instruction  rustc f.rs -Cincremental=.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash with /tmp/SOMUCHICE/ice.rs and the listed rustc incremental-verification command. Start at compiler/rustc_type_ir/src/ty_kind.rs:856:17 and follow the HashStable path shown in the backtrace through incremental query handling. Done means this input reports its existing compiler error without panicking on the type variable.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.