Skip to content

Conversation

frank-king
Copy link
Contributor

@frank-king frank-king commented Jul 27, 2025

This PR is part of the pin_ergonomics experiment (the tracking issue is #130494). It allows implementing Drop with a pinned self receiver, which is required for safe pin-projection.

Implementations:

  • At least and at most one of drop and pin_drop should be implemented.
  • No direct call of drop or pin_drop. They should only be called by the drop glue.
  • pin_drop must and must only be used with types that support pin-projection. It will be implemented after the pin-projection checks are ready (i.e. checking which types can be projected to Pin<&mut FieldType> from Pin<&mut Self>).
  • Allows writing fn drop(&pin mut self) and desugars to fn pin_drop(&pin mut self).

Fixes #122630 (by accident).

Alternatives

Add a PinDrop trait that has the pin_drop method.

It is semantically clearer, but would duplicate all special checks of Drop.

It can be refactored if the trait hierarchy feature is ready.

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 27, 2025
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Sep 6, 2025

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

@frank-king frank-king changed the title Implement Drop::pin_drop for !Unpin types Add Drop::pin_drop for pinned drops Sep 20, 2025
@rust-log-analyzer

This comment has been minimized.

@frank-king frank-king force-pushed the feature/pin-drop branch 2 times, most recently from d6ddfcf to 7b4bb5c Compare September 20, 2025 14:42
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@frank-king
Copy link
Contributor Author

The CI failed because Drop::drop becomes a provided method. I'm afraid it might not be a good way to hack into librustdoc. Is there any other good way to fix it?

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
[TIMING:end] tool::ToolBuild { build_compiler: Compiler { stage: 0, host: aarch64-unknown-linux-gnu, forced_compiler: false }, target: aarch64-unknown-linux-gnu, tool: "linkchecker", path: "src/tools/linkchecker", mode: ToolBootstrap, source_type: InTree, extra_features: [], allow_features: "", cargo_args: [], artifact_kind: Binary } -- 0.156
[TIMING:end] tool::Linkchecker { compiler: Compiler { stage: 0, host: aarch64-unknown-linux-gnu, forced_compiler: false }, target: aarch64-unknown-linux-gnu } -- 0.000
##[group]Testing stage1 Linkcheck (aarch64-unknown-linux-gnu)
book/print.html:3462: broken link fragment `#tymethod.drop` pointing to `std/ops/trait.Drop.html`
book/ch04-01-what-is-ownership.html:386: broken link fragment `#tymethod.drop` pointing to `std/ops/trait.Drop.html`
checked links in: 22.2s
number of HTML files scanned: 46122
number of HTML redirects found: 14532
number of links checked: 2531852
number of links ignored due to external: 121023
---
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage1-tools-bin/linkchecker /checkout/obj/build/aarch64-unknown-linux-gnu/doc` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1561:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:171:77

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:38:24
  local time: Tue Sep 23 01:38:46 UTC 2025
  network time: Tue, 23 Sep 2025 01:38:47 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@bors
Copy link
Collaborator

bors commented Sep 23, 2025

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

@Dylan-DPC Dylan-DPC added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: Assignment between coroutine saved locals whose storage is not marked as conflicting
5 participants