rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.89k stars 12.52k forks source link

ICE: type variables should not be hashed #109864

Open uwuzote opened 1 year ago

uwuzote commented 1 year ago

Code

struct S;
struct S2<P>();

trait Foo<A> {
    type Out;
}

trait Bar<A, B> {
    type Out;
}

trait Qux<A> {
    type Out;
}

trait Fuzz<A> {
    type Out;
}

impl<A: Foo<B>, B> Fuzz<S2<B>> for S2<A> {
    type Out = <<A as Foo<B>>::Out as Bar<
        S2<A>,
        <<<A as Foo<B>>::Out as Qux<S>>::Out as Fuzz<S2<B>>>::Out,
    >>::Out;
}

Build with cargo check or rustc main.rs --crate-type lib -C incremental=./target/debug/incremental -L dependency=./target/debug/deps

Meta

Runnng with rustc +nightly main.rs --crate-type lib -C incremental=./target/debug/incremental -L dependency=./target/debug/deps does not produce compiler panic

rustc --version --verbose:

rustc 1.67.1 (d5a82bbd2 2023-02-07)
binary: rustc
commit-hash: d5a82bbd26e1ad8b7401f6a718a9c57c96905483
commit-date: 2023-02-07
host: x86_64-unknown-linux-gnu
release: 1.67.1
LLVM version: 15.0.6

Error output

rustc main.rs --crate-type lib -C incremental=./target/debug/incremental -L dependency=./target/debug/deps:

error[E0392]: parameter `P` is never used
 --> main.rs:2:11
  |
2 | struct S2<P>();
  |           ^ unused parameter
  |
  = help: consider removing `P`, referring to it in a field, or using a marker such as `PhantomData`
  = help: if you intended `P` to be a const parameter, use `const P: usize` instead

error[E0277]: the trait bound `<A as Foo<B>>::Out: Qux<S>` is not satisfied
  --> main.rs:23:10
   |
23 |         <<<A as Foo<B>>::Out as Qux<S>>::Out as Fuzz<S2<B>>>::Out,
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qux<S>` is not implemented for `<A as Foo<B>>::Out`
   |
help: consider further restricting the associated type
   |
20 | impl<A: Foo<B>, B> Fuzz<S2<B>> for S2<A> where <A as Foo<B>>::Out: Qux<S> {
   |                                          ++++++++++++++++++++++++++++++++

thread 'rustc' panicked at 'type variables should not be hashed: _#1t', /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/compiler/rustc_type_ir/src/lib.rs:681:17
stack backtrace:
   0:     0x7f77e6a0b6fa - std::backtrace_rs::backtrace::libunwind::trace::h79937bc171ada62c
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f77e6a0b6fa - std::backtrace_rs::backtrace::trace_unsynchronized::h2292bca8571cb919
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f77e6a0b6fa - std::sys_common::backtrace::_print_fmt::h9c461f248e4ae90d
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f77e6a0b6fa - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he9fe6bf1a39182e1
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f77e6a6e25e - core::fmt::write::h032658c119c720d7
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f77e69fba85 - std::io::Write::write_fmt::h299fc90dfae41c0d
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/io/mod.rs:1682:15
   6:     0x7f77e6a0b4c5 - std::sys_common::backtrace::_print::heb70d25df9937e3f
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f77e6a0b4c5 - std::sys_common::backtrace::print::had745c0a76b8b521
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f77e6a0e20f - std::panicking::default_hook::{{closure}}::h1ea782cdfa2fd097
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:267:22
   9:     0x7f77e6a0df4b - std::panicking::default_hook::h1cc3af63455a163c
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:286:9
  10:     0x7f77e5860ab1 - <rustc_driver[5c3b90d1fb3964ba]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[e6a29f2585b3d454]::ops::function::FnOnce<(&core[e6a29f2585b3d454]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f77e6a0ea4d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h6e4950ba7c0fd82a
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/alloc/src/boxed.rs:2032:9
  12:     0x7f77e6a0ea4d - std::panicking::rust_panic_with_hook::h5cafdc4b3bfd5528
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:692:13
  13:     0x7f77e6a0e7c9 - std::panicking::begin_panic_handler::{{closure}}::hf31c60f40775892c
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:579:13
  14:     0x7f77e6a0bbac - std::sys_common::backtrace::__rust_end_short_backtrace::h28a5c7be595826cd
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x7f77e6a0e4d2 - rust_begin_unwind
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5
  16:     0x7f77e6a6ac43 - core::panicking::panic_fmt::h8fa27a0b37dd98b7
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14
  17:     0x7f77e5d2d3c7 - <rustc_type_ir[9ee78e40cc0f9c7b]::InferTy as rustc_data_structures[1026114362f98086]::stable_hasher::HashStable<rustc_query_system[7dbbccfee5a2d054]::ich::hcx::StableHashingContext>>::hash_stable
  18:     0x7f77e3832f5b - <rustc_type_ir[9ee78e40cc0f9c7b]::ty_info::WithCachedTypeInfo<rustc_type_ir[9ee78e40cc0f9c7b]::sty::TyKind<rustc_middle[83f907612b22699d]::ty::context::TyCtxt>> as rustc_data_structures[1026114362f98086]::stable_hasher::HashStable<rustc_query_system[7dbbccfee5a2d054]::ich::hcx::StableHashingContext>>::hash_stable
  19:     0x7f77e403e49c - <&rustc_middle[83f907612b22699d]::ty::list::List<rustc_middle[83f907612b22699d]::ty::subst::GenericArg> as rustc_data_structures[1026114362f98086]::stable_hasher::HashStable<rustc_query_system[7dbbccfee5a2d054]::ich::hcx::StableHashingContext>>::hash_stable
  20:     0x7f77e4c38b86 - <rustc_data_structures[1026114362f98086]::intern::Interned<rustc_type_ir[9ee78e40cc0f9c7b]::ty_info::WithCachedTypeInfo<rustc_middle[83f907612b22699d]::ty::sty::Binder<rustc_middle[83f907612b22699d]::ty::PredicateKind>>> as rustc_data_structures[1026114362f98086]::stable_hasher::HashStable<rustc_query_system[7dbbccfee5a2d054]::ich::hcx::StableHashingContext>>::hash_stable
  21:     0x7f77e61c6c96 - <(rustc_middle[83f907612b22699d]::ty::Predicate, rustc_middle[83f907612b22699d]::traits::WellFormedLoc) as rustc_data_structures[1026114362f98086]::stable_hasher::HashStable<rustc_query_system[7dbbccfee5a2d054]::ich::hcx::StableHashingContext>>::hash_stable
  22:     0x7f77e6125bdd - <rustc_query_system[7dbbccfee5a2d054]::query::config::QueryVTable<rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt, (rustc_middle[83f907612b22699d]::ty::Predicate, rustc_middle[83f907612b22699d]::traits::WellFormedLoc), core[e6a29f2585b3d454]::option::Option<rustc_middle[83f907612b22699d]::traits::ObligationCause>>>::to_dep_node
  23:     0x7f77e603310b - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::try_execute_query::<rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt, rustc_query_system[7dbbccfee5a2d054]::query::caches::ArenaCache<(rustc_middle[83f907612b22699d]::ty::Predicate, rustc_middle[83f907612b22699d]::traits::WellFormedLoc), core[e6a29f2585b3d454]::option::Option<rustc_middle[83f907612b22699d]::traits::ObligationCause>>>
  24:     0x7f77e60700e0 - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::get_query::<rustc_query_impl[e214cefb6de2a99d]::queries::diagnostic_hir_wf_check, rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt>
  25:     0x7f77e60b812b - <rustc_query_impl[e214cefb6de2a99d]::Queries as rustc_middle[83f907612b22699d]::ty::query::QueryEngine>::diagnostic_hir_wf_check
  26:     0x7f77e64b22b0 - <rustc_infer[ce51c2dc4d9f2303]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[945b70100f8dd3ec]::traits::error_reporting::TypeErrCtxtExt>::report_selection_error
  27:     0x7f77e64bc267 - <rustc_infer[ce51c2dc4d9f2303]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[945b70100f8dd3ec]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  28:     0x7f77e64b0554 - <rustc_infer[ce51c2dc4d9f2303]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[945b70100f8dd3ec]::traits::error_reporting::TypeErrCtxtExt>::report_fulfillment_errors
  29:     0x7f77e488a1ee - rustc_hir_analysis[44326659f1d3f01d]::check::wfcheck::check_associated_item
  30:     0x7f77e4881b97 - rustc_hir_analysis[44326659f1d3f01d]::check::wfcheck::check_well_formed
  31:     0x7f77e3a6028c - <rustc_query_system[7dbbccfee5a2d054]::dep_graph::graph::DepGraph<rustc_middle[83f907612b22699d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[83f907612b22699d]::ty::context::TyCtxt, rustc_hir[dd085327af2d6b95]::hir_id::OwnerId, ()>
  32:     0x7f77e3a5ece0 - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::get_query::<rustc_query_impl[e214cefb6de2a99d]::queries::check_well_formed, rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt>
  33:     0x7f77e4c32608 - rustc_data_structures[1026114362f98086]::sync::par_for_each_in::<&[rustc_hir[dd085327af2d6b95]::hir::ImplItemId], <rustc_middle[83f907612b22699d]::hir::ModuleItems>::par_impl_items<rustc_hir_analysis[44326659f1d3f01d]::check::wfcheck::check_mod_type_wf::{closure#1}>::{closure#0}>
  34:     0x7f77e4c3242f - rustc_hir_analysis[44326659f1d3f01d]::check::wfcheck::check_mod_type_wf
  35:     0x7f77e440877c - <rustc_query_system[7dbbccfee5a2d054]::dep_graph::graph::DepGraph<rustc_middle[83f907612b22699d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[83f907612b22699d]::ty::context::TyCtxt, rustc_span[41a321a6411ba4fa]::def_id::LocalDefId, ()>
  36:     0x7f77e440668e - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::try_execute_query::<rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt, rustc_query_system[7dbbccfee5a2d054]::query::caches::VecCache<rustc_span[41a321a6411ba4fa]::def_id::LocalDefId, ()>>
  37:     0x7f77e4c02ce3 - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::get_query::<rustc_query_impl[e214cefb6de2a99d]::queries::check_mod_type_wf, rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt>
  38:     0x7f77e3d5b5e8 - rustc_data_structures[1026114362f98086]::sync::par_for_each_in::<&[rustc_hir[dd085327af2d6b95]::hir_id::OwnerId], <rustc_middle[83f907612b22699d]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[44326659f1d3f01d]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
  39:     0x7f77e3d5b3d3 - <rustc_session[b89b9f24749004e7]::session::Session>::track_errors::<rustc_hir_analysis[44326659f1d3f01d]::check_crate::{closure#5}, ()>
  40:     0x7f77e3d5aced - rustc_hir_analysis[44326659f1d3f01d]::check_crate
  41:     0x7f77e3d5a98b - rustc_interface[65dcc5dffb099e04]::passes::analysis
  42:     0x7f77e501291f - <rustc_query_system[7dbbccfee5a2d054]::dep_graph::graph::DepGraph<rustc_middle[83f907612b22699d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[83f907612b22699d]::ty::context::TyCtxt, (), core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  43:     0x7f77e5011a17 - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::try_execute_query::<rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt, rustc_query_system[7dbbccfee5a2d054]::query::caches::DefaultCache<(), core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>>
  44:     0x7f77e5011470 - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::get_query::<rustc_query_impl[e214cefb6de2a99d]::queries::analysis, rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt>
  45:     0x7f77e4a241b3 - <rustc_interface[65dcc5dffb099e04]::passes::QueryContext>::enter::<rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  46:     0x7f77e4a20733 - <rustc_interface[65dcc5dffb099e04]::interface::Compiler>::enter::<rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}::{closure#2}, core[e6a29f2585b3d454]::result::Result<core[e6a29f2585b3d454]::option::Option<rustc_interface[65dcc5dffb099e04]::queries::Linker>, rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  47:     0x7f77e4a1b788 - rustc_span[41a321a6411ba4fa]::with_source_map::<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  48:     0x7f77e4a1b275 - <scoped_tls[393dd8f8fd825c8d]::ScopedKey<rustc_span[41a321a6411ba4fa]::SessionGlobals>>::set::<rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  49:     0x7f77e4a1a862 - std[359ab902947f5f0b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[65dcc5dffb099e04]::util::run_in_thread_pool_with_globals<rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  50:     0x7f77e5113b7a - <<std[359ab902947f5f0b]::thread::Builder>::spawn_unchecked_<rustc_interface[65dcc5dffb099e04]::util::run_in_thread_pool_with_globals<rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>::{closure#1} as core[e6a29f2585b3d454]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:     0x7f77e6a18803 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb77d8d72ebcf79c4
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/alloc/src/boxed.rs:2000:9
  52:     0x7f77e6a18803 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc08c3353e1568487
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/alloc/src/boxed.rs:2000:9
  53:     0x7f77e6a18803 - std::sys::unix::thread::Thread::new::thread_start::h7168e596cd5e5ce6
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys/unix/thread.rs:108:17
  54:     0x7f77e24ae12d - start_thread
  55:     0x7f77e252fbc0 - clone3
  56:                0x0 - <unknown>

error: internal compiler error: unexpected panic

note: 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: rustc 1.67.1 (d5a82bbd2 2023-02-07) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C incremental=[REDACTED]

query stack during panic:
#0 [diagnostic_hir_wf_check] performing HIR wf-checking for predicate `Binder(TraitPredicate(<<A as Foo<B>>::Out as Bar<S2<A>, _>>, polarity:Positive), [])` at item `Ty(DefId(0:24 ~ main[7c5f]::{impl#0}::Out))`
#1 [check_well_formed] checking that `<impl at main.rs:20:1: 20:41>::Out` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

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

cargo +beta build:

   Compiling xuwunum-rev v0.1.0 (/home/uwuzote/gh/rs/xuwunum-rev)
error[E0392]: parameter `P` is never used
 --> src/lib.rs:2:11
  |
2 | struct S2<P>();
  |           ^ unused parameter
  |
  = help: consider removing `P`, referring to it in a field, or using a marker such as `PhantomData`
  = help: if you intended `P` to be a const parameter, use `const P: usize` instead

error[E0277]: the trait bound `<A as Foo<B>>::Out: Qux<S>` is not satisfied
  --> src/lib.rs:23:10
   |
23 |         <<<A as Foo<B>>::Out as Qux<S>>::Out as Fuzz<S2<B>>>::Out,
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qux<S>` is not implemented for `<A as Foo<B>>::Out`
   |
help: consider further restricting the associated type
   |
20 | impl<A: Foo<B>, B> Fuzz<S2<B>> for S2<A> where <A as Foo<B>>::Out: Qux<S> {
   |                                          ++++++++++++++++++++++++++++++++

error[E0277]: the trait bound `<A as Foo<B>>::Out: Bar<S2<A>, _>` is not satisfied
  --> src/lib.rs:21:16
   |
21 |       type Out = <<A as Foo<B>>::Out as Bar<
   |  ________________^
22 | |         S2<A>,
23 | |         <<<A as Foo<B>>::Out as Qux<S>>::Out as Fuzz<S2<B>>>::Out,
24 | |     >>::Out;
   | |___________^ the trait `Bar<S2<A>, _>` is not implemented for `<A as Foo<B>>::Out`

Some errors have detailed explanations: E0277, E0392.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `xuwunum-rev` due to 3 previous errors

rustc +nightly main.rs --crate-type lib -C incremental=./target/debug/incremental -L dependency=./target/debug/deps:

error[E0392]: parameter `P` is never used
 --> main.rs:2:11
  |
2 | struct S2<P>();
  |           ^ unused parameter
  |
  = help: consider removing `P`, referring to it in a field, or using a marker such as `PhantomData`
  = help: if you intended `P` to be a const parameter, use `const P: usize` instead

error[E0277]: the trait bound `<A as Foo<B>>::Out: Qux<S>` is not satisfied
  --> main.rs:23:10
   |
23 |         <<<A as Foo<B>>::Out as Qux<S>>::Out as Fuzz<S2<B>>>::Out,
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qux<S>` is not implemented for `<A as Foo<B>>::Out`
   |
help: consider further restricting the associated type
   |
20 | impl<A: Foo<B>, B> Fuzz<S2<B>> for S2<A> where <A as Foo<B>>::Out: Qux<S> {
   |                                          ++++++++++++++++++++++++++++++++

error[E0277]: the trait bound `<A as Foo<B>>::Out: Bar<S2<A>, _>` is not satisfied
  --> main.rs:21:16
   |
21 |       type Out = <<A as Foo<B>>::Out as Bar<
   |  ________________^
22 | |         S2<A>,
23 | |         <<<A as Foo<B>>::Out as Qux<S>>::Out as Fuzz<S2<B>>>::Out,
24 | |     >>::Out;
   | |___________^ the trait `Bar<S2<A>, _>` is not implemented for `<A as Foo<B>>::Out`

error: aborting due to 3 previous errors

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

```error[E0392]: parameter `P` is never used --> src/lib.rs:2:11 | 2 | struct S2

(); | ^ unused parameter | = help: consider removing `P`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `P` to be a const parameter, use `const P: usize` instead error[E0277]: the trait bound `>::Out: Qux` is not satisfied --> src/lib.rs:23:10 | 23 | <<>::Out as Qux>::Out as Fuzz>>::Out, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qux` is not implemented for `>::Out` | help: consider further restricting the associated type | 20 | impl, B> Fuzz> for S2 where >::Out: Qux { | ++++++++++++++++++++++++++++++++ thread 'rustc' panicked at 'type variables should not be hashed: _#1t', /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/compiler/rustc_type_ir/src/lib.rs:681:17 stack backtrace: 0: rust_begin_unwind at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5 1: core::panicking::panic_fmt at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14 2: >::hash_stable 3: > as rustc_data_structures::stable_hasher::HashStable>::hash_stable 4: <&rustc_middle::ty::list::List as rustc_data_structures::stable_hasher::HashStable>::hash_stable 5: >> as rustc_data_structures::stable_hasher::HashStable>::hash_stable 6: <(rustc_middle::ty::Predicate, rustc_middle::traits::WellFormedLoc) as rustc_data_structures::stable_hasher::HashStable>::hash_stable 7: >>::to_dep_node 8: rustc_query_system::query::plumbing::try_execute_query::>> 9: rustc_query_system::query::plumbing::get_query:: 10: ::diagnostic_hir_wf_check 11: ::report_selection_error 12: ::report_fulfillment_error 13: ::report_fulfillment_errors 14: rustc_hir_analysis::check::wfcheck::check_associated_item 15: rustc_hir_analysis::check::wfcheck::check_well_formed 16: >::with_task:: 17: rustc_query_system::query::plumbing::get_query:: 18: rustc_data_structures::sync::par_for_each_in::<&[rustc_hir::hir::ImplItemId], ::par_impl_items::{closure#0}> 19: rustc_hir_analysis::check::wfcheck::check_mod_type_wf 20: >::with_task:: 21: rustc_query_system::query::plumbing::try_execute_query::> 22: rustc_query_system::query::plumbing::get_query:: 23: rustc_data_structures::sync::par_for_each_in::<&[rustc_hir::hir_id::OwnerId], ::par_for_each_module::{closure#0}> 24: ::track_errors:: 25: rustc_hir_analysis::check_crate 26: rustc_interface::passes::analysis 27: >::with_task::> 28: rustc_query_system::query::plumbing::try_execute_query::>> 29: rustc_query_system::query::plumbing::get_query:: 30: ::enter::> 31: ::enter::, rustc_errors::ErrorGuaranteed>> 32: rustc_span::with_source_map::, rustc_interface::interface::run_compiler, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}> 33: >::set::, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>> note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. error: internal compiler error: unexpected panic note: 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: rustc 1.67.1 (d5a82bbd2 2023-02-07) running on x86_64-unknown-linux-gnu note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [diagnostic_hir_wf_check] performing HIR wf-checking for predicate `Binder(TraitPredicate(<>::Out as Bar, _>>, polarity:Positive), [])` at item `Ty(DefId(0:24 ~ xuwunum_rev[2847]::{impl#0}::Out))` #1 [check_well_formed] checking that `::Out` is well-formed #2 [check_mod_type_wf] checking that types are well-formed in top-level module #3 [analysis] running analysis passes on this crate end of query stack Some errors have detailed explanations: E0277, E0392. For more information about an error, try `rustc --explain E0277`. error: could not compile `xuwunum-rev` due to 2 previous errors ```

Noratrieb commented 1 year ago

Thank you so much for providing a minimial reproduction ❤️

But as far as I know, this issue is already fixed on nightly (and I think beta too now). Although I was unable to reproduce this on 1.67.2 stable (which should not have the fix) so you should try yourself to make sure before closing.