Skip to content

stop unleaking &muts in std and the compiler - #162766

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
maxdexh:unleak-considered-harmful
Sep 14, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
maxdexh:unleak-considered-harmful

Conversation

@maxdexh

@maxdexh maxdexh commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

As discussed on zulip, this PR removes all the dubious uses (I could find) of Box::leak from rustc and std

r? libs

@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 Sep 14, 2026
@maxdexh
maxdexh marked this pull request as ready for review September 14, 2026 13:18
@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 Sep 14, 2026
@maxdexh
maxdexh force-pushed the unleak-considered-harmful branch from 2aaa7e8 to fe15c63 Compare September 14, 2026 13:45
@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

miri is developed in its own repository. If the Miri part of this change can be broken out, consider making this change to rust-lang/miri instead. However, if Miri needs adjusting for rustc changes, just ignore this message.

cc @rust-lang/miri

@saethlin

Copy link
Copy Markdown
Member

I can't approve libs changes but count this as an approval for the compiler change

@hanna-kruppe

Copy link
Copy Markdown
Contributor

r? me @bors r=hanna-kruppe,saethlin rollup

@rust-bors

rust-bors Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

📌 Commit fe15c63 has been approved by hanna-kruppe,saethlin

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 Sep 14, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 14, 2026
…uwer

Rollup of 3 pull requests

Successful merges:

 - #162409 (Fix gap in const stability checks around intrinsics)
 - #162763 (Remove `Box::into_unique`)
 - #162766 (stop unleaking `&mut`s in std and the compiler)
@maxdexh

maxdexh commented Sep 14, 2026 •

Copy link
Copy Markdown
Member Author

@rust-bors
rust-bors Bot merged commit e7feb41 into rust-lang:main Sep 14, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 14, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 14, 2026
Rollup merge of #162766 - maxdexh:unleak-considered-harmful, r=hanna-kruppe,saethlin

stop unleaking `&mut`s in std and the compiler

As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/What.20is.20the.20current.20state.20of.20unleaking.20a.20.60Box.3CT.2C.20Global.3E.60.3F/with/623860839), this PR removes all the dubious uses (I could find) of `Box::leak` from rustc and std

r? libs
pull Bot pushed a commit to LeeeeeeM/miri that referenced this pull request Sep 15, 2026
…uwer

Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#162409 (Fix gap in const stability checks around intrinsics)
 - rust-lang/rust#162763 (Remove `Box::into_unique`)
 - rust-lang/rust#162766 (stop unleaking `&mut`s in std and the compiler)
@rust-timer

Copy link
Copy Markdown
Collaborator

Note

This PR was benchmarked as part of triage of its containing rollup: triage URL.

Finished benchmarking commit (913889f): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.4%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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

Cycles

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

Binary size

Results (secondary -1.2%)

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)
-1.2% [-1.4%, -1.2%] 4
All ❌✅ (primary) - - 0

Bootstrap: missing data
Artifact size: 406.86 MiB -> 406.89 MiB (0.01%)

@maxdexh
maxdexh deleted the unleak-considered-harmful branch September 15, 2026 16:59
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.

6 participants