Skip to content

Remove Clone impl for StableHashingContext.#154744

Open
nnethercote wants to merge 1 commit intorust-lang:mainfrom
nnethercote:rm-Clone-for-StableHashingContext
Open

Remove Clone impl for StableHashingContext.#154744
nnethercote wants to merge 1 commit intorust-lang:mainfrom
nnethercote:rm-Clone-for-StableHashingContext

Conversation

@nnethercote
Copy link
Copy Markdown
Contributor

@nnethercote nnethercote commented Apr 3, 2026

HashStable::hash_stable takes a &mut Hcx. In contrast, ToStableHashKey::to_stable_hash_key takes a &Hcx. But there are some places where the latter calls the former, and due to the mismatch a clone call is required to get a mutable StableHashingContext.

This commit changes to_stable_hash_key to instead take a &mut Hcx. This eliminates the mismatch, the need for the clones, and the need for the Clone impls.

r? @fee1-dead

`HashStable::hash_stable` takes a `&mut Hcx`. In contrast,
`ToStableHashKey::to_stable_hash_key` takes a `&Hcx`. But there are
some places where the latter calls the former, and due to the mismatch a
`clone` call is required to get a mutable `StableHashingContext`.

This commit changes `to_stable_hash_key` to instead take a `&mut Hcx`.
This eliminates the mismatch, the need for the clones, and the need for
the `Clone` impls.
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 3, 2026
@nnethercote
Copy link
Copy Markdown
Contributor Author

@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 Apr 3, 2026
…, r=<try>

Remove `Clone` impl for `StableHashingContext`.
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 3, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 3, 2026

☀️ Try build successful (CI)
Build commit: b67d172 (b67d172374c3229c5c67970f61c951ccc3d2641b, parent: 55e86c996809902e8bbad512cfb4d2c18be446d9)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (b67d172): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (primary -1.0%)

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

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

Cycles

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

Binary size

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

Bootstrap: 486.952s -> 486.532s (-0.09%)
Artifact size: 395.04 MiB -> 395.07 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 3, 2026
@nnethercote nnethercote marked this pull request as ready for review April 3, 2026 08:47
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 3, 2026

fee1-dead is not on the review rotation at the moment.
They may take a while to respond.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 3, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 3, 2026

The Miri subtree was changed

cc @rust-lang/miri

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 3, 2026
@nnethercote
Copy link
Copy Markdown
Contributor Author

This PR makes hash_stable and to_stable_hash_key match by making them both use &mut Hcx. I also tried making them both use &Hcx (by using interior mutability) in #154735 but it was a slight performance regression.

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants