{"id":"22ec8cf391b00473","repo":"rust-lang/rust","slug":"sized-metasized-does-not-have-an-associated-ty","errorCode":null,"errorMessage":"`Sized`/`MetaSized` does not have an associated type: {:?}","messagePattern":"`Sized`/`MetaSized` 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":501,"sourceCode":"        _goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        ecx.cx().delay_bug(\"associated types not allowed on auto traits\");\n        Err(NoSolution.into())\n    }\n\n    fn consider_trait_alias_candidate(\n        _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>,","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs#L483-L519","documentation":"A `panic!` in `consider_builtin_sizedness_candidates`. The built-in `Sized` and `MetaSized` traits have no associated types, so a `NormalizesTo` goal against them is meaningless; reaching this candidate means dispatch sent an associated-type projection goal to the sizedness candidate assembly. It is a solver dispatch invariant, not user-facing.","triggerScenarios":"A `NormalizesTo` goal whose trait is `Sized`/`MetaSized` is assembled by the candidate logic that handles built-in sizedness. Reproducible by naming an associated item on `Sized` under the new solver (which is not allowed by the language).","commonSituations":"Macro-generated code or IR construction that synthesizes `<T as Sized>::Foo`; nightly refactors of the sizedness candidate dispatch.","solutions":["Audit code that builds trait refs to ensure `Sized`/`MetaSized` are never the trait of a projection.","Report as a rustc ICE with a minimal repro under `-Znext-solver`.","Run on the stable solver as a workaround."],"exampleFix":"// before — projecting on the Sized trait (invalid)\nfn f<T: Sized>() -> <T as Sized>::Item { todo!() }\n// after — Sized has no associated type; remove the projection\nfn f<T: Sized>() { todo!() }\n","handlingStrategy":"validation","validationCode":"// Sized / MetaSized are marker traits with no associated types. Block\n// any projection that names them.\nfn is_sized_family(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {\n    let sized  = tcx.require_lang_item(LangItem::Sized, None);\n    let meta   = tcx.lang_items().meta_sized();\n    trait_def_id == sized || meta == Some(trait_def_id)\n}\nif is_sized_family(tcx, did) {\n    return Err(\"Sized/MetaSized has no associated type\");\n}","typeGuard":"fn projection_target_is_not_sized(tcx: TyCtxt<'_>, did: DefId) -> bool {\n    !is_sized_family(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 Sized / MetaSized\"),\n}","preventionTips":["Treat `Sized` and `MetaSized` as markers; never write `T::Assoc` against them.","Use `?Sized` boundaries instead of projecting.","Lint in your own code for `as Sized>::` patterns.","Keep a list of marker traits without associated items and reject projections through them."],"tags":["rustc","trait-solver","sized","builtin-traits","associated-types","compiler-internal","ice"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}