Skip to content

Add #[must_use] attribute to HashMap and HashSet constructors#153204

Open
xtqqczze wants to merge 1 commit intorust-lang:mainfrom
xtqqczze:must-use-map
Open

Add #[must_use] attribute to HashMap and HashSet constructors#153204
xtqqczze wants to merge 1 commit intorust-lang:mainfrom
xtqqczze:must-use-map

Conversation

@xtqqczze
Copy link
Contributor

@xtqqczze xtqqczze commented Feb 28, 2026

  • new_in
  • with_capacity_and_hasher
  • with_capacity_and_hasher_in
  • with_hasher
  • with_hasher_in

See also: #89692

@rustbot
Copy link
Collaborator

rustbot commented Feb 28, 2026

r? @joboet

rustbot has assigned @joboet.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, joboet

@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 Feb 28, 2026
@joboet
Copy link
Member

joboet commented Feb 28, 2026

r? libs-api
but this makes sense to me.

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Feb 28, 2026
@rustbot rustbot assigned the8472 and unassigned joboet Feb 28, 2026
@xtqqczze
Copy link
Contributor Author

@joboet perhaps if the return type name for these functions was specified as Self this would be helpful for review?

@joboet
Copy link
Member

joboet commented Feb 28, 2026

No, on the contrary; having this PR only contain the #[must_use] one-line additions is rather helpful.

@tgross35 tgross35 added the I-libs-nominated Nominated for discussion during a libs team meeting. label Mar 4, 2026
@tgross35
Copy link
Contributor

tgross35 commented Mar 4, 2026

Nominated, agree this seems fine since the base constructors are already must_use.

@Amanieu
Copy link
Member

Amanieu commented Mar 4, 2026

This seems fine to us! r=me

@Amanieu Amanieu removed the I-libs-nominated Nominated for discussion during a libs team meeting. label Mar 4, 2026
@joboet
Copy link
Member

joboet commented Mar 4, 2026

@bors r=Amanieu,joboet

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 4, 2026

📌 Commit dda4f84 has been approved by Amanieu,joboet

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 Mar 4, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 4, 2026
…oboet

Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors

- `new_in`
- `with_capacity_and_hasher`
- `with_capacity_and_hasher_in`
- `with_hasher`
- `with_hasher_in`

See also: rust-lang#89692
rust-bors bot pushed a commit that referenced this pull request Mar 4, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #153402 (miri subtree update)
 - #152164 (Lint unused features)
 - #152801 (Refactor WriteBackendMethods a bit)
 - #153196 (Update path separators to be available in const context)
 - #153204 (Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors)
 - #153317 (Abort after `representability` errors)
 - #153276 (Remove `cycle_fatal` query modifier)
 - #153300 (Tweak some of our internal `#[rustc_*]` TEST attributes)
 - #153396 (use `minicore` in some `run-make` tests)
 - #153401 (Migrationg of `LintDiagnostic` - part 7)
 - #153406 (Remove a ping for myself)
 - #153414 (Rename translation -> formatting)
rust-bors bot pushed a commit that referenced this pull request Mar 4, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #153402 (miri subtree update)
 - #152164 (Lint unused features)
 - #152801 (Refactor WriteBackendMethods a bit)
 - #153196 (Update path separators to be available in const context)
 - #153204 (Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors)
 - #153317 (Abort after `representability` errors)
 - #153276 (Remove `cycle_fatal` query modifier)
 - #153300 (Tweak some of our internal `#[rustc_*]` TEST attributes)
 - #153396 (use `minicore` in some `run-make` tests)
 - #153401 (Migrationg of `LintDiagnostic` - part 7)
 - #153406 (Remove a ping for myself)
 - #153414 (Rename translation -> formatting)
rust-bors bot pushed a commit that referenced this pull request Mar 4, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #153402 (miri subtree update)
 - #152164 (Lint unused features)
 - #152801 (Refactor WriteBackendMethods a bit)
 - #153196 (Update path separators to be available in const context)
 - #153204 (Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors)
 - #153317 (Abort after `representability` errors)
 - #153276 (Remove `cycle_fatal` query modifier)
 - #153300 (Tweak some of our internal `#[rustc_*]` TEST attributes)
 - #153396 (use `minicore` in some `run-make` tests)
 - #153401 (Migrationg of `LintDiagnostic` - part 7)
 - #153406 (Remove a ping for myself)
 - #153414 (Rename translation -> formatting)
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 Relevant to the library team, which will review and decide on the 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 this pull request may close these issues.

6 participants