{"id":"83dad5ee68fe2893","repo":"rust-lang/rust","slug":"asyncfn-are-not-yet-const","errorCode":null,"errorMessage":"AsyncFn* are not yet const","messagePattern":"AsyncFn\\* are not yet const","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_next_trait_solver/src/solve/effect_goals.rs","lineNumber":350,"sourceCode":"        ))\n        .to_host_effect_clause(cx, goal.predicate.constness);\n\n        Self::probe_and_consider_implied_clause(\n            ecx,\n            CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),\n            goal,\n            pred,\n            requirements,\n        )\n        .map_err(Into::into)\n    }\n\n    fn consider_builtin_async_fn_trait_candidates(\n        _ecx: &mut EvalCtxt<'_, D>,\n        _goal: Goal<I, Self>,\n        _kind: rustc_type_ir::ClosureKind,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        unimplemented!(\"AsyncFn* are not yet const\")\n    }\n\n    fn consider_builtin_async_fn_kind_helper_candidate(\n        _ecx: &mut EvalCtxt<'_, D>,\n        _goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        unreachable!(\"AsyncFnKindHelper is not const\")\n    }\n\n    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>,","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs#L332-L368","documentation":"`consider_builtin_async_fn_trait_candidates` (effect_goals.rs:350) is `unimplemented!` because the built-in impls of the `AsyncFn`/`AsyncFnMut`/`AsyncFnOnce` family for closures and fn-like items have no const counterpart. The marker is 'not implemented yet' rather than 'impossible': async-fn-callability under `const` is an open design area (async in const is still incomplete).","triggerScenarios":"Reached when the next solver evaluates a `T: const AsyncFn(..)` (or `AsyncFnMut`/`AsyncFnOnce`) host-effect goal and assembly reaches the async-fn built-in candidate branch (effect_goals.rs:345).","commonSituations":"Using `const async fn` or `async` blocks inside `const` context under `#![feature(const_async_blocks)]` combined with `const_trait_impl`; requiring a closure/async-fn to be `~const AsyncFn`.","solutions":["Do not require async callables to satisfy a `const AsyncFn*` bound; refactor to avoid the obligation.","Disable `const_async_blocks`/`host_effects` if the obligation is generated transitively rather than written by hand.","Upgrade nightly and report the ICE with a minimal reproducer — async-in-const is under active development.","Move the async code path out of the const context into a runtime function."],"exampleFix":"// before: const async fn forced through a const AsyncFn obligation\nconst async fn fetch() -> u32 { 1 }\nconst fn drive<F: ~const AsyncFn() -> u32>(f: F) -> u32 { /* ... */ 0 } // ICE\n\n// after: drop the ~const AsyncFn bound, call directly\nconst async fn fetch() -> u32 { 1 }\nasync fn drive() -> u32 { fetch().await }","handlingStrategy":"validation","validationCode":"// AsyncFn* are not const. Reject async closures/blocks anywhere const eval may reach.\nconst fn reject_async_fn_in_const<F: AsyncFn>(_f: &F) {} // ICEs the next solver if hit","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not declare `async fn` or async blocks inside `const fn` / `const` blocks — AsyncFn traits are non-const.","Keep async entry points out of const generics entirely; const + async is not supported.","If you need a compile-time async-like value, use a generator-free state machine struct with const fn transitions."],"tags":["rustc-ice","const-traits","host-effects","async-fn","nightly","not-yet-implemented"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}