Skip to content

Forward all array PartialOrd to slices - #160996

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
scottmcm:too-many-ampersands-2
Aug 15, 2026
Merged

Forward all array PartialOrd to slices#160996
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
scottmcm:too-many-ampersands-2

Conversation

@scottmcm

@scottmcm scottmcm commented Aug 12, 2026

Copy link
Copy Markdown
Member

I happened to notice that these have had too many &s since before 1.0 -- it ends up using &[T]: PartialOrd and thus wastefully need to forward to [T]: PartialOrd.

So re-written to specify the implementation to which we're trying to delegate explicitly (by writing <[T] as PartialOrd>) which means we no longer need the &&self[..]-style dance at all since the unsizing coercion will do the right thing.

And while I was here delegating stuff, it also delegates the __chaining_* methods, since those have custom overrides for slices (#138881) and we ought to take advantage of that for arrays too.


No LLM used.

@rustbot rustbot added 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 12, 2026
@rustbot

rustbot commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

rustbot has assigned @JohnTitor.
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: libs
  • libs expanded to 12 candidates
  • Random selection from JohnTitor, Mark-Simulacrum, clarfonthey, nia-e

@JohnTitor JohnTitor 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 Aug 15, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 2ea4f2d has been approved by JohnTitor

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

Rollup of 5 pull requests

Successful merges:

 - #160203 (`Iterator::{min,max}(_by_key)` should use overridden `min`/`max`/`lt`)
 - #159862 (Update expect messages for library/alloc/src/vec/mod.rs)
 - #160719 (Improve OpenOptions append+truncate error message)
 - #160996 (Forward all array `PartialOrd` to slices)
 - #161102 (Explicitly pass run_make_support rlib/rmeta paths to compiletest)
@rust-bors
rust-bors Bot merged commit 8a2cd78 into rust-lang:main Aug 15, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 15, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 15, 2026
Rollup merge of #160996 - scottmcm:too-many-ampersands-2, r=JohnTitor

Forward all array `PartialOrd` to slices

I happened to notice that these have had too many `&`s since before 1.0 -- it ends up using `&[T]: PartialOrd` and thus wastefully need to forward to `[T]: PartialOrd`.

So re-written to specify the implementation to which we're trying to delegate explicitly (by writing `<[T] as PartialOrd>`) which means we no longer need the `&&self[..]`-style dance at all since the unsizing coercion will do the right thing.

And while I was here delegating stuff, it also delegates the `__chaining_*` methods, since those have custom overrides for slices (#138881) and we ought to take advantage of that for arrays too.
rust-timer added a commit that referenced this pull request Aug 15, 2026
Rollup merge of #160996 - scottmcm:too-many-ampersands-2, r=JohnTitor

Forward all array `PartialOrd` to slices

I happened to notice that these have had too many `&`s since before 1.0 -- it ends up using `&[T]: PartialOrd` and thus wastefully need to forward to `[T]: PartialOrd`.

So re-written to specify the implementation to which we're trying to delegate explicitly (by writing `<[T] as PartialOrd>`) which means we no longer need the `&&self[..]`-style dance at all since the unsizing coercion will do the right thing.

And while I was here delegating stuff, it also delegates the `__chaining_*` methods, since those have custom overrides for slices (#138881) and we ought to take advantage of that for arrays too.
@scottmcm
scottmcm deleted the too-many-ampersands-2 branch August 16, 2026 05:48
@scottmcm
scottmcm restored the too-many-ampersands-2 branch August 16, 2026 05:50
@scottmcm
scottmcm deleted the too-many-ampersands-2 branch August 16, 2026 05:51
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-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.

3 participants