Require #[pin_v2] for direct &pin borrows of ADTs#2
Conversation
|
The CI failure appears to come from The focused local checks passed and are listed in the PR body. This PR is intended as a patch against the active pin-borrowck feature branch for rust-lang#153693, not as an independent PR directly to |
|
Grateful for your help! Let's merge it first and see if the original PR can pass the CI. |
d7f4bbd
into
frank-king:feature/pin-borrowck
|
I saw the CI failure in https://github.com/rust-lang/rust/actions/runs/25086407095/job/73502863053 after my merged helper PR. I’m reproducing the exact failing If this was caused by my patch, I’ll follow up with a focused fix PR. Sorry for the churn. |
Summary
Require direct user-written
&pinborrows of ADTs to use#[pin_v2].The check runs during HIR type checking for explicit
hir::BorrowKind::Pin, so itrejects direct
&pin mut/&pin constborrow expressions on non-#[pin_v2]ADTs without affecting compiler-generated
AutoBorrow::Pinadjustments orcoercions.
What changed
not
#[pin_v2].FnCtxt::check_expr_addr_offor explicit user-written&pinborrows.AdtDef::is_pin_project()as the source of truth for#[pin_v2].marking their local ADTs
#[pin_v2].&pin mutand&pin constborrows of anon-
#[pin_v2]ADT.Why
The active pin ergonomics borrowck PR still had an unchecked task to forbid
&pinborrows for ADTs without#[pin_v2].Pattern projection already rejects non-
#[pin_v2]ADTs in related cases, butdirect user-written
&pin mut fooand&pin const fooborrow expressions werestill accepted.
This PR enforces that direct rule while avoiding compiler-generated transient pin
adjustments.
Tests
Passed:
Notes for reviewers
The main review questions are:
&pinof thePinADT itself have any special exception, orshould the literal ADT rule apply?
#[pin_v2]suggestion appropriate here, matchingthe existing projection diagnostic style?
Related
&pin mut|const $placerust-lang/rust#153693