rust-lang/rust · error
Future is not const
Error message
Future is not const
What it means
`consider_builtin_future_candidate` (effect_goals.rs:378) is `unreachable!`. The built-in impl of `Future` for coroutine/future types has no const semantics — `T: const Future` is not a meaningful obligation. Hitting this branch means goal assembly produced a `const Future` host-effect goal that should never have been constructed.
Source
Thrown at compiler/rustc_next_trait_solver/src/solve/effect_goals.rs:378
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>,
_goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
unreachable!("Future is not const")
}
fn consider_builtin_iterator_candidate(
_ecx: &mut EvalCtxt<'_, D>,
_goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution))
}
fn consider_builtin_fused_iterator_candidate(
_ecx: &mut EvalCtxt<'_, D>,
_goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
unreachable!("FusedIterator is not const")
}
fn consider_builtin_async_iterator_candidate(
_ecx: &mut EvalCtxt<'_, D>,View on GitHub (pinned to 22057b88b0)
Solutions
- Move async/future-producing code out of the `const` context — futures are not const-evaluable today.
- Disable `const_async_blocks`/`host_effects`/`-Znext-solver` to confirm the source of the obligation.
- Reduce to a minimal `const async {}` reproducer and file an ICE report.
- Upgrade nightly; async-in-const support is incomplete and changes frequently.
Example fix
// before: async block inside const forces a const Future obligation
const fn make() -> impl Future<Output = u32> { async { 1 } } // ICE: Future not const
// after: return the value synchronously, compute at runtime instead
fn make() -> impl Future<Output = u32> { async { 1 } } Defensive patterns
Strategy: validation
Validate before calling
// Future is not const. Reject any `impl Future` obligation reachable from const eval.
const fn reject_future_in_const<F: std::future::Future>(_f: &F) {} // ICEs if next solver reaches it Prevention
- Never await or hold a `Future` value in `const fn` / `const` blocks — the Future trait is non-const.
- Do not declare async fn in const contexts; const + async is unsupported (see also [275]).
- If a compile-time async-like primitive is required, model it as a poll-free state-machine struct, not `impl Future`.
When it happens
Trigger: Reached when the next solver evaluates a `HostEffectPredicate` for the `Future` trait (lang item) with a const effect and reaches the built-in future candidate branch (effect_goals.rs:374).
Common situations: Nightly with `const_async_blocks`/`const_trait_impl`/`host_effects` where an async block inside a `const` context transitively emits a `const Future` obligation; combining `gen`/coroutine features with const-eval; solver regression.
Related errors
- Sized/MetaSized is never const
- AsyncFnKindHelper is not const
- Tuple trait is not const
- Pointee is not const
- Fn* are not yet const
AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03).
Data as JSON: /data/errors/589d4a2835cd87ac.json.
Report an issue: GitHub.