-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
Labels
A-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)
Description
Code
pub trait Trait<T> {
type Assoc;
}
pub trait Foo {
type FooAssoc;
}
pub struct Wrap<U: Foo>(<dyn Trait<i32, Assoc = i64> as Trait<U::FooAssoc>>::Assoc)
where
dyn Trait<i32, Assoc = i64>: Trait<U::FooAssoc>;
fn main() {}This code compiles with the old trait solver, but ICEs with -Znext-solver.
This was discovered while investigating #152783
Has a similar error message to #151329
cc @lcnr
Meta
rustc --version --verbose:
rustc 1.95.0-nightly (838709580 2026-02-17)
binary: rustc
commit-hash: 8387095803f21a256a9a772ac1f9b41ed4d5aa0a
commit-date: 2026-02-17
host: aarch64-apple-darwin
release: 1.95.0-nightly
LLVM version: 22.1.0
Error output
thread 'rustc' (296541) panicked at /rustc-dev/8387095803f21a256a9a772ac1f9b41ed4d5aa0a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs:966:13:
could not replace AliasTerm { args: [dyn [Binder { value: Trait(Trait<i32>), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: DefId(0:5 ~ foo[b507]::Trait::Assoc), args: [i32], term: Term::Ty(i64), use_existential_projection_new_instead: () }), bound_vars: [] }] + '?0, Alias(Projection, AliasTy { args: [!0], def_id: DefId(0:7 ~ foo[b507]::Foo::FooAssoc), .. })], def_id: DefId(0:5 ~ foo[b507]::Trait::Assoc), .. } with term from from dyn [Binder { value: Trait(Trait<i32>), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: DefId(0:5 ~ foo[b507]::Trait::Assoc), args: [i32], term: Term::Ty(i64), use_existential_projection_new_instead: () }), bound_vars: [] }] + '?0
Backtrace
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: <rustc_next_trait_solver::solve::assembly::structural_traits::ReplaceProjectionWith<rustc_middle::ty::context::TyCtxt, rustc_trait_selection::solve::delegate::SolverDelegate>>::try_eagerly_replace_alias
3: <rustc_middle::ty::generic_args::GenericArg as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with::<rustc_next_trait_solver::solve::assembly::structural_traits::ReplaceProjectionWith<rustc_middle::ty::context::TyCtxt, rustc_trait_selection::solve::delegate::SolverDelegate>>
4: <&rustc_middle::ty::list::RawList<(), rustc_middle::ty::generic_args::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with::<rustc_next_trait_solver::solve::assembly::structural_traits::ReplaceProjectionWith<rustc_middle::ty::context::TyCtxt, rustc_trait_selection::solve::delegate::SolverDelegate>>
5: rustc_next_trait_solver::solve::assembly::structural_traits::predicates_for_object_candidate::<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>
6: <rustc_type_ir::predicate::TraitPredicate<rustc_middle::ty::context::TyCtxt> as rustc_next_trait_solver::solve::assembly::GoalKind<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::match_assumption::<<rustc_type_ir::predicate::TraitPredicate<rustc_middle::ty::context::TyCtxt> as rustc_next_trait_solver::solve::assembly::GoalKind<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::probe_and_consider_object_bound_candidate::{closure#0}>
7: <rustc_type_ir::predicate::TraitPredicate<rustc_middle::ty::context::TyCtxt> as rustc_next_trait_solver::solve::assembly::GoalKind<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::probe_and_match_goal_against_assumption::<<rustc_type_ir::predicate::TraitPredicate<rustc_middle::ty::context::TyCtxt> as rustc_next_trait_solver::solve::assembly::GoalKind<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::probe_and_consider_object_bound_candidate::{closure#0}>
8: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::compute_trait_goal
9: <rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate> as rustc_type_ir::search_graph::Delegate>::compute_goal::{closure#0}
10: <rustc_type_ir::search_graph::SearchGraph<rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate>, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_in_task
11: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_raw
12: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_added_goals_step
13: <rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate> as rustc_type_ir::search_graph::Delegate>::compute_goal::{closure#0}
14: <rustc_type_ir::search_graph::SearchGraph<rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate>, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_in_task
15: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_raw
16: <rustc_trait_selection::solve::delegate::SolverDelegate as rustc_next_trait_solver::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal
17: <rustc_trait_selection::solve::fulfill::FulfillmentCtxt<rustc_trait_selection::traits::FulfillmentError> as rustc_infer::traits::engine::TraitEngine<rustc_trait_selection::traits::FulfillmentError>>::try_evaluate_obligations
18: <rustc_trait_selection::solve::normalize::NormalizationFolder<rustc_trait_selection::traits::FulfillmentError>>::normalize_alias_term
19: <rustc_trait_selection::solve::normalize::NormalizationFolder<rustc_trait_selection::traits::FulfillmentError> as rustc_type_ir::fold::FallibleTypeFolder<rustc_middle::ty::context::TyCtxt>>::try_fold_ty::{closure#0}
20: <rustc_hir_analysis::check::wfcheck::WfCheckingCtxt>::deeply_normalize::<rustc_middle::ty::Ty>
21: rustc_hir_analysis::check::wfcheck::check_type_defn
22: rustc_hir_analysis::check::check::check_item_type
23: rustc_hir_analysis::check::wfcheck::check_well_formed
[... omitted 1 frame ...]
24: rustc_hir_analysis::check::wfcheck::check_type_wf
[... omitted 1 frame ...]
25: rustc_hir_analysis::check_crate
26: rustc_interface::passes::analysis
27: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, {rustc_query_impl::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, true>
28: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
29: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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 `/Users/timch/foo/rustc-ice-2026-02-18T08_49_10-24860.txt` to your bug report
note: rustc 1.95.0-nightly (838709580 2026-02-17) running on aarch64-apple-darwin
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED] -Z next-solver
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [check_well_formed] checking that `Wrap` is well-formed
#1 [check_type_wf] checking that types are well-formed
#2 [analysis] running analysis passes on crate `foo`
end of query stack
error: could not compile `foo` (bin "foo")
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)
Type
Projects
Status
todo