Skip to content

Gate direct pin-borrow ADT diagnostic on !Unpin#4

Merged
frank-king merged 1 commit intofrank-king:feature/pin-borrowckfrom
P8L1:gate-pin-borrow-diagnostic-on-unpin
May 1, 2026
Merged

Gate direct pin-borrow ADT diagnostic on !Unpin#4
frank-king merged 1 commit intofrank-king:feature/pin-borrowckfrom
P8L1:gate-pin-borrow-diagnostic-on-unpin

Conversation

@P8L1
Copy link
Copy Markdown

@P8L1 P8L1 commented Apr 30, 2026

Follow-up to #2.

The merged direct &pin borrow diagnostic was too strict for ADTs that are Unpin.

For T: Unpin, &pin mut T and &mut T are mutually coercible, so this diagnostic should only fire when the ADT is known to be !Unpin.

This updates the typeck check to keep the diagnostic limited to explicit user-written &pin borrows, but suppress it unless the ADT is known/proven to be !Unpin.

Tests now cover:

  • non-#[pin_v2] Unpin ADTs being accepted,
  • non-#[pin_v2] !Unpin ADTs being rejected,
  • #[pin_v2] !Unpin ADTs being accepted by this check,
  • &pin mut and &pin const,
  • generic/inference cases being accepted conservatively.

Tested with:

.\x.ps1 test tests/ui/pin-ergonomics/direct-borrow-requires-pin-v2.rs --stage 1 --test-args --force-rerun
.\x.ps1 test tests/pretty/pin-ergonomics.rs --stage 1 --test-args --force-rerun
.\x.ps1 test tests/ui/pin-ergonomics/borrow.rs --stage 1 --test-args --force-rerun
.\x.ps1 test tests/ui/pin-ergonomics/borrow-unpin.rs --stage 1 --test-args --force-rerun
.\x.ps1 test tests/ui/pin-ergonomics/borrow-pinned-projection.rs --stage 1 --test-args --force-rerun
.\x.ps1 test tidy --bless
.\x.ps1 fmt --check
git diff --check
.\x.ps1 test tests/ui/pin-ergonomics --stage 1 --test-args --force-rerun
.\x.ps1 test tests/ui/pin-ergonomics/direct-borrow-requires-pin-v2.rs --stage 2 --test-args --force-rerun

@P8L1 P8L1 force-pushed the gate-pin-borrow-diagnostic-on-unpin branch from 99b01b8 to 965d40f Compare May 1, 2026 10:21
@frank-king frank-king merged commit edeac5e into frank-king:feature/pin-borrowck May 1, 2026
2 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants