Skip to content

Remove Clone impl for StableHashingContext.#154744

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nnethercote:rm-Clone-for-StableHashingContext
Apr 6, 2026
Merged

Remove Clone impl for StableHashingContext.#154744
rust-bors[bot] merged 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.

@fee1-dead
Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 6, 2026

📌 Commit ff1795f has been approved by fee1-dead

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 Apr 6, 2026
rust-bors bot pushed a commit that referenced this pull request Apr 6, 2026
Rollup of 4 pull requests

Successful merges:

 - #152853 (deny-by-default & report in deps `uninhabited_static`)
 - #153615 (fixed generics of crate node ICE)
 - #154744 (Remove `Clone` impl for `StableHashingContext`.)
 - #154841 (add regression test for Redundant memory strores with mut parameters …)
@rust-bors rust-bors bot merged commit 24223a6 into rust-lang:main Apr 6, 2026
12 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 6, 2026
rust-timer added a commit that referenced this pull request Apr 6, 2026
Rollup merge of #154744 - nnethercote:rm-Clone-for-StableHashingContext, r=fee1-dead

Remove `Clone` impl for `StableHashingContext`.

`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
@nnethercote nnethercote deleted the rm-Clone-for-StableHashingContext branch April 6, 2026 22:53
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Apr 7, 2026
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#152853 (deny-by-default & report in deps `uninhabited_static`)
 - rust-lang/rust#153615 (fixed generics of crate node ICE)
 - rust-lang/rust#154744 (Remove `Clone` impl for `StableHashingContext`.)
 - rust-lang/rust#154841 (add regression test for Redundant memory strores with mut parameters …)
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-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