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

Tracking Issue for fn const BuildHasherDefault::new() #123197

Closed
3 tasks done
krtab opened this issue Mar 29, 2024 · 6 comments · Fixed by #133696
Closed
3 tasks done

Tracking Issue for fn const BuildHasherDefault::new() #123197

krtab opened this issue Mar 29, 2024 · 6 comments · Fixed by #133696
Assignees
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@krtab
Copy link
Contributor

krtab commented Mar 29, 2024

Feature gate: #![feature(build_hasher_default_const_new)]

This is a tracking issue for a new new class method for BuildHasherDefault. It allows creating a BuildHasherDefault in const contexts.
Because HashMap::with_hasher constness is being stabilized in #118427 this will in turn allow creating empty HashMap<K,V,BuildHasherDefault<H>> in const context for any H: Default + Hasher.

Public API

impl<H> BuildHasherDefault<H> {
    pub const fn new() -> Self;
}

Steps / History

Unresolved Questions

  • None yet.

@rustbot claim

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@krtab krtab added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Mar 29, 2024
@Amanieu Amanieu added I-libs-api-nominated Nominated for discussion during a libs-api team meeting. and removed I-libs-api-nominated Nominated for discussion during a libs-api team meeting. labels Mar 30, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 2, 2024
…ew, r=Amanieu

Add fn const BuildHasherDefault::new

See [tracking issue](rust-lang#123197) for justification.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 2, 2024
…ew, r=Amanieu

Add fn const BuildHasherDefault::new

See [tracking issue](rust-lang#123197) for justification.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 2, 2024
Rollup merge of rust-lang#123198 - krtab:build_hasher_default_const_new, r=Amanieu

Add fn const BuildHasherDefault::new

See [tracking issue](rust-lang#123197) for justification.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Nov 2, 2024
better test for const HashMap; remove const_hash leftovers

The existing `const_with_hasher` test is kind of silly since the HashMap it constructs can never contain any elements. So this adjusts the test to construct a usable HashMap, which is a bit non-trivial since the default hash builder cannot be built in `const`. `BuildHasherDefault::new()` helps but is unstable (rust-lang#123197), so we also have a test that does not involve that type.

The second commit removes the last remnants of rust-lang#104061, since they aren't actually useful -- without const traits, you can't do any hashing in `const`.

Cc `@rust-lang/libs-api` `@rust-lang/wg-const-eval`
Closes rust-lang#104061
Related to rust-lang#102575
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Nov 3, 2024
better test for const HashMap; remove const_hash leftovers

The existing `const_with_hasher` test is kind of silly since the HashMap it constructs can never contain any elements. So this adjusts the test to construct a usable HashMap, which is a bit non-trivial since the default hash builder cannot be built in `const`. `BuildHasherDefault::new()` helps but is unstable (rust-lang#123197), so we also have a test that does not involve that type.

The second commit removes the last remnants of rust-lang#104061, since they aren't actually useful -- without const traits, you can't do any hashing in `const`.

Cc ``@rust-lang/libs-api`` ``@rust-lang/wg-const-eval``
Closes rust-lang#104061
Related to rust-lang#102575
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Nov 3, 2024
better test for const HashMap; remove const_hash leftovers

The existing `const_with_hasher` test is kind of silly since the HashMap it constructs can never contain any elements. So this adjusts the test to construct a usable HashMap, which is a bit non-trivial since the default hash builder cannot be built in `const`. `BuildHasherDefault::new()` helps but is unstable (rust-lang#123197), so we also have a test that does not involve that type.

The second commit removes the last remnants of rust-lang#104061, since they aren't actually useful -- without const traits, you can't do any hashing in `const`.

Cc ```@rust-lang/libs-api``` ```@rust-lang/wg-const-eval```
Closes rust-lang#104061
Related to rust-lang#102575
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 3, 2024
better test for const HashMap; remove const_hash leftovers

The existing `const_with_hasher` test is kind of silly since the HashMap it constructs can never contain any elements. So this adjusts the test to construct a usable HashMap, which is a bit non-trivial since the default hash builder cannot be built in `const`. `BuildHasherDefault::new()` helps but is unstable (rust-lang#123197), so we also have a test that does not involve that type.

The second commit removes the last remnants of rust-lang#104061, since they aren't actually useful -- without const traits, you can't do any hashing in `const`.

Cc `@rust-lang/libs-api` `@rust-lang/wg-const-eval`
Closes rust-lang#104061
Related to rust-lang#102575
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 3, 2024
better test for const HashMap; remove const_hash leftovers

The existing `const_with_hasher` test is kind of silly since the HashMap it constructs can never contain any elements. So this adjusts the test to construct a usable HashMap, which is a bit non-trivial since the default hash builder cannot be built in `const`. `BuildHasherDefault::new()` helps but is unstable (rust-lang#123197), so we also have a test that does not involve that type.

The second commit removes the last remnants of rust-lang#104061, since they aren't actually useful -- without const traits, you can't do any hashing in `const`.

Cc ``@rust-lang/libs-api`` ``@rust-lang/wg-const-eval``
Closes rust-lang#104061
Related to rust-lang#102575
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 3, 2024
Rollup merge of rust-lang#132503 - RalfJung:const-hash-map, r=Amanieu

better test for const HashMap; remove const_hash leftovers

The existing `const_with_hasher` test is kind of silly since the HashMap it constructs can never contain any elements. So this adjusts the test to construct a usable HashMap, which is a bit non-trivial since the default hash builder cannot be built in `const`. `BuildHasherDefault::new()` helps but is unstable (rust-lang#123197), so we also have a test that does not involve that type.

The second commit removes the last remnants of rust-lang#104061, since they aren't actually useful -- without const traits, you can't do any hashing in `const`.

Cc ``@rust-lang/libs-api`` ``@rust-lang/wg-const-eval``
Closes rust-lang#104061
Related to rust-lang#102575
@RalfJung
Copy link
Member

@rust-lang/libs-api with #132541 on its way into the compiler, we are quite close to stabilizing #102575. However, actually creating a HashMap in const context with just that feature is kind of awkward:

    struct MyBuildDefaultHasher;
    impl BuildHasher for MyBuildDefaultHasher {
        type Hasher = DefaultHasher;

        fn build_hasher(&self) -> Self::Hasher {
            DefaultHasher::new()
        }
    }

    const H: HashMap<(), (), MyBuildDefaultHasher> = HashMap::with_hasher(MyBuildDefaultHasher);

So, I propose that we also stabilize BuildHasherDefault, tracked right here, so that this can instead be written as:

    const H: HashMap<(), (), BuildHasherDefault<DefaultHasher>> =
        HashMap::with_hasher(BuildHasherDefault::new());

@RalfJung RalfJung added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Nov 12, 2024
@RalfJung
Copy link
Member

Cc @rust-lang/wg-const-eval

@m-ou-se
Copy link
Member

m-ou-se commented Nov 12, 2024

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Nov 12, 2024

Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Nov 12, 2024
@Amanieu Amanieu removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Nov 12, 2024
@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Nov 12, 2024
@rfcbot
Copy link

rfcbot commented Nov 12, 2024

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Nov 12, 2024
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Nov 22, 2024
@rfcbot
Copy link

rfcbot commented Nov 22, 2024

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@rfcbot rfcbot added the to-announce Announce this issue on triage meeting label Nov 22, 2024
@bors bors closed this as completed in 1ae6f47 Dec 3, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 3, 2024
Rollup merge of rust-lang#133696 - RalfJung:const-hashmap, r=cuviper

stabilize const_collections_with_hasher and build_hasher_default_const_new

After a lot of preparatory work, finally we can stabilize creating `HashMap` in const context. :)

FCP for const_collections_with_hasher passed in rust-lang#102575.
Fixes rust-lang#102575.

FCP for build_hasher_default_const_new passed in rust-lang#123197.
Fixes rust-lang#123197.

Cc `@Amanieu`
Release notes: rust-lang#133347
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Dec 4, 2024
stabilize const_collections_with_hasher and build_hasher_default_const_new

After a lot of preparatory work, finally we can stabilize creating `HashMap` in const context. :)

FCP for const_collections_with_hasher passed in rust-lang/rust#102575.
Fixes rust-lang/rust#102575.

FCP for build_hasher_default_const_new passed in rust-lang/rust#123197.
Fixes rust-lang/rust#123197.

Cc `@Amanieu`
Release notes: rust-lang/rust#133347
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants