Skip to content

[ICE]: called Result::unwrap_err() on an Ok value: W<'?2, {type error}> #154173

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

struct W<'a, T: ?Sized>;
trait Trait {
    type Assoc: ?Sized;
}
impl<'a> Trait for W<'a, W<'_>> {}
trait Overlap<T: ?Sized> {}
impl<'a, T> Overlap<T> for W<'_, T> {}
impl<T: Trait> Overlap<T::Assoc> for T {}

original:

struct W<'a, T: ?Sized>;
trait Trait {
    type Assoc: ?Sized;
}
impl<'a> Trait for W<'a, W<'_>> {}
trait Overlap<T: ?Sized> {}
impl<'a, T> Overlap<T> for W<'_, T> {}
impl<T: Trait> Overlap<T::Assoc> for T {}
fn main() {}

Version information

rustc 1.96.0-nightly (e52f547ed 2026-03-21)
binary: rustc
commit-hash: e52f547ed4bc554e40ab63b264e8697b8e3c5e09
commit-date: 2026-03-21
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

Possibly related line of code:

source_term: T,
normalize: &mut dyn FnMut(ty::AliasTy<'tcx>) -> Ty<'tcx>,
) -> RelateResult<'tcx, Generalization<T>> {
assert!(!source_term.has_escaping_bound_vars());
let (for_universe, root_vid) = match target_vid.into() {
TermVid::Ty(ty_vid) => {
(self.probe_ty_var(ty_vid).unwrap_err(), TermVid::Ty(self.root_var(ty_vid)))
}
TermVid::Const(ct_vid) => (
self.probe_const_var(ct_vid).unwrap_err(),
TermVid::Const(self.inner.borrow_mut().const_unification_table().find(ct_vid).vid),
),
};

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.QQairma7a6ld/rustc_testrunner_tmpdir_reporting.UqQeULen7N88/mvce.rs:8:42
  |
8 | impl<T: Trait> Overlap<T::Assoc> for T {}
  |                                          ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.QQairma7a6ld/rustc_testrunner_tmpdir_reporting.UqQeULen7N88/mvce.rs`

error[E0392]: lifetime parameter `'a` is never used
 --> /tmp/icemaker_global_tempdir.QQairma7a6ld/rustc_testrunner_tmpdir_reporting.UqQeULen7N88/mvce.rs:1:10
  |
1 | struct W<'a, T: ?Sized>;
  |          ^^ unused lifetime parameter
  |
  = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`

error[E0392]: type parameter `T` is never used
 --> /tmp/icemaker_global_tempdir.QQairma7a6ld/rustc_testrunner_tmpdir_reporting.UqQeULen7N88/mvce.rs:1:14
  |
1 | struct W<'a, T: ?Sized>;
  |              ^ unused type parameter
  |
  = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`

error[E0107]: struct takes 1 generic argument but 0 generic arguments were supplied
 --> /tmp/icemaker_global_tempdir.QQairma7a6ld/rustc_testrunner_tmpdir_reporting.UqQeULen7N88/mvce.rs:5:26
  |
5 | impl<'a> Trait for W<'a, W<'_>> {}
  |                          ^ expected 1 generic argument
  |
note: struct defined here, with 1 generic parameter: `T`
 --> /tmp/icemaker_global_tempdir.QQairma7a6ld/rustc_testrunner_tmpdir_reporting.UqQeULen7N88/mvce.rs:1:8
  |
1 | struct W<'a, T: ?Sized>;
  |        ^     -
help: add missing generic argument
  |
5 | impl<'a> Trait for W<'a, W<'_, T>> {}
  |                              +++


thread 'rustc' (2194207) panicked at /rustc-dev/e52f547ed4bc554e40ab63b264e8697b8e3c5e09/compiler/rustc_infer/src/infer/relate/generalize.rs:294:44:
called `Result::unwrap_err()` on an `Ok` value: W<'?2, {type error}>
stack backtrace:
   0:     0x7f6d059ae18b - <<std[621601a63b8164bd]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[808b3c8ca0839621]::fmt::Display>::fmt
   1:     0x7f6d0602f288 - core[808b3c8ca0839621]::fmt::write
   2:     0x7f6d059c5196 - <std[621601a63b8164bd]::sys::stdio::unix::Stderr as std[621601a63b8164bd]::io::Write>::write_fmt
   3:     0x7f6d05984198 - std[621601a63b8164bd]::panicking::default_hook::{closure#0}
   4:     0x7f6d059a1593 - std[621601a63b8164bd]::panicking::default_hook
   5:     0x7f6d04998fec - std[621601a63b8164bd]::panicking::update_hook::<alloc[f42117cbe29c560]::boxed::Box<rustc_driver_impl[bb12b93e7ed3d66e]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f6d059a1872 - std[621601a63b8164bd]::panicking::panic_with_hook
   7:     0x7f6d05984258 - std[621601a63b8164bd]::panicking::panic_handler::{closure#0}
   8:     0x7f6d059787a9 - std[621601a63b8164bd]::sys::backtrace::__rust_end_short_backtrace::<std[621601a63b8164bd]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f6d05985cbd - __rustc[2aef9aea54ef6ab7]::rust_begin_unwind
  10:     0x7f6d0210d65c - core[808b3c8ca0839621]::panicking::panic_fmt
  11:     0x7f6d02233092 - core[808b3c8ca0839621]::result::unwrap_failed
  12:     0x7f6d06d3f4ca - <rustc_infer[cbf2577b762f90cd]::infer::InferCtxt>::instantiate_ty_var::<rustc_type_ir[366a33e2bd687e07]::relate::solver_relating::SolverRelating<rustc_infer[cbf2577b762f90cd]::infer::InferCtxt, rustc_middle[260c6ff029005197]::ty::context::TyCtxt>>
  13:     0x7f6d06d3f918 - <rustc_type_ir[366a33e2bd687e07]::relate::solver_relating::SolverRelating<rustc_infer[cbf2577b762f90cd]::infer::InferCtxt, rustc_middle[260c6ff029005197]::ty::context::TyCtxt> as rustc_type_ir[366a33e2bd687e07]::relate::TypeRelation<rustc_middle[260c6ff029005197]::ty::context::TyCtxt>>::tys
  14:     0x7f6d06d41e37 - <core[808b3c8ca0839621]::result::Result<rustc_middle[260c6ff029005197]::ty::generic_args::GenericArg, rustc_type_ir[366a33e2bd687e07]::error::TypeError<rustc_middle[260c6ff029005197]::ty::context::TyCtxt>> as rustc_type_ir[366a33e2bd687e07]::interner::CollectAndApply<rustc_middle[260c6ff029005197]::ty::generic_args::GenericArg, &rustc_middle[260c6ff029005197]::ty::list::RawList<(), rustc_middle[260c6ff029005197]::ty::generic_args::GenericArg>>>::collect_and_apply::<core[808b3c8ca0839621]::iter::adapters::map::Map<core[808b3c8ca0839621]::iter::adapters::zip::Zip<core[808b3c8ca0839621]::iter::adapters::copied::Copied<core[808b3c8ca0839621]::slice::iter::Iter<rustc_middle[260c6ff029005197]::ty::generic_args::GenericArg>>, core[808b3c8ca0839621]::iter::adapters::copied::Copied<core[808b3c8ca0839621]::slice::iter::Iter<rustc_middle[260c6ff029005197]::ty::generic_args::GenericArg>>>, rustc_type_ir[366a33e2bd687e07]::relate::relate_args_invariantly<rustc_middle[260c6ff029005197]::ty::context::TyCtxt, rustc_type_ir[366a33e2bd687e07]::relate::solver_relating::SolverRelating<rustc_infer[cbf2577b762f90cd]::infer::InferCtxt, rustc_middle[260c6ff029005197]::ty::context::TyCtxt>>::{closure#0}>, <rustc_middle[260c6ff029005197]::ty::context::TyCtxt>::mk_args_from_iter<core[808b3c8ca0839621]::iter::adapters::map::Map<core[808b3c8ca0839621]::iter::adapters::zip::Zip<core[808b3c8ca0839621]::iter::adapters::copied::Copied<core[808b3c8ca0839621]::slice::iter::Iter<rustc_middle[260c6ff029005197]::ty::generic_args::GenericArg>>, core[808b3c8ca0839621]::iter::adapters::copied::Copied<core[808b3c8ca0839621]::slice::iter::Iter<rustc_middle[260c6ff029005197]::ty::generic_args::GenericArg>>>, rustc_type_ir[366a33e2bd687e07]::relate::relate_args_invariantly<rustc_middle[260c6ff029005197]::ty::context::TyCtxt, rustc_type_ir[366a33e2bd687e07]::relate::solver_relating::SolverRelating<rustc_infer[cbf2577b762f90cd]::infer::InferCtxt, rustc_middle[260c6ff029005197]::ty::context::TyCtxt>>::{closure#0}>, core[808b3c8ca0839621]::result::Result<rustc_middle[260c6ff029005197]::ty::generic_args::GenericArg, rustc_type_ir[366a33e2bd687e07]::error::TypeError<rustc_middle[260c6ff029005197]::ty::context::TyCtxt>>>::{closure#0}>
  15:     0x7f6d0606d132 - <rustc_infer[cbf2577b762f90cd]::infer::at::At>::eq_trace::<rustc_type_ir[366a33e2bd687e07]::predicate::TraitRef<rustc_middle[260c6ff029005197]::ty::context::TyCtxt>>
  16:     0x7f6d06a4a094 - rustc_trait_selection[cb4b04e0bd0f99fe]::traits::coherence::overlap
  17:     0x7f6d033769c7 - <rustc_middle[260c6ff029005197]::traits::specialization_graph::Children as rustc_trait_selection[cb4b04e0bd0f99fe]::traits::specialize::specialization_graph::ChildrenExt>::insert
  18:     0x7f6d06fba6e7 - <rustc_middle[260c6ff029005197]::traits::specialization_graph::Graph as rustc_trait_selection[cb4b04e0bd0f99fe]::traits::specialize::specialization_graph::GraphExt>::insert
  19:     0x7f6d0604b534 - rustc_trait_selection[cb4b04e0bd0f99fe]::traits::specialize::specialization_graph_provider
  20:     0x7f6d0604f04d - rustc_query_impl[b8e239cf1f60d90b]::execution::try_execute_query::<rustc_middle[260c6ff029005197]::query::caches::DefIdCache<rustc_middle[260c6ff029005197]::query::erase::ErasedData<[u8; 8usize]>>, false>
  21:     0x7f6d063aaa10 - rustc_query_impl[b8e239cf1f60d90b]::query_impl::specialization_graph_of::execute_query_non_incr::__rust_end_short_backtrace
  22:     0x7f6d063ae147 - rustc_hir_analysis[649a4a35adec2fd0]::coherence::coherent_trait
  23:     0x7f6d063ade5d - rustc_query_impl[b8e239cf1f60d90b]::query_impl::coherent_trait::invoke_provider_fn::__rust_begin_short_backtrace
  24:     0x7f6d063dd86c - rustc_query_impl[b8e239cf1f60d90b]::execution::try_execute_query::<rustc_middle[260c6ff029005197]::query::caches::DefIdCache<rustc_middle[260c6ff029005197]::query::erase::ErasedData<[u8; 1usize]>>, false>
  25:     0x7f6d063dc9c0 - rustc_query_impl[b8e239cf1f60d90b]::query_impl::coherent_trait::execute_query_non_incr::__rust_end_short_backtrace
  26:     0x7f6d066945ee - rustc_hir_analysis[649a4a35adec2fd0]::check::check::check_item_type
  27:     0x7f6d06692aaa - rustc_hir_analysis[649a4a35adec2fd0]::check::wfcheck::check_well_formed
  28:     0x7f6d06692a8b - rustc_query_impl[b8e239cf1f60d90b]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  29:     0x7f6d066920b0 - rustc_query_impl[b8e239cf1f60d90b]::execution::try_execute_query::<rustc_data_structures[bb62459f0a36fa82]::vec_cache::VecCache<rustc_span[22ab794771ab4f9e]::def_id::LocalDefId, rustc_middle[260c6ff029005197]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[260c6ff029005197]::dep_graph::graph::DepNodeIndex>, false>
  30:     0x7f6d06691e47 - rustc_query_impl[b8e239cf1f60d90b]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7f6d0668edf9 - rustc_hir_analysis[649a4a35adec2fd0]::check::wfcheck::check_type_wf
  32:     0x7f6d0668ecef - rustc_query_impl[b8e239cf1f60d90b]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  33:     0x7f6d07257390 - rustc_query_impl[b8e239cf1f60d90b]::execution::try_execute_query::<rustc_middle[260c6ff029005197]::query::caches::SingleCache<rustc_middle[260c6ff029005197]::query::erase::ErasedData<[u8; 1usize]>>, false>
  34:     0x7f6d07257169 - rustc_query_impl[b8e239cf1f60d90b]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  35:     0x7f6d06849617 - rustc_hir_analysis[649a4a35adec2fd0]::check_crate
  36:     0x7f6d0613eb93 - rustc_interface[14d7cdb3160378a8]::passes::analysis
  37:     0x7f6d07259b09 - rustc_query_impl[b8e239cf1f60d90b]::execution::try_execute_query::<rustc_middle[260c6ff029005197]::query::caches::SingleCache<rustc_middle[260c6ff029005197]::query::erase::ErasedData<[u8; 0usize]>>, false>
  38:     0x7f6d07259775 - rustc_query_impl[b8e239cf1f60d90b]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  39:     0x7f6d0722eb94 - rustc_interface[14d7cdb3160378a8]::interface::run_compiler::<(), rustc_driver_impl[bb12b93e7ed3d66e]::run_compiler::{closure#0}>::{closure#1}
  40:     0x7f6d0721983e - std[621601a63b8164bd]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[14d7cdb3160378a8]::util::run_in_thread_with_globals<rustc_interface[14d7cdb3160378a8]::util::run_in_thread_pool_with_globals<rustc_interface[14d7cdb3160378a8]::interface::run_compiler<(), rustc_driver_impl[bb12b93e7ed3d66e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  41:     0x7f6d0721a0e0 - <std[621601a63b8164bd]::thread::lifecycle::spawn_unchecked<rustc_interface[14d7cdb3160378a8]::util::run_in_thread_with_globals<rustc_interface[14d7cdb3160378a8]::util::run_in_thread_pool_with_globals<rustc_interface[14d7cdb3160378a8]::interface::run_compiler<(), rustc_driver_impl[bb12b93e7ed3d66e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[808b3c8ca0839621]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7f6d0721af6c - <std[621601a63b8164bd]::sys::thread::unix::Thread>::new::thread_start
  43:     0x7f6d00c5e97a - <unknown>
  44:     0x7f6d00ce22bc - <unknown>
  45:                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: rustc 1.96.0-nightly (e52f547ed 2026-03-21) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [specialization_graph_of] building specialization graph of trait `Overlap`
#1 [coherent_trait] coherence checking all impls of trait `Overlap`
#2 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.QQairma7a6ld/rustc_testrunner_tmpdir_reporting.UqQeULen7N88/mvce.rs:7:1: 7:36>` is well-formed
#3 [check_type_wf] checking that types are well-formed
#4 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors

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

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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions