{"id":"f291b278c81c278c","repo":"rust-lang/rust","slug":"no-such-associated-type-in-asyncfn","errorCode":null,"errorMessage":"no such associated type in `AsyncFn*`: {:?}","messagePattern":"no such associated type in `AsyncFn\\*`: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs","lineNumber":627,"sourceCode":"                    [\n                        I::GenericArg::from(goal.predicate.self_ty()),\n                        tupled_inputs_ty.into(),\n                        env_region.into(),\n                    ],\n                ),\n                output_coroutine_ty.into(),\n            )\n        } else if cx.is_projection_lang_item(def_id, SolverProjectionLangItem::AsyncFnOnceOutput) {\n            (\n                ty::AliasTerm::new(\n                    cx,\n                    goal.predicate.alias.kind,\n                    [goal.predicate.self_ty(), tupled_inputs_ty],\n                ),\n                coroutine_return_ty.into(),\n            )\n        } else {\n            panic!(\"no such associated type in `AsyncFn*`: {:?}\", def_id)\n        };\n        let pred = ty::ProjectionPredicate { projection_term, term }.upcast(cx);\n\n        Self::probe_and_consider_implied_clause(\n            ecx,\n            CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),\n            goal,\n            pred,\n            [goal.with(cx, output_is_sized_pred)]\n                .into_iter()\n                .chain(nested_preds.into_iter().map(|pred| goal.with(cx, pred)))\n                .map(|goal| (GoalSource::ImplWhereBound, goal)),\n        )\n    }\n\n    fn consider_builtin_async_fn_kind_helper_candidate(\n        ecx: &mut EvalCtxt<'_, D>,\n        goal: Goal<I, Self>,","sourceCodeStart":609,"sourceCodeEnd":645,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs#L609-L645","documentation":"This panic lives in consider_builtin_async_fn_trait_candidates (normalizes_to.rs:627). That function computes the projection for an async-callable trait by matching the projection's def_id against exactly three lang items: CallOnceFuture, CallRefFuture, and AsyncFnOnceOutput. The else branch fires only if the def_id is an async-fn-family projection that the compiler recognizes but this match does not handle. It is an internal invariant: under correct compiler logic every async-fn projection goal is one of those three, so reaching the else means a new async-closure/projection lang item was introduced elsewhere without updating this arm.","triggerScenarios":"Reached only when a NormalizesTo goal for an AsyncFn*-family projection lands in consider_builtin_async_fn_trait_candidates whose def_id is none of CallOnceFuture / CallRefFuture / AsyncFnOnceOutput. Concretely: compiling code that exercises async closures / async-fn-trait projections under -Znext-solver on a nightly where the lang-item table and this match arm have drifted out of sync (e.g. mid-development of the CoroutineClosure / async-closure feature).","commonSituations":"Using unstable async-closure or AsyncFn features on a bleeding-edge nightly with -Znext-solver enabled; a rustc toolchain regression where a recently-added async projection lang item is not yet wired into this match; bisecting across nightlies during an async-fn-trait refactor in rustc itself.","solutions":["Update to the latest nightly toolchain (rustup update nightly); async-closure/next-solver mismatches are usually fixed within days.","Disable the next solver for the affected crate: remove -Znext-solver (or pass -Znext-solver=no) from RUSTFLAGS / .cargo/config.toml so the projection is handled by the legacy solver.","Reduce the failing crate to a minimal reproducer and file an ICE at https://github.com/rust-lang/rust/issues including the nightly hash and the def_id printed in the panic.","If you depend on a crate using nightly async-closure features, pin that crate to a version compatible with your toolchain, or pin your toolchain to a known-good nightly."],"exampleFix":"# before (RUSTFLAGS in .cargo/config.toml)\n[build]\nrustflags = [\"-Znext-solver\"]\n\n# after\n[build]\nrustflags = []","handlingStrategy":"type-guard","validationCode":"// Before projecting an associated type off an async fn trait,\n// confirm the trait + variant expose that name. Only these exist:\n//   AsyncFn::Output, AsyncFnMut::Output, AsyncFnOnce::Output,\n//   AsyncFnOnce::CallOnceOutput\nfn assert_async_fn_output<F>()\nwhere\n    F: for<'a> AsyncFn<&'a str>,        // concrete AsyncFn* bound\n    F::Output: Send,                    // only valid associated name\n{}\n","typeGuard":"// Narrow an async-callable to a known variant before projecting Output.\ntrait AsyncFnRet { type Output; }\nimpl<F: AsyncFn<T>, T> AsyncFnRet for F { type Output = <Self as AsyncFn<T>>::Output; }\nfn is_async_fn_with_output<F: AsyncFnRet>() where F::Output: Sized {}\n","tryCatchPattern":null,"preventionTips":["Never invent associated-type names on AsyncFn/AsyncFnMut/AsyncFnOnce; only Output (and CallOnceOutput on AsyncFnOnce) exist.","Use higher-ranked bounds (`for<'a> AsyncFn<&'a str>`) rather than projecting from an unbounded `F: AsyncFn<...>`.","Pin your nightly toolchain: this ICE is a rustc_next_trait_solver bug, behavior shifts between nightlies.","If it reproduces on stable, file a rustc issue with the minimal trait-solver repro before changing library code."],"tags":["rust","rustc","trait-solver","next-solver","ice","panic","async","associated-type","builtin-impl"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}