rust-lang/rust · error
no partial res expected for precise capture arg
Error message
no partial res expected for precise capture arg
What it means
lib.rs:1908: lower_precise_capturing_args handles `use<'a, T>` precise-capture lists. For a non-lifetime arg it calls partial_res.full_res().expect("no partial res expected for precise capture arg"). The invariant: name resolution must have produced a partial resolution whose full_res() is Some for every precise-capture arg.
Source
Thrown at compiler/rustc_ast_lowering/src/lib.rs:1908
let opaque_ty_def = self.arena.alloc(opaque_ty_def);
hir::TyKind::OpaqueDef(opaque_ty_def)
}
fn lower_precise_capturing_args(
&mut self,
precise_capturing_args: &[PreciseCapturingArg],
) -> &'hir [hir::PreciseCapturingArg<'hir>] {
self.arena.alloc_from_iter(precise_capturing_args.iter().map(|arg| match arg {
PreciseCapturingArg::Lifetime(lt) => hir::PreciseCapturingArg::Lifetime(
self.lower_lifetime(lt, LifetimeSource::PreciseCapturing, lt.ident.into()),
),
PreciseCapturingArg::Arg(path, id) => {
let [segment] = path.segments.as_slice() else {
panic!();
};
let res = self.get_partial_res(*id).map_or(Res::Err, |partial_res| {
partial_res.full_res().expect("no partial res expected for precise capture arg")
});
hir::PreciseCapturingArg::Param(hir::PreciseCapturingNonLifetimeArg {
hir_id: self.lower_node_id(*id),
ident: self.lower_ident(segment.ident),
res: self.lower_res(res),
})
}
}))
}
fn lower_fn_params_to_idents(&mut self, decl: &FnDecl) -> &'hir [Option<Ident>] {
self.arena.alloc_from_iter(decl.inputs.iter().map(|param| match param.pat.kind {
PatKind::Missing => None,
PatKind::Ident(_, ident, _) => Some(self.lower_ident(ident)),
PatKind::Wild => Some(Ident::new(kw::Underscore, self.lower_span(param.pat.span))),
_ => {
self.dcx().span_delayed_bug(
param.pat.span,View on GitHub (pinned to 7088e4b63a)
Solutions
- File a rustc ICE with the minimized `use<...>` repro.
- Ensure every precise-capture argument is a resolvable type/lifetime in scope.
- Simplify the capture list (fewer args) to isolate the offending one.
- Bisect with cargo bisect-rustc.
Defensive patterns
Strategy: validation
Prevention
- Ensure every precise-capture argument in `use<...>` is a resolvable type/lifetime in scope.
- Keep precise-capture lists small and well-named to ease minimization.
- File a rustc ICE with the minimized `use<...>` repro.
- Bisect with cargo bisect-rustc across nightlies.
When it happens
Trigger: A precise-capturing use clause (`impl Trait + use<T>`) where the resolver did not produce a full resolution for an argument; a resolver/lowering mismatch.
Common situations: Nightly code using precise-capturing syntax with an unresolved or malformed capture argument; a compiler bug in resolution of precise-capture args.
Related errors
- alt layout should always work
- alt layout should have a niche like the regular one
- `Self` generic param is not found while expected
- must be at least one segment
- must contain self type as `SelfTy` propagation kind is speci
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/8ddbf85ddee9c72c.
Report an issue: GitHub.