Skip to content

ReverseMapper::fold_ty missing CoroutineClosure arm; fold_const skips super_fold_with #469

@SebTardif

Description

@SebTardif

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemType systemI-wrongWrong result or data corruptionP-mediumMedium impact: affects specific usage patternsbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions