rust-lang/rust · critical
`Copy`/`Clone` does not have an associated type: {:?}
Error message
`Copy`/`Clone` does not have an associated type: {:?} What it means
A `panic!` in `consider_builtin_copy_clone_candidate`. The built-in `Copy` and `Clone` traits have no associated types; a `NormalizesTo` goal against them should never reach the copy/clone candidate. Like 307, this is a solver dispatch invariant — the candidate assembly must skip projection goals for marker traits.
Source
Thrown at compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs:508
_ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
panic!("trait aliases do not have associated types: {:?}", goal);
}
fn consider_builtin_sizedness_candidates(
_ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
_sizedness: SizedTraitKind,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
panic!("`Sized`/`MetaSized` does not have an associated type: {:?}", goal);
}
fn consider_builtin_copy_clone_candidate(
_ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
panic!("`Copy`/`Clone` does not have an associated type: {:?}", goal);
}
fn consider_builtin_fn_ptr_trait_candidate(
_ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
panic!("`FnPtr` does not have an associated type: {:?}", goal);
}
fn consider_builtin_fn_trait_candidates(
ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
goal_kind: ty::ClosureKind,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
let cx = ecx.cx();
let Some(tupled_inputs_and_output) =
structural_traits::extract_tupled_inputs_and_output_from_callable(
cx,View on GitHub (pinned to 22057b88b0)
Solutions
- Ensure no code path builds a projection whose trait is `Copy`/`Clone`.
- If reached during normal compilation, reduce and file as a rustc ICE.
- Work around by disabling `-Znext-solver`.
Example fix
// before — projecting on Copy (invalid)
fn f<T: Copy>() -> <T as Copy>::Out { todo!() }
// after — Copy has no associated type
fn f<T: Copy>() { todo!() }
Defensive patterns
Strategy: validation
Validate before calling
// Copy / Clone also have no associated types.
fn is_copy_clone(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {
let copy = tcx.lang_items().copy_trait();
let clone = tcx.lang_items().clone_trait();
copy == Some(trait_def_id) || clone == Some(trait_def_id)
}
if is_copy_clone(tcx, did) {
return Err("Copy/Clone has no associated type");
} Type guard
fn projection_target_is_not_copy_clone(tcx: TyCtxt<'_>, did: DefId) -> bool {
!is_copy_clone(tcx, did)
} Try / catch
use std::panic;
match panic::catch_unwind(panic::AssertUnwindSafe(|| solver.normalizes_to(goal))) {
Ok(v) => v,
Err(_) => Err("do not project an associated type off Copy or Clone"),
} Prevention
- Never write `<T as Copy>::Item` or `<T as Clone>::Item`; these traits carry none.
- Project only through traits that declare the associated type you want.
- Add a build-time check that rejects Copy/Clone in projection positions.
- Remember marker/auto traits generally expose no associated items.
When it happens
Trigger: A `NormalizesTo` goal whose trait is `Copy` or `Clone` is dispatched into the built-in copy/clone candidate assembly under the new solver.
Common situations: Code that synthesizes trait refs with `Copy`/`Clone` as the projection trait (e.g. proc-macro or compiler-internal IR); nightly regressions in candidate filtering.
Related errors
- `Sized`/`MetaSized` does not have an associated type: {:?}
- `FnPtr` does not have an associated type: {:?}
- reservation impl for trait with assoc item: {:?}
- trait aliases do not have associated types: {:?}
- `ConstKind::Param` should have been canonicalized to `Placeh
AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03).
Data as JSON: /data/errors/36b625c8e302ecc5.json.
Report an issue: GitHub.