Skip to content

[compiler] Implement PartialOrd via Ord for Span and newtype_indexes - #158996

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
scottmcm:better-partial-cmp
Jul 10, 2026
Merged

[compiler] Implement PartialOrd via Ord for Span and newtype_indexes#158996
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
scottmcm:better-partial-cmp

Conversation

@scottmcm

Copy link
Copy Markdown
Member

For something unconditionally Ord, this is better than using partial_cmp on fields.

I couldn't find any other cases in the compiler codebase of this, but it's entirely possible I missed some. Let me know if you can think of any.

…dexes
For something unconditionally `Ord`, this is better than using `partial_cmp` on fields.
I couldn't find any other cases in the compiler codebase of this, but it's entirely possible I missed some. Let me know if you can think of any.
@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 9, 2026
@rustbot

Copy link
Copy Markdown
Collaborator

r? @folkertdev

rustbot has assigned @folkertdev.
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 75 candidates
  • Random selection from 18 candidates

@folkertdev

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-borsBot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 7269b96 has been approved by folkertdev

It is now in the queue for this repository.

@rust-borsrust-borsBot 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 9, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
…kertdev
[compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes
For something unconditionally `Ord`, this is better than using `partial_cmp` on fields.
I couldn't find any other cases in the compiler codebase of this, but it's entirely possible I missed some. Let me know if you can think of any.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
…kertdev
[compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes
For something unconditionally `Ord`, this is better than using `partial_cmp` on fields.
I couldn't find any other cases in the compiler codebase of this, but it's entirely possible I missed some. Let me know if you can think of any.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
…kertdev
[compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes
For something unconditionally `Ord`, this is better than using `partial_cmp` on fields.
I couldn't find any other cases in the compiler codebase of this, but it's entirely possible I missed some. Let me know if you can think of any.
@Kobzol

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

Just to make sure, spans are quite hot.

@rust-timer

This comment has been minimized.

@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 9, 2026
@rust-bors

This comment has been minimized.

rust-borsBot pushed a commit that referenced this pull request Jul 9, 2026
[compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes
rust-borsBot pushed a commit that referenced this pull request Jul 9, 2026
…uwer
Rollup of 21 pull requests
Successful merges:
- #150946 (intrinsics: Add a fallback for non-const libm float functions)
- #158510 (Enable `static_position_independent_executables` on all gnu and musl targets)
- #158541 (Move `std::io::Write` to `core::io`)
- #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`)
- #155429 (Support `u128`/`i128` c-variadic arguments)
- #156370 (Reject linked dylib EII default overrides)
- #156508 (Infer all anonymous lifetimes in assoc consts as `'static`)
- #158617 (allow mGCA const arguments to fall back to anon consts)
- #158645 (Fix splat ICEs and ban it in closures)
- #158859 (Improve `-Zls` diagnostic message on `.rs` files)
- #158988 (Redo `TokenStreamIter`)
- #158347 (Improve generic parameters handling for #[diagnostic::on_const])
- #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
- #158739 (view-types: HIR lowering)
- #158883 (tests: fix enum-match.rs to handle LLVM 23)
- #158886 (Add documentation for the `no_std` attribute)
- #158940 (Implement feature `char_to_u32`)
- #158951 (Merge three `MaxUniverse`s into one)
- #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
- #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
- #159005 (Use `as_lang_item` instead of repeatedly matching)
@rust-bors

rust-borsBot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 5e75c18 (5e75c1827c11c6e0f4cf5e862d7febc153bee8aa)
Base parent: 561ea2b (561ea2bfa3022226082e2db39d6ccb241e9e34bc)

@rust-timer

This comment has been minimized.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
…kertdev
[compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes
For something unconditionally `Ord`, this is better than using `partial_cmp` on fields.
I couldn't find any other cases in the compiler codebase of this, but it's entirely possible I missed some. Let me know if you can think of any.
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (5e75c18): comparison URL.

Overall result: no relevant changes - 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

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

Max RSS (memory usage)

Results (secondary 6.5%)

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

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
6.5%[6.5%, 6.5%]1
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)--0

Cycles

Results (primary 0.3%, secondary 0.1%)

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

meanrangecount
Regressions ❌
(primary)
2.6%[2.6%, 2.6%]1
Regressions ❌
(secondary)
2.6%[2.2%, 2.9%]4
Improvements ✅
(primary)
-2.1%[-2.1%, -2.1%]1
Improvements ✅
(secondary)
-3.2%[-4.4%, -2.2%]3
All ❌✅ (primary)0.3%[-2.1%, 2.6%]2

Binary size

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

Bootstrap: 489.147s -> 489.205s (0.01%)
Artifact size: 388.47 MiB -> 388.47 MiB (0.00%)

@rustbotrustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 9, 2026
rust-borsBot pushed a commit that referenced this pull request Jul 9, 2026
…uwer
Rollup of 24 pull requests
Successful merges:
- #150946 (intrinsics: Add a fallback for non-const libm float functions)
- #158510 (Enable `static_position_independent_executables` on all gnu and musl targets)
- #158541 (Move `std::io::Write` to `core::io`)
- #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`)
- #156027 (Consider captured regions for opaque type region liveness.)
- #156370 (Reject linked dylib EII default overrides)
- #156508 (Infer all anonymous lifetimes in assoc consts as `'static`)
- #157561 (rustdoc: do not include extra stuff in span)
- #158617 (allow mGCA const arguments to fall back to anon consts)
- #158645 (Fix splat ICEs and ban it in closures)
- #158859 (Improve `-Zls` diagnostic message on `.rs` files)
- #158988 (Redo `TokenStreamIter`)
- #158347 (Improve generic parameters handling for #[diagnostic::on_const])
- #158384 (Allow BackwardIncompatibleDropHint in polonius legacy)
- #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
- #158739 (view-types: HIR lowering)
- #158877 (borrowck: Keep returned `path` from `best_blame_constraint()` consistent)
- #158883 (tests: fix enum-match.rs to handle LLVM 23)
- #158886 (Add documentation for the `no_std` attribute)
- #158940 (Implement feature `char_to_u32`)
- #158951 (Merge three `MaxUniverse`s into one)
- #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
- #158995 (Use REST API in linkchecker script)
- #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 9, 2026
…kertdev
[compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes
For something unconditionally `Ord`, this is better than using `partial_cmp` on fields.
I couldn't find any other cases in the compiler codebase of this, but it's entirely possible I missed some. Let me know if you can think of any.
@jhprattjhpratt mentioned this pull request Jul 9, 2026
@jhprattjhpratt mentioned this pull request Jul 10, 2026
rust-borsBot pushed a commit that referenced this pull request Jul 10, 2026
Rollup of 24 pull requests
Successful merges:
- #150946 (intrinsics: Add a fallback for non-const libm float functions)
- #158541 (Move `std::io::Write` to `core::io`)
- #156027 (Consider captured regions for opaque type region liveness.)
- #156370 (Reject linked dylib EII default overrides)
- #156508 (Infer all anonymous lifetimes in assoc consts as `'static`)
- #157561 (rustdoc: do not include extra stuff in span)
- #158617 (allow mGCA const arguments to fall back to anon consts)
- #158645 (Fix splat ICEs and ban it in closures)
- #158859 (Improve `-Zls` diagnostic message on `.rs` files)
- #158988 (Redo `TokenStreamIter`)
- #158347 (Improve generic parameters handling for #[diagnostic::on_const])
- #158384 (Allow BackwardIncompatibleDropHint in polonius legacy)
- #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
- #158739 (view-types: HIR lowering)
- #158877 (borrowck: Keep returned `path` from `best_blame_constraint()` consistent)
- #158883 (tests: fix enum-match.rs to handle LLVM 23)
- #158886 (Add documentation for the `no_std` attribute)
- #158940 (Implement feature `char_to_u32`)
- #158951 (Merge three `MaxUniverse`s into one)
- #158960 (Fix bootstrap submodule path prefix matching)
- #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
- #158995 (Use REST API in linkchecker script)
- #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
- #159036 (bootstrap: expand '@argfile' arguments to rustc shim)
@rust-bors
rust-borsBot merged commit adf4488 into rust-lang:mainJul 10, 2026
14 checks passed
rust-timer added a commit that referenced this pull request Jul 10, 2026
Rollup merge of #158996 - scottmcm:better-partial-cmp, r=folkertdev
[compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes
For something unconditionally `Ord`, this is better than using `partial_cmp` on fields.
I couldn't find any other cases in the compiler codebase of this, but it's entirely possible I missed some. Let me know if you can think of any.
@scottmcm
scottmcm deleted the better-partial-cmp branch July 10, 2026 06:50
@JonathanBrouwer

Copy link
Copy Markdown
Member

@rust-timer build 4db5f96

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (4db5f96): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@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.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
0.2%[0.0%, 0.3%]11
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)--0

Max RSS (memory usage)

Results (primary -3.6%, secondary -3.4%)

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

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
-3.6%[-3.6%, -3.6%]1
Improvements ✅
(secondary)
-3.4%[-7.3%, -1.4%]4
All ❌✅ (primary)-3.6%[-3.6%, -3.6%]1

Cycles

Results (secondary -0.7%)

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

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
4.7%[2.4%, 8.8%]4
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-3.4%[-8.9%, -1.4%]8
All ❌✅ (primary)--0

Binary size

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

Bootstrap: 490.768s -> 489.353s (-0.29%)
Artifact size: 389.74 MiB -> 389.20 MiB (-0.14%)

@rustbotrustbot added the perf-regression Performance regression. label Jul 12, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@rustbot label: +perf-regression-triaged
Noise

@rustbotrustbot added the perf-regression-triaged The performance regression has been triaged. label Jul 12, 2026
@cuvipercuviper added this to the 1.99.0 milestone Jul 20, 2026
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Aug 17, 2026
Rollup of 24 pull requests
Successful merges:
- rust-lang/rust#150946 (intrinsics: Add a fallback for non-const libm float functions)
- rust-lang/rust#158541 (Move `std::io::Write` to `core::io`)
- rust-lang/rust#156027 (Consider captured regions for opaque type region liveness.)
- rust-lang/rust#156370 (Reject linked dylib EII default overrides)
- rust-lang/rust#156508 (Infer all anonymous lifetimes in assoc consts as `'static`)
- rust-lang/rust#157561 (rustdoc: do not include extra stuff in span)
- rust-lang/rust#158617 (allow mGCA const arguments to fall back to anon consts)
- rust-lang/rust#158645 (Fix splat ICEs and ban it in closures)
- rust-lang/rust#158859 (Improve `-Zls` diagnostic message on `.rs` files)
- rust-lang/rust#158988 (Redo `TokenStreamIter`)
- rust-lang/rust#158347 (Improve generic parameters handling for #[diagnostic::on_const])
- rust-lang/rust#158384 (Allow BackwardIncompatibleDropHint in polonius legacy)
- rust-lang/rust#158722 (delegation: do not always inherit `ConstArgHasType` predicates)
- rust-lang/rust#158739 (view-types: HIR lowering)
- rust-lang/rust#158877 (borrowck: Keep returned `path` from `best_blame_constraint()` consistent)
- rust-lang/rust#158883 (tests: fix enum-match.rs to handle LLVM 23)
- rust-lang/rust#158886 (Add documentation for the `no_std` attribute)
- rust-lang/rust#158940 (Implement feature `char_to_u32`)
- rust-lang/rust#158951 (Merge three `MaxUniverse`s into one)
- rust-lang/rust#158960 (Fix bootstrap submodule path prefix matching)
- rust-lang/rust#158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
- rust-lang/rust#158995 (Use REST API in linkchecker script)
- rust-lang/rust#158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
- rust-lang/rust#159036 (bootstrap: expand '@argfile' arguments to rustc shim)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regressionPerformance regression.perf-regression-triagedThe performance regression has been triaged.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@scottmcm@rustbot@folkertdev@Kobzol@rust-timer@JonathanBrouwer@cuviper