-
-
Notifications
You must be signed in to change notification settings - Fork 17k
Coroutine upvars are not required to be live in borrowck if witness has no drop requirements #144155
Copy link
Copy link
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-borrow-checkerArea: The borrow checkerArea: The borrow checkerC-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-criticalCritical priorityCritical priorityS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issue
Description
Activity
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-borrow-checkerArea: The borrow checkerArea: The borrow checkerC-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-criticalCritical priorityCritical priorityS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issue
I tried this code:
I expected it to fail, since dropping the coroutine
crequires thatNeedsDrop's'alifetime is live, since dropping the coroutine also performs a drop ofNeedsDrop(as an upvar).Instead, it compiled. This is UB.
This fails on rustc as of nightly 2025-07-18.
Not sure if this has either always been incorrect, or ifthis was introduced due to the fix in #117134.