Commit Graph

206 Commits

Author SHA1 Message Date
Josh Stone 567fd9610c replace placeholder version 2024-10-14 10:22:50 -07:00
ltdk 11f738fcb2 impl Default for Hash{Map,Set} iterators that don't already have it 2024-10-02 23:43:48 -04:00
Urgau 8760a401bd Update hashbrown to 0.15 and adjust some methods
as well as removing some from std as they no longer
exists in Hashbrown it-self.
2024-10-02 09:44:51 +02:00
Ralf Jung 4529b86196 make test_lots_of_insertions test take less long in Miri 2024-10-01 11:03:05 +02:00
Nicola Krumschmidt 87f17f3ccb Fix std tests for wasm32-wasip2 target 2024-09-29 04:48:13 +02:00
Michael Goulet c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
GnomedDev 364e552940 [Clippy] Swap iter_over_hash_type to use diagnostic items instead of paths 2024-09-19 13:13:43 +01:00
GnomedDev a786be5d06 [Clippy] Swap map_entry to use diagnostic items instead of paths 2024-09-19 08:26:37 +01:00
GnomedDev a18564c198 [Clippy] Swap manual_retain to use diagnostic items instead of paths 2024-09-18 17:20:44 +01:00
Félix Saparelli 0b2235d732 Stabilize entry_insert 2024-09-13 11:45:44 +12:00
James Liu 4198594ef2 Clarify docs for std::collections
Page affected: https://doc.rust-lang.org/std/collections/index.html#performance

Changes:

- bulleted conventions
- expanded definitions on terms used
- more accessible language
- merged Sequence and Map performance cost tables
2024-09-10 14:25:38 -07:00
Nicholas Nethercote 84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Jubilee Young 87d850dff0 std: Unsafe-wrap HashMap::get_many_unchecked_mut 2024-07-14 16:49:16 -07:00
Jubilee Young 4572ed6389 std: deny(unsafe_op_in_unsafe_fn) but allow sites
This provides a list of locations to hunt down issues in.
2024-07-14 16:44:01 -07:00
Tim Kurdov 9436fbe00d Fix typo in the docs of HashMap::raw_entry_mut 2024-06-03 17:35:58 +01:00
Matthias Krüger 21deaed4a1 Rollup merge of #122201 - coolreader18:doc-clone_from, r=dtolnay
Document overrides of `clone_from()` in core/std

As mentioned in https://github.com/rust-lang/rust/pull/96979#discussion_r1379502413

Specifically, when an override doesn't just forward to an inner type, document the behavior and that it's preferred over simply assigning a clone of source. Also, change instances where the second parameter is "other" to "source".

I reused some of the wording over and over for similar impls, but I'm not sure that the wording is actually *good*. Would appreciate feedback about that.

Also, now some of these seem to provide pretty specific guarantees about behavior (e.g. will reuse the exact same allocation iff the len is the same), but I was basing it off of the docs for [`Box::clone_from`](https://doc.rust-lang.org/1.75.0/std/boxed/struct.Box.html#method.clone_from-1) - I'm not sure if providing those strong guarantees is actually good or not.
2024-04-17 18:01:37 +02:00
Sky 49dd50f880 Add "put" as a confusable for insert on hash map/set 2024-03-19 14:28:01 -04:00
Noa c0e913fdd7 Document overrides of clone_from()
Specifically, when an override doesn't just forward to an inner type,
document the behavior and that it's preferred over simply assigning
a clone of source. Also, change instances where the second parameter is
"other" to "source".
2024-03-08 12:27:24 -06:00
Esteban Küber e5b3c7ef14 Add rustc_confusables annotations to some stdlib APIs
Help with common API confusion, like asking for `push` when the data structure really has `append`.

```
error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope
  --> $DIR/rustc_confusables_std_cases.rs:17:7
   |
LL |     x.size();
   |       ^^^^
   |
help: you might have meant to use `len`
   |
LL |     x.len();
   |       ~~~
help: there is a method with a similar name
   |
LL |     x.resize();
   |       ~~~~~~
```

#59450
2024-02-22 18:04:55 +00:00
yukang ad526d831e add missing potential_query_instability for keys and values in hashmap 2024-01-30 12:43:10 +08:00
bors 1828461982 Auto merge of #117756 - a1phyr:hashmap_fold, r=the8472
`HashMap`/`HashSet`: forward `fold` implementations of iterators

Use [rust-lang/hasbrown#480](https://github.com/rust-lang/hashbrown/pull/480) in `std`

Note: this needs a version bump of hashbrown before merging
2024-01-20 17:53:26 +00:00
Jake Goulding 5772818dc8 Adjust library tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
Benoît du Garreau 7d369f9830 Specialize count too 2023-12-04 19:48:20 +01:00
Benoît du Garreau 6318cbbe49 HashMap/HashSet: forward fold implementations of iterators 2023-12-04 19:48:20 +01:00
ltdk 8337e86b28 Add insta-stable std::hash::{DefaultHasher, RandomState} exports 2023-11-02 20:35:20 -04:00
ltdk 075409ddd9 Move RandomState and DefaultHasher into std::hash, but don't export for now 2023-11-02 20:35:20 -04:00
Oli Scherer e96ce20b34 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
bors fc01a7432b Auto merge of #109214 - tosti007:std_collection_hash_new_rework, r=workingjubilee
Use `HashMap::with_capacity_and_hasher` instead of using base

Cleans up the internal logic for `HashMap::with_capacity` slightly.
2023-10-07 05:26:12 +00:00
Easyoakland 98e434a01e Increase clarity about Hash - Eq consistency in HashMap and HashSet docs 2023-08-07 20:31:49 -06:00
Tshepang Mbambo df3f45dbc5 avoid ambiguous word
See https://github.com/rust-lang/rust/pull/113618#pullrequestreview-1526295432
2023-07-12 20:10:52 +02:00
Tshepang Mbambo 5710fca279 update ancient note 2023-07-12 12:23:40 +02:00
Tshepang Mbambo 5b46aa1122 make HashMap::or_insert_with example more simple 2023-06-29 09:33:15 +02:00
bors 6ee4265ca6 Auto merge of #104455 - the8472:dont-drain-on-drop, r=Amanieu
Don't drain-on-drop in DrainFilter impls of various collections.

This removes drain-on-drop behavior from various unstable DrainFilter impls (not yet for HashSet/Map) because that behavior [is problematic](https://github.com/rust-lang/rust/issues/43244#issuecomment-641638196) (because it can lead to panic-in-drop when user closures panic) and may become forbidden if [this draft RFC passes](https://github.com/rust-lang/rfcs/pull/3288).

closes #101122

[ACP](https://github.com/rust-lang/libs-team/issues/136)

affected tracking issues
* #43244
* #70530
* #59618

Related hashbrown update: https://github.com/rust-lang/hashbrown/pull/374
2023-06-15 00:03:10 +00:00
Matthias Krüger d54bb505d0 Rollup merge of #107619 - stepancheg:hash-set-insert, r=Amanieu
Specify behavior of HashSet::insert

`HashSet::insert` does not replace the value with equal value.

Fixes #107581.
2023-06-14 18:10:28 +02:00
The 8472 479be6ac43 update hashbrown and replace Hash{Set,Map}::DrainFilter with ExtractIf 2023-06-14 09:28:56 +02:00
Deadbeef 76dbe29104 rm const traits in libcore 2023-04-16 06:49:27 +00:00
Matthias Krüger d5c7237400 Rollup merge of #110244 - kadiwa4:unnecessary_imports, r=JohnTitor
Remove some unneeded imports / qualified paths

Continuation of #105537.
2023-04-14 21:11:13 +02:00
Yuki Okushi 7361b17740 Rollup merge of #110047 - skaunov:patch-1, r=ChrisDenton
Add link to `collections` docs to `extend` trait

I believe it would be useful here.
2023-04-14 23:00:34 +09:00
Sergey Kaunov 18ca509e99 Add links to docs to Iterator
and couple of its methods
2023-04-14 11:28:24 +03:00
KaDiWa ad2b34d0e3 remove some unneeded imports 2023-04-12 19:27:18 +02:00
Vadim Petrochenkov 612ddd2196 std: Mark two reexports that should be inlined as doc(inline) 2023-04-08 13:29:16 +03:00
tosti007 6b98dcc743 Use with_capacity_and_hasher instead of using base 2023-03-29 15:10:35 +02:00
Maybe Waffle c513c3b9a5 Remove outdated comments 2023-03-20 17:42:04 +00:00
Kiran Shila f5c45ad284 Fix typo in HashMap::with_capacity 2023-02-05 10:13:30 -08:00
Stiopa Koltsov e800d5a0ec Specify behavior of HashSet::insert
`HashSet::insert` does not replace the value with equal value.

Fixes #107581.
2023-02-03 00:18:31 +00:00
bors 2afe58571e Auto merge of #104658 - thomcc:rand-update-and-usable-no_std, r=Mark-Simulacrum
Update `rand` in the stdlib tests, and remove the `getrandom` feature from it.

The main goal is actually removing `getrandom`, so that eventually we can allow running the stdlib test suite on tier3 targets which don't have `getrandom` support. Currently those targets can only run the subset of stdlib tests that exist in uitests, and (generally speaking), we prefer not to test libstd functionality in uitests, which came up recently in https://github.com/rust-lang/rust/pull/104095 and https://github.com/rust-lang/rust/pull/104185. Additionally, the fact that we can't update `rand`/`getrandom` means we're stuck with the old set of tier3 targets, so can't test new ones.

~~Anyway, I haven't checked that this actually does allow use on tier3 targets (I think it does not, as some work is needed in stdlib submodules) but it moves us slightly closer to this, and seems to allow at least finally updating our `rand` dep, which definitely improves the status quo.~~ Checked and works now.

For the most part, our tests and benchmarks are fine using hard-coded seeds. A couple tests seem to fail with this (stuff manipulating the environment expecting no collisions, for example), or become pointless (all inputs to a function become equivalent). In these cases I've done a (gross) dance (ab)using `RandomState` and `Location::caller()` for some extra "entropy".

Trying to share that code seems *way* more painful than it's worth given that the duplication is a 7-line function, even if the lines are quite gross. (Keeping in mind that sharing it would require adding `rand` as a non-dev dep to std, and exposing a type from it publicly, all of which sounds truly awful, even if done behind a perma-unstable feature).

See also some previous attempts:
- https://github.com/rust-lang/rust/pull/86963 (in particular https://github.com/rust-lang/rust/pull/86963#issuecomment-885438936 which explains why this is non-trivial)
- https://github.com/rust-lang/rust/pull/89131
- https://github.com/rust-lang/rust/pull/96626#issuecomment-1114562857 (I tried in that PR at the same time, but settled for just removing the usage of `thread_rng()` from the benchmarks, since that was the main goal).
- https://github.com/rust-lang/rust/pull/104185
- Probably more. It's very tempting of a thing to "just update".

r? `@Mark-Simulacrum`
2023-01-08 01:34:05 +00:00
Ezra Shaw 43bec83266 docs: make HashSet::retain doctest more clear 2023-01-07 17:08:07 +13:00
Thom Chiovoloni a4bf36e87b Update rand in the stdlib tests, and remove the getrandom feature from it 2023-01-04 14:52:41 -08:00
onestacked dc1f1a8e97 Added const_hash tracking issue id 2022-11-06 18:01:44 +01:00
onestacked 5f9899b289 Made Sip const Hasher 2022-11-06 17:46:38 +01:00