Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop sorting Spans' SyntaxContext, as that is incompatible with incremental #123165

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Mar 28, 2024

work towards #90317

Luckily no one actually needed these to be sorted, so it didn't even affect diagnostics. I'm guessing they'd have been sorted by creation time anyway, so it wouldn't really have mattered.

r? @cjgillot

@rustbot rustbot 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 Mar 28, 2024
@@ -460,21 +460,21 @@ impl Ord for SpanData {
let SpanData {
lo: s_lo,
hi: s_hi,
ctxt: s_ctxt,
ctxt: _,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a comment for macro expansions.
Side note: this Ord impl is not consistent with the derived impl for PartialEq. Should we fix the latter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about ensuring that for equal (including the sort-ignored fields) SpanDatas we just return Ordering::Equal, and only sort the others?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not consistent either.
The a == b implies partial_cmp(a, b) == Some(Equal) direction is easy. We have it without adding a special case.
The converse is harder: if s_lo == o_lo && s_hi == o_hi we get Some(Equal), but s_ctxt may not be o_ctxt.

Copy link
Contributor Author

@oli-obk oli-obk Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Spans should just be PartialOrd, but not Ord. I'll try if we can get away with just removing Ord

Edit: ah no, we need Ord for sort and friends.

Yea, idk how to solve this in a way that makes everything work out, except go full in with https://github.com/rust-lang/rust/compare/master...oli-obk:rust:no_ord_span?expand=1, no matter how annoying it is

@cjgillot cjgillot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 30, 2024
@oli-obk oli-obk 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 Apr 2, 2024
@petrochenkov
Copy link
Contributor

Is it hard to remove PartialOrd from Span and use some explicit location_only_ordering_hygiene_is_ignored method instead?
If the change affects SyntaxContext only, then the cure seems to be worse than the disease.

@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 3, 2024

@rustbot author

I'll explore that, but I think at least borrowck uses it to sort its diagnostics

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 3, 2024
@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 19, 2024

Is it hard to remove PartialOrd from Span and use some explicit location_only_ordering_hygiene_is_ignored method instead? If the change affects SyntaxContext only, then the cure seems to be worse than the disease.

I tried it, but sorting spans is used all over the compiler, even if we added convenience helpers for it, the right way would be to replace most of these spans with a SpanSortedByBytePos wrapper struct, everything else is too annoying. See https://github.com/rust-lang/rust/compare/master...oli-obk:rust:no_ord_span?expand=1 for a hacky way towards that

@rustbot
Copy link
Collaborator

rustbot commented Apr 19, 2024

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@oli-obk oli-obk 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 Jun 3, 2024
@cjgillot
Copy link
Contributor

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Jun 21, 2024

📌 Commit 4239a73 has been approved by cjgillot

It is now in the queue for this repository.

@bors bors 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 Jun 21, 2024
@bors
Copy link
Contributor

bors commented Jun 21, 2024

⌛ Testing commit 4239a73 with merge 25c9f2c...

@bors
Copy link
Contributor

bors commented Jun 21, 2024

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 25c9f2c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 21, 2024
@bors bors merged commit 25c9f2c into rust-lang:master Jun 21, 2024
13 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 21, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (25c9f2c): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.3% [0.3%, 0.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.3%, 0.3%] 1

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (secondary -2.6%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.6% [-2.6%, -2.6%] 2
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 694.36s -> 694.089s (-0.04%)
Artifact size: 326.84 MiB -> 326.85 MiB (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants