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

  1. 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.
  2. Remove `-Znext-solver` / `-Znext-solver=coherence` from your build (e.g. `.cargo/config.toml` or RUSTFLAGS) to fall back to the stable old solver.
  3. `rustup update nightly` to pick up a fix if one has landed.
  4. `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

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


AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03). Data as JSON: /data/errors/6a12d846939217a0.json. Report an issue: GitHub.