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

Make Hash{Set,Map}::with_hasher unstably const #102574

Merged
merged 1 commit into from
Oct 5, 2022

Conversation

aDotInTheVoid
Copy link
Member

@aDotInTheVoid aDotInTheVoid commented Oct 2, 2022

Makes HashMap::with_hasher and HashSet::with_hasher const.

This allows

static GlobalState: Mutex<HashMap<i32, i32, SomeHasher>> = Mutex::new(HashMap::with_hasher(SomeHasher::new()))

Tracking issue: #102575

@rustbot
Copy link
Collaborator

rustbot commented Oct 2, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Oct 2, 2022
@rust-highfive
Copy link
Collaborator

r? @thomcc

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 2, 2022
@aDotInTheVoid aDotInTheVoid force-pushed the const_collections_with_hasher branch from 04d13ab to 346a49f Compare October 2, 2022 12:07
@aDotInTheVoid
Copy link
Member Author

@rustbot label +T-libs-api -T-libs

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 2, 2022
@cuviper
Copy link
Member

cuviper commented Oct 4, 2022

= Mutex::new(HashMap::new(SomeHasher::new()))

This should be HashMap::with_hasher.
(and we can't do ::new because that uses runtime randomization)

@aDotInTheVoid
Copy link
Member Author

Typo Fixed. Thanks.

@thomcc
Copy link
Member

thomcc commented Oct 4, 2022

CC @rust-lang/wg-const-eval

@fee1-dead
Copy link
Member

Thanks for the ping :). This looks fine as we are not doing any additional stuff to make it work. It is just turning it into a const fn. LGTM

@oli-obk
Copy link
Contributor

oli-obk commented Oct 4, 2022

@bors r=oli-obk,fee1-dead

@bors
Copy link
Contributor

bors commented Oct 4, 2022

📌 Commit 346a49f has been approved by oli-obk,fee1-dead

It is now in the queue for this repository.

@bors bors 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 Oct 4, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 5, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#102574 (Make Hash{Set,Map}::with_hasher unstably const)
 - rust-lang#102650 (Slightly improve no return for returning function error)
 - rust-lang#102662 (rustdoc: remove no-op CSS `.code-header { display: block }`)
 - rust-lang#102670 (follow-up fix about 101866 to print the self type.)
 - rust-lang#102686 (Don't build the compiler before building rls)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4025e95 into rust-lang:master Oct 5, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 5, 2022
@aDotInTheVoid aDotInTheVoid deleted the const_collections_with_hasher branch August 3, 2023 23:06
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-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants