{"record":{"id":"768caf97a28a075b","repo":"rust-lang/rust","slug":"fn-are-not-yet-const","errorCode":null,"errorMessage":"Fn* are not yet const","messagePattern":"Fn\\* are not yet const","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_next_trait_solver/src/solve/effect_goals.rs","lineNumber":292,"sourceCode":"                        goal.with(\n                            cx,\n                            ty::ClauseKind::HostEffect(\n                                goal.predicate.with_replaced_self_ty(cx, ty),\n                            ),\n                        )\n                    }),\n                )\n            })?;\n\n            ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)\n        })\n    }\n\n    fn consider_builtin_fn_ptr_trait_candidate(\n        _ecx: &mut EvalCtxt<'_, D>,\n        _goal: Goal<I, Self>,\n    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {\n        unimplemented!(\"Fn* are not yet const\")\n    }\n\n    #[instrument(level = \"trace\", skip_all, ret)]\n    fn consider_builtin_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        let cx = ecx.cx();\n\n        let self_ty = goal.predicate.self_ty();\n        let (inputs_and_output, def_id, args) =\n            structural_traits::extract_fn_def_from_const_callable(cx, self_ty)?;\n        let (inputs, output) = ecx.instantiate_binder_with_infer(inputs_and_output);\n\n        // A built-in `Fn` impl only holds if the output is sized.\n        // (FIXME: technically we only need to check this if the type is a fn ptr...)\n        let output_is_sized_pred =","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs#L274-L310","documentation":"An `unimplemented!(\"Fn* are not yet const\")` ICE in the next (new) trait solver's effect-goal handling (`consider_builtin_fn_ptr_trait_candidate`). When the new solver must produce a candidate proving that a function-pointer type satisfies a const-calling-convention `Fn`/`FnMut`/`FnOnce` obligation, no candidate exists yet and it panics at effect_goals.rs:292.","triggerScenarios":"Enabling the next trait solver (`-Znext-solver`) and requiring a const `Fn`/`FnMut`/`FnOnce` impl for a function pointer (e.g. calling a function pointer inside a `const fn` in a context the new solver must evaluate).","commonSituations":"Nightly + `-Znext-solver` + const-eval code that invokes a function pointer in const context. Not reachable on stable or with the old solver.","solutions":["Do not enable `-Znext-solver` for crates that need const function-pointer calls.","Replace the function-pointer call in const context with a direct (monomorphized) function call or a closure that the solver can handle.","Track the upstream const-`Fn*` work for the next solver; upgrade when implemented."],"exampleFix":"// before (next solver + const fn-pointer call -> ICE)\nconst fn run(f: fn() -> i32) -> i32 { f() }\n// compiled with: -Znext-solver\n\n// after — call directly, or drop -Znext-solver\nconst fn run() -> i32 { 42 }","handlingStrategy":"fallback","validationCode":"# Detect next-solver + const fn-pointer calls\nif [[ \"${RUSTFLAGS:-}\" == *next-solver* ]]; then\n  rg -nE 'const fn .*\\bfn\\(' src/ && echo \"avoid: const Fn* calls unsupported in the next solver\"\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not enable `-Znext-solver` for crates that perform const function-pointer calls.","Replace const fn-pointer calls with direct calls or closures.","Track const-`Fn*` support in the next solver."],"tags":["rustc","next-solver","const-eval","fn-traits","nightly","ice","compiler-internal","unfinished-feature"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}