Simplify HashStable#155018
Conversation
This comment has been minimized.
This comment has been minimized.
|
Why on earth is |
|
I just tried PR on an aarch64-unknown-linux-gnu box that I have and it compiled fine. Weird. |
This comment has been minimized.
This comment has been minimized.
3bc77fb to
9e9a113
Compare
| /// visible. | ||
| pub trait HashStableContext { | ||
| /// The main event: stable hashing of a span. | ||
| fn span_hash_stable(&mut self, span: RawSpan, hasher: &mut StableHasher); |
There was a problem hiding this comment.
| fn span_hash_stable(&mut self, span: RawSpan, hasher: &mut StableHasher); | |
| fn span_hash_stable(&mut self, span: Self::Span, hasher: &mut StableHasher); |
Perhaps Span, DefId and RawDefPathHash could be associated types in HashStableContext?
Then impl HashStableContext for StableHashingContext could fill them with concrete types.
If that works then "type erased" versions of the aforementioned types could be avoided.
There was a problem hiding this comment.
I tried that but I couldn't get it to work.
There was a problem hiding this comment.
Specifically, if I add an associate type MySpan to the trait, then in Span::hash_stable I get this error:
error[E0308]: mismatched types
--> compiler/rustc_span/src/lib.rs:2793:30
|
2793 | hcx.span_hash_stable(*self, hasher)
| ---------------- ^^^^^ expected associated type, found `Span`
| |
| arguments to this method are incorrect
|
= note: expected associated type `<Hcx as HashStableContext>::MySpan`
found struct `span_encoding::Span`
help: consider constraining the associated type `<Hcx as HashStableContext>::MySpan` to `span_encoding::Span`
|
2791 | fn hash_stable<Hcx: HashStableContext<MySpan = span_encoding::Span>>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
| ++++++++++++++++++++++++++++++
Then if I try the help suggestion I get this error:
error[E0271]: type mismatch resolving `<Hcx as HashStableContext>::MySpan == Span`
--> compiler/rustc_span/src/lib.rs:2791:43
|
2791 | ...ashStableContext<MySpan = Span>>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
| ^^^^^^^^^^^^^ expected `Span`, found associated type
|
= note: expected struct `span_encoding::Span`
found associated type `<Hcx as HashStableContext>::MySpan`
note: the requirement `<Hcx as HashStableContext>::MySpan == span_encoding::Span` appears on the `impl`'s method `hash_stable` but not on the corresponding trait's method
--> compiler/rustc_data_structures/src/stable_hasher.rs:82:8
In other words, the impl method no longer matches the trait method.
Maybe there's a way around this? I couldn't find one.
There was a problem hiding this comment.
You can probably make it work with appropriate bounds on the associated types for the impl, but that's going to be crate dependent so still doesn't play nicely with the proc macro. I think you'd need to keep the generic on the trait too.
This comment has been minimized.
This comment has been minimized.
|
This is blocked by #154924. |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9e9a113 to
ce139ba
Compare
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (959be73): 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 @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary 6.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 488.849s -> 492.643s (0.78%) |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
I added a new commit with the requested comment. @bors r=fee1-dead p=1 (conflict-prone) |
This comment has been minimized.
This comment has been minimized.
Simplify `HashStable` This PR: - Simplifies the `HashStable` trait, by moving its generic parameter from the trait to its single method. - Eliminates the need for the non-obvious `derive(HashStable)`/`derive(HashStable_Generic)` distinction. - Reduces the need for, and clarifies, the non-obvious `derive(HashStable)`/`derive(HashStable_NoContext)` distinction. r? @fee1-dead
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
💔 Test for e4a01d5 failed: CI. Failed job:
|
|
Unclear what went wrong. The last lines in the failing log are "Vendoring" steps. Doesn't seem related to anything in this PR. @bors retry |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 57f772f (parent) -> f53b654 (this PR) Test differencesShow 80 test diffs80 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard f53b654a8882fd5fc036c4ca7a4ff41ce32497a6 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (f53b654): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.9%, secondary -3.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis perf run didn't have relevant results for this metric. Binary sizeResults (secondary -0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 483.007s -> 487.787s (0.99%) |
View all comments
This PR:
HashStabletrait, by moving its generic parameter from the trait to its single method.derive(HashStable)/derive(HashStable_Generic)distinction.derive(HashStable)/derive(HashStable_NoContext)distinction.r? @fee1-dead