Bug
In compiler/rustc_middle/src/ty/opaque_types.rs, ReverseMapper::fold_ty (line 146) handles Closure, Coroutine, and CoroutineWitness with fold_closure_args (which suppresses region-not-found errors for parent lifetimes), but CoroutineClosure (async closures, stable since Rust 1.85) falls through to the _ => ty.super_fold_with(self) catch-all. This calls fold_kind_normally on ALL args including parent args, causing spurious compilation errors for unused parent lifetimes.
Additionally, fold_const (line 192) returns non-Param consts unchanged (_ => ct) without calling ct.super_fold_with(self), so nested types and regions inside const expressions are not properly remapped.
Impact
Async closures inside opaque types (impl Trait) with unused enclosing lifetimes will hit a false "lifetime is part of concrete type but not used in parameter list" error.
Fix
PR #476
Bug
In
compiler/rustc_middle/src/ty/opaque_types.rs,ReverseMapper::fold_ty(line 146) handlesClosure,Coroutine, andCoroutineWitnesswithfold_closure_args(which suppresses region-not-found errors for parent lifetimes), butCoroutineClosure(async closures, stable since Rust 1.85) falls through to the_ => ty.super_fold_with(self)catch-all. This callsfold_kind_normallyon ALL args including parent args, causing spurious compilation errors for unused parent lifetimes.Additionally,
fold_const(line 192) returns non-Param consts unchanged (_ => ct) without callingct.super_fold_with(self), so nested types and regions inside const expressions are not properly remapped.Impact
Async closures inside opaque types (
impl Trait) with unused enclosing lifetimes will hit a false "lifetime is part of concrete type but not used in parameter list" error.Fix
PR #476