rust-lang/rust · critical

`TransmuteFrom` does not have an associated type: {:?}

Error message

`TransmuteFrom` does not have an associated type: {:?}

What it means

consider_builtin_transmute_candidate (normalizes_to.rs:1047) panics unconditionally. The TransmuteFrom trait (core::mem::TransmuteFrom, the safe-transmute foundation) has no associated types — it answers a yes/no trait question. Trait goals are handled in trait_goals.rs; if a NormalizesTo (projection) goal for TransmuteFrom reaches this stub, the solver has constructed an impossible projection against an associated-type-less trait.

Source

Thrown at compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs:1047

        ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| {
            ecx.instantiate_normalizes_to_term(goal, discriminant_ty.into())?;
            ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
        })
    }

    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)

View on GitHub (pinned to 22057b88b0)

Solutions

  1. Update to the latest nightly (rustup update nightly).
  2. Disable -Znext-solver (remove the flag or -Znext-solver=no) to use the legacy solver.
  3. File an ICE at https://github.com/rust-lang/rust/issues with the goal printed in the panic and a minimal reproducer.
  4. Bisect nightlies to locate the introducing commit and include it in the report.
Defensive patterns

Strategy: type-guard

Validate before calling

// `TransmuteFrom` (nightly) is a bool-like trait with NO associated types.
// Use it only as a bound: `T: TransmuteFrom<U, const ASSUME: bool>`.
fn safe_transmute<S, D>() where D: core::mem::TransmuteFrom<S, false> {} // OK

Type guard

trait _GuardTransmute<S, D: core::mem::TransmuteFrom<S, false>> {} // bound-only sentinel

Prevention

When it happens

Trigger: A NormalizesTo goal whose trait_ref is the TransmuteTrait lang item reaches the next-solver builtin-candidate assembly. Because TransmuteFrom has no associated items, no valid surface code can produce such a projection; it indicates a goal-kind misclassification or malformed projection inside the solver.

Common situations: Experimenting with the `safe_transmute` / TransmuteFrom nightly feature under -Znext-solver on a regressed toolchain; fuzzing; not triggered by normal transmute/mem::transmute usage.

Related errors


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