Skip to content

Generalise (most) impls on Box - #161946

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
nia-e:more-box-impls
Sep 9, 2026
Merged

Generalise (most) impls on Box#161946
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
nia-e:more-box-impls

Conversation

@nia-e

@nia-e nia-e commented Aug 28, 2026

Copy link
Copy Markdown
Member

View all comments

Resolves the trait impl concern for #156882; Default wasn't touched since changing that would be breaking, but hopefully all of this should be fine - I'll do a crater run to be sure. Certain impls that were for one reason or another Annoying to generalise (e.g. Clone for Box<Path>) were also untouched since I believe we can add those in the future, as they're on concrete types.

r? clarfonthey

@rustbot rustbot added O-solid Operating System: SOLID O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 28, 2026
@nia-e

nia-e commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

also should do a perf run since monomorphisation.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 28, 2026
Generalise (most) impls on `Box`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 28, 2026
@nia-e nia-e added A-allocators Area: Custom and system allocators S-waiting-on-perf Status: Waiting on a perf run to be completed. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 28, 2026
@clarfonthey

Copy link
Copy Markdown
Contributor

r=me pending crater + perf

@rust-bors

rust-bors Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 0c3b2c2 (0c3b2c226322b623e493b7611e4909ee6bc6a48d)
Base parent: 344f790 (344f7902949345394fa40a5d7dda31f012ccbc0d)

@rust-timer

This comment has been minimized.

@nia-e

nia-e commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

@craterbot check

@craterbot

Copy link
Copy Markdown
Collaborator

👌 Experiment pr-161946 created and queued.
🤖 Automatically detected try build 0c3b2c2
🔍 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-perf Status: Waiting on a perf run to be completed. labels Aug 28, 2026
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0c3b2c2): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

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

Max RSS (memory usage)

Results (primary 3.2%, secondary -0.3%)

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

mean range count
Regressions ❌
(primary)
9.0% [9.0%, 9.0%] 1
Regressions ❌
(secondary)
4.1% [1.6%, 8.7%] 5
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
-4.6% [-5.7%, -2.4%] 5
All ❌✅ (primary) 3.2% [-2.6%, 9.0%] 2

Cycles

Results (primary 2.7%, secondary -11.8%)

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

mean range count
Regressions ❌
(primary)
2.7% [2.7%, 2.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-11.8% [-20.6%, -3.9%] 7
All ❌✅ (primary) 2.7% [2.7%, 2.7%] 1

Binary size

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

Bootstrap: 475.673s -> 475.454s (-0.05%)
Artifact size: 403.60 MiB -> 402.86 MiB (-0.18%)

@nia-e

nia-e commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

that's a nothingburger, nice. time to just wait a zillion years for crater lol

@theemathas

Copy link
Copy Markdown
Contributor

Is there a reason impl<T> From<T> for Box<T> wasn't generalized?

And how is changing the Default impl breaking?

@zachs18

zachs18 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

I'm think this is the issue Nia's referring to: the Default impl would break type inference in some cases (playground). The From impl could also have the same issue (playground). So, those impls would probably need at least a crater run.

cc https://faultlore.com/blah/defaults-affect-inference/ which discusses the same issue for why Default for Vec<T, A> wasn't generalized (yet ™️ ).

@clarfonthey

Copy link
Copy Markdown
Contributor

Is there a reason impl<T> From<T> for Box<T> wasn't generalized?

And how is changing the Default impl breaking?

Inference basically. It becomes ambiguous in allocator what a default box might mean, or a box converted from another type.

@theemathas theemathas mentioned this pull request Sep 3, 2026
@theemathas

Copy link
Copy Markdown
Contributor

@craterbot cancel

See #162233

@craterbot

Copy link
Copy Markdown
Collaborator

🗑️ Experiment pr-161946 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 Sep 3, 2026
@theemathas

Copy link
Copy Markdown
Contributor

@craterbot

Copy link
Copy Markdown
Collaborator

👌 Experiment pr-161946 created and queued.
🤖 Automatically detected try build 0c3b2c2
🔍 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-review Status: Awaiting review from the assignee but also interested parties. labels Sep 6, 2026
@nia-e

nia-e commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

looked at the regression list on the rollup and i think this pr was entirely harmless? if so yay

@craterbot

Copy link
Copy Markdown
Collaborator

🚧 Experiment pr-161946 is now running

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

@craterbot

Copy link
Copy Markdown
Collaborator

🎉 Experiment pr-161946 is completed!
📊 0 regressed and 0 fixed (7794 total)
📊 773 spurious results on the retry-regressed-list.txt, consider a retry1 if this is a significant amount.
📰 Open the summary report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Footnotes

  1. re-run the experiment with crates=https://crater-reports.s3.amazonaws.com/pr-161946/retry-regressed-list.txt

@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 Sep 8, 2026
@clarfonthey

Copy link
Copy Markdown
Contributor

Needs rebase for stable API timestamp (and thus has to be rollup=never) but otherwise good

@clarfonthey

Copy link
Copy Markdown
Contributor

Side note: confused myself into thinking this needed FCP but that's included as part of the allocator FCP

@nia-e

nia-e commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

yeah this is not gonna need rebase dw. per the above,

@bors r=clarfonthey

@rust-bors

rust-bors Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

📌 Commit f01082b has been approved by clarfonthey

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 9, 2026
@clarfonthey

Copy link
Copy Markdown
Contributor

Right, I guess this doesn't add new stable API.

rust-bors Bot pushed a commit that referenced this pull request Sep 9, 2026
Rollup of 8 pull requests

Successful merges:

 - #162412 (Fix msvc-specific differences in debuginfo tests)
 - #160651 (mir: validate `Move` call arguments are locals or box derefs)
 - #161946 (Generalise (most) impls on `Box`)
 - #162192 (normalize CoerceShared field types before relating)
 - #160518 (fix: fix no resolution for self import in namespaced crates)
 - #162509 (Avoid suggesting gated generic arguments for Fn-family traits)
 - #162521 (Don't explicitly specify `OnDuplicate::Error` as it is the default)
 - #162526 (yeet VisitorExt)
rust-bors Bot pushed a commit that referenced this pull request Sep 9, 2026
Rollup of 8 pull requests

Successful merges:

 - #162412 (Fix msvc-specific differences in debuginfo tests)
 - #160651 (mir: validate `Move` call arguments are locals or box derefs)
 - #161946 (Generalise (most) impls on `Box`)
 - #162192 (normalize CoerceShared field types before relating)
 - #160518 (fix: fix no resolution for self import in namespaced crates)
 - #162509 (Avoid suggesting gated generic arguments for Fn-family traits)
 - #162521 (Don't explicitly specify `OnDuplicate::Error` as it is the default)
 - #162526 (yeet VisitorExt)
rust-bors Bot pushed a commit that referenced this pull request Sep 9, 2026
Rollup of 8 pull requests

Successful merges:

 - #162412 (Fix msvc-specific differences in debuginfo tests)
 - #160651 (mir: validate `Move` call arguments are locals or box derefs)
 - #161946 (Generalise (most) impls on `Box`)
 - #162192 (normalize CoerceShared field types before relating)
 - #160518 (fix: fix no resolution for self import in namespaced crates)
 - #162509 (Avoid suggesting gated generic arguments for Fn-family traits)
 - #162521 (Don't explicitly specify `OnDuplicate::Error` as it is the default)
 - #162526 (yeet VisitorExt)
@rust-bors
rust-bors Bot merged commit 5df5032 into rust-lang:main Sep 9, 2026
14 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 9, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 9, 2026
Rollup merge of #161946 - nia-e:more-box-impls, r=clarfonthey

Generalise (most) impls on `Box`

Resolves the trait impl concern for #156882; `Default` wasn't touched since changing that would be breaking, but hopefully all of this should be fine - I'll do a crater run to be sure. Certain impls that were for one reason or another Annoying to generalise (e.g. `Clone for Box<Path>`) were also untouched since I believe we can add those in the future, as they're on concrete types.

r? clarfonthey
@lcnr lcnr added the relnotes Marks issues that should be documented in the release notes of the next release. label Sep 10, 2026
@lcnr

lcnr commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

even if this didn't cause any breakage on crater, generalizing these impls does cause potential inference breakage and might have been worth an FCP, does it not? Marking it as relnotes at least :>

@clarfonthey

Copy link
Copy Markdown
Contributor

Note: these are part of the allocator FCP which is currently happening FWIW.

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

Labels

A-allocators Area: Custom and system allocators O-solid Operating System: SOLID O-windows Operating system: Windows relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

8 participants