Skip long lived pin facts for unpin places#5
Conversation
59822e7 to
3b155c2
Compare
Remove the now-unnecessary helper method and access state.pinned_borrows directly.
be61203
into
frank-king:feature/pin-borrowck
|
|
||
| fn baz(mut x: Foo, mut y: Foo) { | ||
| { | ||
| let _x = &pin mut x; |
There was a problem hiding this comment.
Could you please also add a test for ref pin patterns? (And similarly, tests that involve both &pin borrows and moves (or &mut borrows) should also be tested together with ref pin patterns).
{
let ref pin mut _x = x;
}
let _x = &mut x; //~ ERROR ...
let _x = x; //~ ERROR ...Previous tests for pin patterns focused on pin projections only, but didn't test whether it works well with the borrowck stuff (Ideally, &pin borrows should be equivalent with ref pin patterns, just like the normal borrows &mut with ref mut patterns). That's the remaining TODOs related to pin patterns.
There was a problem hiding this comment.
Thanks, added the requested ref pin pattern coverage.
This required a small MIR build change as well: with only the new tests kept and the implementation files reverted, the new ref pin diagnostics were missing. So the implementation now lowers ref pin mut / ref pin const patterns to BorrowKind::Pinned(..., PinBorrowKind::Persistent), while preserving the old behavior for ordinary non-pinned ref / ref mut patterns.
Added coverage for:
ref pin mutfollowed by later&mutref pin mutfollowed by later moveref pin constfollowed by later&mutref pin constfollowed by later move- pinned projection cases
- pinned parent / field cases
Unpinvs!Unpinbehavior
This fixes the borrowck side of the
Unpinbehaviour for&pin.The typeck check already accepts direct
&pinborrows when the target type is known to beUnpin, but thePinsdataflow analysis still generated long-lived pinned-borrow facts for those borrows.This now suppresses long-lived pin facts at their source when the original pinned place type is known to be
Unpin. The decision is tied to the original pinned place, not the later accessed place, so projected accesses are not accidentally made too permissive.Tests cover expired
&pinborrows ofUnpinplaces, genericT: Unpinplaces, existing!Unpinbehaviour, and projection cases where a pinned parent still blocks moving or mutably borrowing a conflicting field.