{"id":"589d4a2835cd87ac","repo":"rust-lang/rust","slug":"future-is-not-const","errorCode":null,"errorMessage":"Future is not const","messagePattern":"Future is not const","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_next_trait_solver/src/solve/effect_goals.rs","lineNumber":378,"sourceCode":"    fn consider_builtin_tuple_candidate(\n        _ecx: &mut EvalCtxt<'_, D>,\n        _goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        unreachable!(\"Tuple trait is not const\")\n    }\n\n    fn consider_builtin_pointee_candidate(\n        _ecx: &mut EvalCtxt<'_, D>,\n        _goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        unreachable!(\"Pointee is not const\")\n    }\n\n    fn consider_builtin_future_candidate(\n        _ecx: &mut EvalCtxt<'_, D>,\n        _goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        unreachable!(\"Future is not const\")\n    }\n\n    fn consider_builtin_iterator_candidate(\n        _ecx: &mut EvalCtxt<'_, D>,\n        _goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution))\n    }\n\n    fn consider_builtin_fused_iterator_candidate(\n        _ecx: &mut EvalCtxt<'_, D>,\n        _goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        unreachable!(\"FusedIterator is not const\")\n    }\n\n    fn consider_builtin_async_iterator_candidate(\n        _ecx: &mut EvalCtxt<'_, D>,","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs#L360-L396","documentation":"`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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before: async block inside const forces a const Future obligation\nconst fn make() -> impl Future<Output = u32> { async { 1 } } // ICE: Future not const\n\n// after: return the value synchronously, compute at runtime instead\nfn make() -> impl Future<Output = u32> { async { 1 } }","handlingStrategy":"validation","validationCode":"// Future is not const. Reject any `impl Future` obligation reachable from const eval.\nconst fn reject_future_in_const<F: std::future::Future>(_f: &F) {} // ICEs if next solver reaches it","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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`."],"tags":["rustc-ice","const-traits","host-effects","future","async","nightly","compiler-internal"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}