Skip to content

Add const Default impls for HashSet and HashMap with custom Hasher#151190

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
estebank:const-default-hashmap
Jan 18, 2026
Merged

Add const Default impls for HashSet and HashMap with custom Hasher#151190
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
estebank:const-default-hashmap

Conversation

@estebank
Copy link
Copy Markdown
Contributor

@estebank estebank commented Jan 16, 2026

Follow up to #134628. Tracking issue #143894.

r? @fmease

cc @fee1-dead @oli-obk

This doesn't allow for const H: HashSet<()> = Default::default();, but would allow for it to work with a custom hasher, which would enable the Fx* family to work.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 16, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jan 16, 2026

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

@fmease fmease changed the title Add const Default impls for HashSet and HashMap with custom Hahser Add const Default impls for HashSet and HashMap with custom Hasher Jan 16, 2026
Comment thread library/core/src/hash/mod.rs
@estebank estebank force-pushed the const-default-hashmap branch from 3173ea4 to 5f58acb Compare January 16, 2026 16:32
@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Jan 17, 2026

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Jan 17, 2026

📌 Commit 5f58acb has been approved by oli-obk

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 Jan 17, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 18, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Jan 18, 2026

☀️ Test successful - CI
Approved by: oli-obk
Pushing cd7ad97 to main...

@rust-bors rust-bors bot merged commit cd7ad97 into rust-lang:main Jan 18, 2026
12 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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 fe98ddc (parent) -> cd7ad97 (this PR)

Test differences

Show 226 test diffs

226 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard cd7ad97987010603f0007288547927e648e9a369 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-apple: 6992.9s -> 8163.6s (+16.7%)
  2. dist-x86_64-apple: 7357.9s -> 8247.1s (+12.1%)
  3. dist-apple-various: 3943.8s -> 3507.2s (-11.1%)
  4. x86_64-gnu-llvm-21-3: 5986.2s -> 6640.1s (+10.9%)
  5. x86_64-gnu-tools: 3276.4s -> 3631.3s (+10.8%)
  6. x86_64-gnu-llvm-20-2: 5055.2s -> 5598.8s (+10.8%)
  7. aarch64-msvc-2: 6089.5s -> 6716.2s (+10.3%)
  8. dist-aarch64-msvc: 5441.3s -> 5992.0s (+10.1%)
  9. x86_64-msvc-2: 8303.7s -> 9141.8s (+10.1%)
  10. dist-x86_64-msvc-alt: 8978.1s -> 9846.4s (+9.7%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (cd7ad97): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -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)
4.7% [4.7%, 4.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.8% [-2.8%, -2.8%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.0% [-2.8%, 4.7%] 2

Cycles

Results (primary -4.8%, secondary 4.1%)

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)
4.1% [3.6%, 4.6%] 2
Improvements ✅
(primary)
-4.8% [-4.8%, -4.8%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.8% [-4.8%, -4.8%] 1

Binary size

Results (primary -0.1%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.1%, 0.1%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.6%, -0.1%] 5
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-0.6%, 0.1%] 7

Bootstrap: 473.229s -> 472.349s (-0.19%)
Artifact size: 383.52 MiB -> 383.53 MiB (0.00%)

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 13, 2026
…hpratt

Add `const Default` impls for `LazyCell` and `LazyLock`

Follow up to these commits by @estebank rust-lang#134628 and rust-lang#151190.
Tracking issue rust-lang#143894.

cc @fmease @fee1-dead @oli-obk

This enables `static L: LazyLock<D> = Default::default()`  for any type `D: Default` which is safe as `D::default()` is only evaluated at runtime.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 13, 2026
…hpratt

Add `const Default` impls for `LazyCell` and `LazyLock`

Follow up to these commits by @estebank rust-lang#134628 and rust-lang#151190.
Tracking issue rust-lang#143894.

cc @fmease @fee1-dead @oli-obk

This enables `static L: LazyLock<D> = Default::default()`  for any type `D: Default` which is safe as `D::default()` is only evaluated at runtime.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 13, 2026
…hpratt

Add `const Default` impls for `LazyCell` and `LazyLock`

Follow up to these commits by @estebank rust-lang#134628 and rust-lang#151190.
Tracking issue rust-lang#143894.

cc @fmease @fee1-dead @oli-obk

This enables `static L: LazyLock<D> = Default::default()`  for any type `D: Default` which is safe as `D::default()` is only evaluated at runtime.
rust-timer added a commit that referenced this pull request Apr 13, 2026
Rollup merge of #154929 - davidgauch:const-default-lazy, r=jhpratt

Add `const Default` impls for `LazyCell` and `LazyLock`

Follow up to these commits by @estebank #134628 and #151190.
Tracking issue #143894.

cc @fmease @fee1-dead @oli-obk

This enables `static L: LazyLock<D> = Default::default()`  for any type `D: Default` which is safe as `D::default()` is only evaluated at runtime.
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Apr 13, 2026
Add `const Default` impls for `LazyCell` and `LazyLock`

Follow up to these commits by @estebank rust-lang/rust#134628 and rust-lang/rust#151190.
Tracking issue rust-lang/rust#143894.

cc @fmease @fee1-dead @oli-obk

This enables `static L: LazyLock<D> = Default::default()`  for any type `D: Default` which is safe as `D::default()` is only evaluated at runtime.
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Apr 16, 2026
Add `const Default` impls for `LazyCell` and `LazyLock`

Follow up to these commits by @estebank rust-lang/rust#134628 and rust-lang/rust#151190.
Tracking issue rust-lang/rust#143894.

cc @fmease @fee1-dead @oli-obk

This enables `static L: LazyLock<D> = Default::default()`  for any type `D: Default` which is safe as `D::default()` is only evaluated at runtime.
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. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants