Skip to content

fix: add CoroutineClosure to maybe_drop_guard type list#480

Open
SebTardif wants to merge 2 commits into
mainfrom
fix-liveness-coroutine-closure
Open

fix: add CoroutineClosure to maybe_drop_guard type list#480
SebTardif wants to merge 2 commits into
mainfrom
fix-liveness-coroutine-closure

Conversation

@SebTardif

Copy link
Copy Markdown
Owner

Summary

Fixes #479

maybe_drop_guard in liveness.rs determines whether a type should suppress false unused variable lint warnings when used as a drop guard. It explicitly lists ty::Closure and ty::Coroutine but misses ty::CoroutineClosure, causing false positive warnings when async closures are used as drop guards.

Failure scenario

When a user writes let _guard = create_async_closure(); as a drop guard pattern, the lint pass does not recognize the async closure type as a valid drop guard and emits a spurious unused variable warning.

Fix

Add ty::CoroutineClosure(..) to the matches! list, alongside ty::Closure and ty::Coroutine.

Bug origin

The CoroutineClosure variant was added to TyKind for async closures (stable since Rust 1.85). The maybe_drop_guard function was not updated to include the new variant.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@SebTardif SebTardif added bug Something isn't working I-wrong Wrong result or data corruption P-medium Medium impact: affects specific usage patterns A-diagnostics Compiler diagnostics labels Jun 19, 2026
Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-diagnostics Compiler diagnostics bug Something isn't working I-wrong Wrong result or data corruption P-medium Medium impact: affects specific usage patterns

Projects

None yet

Development

Successfully merging this pull request may close these issues.

maybe_drop_guard missing CoroutineClosure, false unused variable warning for async closure drop guards

1 participant