Skip to content

Add Drop::pin_drop for pinned drops#144537

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
frank-king:feature/pin-drop
May 10, 2026
Merged

Add Drop::pin_drop for pinned drops#144537
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
frank-king:feature/pin-drop

Conversation

@frank-king
Copy link
Copy Markdown
Contributor

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

View all comments

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 (i.e. types with #[pin_v2]).
  • Allows writing fn drop(&pin mut self) and desugars to fn pin_drop(&pin mut self). (Will be in the next PRs)

@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

This comment was marked as resolved.

@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
Copy Markdown
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

This comment has been minimized.

@bors

This comment was marked as resolved.

@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
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@frank-king frank-king force-pushed the feature/pin-drop branch 3 times, most recently from 9618d10 to c3e34d5 Compare November 7, 2025 12:45
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 4, 2026

💔 Test for edafd5c failed: CI. Failed job:

@frank-king

This comment has been minimized.

@petrochenkov
Copy link
Copy Markdown
Contributor

Broken links in the reference again.
@rustbot author

@P8L1

This comment was marked as resolved.

@ehuss
Copy link
Copy Markdown
Contributor

ehuss commented May 5, 2026

I think for fixing the test failure, I think I would prefer to do something like this:

diff --git a/src/ci/docker/scripts/x86_64-gnu-llvm3.sh b/src/ci/docker/scripts/x86_64-gnu-llvm3.sh
index 17eb2cea59a..d2989b3aae6 100755
--- a/src/ci/docker/scripts/x86_64-gnu-llvm3.sh
+++ b/src/ci/docker/scripts/x86_64-gnu-llvm3.sh
@@ -4,7 +4,9 @@ set -ex

 ##### Test stage 1 #####

-../x.py --stage 1 test --skip src/tools/tidy
+# linkchecker is skipped because mixing old rustc/rustdoc with new standard
+# library causes problems with generating correct links.
+../x.py --stage 1 test --skip src/tools/tidy --skip src/tools/linkchecker

 # Run the `mir-opt` tests again but this time for a 32-bit target.
 # This enforces that tests using `// EMIT_MIR_FOR_EACH_BIT_WIDTH` have

Generally I think it is too problematic to try to get the linkchecks working with --stage 1.

cc @jieyouxu @Kobzol in case you want to weigh in on this kind of change.

This was previously discussed at https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Skipping.20stage.201.20tests/with/583642338 for a closely related issue. In this case, I don't think we can employ easy tricks to make this work in the general case.

@jieyouxu
Copy link
Copy Markdown
Member

jieyouxu commented May 6, 2026

Generally I think it is too problematic to try to get the linkchecks working with --stage 1.

I would tend to agree. Should we extract the linkchecker change to a separate PR (I can review that bit)? (Though I'm fine with leaving the change in this PR too.)

@frank-king
Copy link
Copy Markdown
Contributor Author

I skipped the link check according to @ehuss's suggestion, and let's try it again?

@rustbot ready

@rust-log-analyzer

This comment has been minimized.

@frank-king

This comment was marked as resolved.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 9, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@petrochenkov
Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 9, 2026

📌 Commit 7c656d8 has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors

This comment has been minimized.

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test expr_store::scope::tests::test_resolve_local_name_shadow ... ok
test expr_store::tests::body::array_element_cfg ... ok
test expr_store::scope::tests::while_let_adds_binding ... ok
test expr_store::tests::body::block::inner_item_smoke ... ok
error: test failed, to rerun pass `-p hir-def --lib`

Caused by:
  process didn't exit successfully: `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/hir_def-c439368f2b64a049 '--skip=tests::smoke_test_real_sysroot_cargo' --skip=check_code_formatting -Z unstable-options --format json` (signal: 11, SIGSEGV: invalid memory reference)
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 1:11:59
  local time: Sat May  9 18:30:26 UTC 2026
  network time: Sat, 09 May 2026 18:30:26 GMT
##[error]Process completed with exit code 1.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 9, 2026

💔 Test for f56dcfe failed: CI. Failed job:

@P8L1
Copy link
Copy Markdown
Contributor

P8L1 commented May 10, 2026

@petrochenkov
@frank-king

I investigated the x86_64-gnu-llvm-21-1 SIGSEGV from the auto run.

The failed job crashed while running the stage2 rust-analyser hir_def libtest binary:

hir_def ... '--skip=tests::smoke_test_real_sysroot_cargo' --skip=check_code_formatting -Z unstable-options --format json
signal: 11, SIGSEGV

I tried to reproduce this on a temporary branch from the exact failing auto head SHA, focused reproduction run:

https://github.com/P8L1/rust/actions/runs/25625570467/

The hir_def libtest process ran successfully:

running 480 tests
Build completed successfully
exit code: 0

No SIGSEGV reproduced, and I did not make any Rust code changes.

Given that, I don’t think there is enough evidence for a code fix here yet. Could we retry the failed auto/CI job?

@petrochenkov
Copy link
Copy Markdown
Contributor

@bors retry

@rust-bors

This comment has been minimized.


impl Drop for StructWithDrop {
//~ MONO_ITEM fn <StructWithDrop as std::ops::Drop>::drop
//~ MONO_ITEM fn <StructWithDrop as std::ops::Drop>::pin_drop
Copy link
Copy Markdown
Member

@bjorn3 bjorn3 May 10, 2026

Choose a reason for hiding this comment

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

It is not possible to manually call drop, so maybe it would be possible to only codegen drop or pin_drop depending on which was implemented and then have the drop glue directly call the correct method?

View changes since the review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Opened a PR: #156495

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 10, 2026

☀️ Test successful - CI
Approved by: petrochenkov
Duration: 3h 15m 9s
Pushing e8f92f5 to main...

@github-actions
Copy link
Copy Markdown
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 99eed20 (parent) -> e8f92f5 (this PR)

Test differences

Show 30 test diffs

Stage 0

  • basic_broken: pass -> [missing] (J0)
  • broken_fragment_local: pass -> [missing] (J0)
  • broken_fragment_remote: pass -> [missing] (J0)
  • broken_intra_doc_link: pass -> [missing] (J0)
  • broken_redir: pass -> [missing] (J0)
  • directory_link: pass -> [missing] (J0)
  • redirect_loop: pass -> [missing] (J0)
  • valid: pass -> [missing] (J0)

Stage 1

  • [ui] tests/ui/pin-ergonomics/pinned-drop-check.rs: [missing] -> pass (J0)
  • [ui] tests/ui/pin-ergonomics/pinned-drop-unsafety-check.rs: [missing] -> pass (J0)
  • [ui] tests/ui/pin-ergonomics/pinned-drop.rs: [missing] -> pass (J0)

Stage 2

  • [ui] tests/ui/pin-ergonomics/pinned-drop-check.rs: [missing] -> pass (J1)
  • [ui] tests/ui/pin-ergonomics/pinned-drop-unsafety-check.rs: [missing] -> pass (J1)
  • [ui] tests/ui/pin-ergonomics/pinned-drop.rs: [missing] -> pass (J1)

Additionally, 16 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard e8f92f576974f7d1d5ef5dfafc56eae303b4c73e --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-msvc-ext1: 1h 40m -> 2h 18m (+38.4%)
  2. dist-ohos-armv7: 59m 43s -> 1h 14m (+24.1%)
  3. dist-x86_64-musl: 2h 15m -> 1h 43m (-23.5%)
  4. dist-arm-linux-musl: 1h 42m -> 1h 20m (-21.7%)
  5. dist-i686-msvc: 2h 14m -> 1h 47m (-20.1%)
  6. dist-powerpc64le-linux-gnu: 1h 34m -> 1h 16m (-19.0%)
  7. x86_64-mingw-1: 2h 41m -> 2h 12m (-18.3%)
  8. dist-aarch64-apple: 1h 55m -> 2h 16m (+17.5%)
  9. dist-android: 29m 10s -> 32m 18s (+10.7%)
  10. x86_64-gnu-llvm-21: 1h 16m -> 1h 24m (+9.9%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (e8f92f5): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary 1.5%, secondary 0.5%)

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

mean range count
Regressions ❌
(primary)
1.5% [1.5%, 1.5%] 1
Regressions ❌
(secondary)
2.3% [1.0%, 3.6%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.0% [-3.0%, -3.0%] 1
All ❌✅ (primary) 1.5% [1.5%, 1.5%] 1

Cycles

Results (secondary 3.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)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.1%, secondary -0.1%)

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.1% [-0.1%, -0.0%] 27
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 19
All ❌✅ (primary) -0.1% [-0.1%, -0.0%] 27

Bootstrap: 499.454s -> 501.011s (0.31%)
Artifact size: 397.23 MiB -> 397.14 MiB (-0.02%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. 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-infra Relevant to the infrastructure 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.