Bug
maybe_drop_guard in compiler/rustc_mir_transform/src/liveness.rs (line 238) determines whether a type should be treated as a "drop guard" to suppress false unused variable lint warnings. It explicitly lists ty::Closure and ty::Coroutine but misses ty::CoroutineClosure.
Evidence
matches!(
ty.kind(),
ty::Closure(..)
| ty::Coroutine(..)
| ty::Tuple(..)
| ty::Adt(..)
| ty::Dynamic(..)
| ty::Array(..)
| ty::Slice(..)
| ty::Alias(ty::AliasTy { kind: ty::Opaque { .. }, .. })
) && ty.needs_drop(tcx, typing_env)
ty::CoroutineClosure is not in the list. When an async closure is used as a drop guard (e.g., let _guard = create_async_closure();), the lint pass will not recognize it as a drop guard.
Impact
False positive unused variable warning on stable Rust (async closures stable since 1.85) when async closures are used as drop guards.
PR #480
Bug
maybe_drop_guardincompiler/rustc_mir_transform/src/liveness.rs(line 238) determines whether a type should be treated as a "drop guard" to suppress falseunused variablelint warnings. It explicitly liststy::Closureandty::Coroutinebut missesty::CoroutineClosure.Evidence
ty::CoroutineClosureis not in the list. When an async closure is used as a drop guard (e.g.,let _guard = create_async_closure();), the lint pass will not recognize it as a drop guard.Impact
False positive
unused variablewarning on stable Rust (async closures stable since 1.85) when async closures are used as drop guards.PR #480