rust-lang/rust · error

AsyncFnKindHelper is not const

Error message

AsyncFnKindHelper is not const

What it means

`consider_builtin_async_fn_kind_helper_candidate` (effect_goals.rs:357) is `unreachable!`. `AsyncFnKindHelper` is an internal lang item used during async-fn by-move vs by-ref analysis; it is a purely runtime/type-system helper with no meaningful const semantics. Reaching this branch means a `const AsyncFnKindHelper` goal was assembled, which is logically impossible by construction — a compiler bug in goal routing.

Source

Thrown at compiler/rustc_next_trait_solver/src/solve/effect_goals.rs:357

            pred,
            requirements,
        )
        .map_err(Into::into)
    }

    fn consider_builtin_async_fn_trait_candidates(
        _ecx: &mut EvalCtxt<'_, D>,
        _goal: Goal<I, Self>,
        _kind: rustc_type_ir::ClosureKind,
    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
        unimplemented!("AsyncFn* are not yet const")
    }

    fn consider_builtin_async_fn_kind_helper_candidate(
        _ecx: &mut EvalCtxt<'_, D>,
        _goal: Goal<I, Self>,
    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
        unreachable!("AsyncFnKindHelper is not const")
    }

    fn consider_builtin_tuple_candidate(
        _ecx: &mut EvalCtxt<'_, D>,
        _goal: Goal<I, Self>,
    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
        unreachable!("Tuple trait is not const")
    }

    fn consider_builtin_pointee_candidate(
        _ecx: &mut EvalCtxt<'_, D>,
        _goal: Goal<I, Self>,
    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
        unreachable!("Pointee is not const")
    }

    fn consider_builtin_future_candidate(
        _ecx: &mut EvalCtxt<'_, D>,

View on GitHub (pinned to 22057b88b0)

Solutions

  1. Confirm `const_trait_impl`/`-Znext-solver`/async-closure features are responsible by toggling them off.
  2. Reduce the async-closure + const interaction to a minimal case and file an ICE report.
  3. Bisect the toolchain with `cargo bisect-rustc` to locate the regression.
  4. Avoid `const` bounds on code paths that involve async closures until the feature stabilizes.
Defensive patterns

Strategy: validation

Validate before calling

// AsyncFnKindHelper is an internal, non-const lang trait. Never let it appear in a const obligation.
// Reviewer check: any `async fn` in generic position whose kind must be inferred is a risk.
fn no_async_kind_helper_in_const<T>(_t: &T) where T: Sized /* not : AsyncFnKindHelper */ {}

Prevention

When it happens

Trigger: Reached when the next solver assembles a `HostEffectPredicate` whose trait is `AsyncFnKindHelper` (lang item) and reaches the built-in candidate branch (effect_goals.rs:353). This should never happen for well-formed input.

Common situations: Nightly with `const_trait_impl`/`host_effects` combined with async-closure features (`async_closure`, `async_fn_in_trait`); miscompilation or goal-routing regression after a solver change.

Related errors


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