{"id":"7f31909bce03d83c","repo":"rust-lang/rust","slug":"unsize-does-not-have-an-associated-type","errorCode":null,"errorMessage":"`Unsize` does not have an associated type: {:?}","messagePattern":"`Unsize` 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":973,"sourceCode":"                projection_term: ty::AliasTerm::new(\n                    ecx.cx(),\n                    goal.predicate.alias.kind,\n                    [self_ty, coroutine.resume_ty()],\n                ),\n                term,\n            }\n            .upcast(cx),\n            // Technically, we need to check that the coroutine type is Sized,\n            // but that's already proven by the coroutine being WF.\n            [],\n        )\n    }\n\n    fn consider_structural_builtin_unsize_candidates(\n        _ecx: &mut EvalCtxt<'_, D>,\n        goal: Goal<I, Self>,\n    ) -> Result<Vec<Candidate<I>>, RerunNonErased> {\n        panic!(\"`Unsize` does not have an associated type: {:?}\", goal);\n    }\n\n    fn consider_builtin_discriminant_kind_candidate(\n        ecx: &mut EvalCtxt<'_, D>,\n        goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        let self_ty = goal.predicate.self_ty();\n        let discriminant_ty = match self_ty.kind() {\n            ty::Bool\n            | ty::Char\n            | ty::Int(..)\n            | ty::Uint(..)\n            | ty::Float(..)\n            | ty::Array(..)\n            | ty::Pat(..)\n            | ty::RawPtr(..)\n            | ty::Ref(..)\n            | ty::FnDef(..)","sourceCodeStart":955,"sourceCodeEnd":991,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs#L955-L991","documentation":"consider_structural_builtin_unsize_candidates (normalizes_to.rs:973) panics unconditionally. The Unsize trait (used for unsized coercions like `&[T; N] -> &[T]` and `T -> dyn Trait`) has no associated types; it is only meaningful as a trait goal (the real impl lives in trait_goals.rs). assembly/mod.rs:690 additionally calls this for Unsize, so a projection goal against Unsize is a goal-construction invariant violation.","triggerScenarios":"A NormalizesTo goal whose trait_ref is the Unsize lang item is assembled by the next solver. Valid Rust cannot project an associated type off Unsize, so this indicates the solver mis-routed a goal or built an ill-formed projection.","commonSituations":"Nightly rustc regression in the next solver during unsizing/coercion handling; fuzzing; not produced by ordinary `as dyn Trait` or slice-coercion code.","solutions":["Update to the latest nightly (rustup update nightly).","Disable -Znext-solver (remove the flag or -Znext-solver=no).","File an ICE at https://github.com/rust-lang/rust/issues including the goal from the panic and a minimal reproducer.","Bisect nightlies to identify the introducing commit."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// `Unsize` is a lang trait with NO associated types; it only governs\n// coercions (`&[T; N]` -> `&[T]`, `&Concrete` -> `&dyn Trait`).\n// Never write `<T as Unsize<U>>::Foo`.\nfn unsize_coerce<'a, T: Unsize<U>, U>(x: &'a T) -> &'a U { x } // OK as bound\n","typeGuard":"trait _GuardUnsize<T: ?Sized, U: ?Sized> where T: Unsize<U> {} // bound-only sentinel\n","tryCatchPattern":null,"preventionTips":["Use `Unsize` purely as a coercion bound, not an associated-type source.","Prefer `CoerceUnsized` or explicit `.into()`/`as` over manual Unsize reasoning.","Lint against `as Unsize` followed by `>::`."],"tags":["rust","rustc","trait-solver","next-solver","ice","panic","builtin-impl","unsize","associated-type"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}