Skip to content

Implement coercions between &pin (mut|const) T and &(mut) T when T: Unpin#149130

Merged
rust-bors[bot] merged 4 commits intorust-lang:mainfrom
frank-king:feature/pin-coerce
Mar 11, 2026
Merged

Implement coercions between &pin (mut|const) T and &(mut) T when T: Unpin#149130
rust-bors[bot] merged 4 commits intorust-lang:mainfrom
frank-king:feature/pin-coerce

Conversation

@frank-king
Copy link
Contributor

@frank-king frank-king commented Nov 20, 2025

View all comments

This allows the following (mutual) coercions when T: Unpin:

  • &T <-> Pin<&T>
  • &mut T <-> Pin<&mut T>
  • &mut T -> Pin<&T>
  • Pin<&mut T> -> &T

Part of Pin Ergonomics.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 20, 2025
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Nov 20, 2025
@frank-king frank-king marked this pull request as ready for review November 20, 2025 11:57
@rustbot
Copy link
Collaborator

rustbot commented Nov 20, 2025

Some changes occurred in need_type_info.rs

cc @lcnr

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in exhaustiveness checking

cc @Nadrieril

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 20, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 20, 2025

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@nnethercote
Copy link
Contributor

I am not a good person to review this. How about...

r? @lcnr

@rustbot rustbot assigned lcnr and unassigned nnethercote Nov 21, 2025
@lcnr
Copy link
Contributor

lcnr commented Nov 24, 2025

r? types

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Nov 24, 2025
@rustbot rustbot assigned spastorino and unassigned lcnr Nov 24, 2025
@spastorino
Copy link
Member

r? types

@rustbot rustbot assigned jackh726 and unassigned spastorino Nov 24, 2025
@bors
Copy link
Collaborator

bors commented Dec 5, 2025

☔ The latest upstream changes (presumably #148602) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Dec 18, 2025

☔ The latest upstream changes (presumably #150115) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incredibly sorry about the review latency here.

Overall, the changes look not bad. That being said, there are two very mechanical changes that would be useful to split into a separate PR (or really, a separate commit is fine, but I prefer a separate PR since they stand alone well).

View changes since this review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 23, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 23, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@frank-king
Copy link
Contributor Author

@bors r=jackh726

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 10, 2026

📌 Commit d38c8c0 has been approved by jackh726

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 1000. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 10, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 10, 2026
…ackh726

Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`

This allows the following (mutual) coercions when `T: Unpin`:
- `&T` <-> `Pin<&T>`
- `&mut T` <-> `Pin<&mut T>`
- `&mut T` -> `Pin<&T>`
- `Pin<&mut T>` -> `&T`

Part of [Pin Ergonomics](rust-lang#130494).
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 10, 2026
…ackh726

Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`

This allows the following (mutual) coercions when `T: Unpin`:
- `&T` <-> `Pin<&T>`
- `&mut T` <-> `Pin<&mut T>`
- `&mut T` -> `Pin<&T>`
- `Pin<&mut T>` -> `&T`

Part of [Pin Ergonomics](rust-lang#130494).
rust-bors bot pushed a commit that referenced this pull request Mar 10, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`)
 - #152457 (Pass -pg to linker when using -Zinstrument-mcount)
 - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks)
 - #153653 (scalable vector: type renames and simple checks)
 - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself)
 - #153641 (Move `Spanned`.)
 - #153643 (Avoid projection-only suggestions for inherent assoc types)
 - #153657 (triagebot: remove myself from some mention groups)
rust-bors bot pushed a commit that referenced this pull request Mar 10, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`)
 - #152457 (Pass -pg to linker when using -Zinstrument-mcount)
 - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks)
 - #153653 (scalable vector: type renames and simple checks)
 - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself)
 - #153641 (Move `Spanned`.)
 - #153643 (Avoid projection-only suggestions for inherent assoc types)
 - #153657 (triagebot: remove myself from some mention groups)
rust-bors bot pushed a commit that referenced this pull request Mar 10, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`)
 - #152457 (Pass -pg to linker when using -Zinstrument-mcount)
 - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks)
 - #153653 (scalable vector: type renames and simple checks)
 - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself)
 - #153641 (Move `Spanned`.)
 - #153643 (Avoid projection-only suggestions for inherent assoc types)
 - #153657 (triagebot: remove myself from some mention groups)
rust-bors bot pushed a commit that referenced this pull request Mar 10, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`)
 - #152457 (Pass -pg to linker when using -Zinstrument-mcount)
 - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks)
 - #153653 (scalable vector: type renames and simple checks)
 - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself)
 - #153641 (Move `Spanned`.)
 - #153643 (Avoid projection-only suggestions for inherent assoc types)
 - #153657 (triagebot: remove myself from some mention groups)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 10, 2026
…ackh726

Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`

This allows the following (mutual) coercions when `T: Unpin`:
- `&T` <-> `Pin<&T>`
- `&mut T` <-> `Pin<&mut T>`
- `&mut T` -> `Pin<&T>`
- `Pin<&mut T>` -> `&T`

Part of [Pin Ergonomics](rust-lang#130494).
rust-bors bot pushed a commit that referenced this pull request Mar 10, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`)
 - #152457 (Pass -pg to linker when using -Zinstrument-mcount)
 - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks)
 - #153471 (Refactor `ActiveJobGuard`)
 - #153595 (`QueryLatch` cleanups)
 - #153653 (scalable vector: type renames and simple checks)
 - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself)
 - #153479 (Add rationale for intentional potential_query_instability allows)
 - #153600 (add test for proc-macros with custom panic payloads)
 - #153641 (Move `Spanned`.)
 - #153643 (Avoid projection-only suggestions for inherent assoc types)
 - #153657 (triagebot: remove myself from some mention groups)
 - #153659 (Mark an unreachable match arm as such)
rust-bors bot pushed a commit that referenced this pull request Mar 10, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`)
 - #152457 (Pass -pg to linker when using -Zinstrument-mcount)
 - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks)
 - #153471 (Refactor `ActiveJobGuard`)
 - #153595 (`QueryLatch` cleanups)
 - #153653 (scalable vector: type renames and simple checks)
 - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself)
 - #153479 (Add rationale for intentional potential_query_instability allows)
 - #153600 (add test for proc-macros with custom panic payloads)
 - #153641 (Move `Spanned`.)
 - #153643 (Avoid projection-only suggestions for inherent assoc types)
 - #153657 (triagebot: remove myself from some mention groups)
 - #153659 (Mark an unreachable match arm as such)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 10, 2026
…ackh726

Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`

This allows the following (mutual) coercions when `T: Unpin`:
- `&T` <-> `Pin<&T>`
- `&mut T` <-> `Pin<&mut T>`
- `&mut T` -> `Pin<&T>`
- `Pin<&mut T>` -> `&T`

Part of [Pin Ergonomics](rust-lang#130494).
rust-bors bot pushed a commit that referenced this pull request Mar 10, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`)
 - #152457 (Pass -pg to linker when using -Zinstrument-mcount)
 - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks)
 - #153471 (Refactor `ActiveJobGuard`)
 - #153595 (`QueryLatch` cleanups)
 - #153653 (scalable vector: type renames and simple checks)
 - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself)
 - #153283 (feat(rustdoc-json): Add optional support for rkyv (de)serialization)
 - #153479 (Add rationale for intentional potential_query_instability allows)
 - #153533 (Fix LegacyKeyValueFormat report from docker build: miscellaneous)
 - #153600 (add test for proc-macros with custom panic payloads)
 - #153643 (Avoid projection-only suggestions for inherent assoc types)
 - #153657 (triagebot: remove myself from some mention groups)
 - #153659 (Mark an unreachable match arm as such)
rust-bors bot pushed a commit that referenced this pull request Mar 10, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`)
 - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks)
 - #153471 (Refactor `ActiveJobGuard`)
 - #153595 (`QueryLatch` cleanups)
 - #153653 (scalable vector: type renames and simple checks)
 - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself)
 - #153283 (feat(rustdoc-json): Add optional support for rkyv (de)serialization)
 - #153479 (Add rationale for intentional potential_query_instability allows)
 - #153533 (Fix LegacyKeyValueFormat report from docker build: miscellaneous)
 - #153600 (add test for proc-macros with custom panic payloads)
 - #153643 (Avoid projection-only suggestions for inherent assoc types)
 - #153657 (triagebot: remove myself from some mention groups)
 - #153659 (Mark an unreachable match arm as such)
rust-bors bot pushed a commit that referenced this pull request Mar 10, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`)
 - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks)
 - #153471 (Refactor `ActiveJobGuard`)
 - #153595 (`QueryLatch` cleanups)
 - #153653 (scalable vector: type renames and simple checks)
 - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself)
 - #153283 (feat(rustdoc-json): Add optional support for rkyv (de)serialization)
 - #153479 (Add rationale for intentional potential_query_instability allows)
 - #153533 (Fix LegacyKeyValueFormat report from docker build: miscellaneous)
 - #153600 (add test for proc-macros with custom panic payloads)
 - #153643 (Avoid projection-only suggestions for inherent assoc types)
 - #153657 (triagebot: remove myself from some mention groups)
 - #153659 (Mark an unreachable match arm as such)
@rust-bors rust-bors bot merged commit 6419556 into rust-lang:main Mar 11, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 11, 2026
rust-timer added a commit that referenced this pull request Mar 11, 2026
Rollup merge of #149130 - frank-king:feature/pin-coerce, r=jackh726

Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`

This allows the following (mutual) coercions when `T: Unpin`:
- `&T` <-> `Pin<&T>`
- `&mut T` <-> `Pin<&mut T>`
- `&mut T` -> `Pin<&T>`
- `Pin<&mut T>` -> `&T`

Part of [Pin Ergonomics](#130494).
Delta17920 pushed a commit to Delta17920/rust that referenced this pull request Mar 11, 2026
…nathanBrouwer

Rollup of 13 pull requests

Successful merges:

 - rust-lang#149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`)
 - rust-lang#153143 (Allow `./x test` to run tests without doc tests and without benchmarks)
 - rust-lang#153471 (Refactor `ActiveJobGuard`)
 - rust-lang#153595 (`QueryLatch` cleanups)
 - rust-lang#153653 (scalable vector: type renames and simple checks)
 - rust-lang#152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself)
 - rust-lang#153283 (feat(rustdoc-json): Add optional support for rkyv (de)serialization)
 - rust-lang#153479 (Add rationale for intentional potential_query_instability allows)
 - rust-lang#153533 (Fix LegacyKeyValueFormat report from docker build: miscellaneous)
 - rust-lang#153600 (add test for proc-macros with custom panic payloads)
 - rust-lang#153643 (Avoid projection-only suggestions for inherent assoc types)
 - rust-lang#153657 (triagebot: remove myself from some mention groups)
 - rust-lang#153659 (Mark an unreachable match arm as such)
@JonathanBrouwer
Copy link
Contributor

@rust-timer build 59484a8

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (59484a8): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.1%, 0.5%] 17
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 2.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.0% [2.0%, 2.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.0% [2.0%, 2.0%] 1

Cycles

Results (secondary -2.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 480.034s -> 487.723s (1.60%)
Artifact size: 394.90 MiB -> 395.00 MiB (0.03%)

@rustbot rustbot added the perf-regression Performance regression. label Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants