rust-lang/rust · critical
`BikeshedGuaranteedNoDrop` does not have an associated type:
Error message
`BikeshedGuaranteedNoDrop` does not have an associated type: {:?} What it means
`BikeshedGuaranteedNoDrop` is an internal rustc lang-item trait (used for layout/niche-drop analysis) that deliberately declares no associated types. This `unreachable!` in `consider_builtin_bikeshed_guaranteed_no_drop_candidate` (normalizes_to.rs:1054) fires only when the NormalizesTo/projection machinery routes a goal of the shape `<T as BikeshedGuaranteedNoDrop>::SomeType` into this builtin candidate. Because the trait has no associated types, such a projection goal is malformed and the solver should never have assembled it — reaching this line is a compiler bug.
Source
Thrown at compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs:1054
fn consider_builtin_destruct_candidate(
_ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
panic!("`Destruct` does not have an associated type: {:?}", goal);
}
fn consider_builtin_transmute_candidate(
_ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
panic!("`TransmuteFrom` does not have an associated type: {:?}", goal)
}
fn consider_builtin_bikeshed_guaranteed_no_drop_candidate(
_ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
unreachable!("`BikeshedGuaranteedNoDrop` does not have an associated type: {:?}", goal)
}
fn consider_builtin_field_candidate(
ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
let self_ty = goal.predicate.self_ty();
let ty::Adt(def, args) = self_ty.kind() else {
return Err(NoSolution.into());
};
let Some(FieldInfo { base, ty, .. }) = def.field_representing_type_info(ecx.cx(), args)
else {
return Err(NoSolution.into());
};
let def_id = goal.predicate.alias.expect_projection_ty_def_id();
let ty = match ecx.cx().as_projection_lang_item(def_id) {
Some(SolverProjectionLangItem::FieldBase) => base,
Some(SolverProjectionLangItem::FieldType) => ty,View on GitHub (pinned to 22057b88b0)
Solutions
- Search https://github.com/rust-lang/rust/issues for the panic string `BikeshedGuaranteedNoDrop does not have an associated type`; if none, file an ICE with the full backtrace and a minimal repro.
- Remove `-Znext-solver` / `-Znext-solver=coherence` from your build (e.g. `.cargo/config.toml` or RUSTFLAGS) to fall back to the stable old solver.
- `rustup update nightly` to pick up a fix if one has landed.
- `cargo bisect-rustc` on the reproducer to identify the regression window and attach it to the issue.
Example fix
// before (.cargo/config.toml) [build] rustflags = ["-Znext-solver=coherence"] // after [build] rustflags = []
Defensive patterns
Strategy: type-guard
Validate before calling
// Guard: never project an associated type off BikeshedGuaranteedNoDrop.
// The auto-trait BikeshedGuaranteedNoDrop has NO associated types,
// so any `<T as BikeshedGuaranteedNoDrop>::Foo` projection is always invalid.
// Validate trait definitions before using them in projections.
fn trait_has_assoc_type<T, A>() -> bool { false } // placeholder: use compile-time checks instead
macro_rules! assert_no_assoc_type {
($trait_:ty) => {
const _: () = { /* will fail to compile if you try to project */ };
};
} Type guard
// Compile-time guard: only use BikeshedGuaranteedNoDrop as a *bound*, never as a
// projection source.
// GOOD: fn f<T: BikeshedGuaranteedNoDrop>()
// BAD: <T as BikeshedGuaranteedNoDrop>::SomeAssocType
macro_rules! no_bikeshed_projection {
() => {
compile_error!("Do not project associated types from BikeshedGuaranteedNoDrop; it has none.");
};
} Prevention
- Never write associated-type projections (e.g. `<T as BikeshedGuaranteedNoDrop>::X`) from the BikeshedGuaranteedNoDrop auto-trait — it has no associated types.
- Use BikeshedGuaranteedNoDrop only as a where-clause bound, not as a source of type normalisation.
- If you see this as an ICE, file a rustc bug; as a user the only mitigation is removing the offending projection.
When it happens
Trigger: Compiling code under `-Znext-solver` (or `-Znext-solver=coherence`) where the solver constructs and dispatches a `NormalizesTo` goal whose trait_ref is the `BikeshedGuaranteedNoDrop` lang item. The candidate is wired into the structural-trait assembly, so any projection goal on that trait reaches it.
Common situations: Nightly-only; hits users opting into the next solver, especially with crates exercising drop/layout analysis (memoffset-like, custom niche code) or after a `rustup update` that regressed projection assembly for builtin marker traits.
Related errors
- unexpected self ty `{:?}` when normalizing `<T as Pointee>::
- unexpected self ty `{:?}` when normalizing `<T as Discrimina
- unexpected type `{ty:?}`
- we never retry stalled queries if the parent was erased
- this never happens at the root, we're never in erased mode h
AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03).
Data as JSON: /data/errors/6a12d846939217a0.json.
Report an issue: GitHub.