[ICE]: could not replace AliasTerm
Open
@ShoyuVanilla is already working on this.
Since Apr 25, 2026.
C-bug
I-ICE
T-compiler
WG-trait-system-refactor
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
Code
//@compile-flags: -Znext-solver
trait Foo {
type V;
}
trait Callback<T: Foo + ?Sized>: Fn(&T::V) {}
fn try_object<T: Foo>() {
<dyn Callback<dyn Callback<T>>>::call(());
}
Meta
rustc --version --verbose:
rustc-nightly 2026-04-21
Error output
error[E0277]: the trait bound `dyn Callback<T>: Foo` is not satisfied
--> <source>:8:6
|
8 | <dyn Callback<dyn Callback<T>>>::call(());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `dyn Callback<T>`
|
help: this trait has no implementations, consider adding one
--> <source>:1:1
|
1 | trait Foo {
| ^^^^^^^^^
Backtrace
thread 'rustc' (3) panicked at /rustc-dev/9ec5d5f32e19d250c7fbeaa90978c79105b39dee/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs:997:13:
could not replace AliasTerm { args: [dyn [Binder { value: Trait(Callback<dyn Callback<!0, Output = ()>>), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: DefId(2:4395 ~ core[a650]::ops::function::FnOnce::Output), args: [(&'^0.Named(DefId(0:10 ~ example[0de3]::Callback::'_)) ?1t,)], term: Term::Ty(()), .. }), bound_vars: [Region(BrNamed(DefId(0:10 ~ example[0de3]::Callback::'_)))] }] + '?1, (&'?4 Alias(AliasTy { args: [dyn [Binder { value: Trait(Callback<!0>), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: DefId(2:4395 ~ core[a650]::ops::function::FnOnce::Output), args: [(&'^0.Named(DefId(0:10 ~ example[0de3]::Callback::'_)) ?0t,)], term: Term::Ty(()), .. }), bound_vars: [Region(BrNamed(DefId(0:10 ~ example[0de3]::Callback::'_)))] }] + '?0], kind: Projection { def_id: DefId(0:4 ~ example[0de3]::Foo::V) }, .. }),)], def_id: DefId(2:4395 ~ core[a650]::ops::function::FnOnce::Output), .. } with term from from dyn [Binder { value: Trait(Callback<dyn Callback<!0, Output = ()>>), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: DefId(2:4395 ~ core[a650]::ops::function::FnOnce::Output), args: [(&'^0.Named(DefId(0:10 ~ example[0de3]::Callback::'_)) ?1t,)], term: Term::Ty(()), .. }), bound_vars: [Region(BrNamed(DefId(0:10 ~ example[0de3]::Callback::'_)))] }] + '?1
stack backtrace:
0: 0x763cd6a3039b - <<std[5b7e30f7807aa615]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[a650ce4d277d25c6]::fmt::Display>::fmt
1: 0x763cd704d8c8 - core[a650ce4d277d25c6]::fmt::write
2: 0x763cd6a47346 - <std[5b7e30f7807aa615]::sys::stdio::unix::Stderr as std[5b7e30f7807aa615]::io::Write>::write_fmt
3: 0x763cd6a06618 - std[5b7e30f7807aa615]::panicking::default_hook::{closure#0}
4: 0x763cd6a23a03 - std[5b7e30f7807aa615]::panicking::default_hook
5: 0x763cd59e74ec - std[5b7e30f7807aa615]::panicking::update_hook::<alloc[2f19c8fd823c5f05]::boxed::Box<rustc_driver_impl[ca0a413bf4c58e0a]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x763cd6a23ce2 - std[5b7e30f7807aa615]::panicking::panic_with_hook
7: 0x763cd6a066d8 - std[5b7e30f7807aa615]::panicking::panic_handler::{closure#0}
8: 0x763cd69fd419 - std[5b7e30f7807aa615]::sys::backtrace::__rust_end_short_backtrace::<std[5b7e30f7807aa615]::panicking::panic_handler::{closure#0}, !>
9: 0x763cd6a0813d - __rustc[7cfefe7501ea3438]::rust_begin_unwind
10: 0x763cd365932c - core[a650ce4d277d25c6]::panicking::panic_fmt
11: 0x763cd7c824c6 - <rustc_next_trait_solver[b0c3b3a1db1e2b47]::solve::assembly::structural_traits::ReplaceProjectionWith<rustc_middle[39029d37c6b18166]::ty::context::TyCtxt, rustc_trait_selection[18f802a42dd088d6]::solve::delegate::SolverDelegate> as rustc_type_ir[edbc09207784f1ad]::fold::FallibleTypeFolder<rustc_middle[39029d37c6b18166]::ty::context::TyCtxt>>::try_fold_ty
12: 0x763cd7c817dd - <&rustc_middle[39029d37c6b18166]::ty::list::RawList<(), rustc_middle[39029d37c6b18166]::ty::generic_args::GenericArg> as rustc_type_ir[edbc09207784f1ad]::fold::TypeFoldable<rustc_middle[39029d37c6b18166]::ty::context::TyCtxt>>::try_fold_with::<rustc_next_trait_solver[b0c3b3a1db1e2b47]::solve::assembly::structural_traits::ReplaceProjectionWith<rustc_middle[39029d37c6b18166]::ty::context::TyCtxt, rustc_trait_selection[18f802a42dd088d6]::solve::delegate::SolverDelegate>>
13: 0x763cd7ff80ab - rustc_next_trait_solver[b0c3b3a1db1e2b47]::solve::assembly::structural_traits::predicates_for_object_candidate::<rustc_trait_selection[18f802a42dd088d6]::solve::delegate::SolverDelegate, rustc_middle[39029d37c6b18166]::ty::context::TyCtxt>
14: 0x763cd7d8de2d - <rustc_type_ir[edbc09207784f1ad]::predicate::TraitPredicate<rustc_middle[39029d37c6b18166]::ty::context::TyCtxt> as rustc_next_trait_solver[b0c3b3a1db1e2b47]::solve::assembly::GoalKind<rustc_trait_selection[18f802a42dd088d6]::solve::delegate::SolverDelegate, rustc_middle[39029d37c6b18166]::ty::context::TyCtxt>>::match_assumption::<<rustc_type_ir[edbc09207784f1ad]::predicate::TraitPredicate<rustc_middle[39029d37c6b18166]::ty::context::TyCtxt> as rustc_next_trait_solver[b0c3b3a1db1e2b47]::solve::assembly::GoalKind<rustc_trait_selection[18f802a42dd088d6]::solve::delegate::SolverDelegate, rustc_middle[39029d37c6b18166]::ty::context::TyCtxt>>::probe_and_consider_object_bound_candidate::{closure#0}>
15: 0x763cd7d951d1 - <rustc_type_ir[edbc09207784f1ad]::predicate::TraitPredicate<rustc_middle[39029d37c6b18166]::ty::context::TyCtxt> as rustc_next_trait_solver[b0c3b3a1db1e2b47]::solve::assembly::GoalKind<rustc_trait_selection[18f802a42dd088d6]::solve::delegate::SolverDelegate, rustc_middle[39029d37c6b18166]::ty::context::TyCtxt>>::probe_and_consider_object_bound_candidate
16: 0x763cd7d98957 - <rustc_next_trait_solver[b0c3b3a1db1e2b47]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[18f802a42dd088d6]::solve::delegate::SolverDelegate, rustc_middle[39029d37c6b18166]::ty::context::TyCtxt>>::compute_trait_goal
17: 0x763cd7d90b73 - <rustc_next_trait_solver[b0c3b3a1db1e2b47]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[18f802a42dd088d6]::solve::delegate::SolverDelegate> as rustc_type_ir[edbc09207784f1ad]::search_graph::Delegate>::compute_goal::{closure#0}
18: 0x763cd7d8f2d7 - <rustc_type_ir[edbc09207784f1ad]::search_graph::SearchGraph<rustc_next_trait_solver[b0c3b3a1db1e2b47]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[18f802a42dd088d6]::solve::delegate::SolverDelegate>, rustc_middle[39029d37c6b18166]::ty::context::TyCtxt>>::evaluate_goal_in_task
19: 0x763cd7d8bcd1 - rustc_trait_selection[18f802a42dd088d6]::solve::evaluate_root_goal_for_proof_tree_raw
20: 0x763cd7d8bb18 - rustc_query_impl[8ab6e76c7884f2c3]::query_impl::evaluate_root_goal_for_proof_tree_raw::invoke_provider_fn::__rust_begin_short_backtrace
21: 0x763cd7d76fc5 - rustc_query_impl[8ab6e76c7884f2c3]::execution::try_execute_query::<rustc_middle[39029d37c6b18166]::query::caches::DefaultCache<rustc_type_ir[edbc09207784f1ad]::canonical::CanonicalQueryInput<rustc_middle[39029d37c6b18166]::ty::context::TyCtxt, rustc_type_ir[edbc09207784f1ad]::solve::QueryInput<rustc_middle[39029d37c6b18166]::ty::context::TyCtxt, rustc_middle[39029d37c6b18166]::ty::predicate::Predicate>>, rustc_middle[39029d37c6b18166]::query::erase::ErasedData<[u8; 48usize]>>, false>
22: 0x763cd7d76c01 - rustc_query_impl[8ab6e76c7884f2c3]::query_impl::evaluate_root_goal_for_proof_tree_raw::execute_query_non_incr::__rust_end_short_backtrace
23: 0x763cd7d7dd2e - <rustc_middle[39029d37c6b18166]::ty::context::TyCtxt as rustc_type_ir[edbc09207784f1ad]::interner::Interner>::evaluate_root_goal_for_proof_tree_raw
24: 0x763cd7d7cee8 - <rustc_trait_selection[18f802a42dd088d6]::solve::delegate::SolverDelegate as rustc_next_trait_solver[b0c3b3a1db1e2b47]::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal_for_proof_tree
25: 0x763cd7d7c292 - <rustc_trait_selection[18f802a42dd088d6]::solve::inspect::analyse::InspectCandidate>::instantiate_proof_tree_for_nested_goal
26: 0x763cd7d7bd97 - <rustc_trait_selection[18f802a42dd088d6]::solve::inspect::analyse::InspectCandidate>::instantiate_nested_goals
27: 0x763cd7d7269c - <rustc_trait_selection[18f802a42dd088d6]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[18f802a42dd088d6]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
28: 0x763cd7d72330 - <rustc_infer[1e563b890ff86346]::infer::InferCtxt as rustc_trait_selection[18f802a42dd088d6]::solve::inspect::analyse::InferCtxtProofTreeExt>::visit_proof_tree_at_depth::<rustc_trait_selection[18f802a42dd088d6]::solve::fulfill::derive_errors::BestObligation>
29: 0x763cd7ff5651 - rustc_trait_selection[18f802a42dd088d6]::solve::fulfill::derive_errors::find_best_leaf_obligation
30: 0x763cd7ff4cb8 - <rustc_trait_selection[18f802a42dd088d6]::traits::FulfillmentError as rustc_infer[1e563b890ff86346]::traits::engine::FromSolverError<rustc_trait_selection[18f802a42dd088d6]::solve::fulfill::NextSolverError>>::from_solver_error
31: 0x763cd7c6d91a - <rustc_trait_selection[18f802a42dd088d6]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[18f802a42dd088d6]::traits::FulfillmentError> as rustc_infer[1e563b890ff86346]::traits::engine::TraitEngine<rustc_trait_selection[18f802a42dd088d6]::traits::FulfillmentError>>::try_evaluate_obligations
32: 0x763cd74c938b - <core[a650ce4d277d25c6]::iter::adapters::map::Map<core[a650ce4d277d25c6]::iter::adapters::filter::Filter<core[a650ce4d277d25c6]::slice::iter::Iter<rustc_hir_typeck[64a322df4177e7a0]::method::probe::Candidate>, <rustc_hir_typeck[64a322df4177e7a0]::method::probe::ProbeContext>::consider_candidates::{closure#0}>, <rustc_hir_typeck[64a322df4177e7a0]::method::probe::ProbeContext>::consider_candidates::{closure#1}> as core[a650ce4d277d25c6]::iter::traits::iterator::Iterator>::try_fold::<(), core[a650ce4d277d25c6]::iter::traits::iterator::Iterator::find::check<(&rustc_hir_typeck[64a322df4177e7a0]::method::probe::Candidate, rustc_hir_typeck[64a322df4177e7a0]::method::probe::ProbeResult), &mut <rustc_hir_typeck[64a322df4177e7a0]::method::probe::ProbeContext>::consider_candidates::{closure#2}>::{closure#0}, core[a650ce4d277d25c6]::ops::control_flow::ControlFlow<(&rustc_hir_typeck[64a322df4177e7a0]::method::probe::Candidate, rustc_hir_typeck[64a322df4177e7a0]::method::probe::ProbeResult)>>
33: 0x763cd74bf211 - <rustc_hir_typeck[64a322df4177e7a0]::method::probe::ProbeContext>::pick_all_method
34: 0x763cd76362eb - <rustc_hir_typeck[64a322df4177e7a0]::fn_ctxt::FnCtxt>::probe_for_name
35: 0x763cd7339e28 - <rustc_hir_typeck[64a322df4177e7a0]::fn_ctxt::FnCtxt>::resolve_ty_and_res_fully_qualified_call
36: 0x763cd7394086 - <rustc_hir_typeck[64a322df4177e7a0]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
37: 0x763cd736da31 - <rustc_hir_typeck[64a322df4177e7a0]::fn_ctxt::FnCtxt>::check_expr_call
38: 0x763cd7394d09 - <rustc_hir_typeck[64a322df4177e7a0]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
39: 0x763cd73a990b - <rustc_hir_typeck[64a322df4177e7a0]::fn_ctxt::FnCtxt>::check_expr_block
40: 0x763cd7395752 - <rustc_hir_typeck[64a322df4177e7a0]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
41: 0x763cd73a0e8e - rustc_hir_typeck[64a322df4177e7a0]::check::check_fn
42: 0x763cd7a04a9c - rustc_hir_typeck[64a322df4177e7a0]::typeck_with_inspect::{closure#0}
43: 0x763cd7a01944 - rustc_query_impl[8ab6e76c7884f2c3]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
44: 0x763cd7145be6 - rustc_query_impl[8ab6e76c7884f2c3]::execution::try_execute_query::<rustc_data_structures[f6fa982204ebe71d]::vec_cache::VecCache<rustc_span[b665a13c49a7c32c]::def_id::LocalDefId, rustc_middle[39029d37c6b18166]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[39029d37c6b18166]::dep_graph::graph::DepNodeIndex>, false>
45: 0x763cd71454c3 - rustc_query_impl[8ab6e76c7884f2c3]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
46: 0x763cd771b194 - <rustc_middle[39029d37c6b18166]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[d6f3c783d834b8ee]::check_crate::{closure#1}>::{closure#0}
47: 0x763cd771ab69 - rustc_hir_analysis[d6f3c783d834b8ee]::check_crate
48: 0x763cd7ebbc27 - rustc_interface[151f824d9b9b2f92]::passes::analysis
49: 0x763cd81653c9 - rustc_query_impl[8ab6e76c7884f2c3]::execution::try_execute_query::<rustc_middle[39029d37c6b18166]::query::caches::SingleCache<rustc_middle[39029d37c6b18166]::query::erase::ErasedData<[u8; 0usize]>>, false>
50: 0x763cd8165029 - rustc_query_impl[8ab6e76c7884f2c3]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
51: 0x763cd813dfad - rustc_interface[151f824d9b9b2f92]::interface::run_compiler::<(), rustc_driver_impl[ca0a413bf4c58e0a]::run_compiler::{closure#0}>::{closure#1}
52: 0x763cd817ad84 - std[5b7e30f7807aa615]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[151f824d9b9b2f92]::util::run_in_thread_with_globals<rustc_interface[151f824d9b9b2f92]::util::run_in_thread_pool_with_globals<rustc_interface[151f824d9b9b2f92]::interface::run_compiler<(), rustc_driver_impl[ca0a413bf4c58e0a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
53: 0x763cd817b46d - <std[5b7e30f7807aa615]::thread::lifecycle::spawn_unchecked<rustc_interface[151f824d9b9b2f92]::util::run_in_thread_with_globals<rustc_interface[151f824d9b9b2f92]::util::run_in_thread_pool_with_globals<rustc_interface[151f824d9b9b2f92]::interface::run_compiler<(), rustc_driver_impl[ca0a413bf4c58e0a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a650ce4d277d25c6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
54: 0x763cd817c2ec - <std[5b7e30f7807aa615]::sys::thread::unix::Thread>::new::thread_start
55: 0x763cd1a94ac3 - <unknown>
56: 0x763cd1b268d0 - <unknown>
57: 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 `/app/rustc-ice-2026-04-25T02_48_06-1.txt` to your bug report
note: rustc 1.97.0-nightly (9ec5d5f32 2026-04-21) running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C llvm-args=--x86-asm-syntax=intel --crate-type rlib -Z next-solver
query stack during panic:
#0 [evaluate_root_goal_for_proof_tree_raw] computing proof tree for `dyn Callback<dyn Callback<^c_0, Output = ()>, Output = ()>: core::ops::function::FnOnce<(&^c_6,)>`
#1 [typeck_root] type-checking `try_object`
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: aborting due to 1 previous error
#152859 doesn't seem to fix this variant. cc @ShoyuVanilla
I feel like the assumption that projection with object self_ty always has the corresponding existential projection predicate is brittle. Any ill-formed projection can break that.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.