{"id":"36b625c8e302ecc5","repo":"rust-lang/rust","slug":"copy-clone-does-not-have-an-associated-type","errorCode":null,"errorMessage":"`Copy`/`Clone` does not have an associated type: {:?}","messagePattern":"`Copy`/`Clone` does not have an associated type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs","lineNumber":508,"sourceCode":"        _ecx: &mut EvalCtxt<'_, D>,\n        goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        panic!(\"trait aliases do not have associated types: {:?}\", goal);\n    }\n\n    fn consider_builtin_sizedness_candidates(\n        _ecx: &mut EvalCtxt<'_, D>,\n        goal: Goal<I, Self>,\n        _sizedness: SizedTraitKind,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        panic!(\"`Sized`/`MetaSized` does not have an associated type: {:?}\", goal);\n    }\n\n    fn consider_builtin_copy_clone_candidate(\n        _ecx: &mut EvalCtxt<'_, D>,\n        goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        panic!(\"`Copy`/`Clone` does not have an associated type: {:?}\", goal);\n    }\n\n    fn consider_builtin_fn_ptr_trait_candidate(\n        _ecx: &mut EvalCtxt<'_, D>,\n        goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        panic!(\"`FnPtr` does not have an associated type: {:?}\", goal);\n    }\n\n    fn consider_builtin_fn_trait_candidates(\n        ecx: &mut EvalCtxt<'_, D>,\n        goal: Goal<I, Self>,\n        goal_kind: ty::ClosureKind,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        let cx = ecx.cx();\n        let Some(tupled_inputs_and_output) =\n            structural_traits::extract_tupled_inputs_and_output_from_callable(\n                cx,","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs#L490-L526","documentation":"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.","triggerScenarios":"A `NormalizesTo` goal whose trait is `Copy` or `Clone` is dispatched into the built-in copy/clone candidate assembly under the new solver.","commonSituations":"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.","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`."],"exampleFix":"// before — projecting on Copy (invalid)\nfn f<T: Copy>() -> <T as Copy>::Out { todo!() }\n// after — Copy has no associated type\nfn f<T: Copy>() { todo!() }\n","handlingStrategy":"validation","validationCode":"// Copy / Clone also have no associated types.\nfn is_copy_clone(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {\n    let copy  = tcx.lang_items().copy_trait();\n    let clone = tcx.lang_items().clone_trait();\n    copy == Some(trait_def_id) || clone == Some(trait_def_id)\n}\nif is_copy_clone(tcx, did) {\n    return Err(\"Copy/Clone has no associated type\");\n}","typeGuard":"fn projection_target_is_not_copy_clone(tcx: TyCtxt<'_>, did: DefId) -> bool {\n    !is_copy_clone(tcx, did)\n}","tryCatchPattern":"use std::panic;\nmatch panic::catch_unwind(panic::AssertUnwindSafe(|| solver.normalizes_to(goal))) {\n    Ok(v) => v,\n    Err(_) => Err(\"do not project an associated type off Copy or Clone\"),\n}","preventionTips":["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."],"tags":["rustc","trait-solver","copy-clone","builtin-traits","associated-types","compiler-internal","ice"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}