Skip to content

fix error when a dangling ref in a ManuallyDrop is used in a pattern#159707

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:dangling-ref-in-pattern
Jul 22, 2026
Merged

fix error when a dangling ref in a ManuallyDrop is used in a pattern#159707
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:dangling-ref-in-pattern

Conversation

@RalfJung

@RalfJung RalfJung commented Jul 22, 2026

Copy link
Copy Markdown
Member

Fixes #159701
Cc @rust-lang/wg-const-eval

@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 22, 2026
@RalfJung

Copy link
Copy Markdown
Member Author

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 22, 2026
remove StructuralPartialEq from MaybeDangling and ManuallyDrop
@rust-log-analyzer

This comment has been minimized.

@RalfJung
RalfJung force-pushed the dangling-ref-in-pattern branch from c73f4ac to 83c3709 Compare July 22, 2026 09:39
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: c5a809f (c5a809f60f7ac1395e7e475e6c7ef0f79f4667bd)
Base parent: 1af98b7 (1af98b7cdf86932b76182a387f52f1be6f0c1be0)

@RalfJung

Copy link
Copy Markdown
Member Author

Ah, we have a test specifically checking that it can be used in a match.^^
That's from #154890, Cc @WaffleLapkin

Still seems worth taking back if we can.
@craterbot check

@craterbot

Copy link
Copy Markdown
Collaborator

👌 Experiment pr-159707 created and queued.
🤖 Automatically detected try build c5a809f
⚠️ Try build based on commit c73f4ac, but latest commit is 83c3709. Did you forget to make a new try build?
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 22, 2026
@RalfJung

Copy link
Copy Markdown
Member Author

Apparently this has worked since Rust 1.31 so... actually it's probably not worth trying to take this back. We should just give a better error message for this case.

@craterbot cancel

@craterbot

Copy link
Copy Markdown
Collaborator

🗑️ Experiment pr-159707 deleted!

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Jul 22, 2026
@WaffleLapkin

Copy link
Copy Markdown
Member

@RalfJung I think this is potentially still worth to try to take back; using ManuallyDrop in matches seems dubious and (possibly more importantly) not really useful?

@RalfJung

Copy link
Copy Markdown
Member Author

I feel like a breaking change for something that worked for >5 years should have a stronger motivation than that.

@RalfJung
RalfJung force-pushed the dangling-ref-in-pattern branch from 83c3709 to c22fbbe Compare July 22, 2026 13:26
@RalfJung RalfJung changed the title remove StructuralPartialEq from MaybeDangling and ManuallyDrop fix error when a dangling ref in a ManuallyDrop is used in a pattern Jul 22, 2026
@RalfJung
RalfJung marked this pull request as ready for review July 22, 2026 13:27
@rustbot

rustbot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 20 candidates

@WaffleLapkin WaffleLapkin left a comment

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.

@rust-bors

rust-bors Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c22fbbe has been approved by WaffleLapkin

It is now in the queue for this repository.

@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-review Status: Awaiting review from the assignee but also interested parties. labels Jul 22, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 22, 2026
…r=WaffleLapkin

fix error when a dangling ref in a ManuallyDrop is used in a pattern

Fixes rust-lang#159701
Cc @rust-lang/wg-const-eval
rust-bors Bot pushed a commit that referenced this pull request Jul 22, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #159712 (Subtree sync for rustc_codegen_cranelift)
 - #155697 (Stabilize c-variadic function definitions)
 - #159285 (Simplify `apply_effects_in_range`)
 - #159596 (unify the AST repr of type const and const RHS)
 - #159607 (test: update riscv32e-registers.rs for LLVM 24 MC diagnostic changes)
 - #159659 (Move `Limit` out of `rustc_hir`)
 - #159707 (fix error when a dangling ref in a ManuallyDrop is used in a pattern)
 - #158479 (Reject static item as direct const generic arg)
 - #158738 (next_trait_solver: Recover from GCE const exprs)
 - #159451 (Remove config cloning in compiletest)
 - #159646 (Increase depth for float infer var fallback hack)
 - #159705 (bootstrap: Prefer `cfg!(not(test))` when skipping code paths during unit tests)
rust-bors Bot pushed a commit that referenced this pull request Jul 22, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #159712 (Subtree sync for rustc_codegen_cranelift)
 - #155697 (Stabilize c-variadic function definitions)
 - #159285 (Simplify `apply_effects_in_range`)
 - #159596 (unify the AST repr of type const and const RHS)
 - #159607 (test: update riscv32e-registers.rs for LLVM 24 MC diagnostic changes)
 - #159659 (Move `Limit` out of `rustc_hir`)
 - #159707 (fix error when a dangling ref in a ManuallyDrop is used in a pattern)
 - #158738 (next_trait_solver: Recover from GCE const exprs)
 - #159451 (Remove config cloning in compiletest)
 - #159646 (Increase depth for float infer var fallback hack)
 - #159705 (bootstrap: Prefer `cfg!(not(test))` when skipping code paths during unit tests)
@rust-bors
rust-bors Bot merged commit 9111027 into rust-lang:main Jul 22, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 22, 2026
rust-timer added a commit that referenced this pull request Jul 22, 2026
Rollup merge of #159707 - RalfJung:dangling-ref-in-pattern, r=WaffleLapkin

fix error when a dangling ref in a ManuallyDrop is used in a pattern

Fixes #159701
Cc @rust-lang/wg-const-eval
Kobzol pushed a commit to Kobzol/rustc_codegen_cranelift that referenced this pull request Jul 23, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#159712 (Subtree sync for rustc_codegen_cranelift)
 - rust-lang/rust#155697 (Stabilize c-variadic function definitions)
 - rust-lang/rust#159285 (Simplify `apply_effects_in_range`)
 - rust-lang/rust#159596 (unify the AST repr of type const and const RHS)
 - rust-lang/rust#159607 (test: update riscv32e-registers.rs for LLVM 24 MC diagnostic changes)
 - rust-lang/rust#159659 (Move `Limit` out of `rustc_hir`)
 - rust-lang/rust#159707 (fix error when a dangling ref in a ManuallyDrop is used in a pattern)
 - rust-lang/rust#158738 (next_trait_solver: Recover from GCE const exprs)
 - rust-lang/rust#159451 (Remove config cloning in compiletest)
 - rust-lang/rust#159646 (Increase depth for float infer var fallback hack)
 - rust-lang/rust#159705 (bootstrap: Prefer `cfg!(not(test))` when skipping code paths during unit tests)
moabo3li pushed a commit to moabo3li/miri that referenced this pull request Jul 23, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#159712 (Subtree sync for rustc_codegen_cranelift)
 - rust-lang/rust#155697 (Stabilize c-variadic function definitions)
 - rust-lang/rust#159285 (Simplify `apply_effects_in_range`)
 - rust-lang/rust#159596 (unify the AST repr of type const and const RHS)
 - rust-lang/rust#159607 (test: update riscv32e-registers.rs for LLVM 24 MC diagnostic changes)
 - rust-lang/rust#159659 (Move `Limit` out of `rustc_hir`)
 - rust-lang/rust#159707 (fix error when a dangling ref in a ManuallyDrop is used in a pattern)
 - rust-lang/rust#158738 (next_trait_solver: Recover from GCE const exprs)
 - rust-lang/rust#159451 (Remove config cloning in compiletest)
 - rust-lang/rust#159646 (Increase depth for float infer var fallback hack)
 - rust-lang/rust#159705 (bootstrap: Prefer `cfg!(not(test))` when skipping code paths during unit tests)
@RalfJung
RalfJung deleted the dangling-ref-in-pattern branch July 24, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

ManuallyDrop allows storing invalid references in consts and statics.

6 participants