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

  1. File a rustc ICE with the minimized `use<...>` repro.
  2. Ensure every precise-capture argument is a resolvable type/lifetime in scope.
  3. Simplify the capture list (fewer args) to isolate the offending one.
  4. Bisect with cargo bisect-rustc.
Defensive patterns

Strategy: validation

Prevention

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


AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10). Data as JSON: /api/errors/8ddbf85ddee9c72c. Report an issue: GitHub.