Commit graph

570 commits

Author SHA1 Message Date
Stein Somers
8823bf0b40 Fix poor worst case performance of is_disjoint 2019-01-09 22:19:54 +01:00
Stein Somers
ccba43df81 Merge remote-tracking branch 'upstream/master' 2019-01-09 15:15:18 +01:00
Wiktor Kuchta
190d139f3a Fix repeated word typos
Found with `git grep -P '\b([a-z]+)\s+\1\b'`
2019-01-03 21:33:37 +01:00
bors
ee49bf8964 Auto merge of #55519 - fhartwig:hashmap-index-example, r=Centril
Add example of using the indexing operator to HashMap docs

Fixes #52575
2018-12-28 06:52:15 +00:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
kennytm
bba398ee2c
Rollup merge of #57050 - RyanMarcus:master, r=zackmdavis
Fixed typo in HashMap documentation

Previously "with a custom type as key", now "with a custom key type"
2018-12-23 02:12:25 +08:00
Ryan Marcus
51e4c1f320
Fixed typo in HashMap documentation
Previously "with a custom type as key", now "with a custom key type"
2018-12-21 14:50:25 -05:00
Stein Somers
f9f71cc324 Fix poor worst case performance of set intersection (and union, somewhat) on asymmetrically sized sets and extend unit tests slightly beyond that 2018-12-21 14:57:56 +01:00
John Kåre Alsaker
4f30a24e42 Inline tweaks 2018-12-21 12:09:43 +01:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
kennytm
06f3b57633
Rollup merge of #56561 - Zoxc:too-raw, r=Gankro
Fix bug in from_key_hashed_nocheck
2018-12-07 12:42:35 +08:00
John Kåre Alsaker
7df4b812f0 Fix bug in from_key_hashed_nocheck 2018-12-06 14:32:00 +01:00
Corey Farwell
c025d61409 Replace usages of ..i + 1 ranges with ..=i. 2018-12-04 12:05:19 -08:00
Hidehito Yabuuchi
1e18cc916f Update issue number of shrink_to methods to point the tracking issue 2018-12-02 16:08:08 +09:00
John Kåre Alsaker
946ea1453d Inline things 2018-11-30 08:14:22 +01:00
Steven Fackler
d0f99ddefa Fix the tracking issue for hash_raw_entry
It used to point to the implementation PR.
2018-11-22 09:52:24 -07:00
Guillaume Gomez
89e0fcee40
Rollup merge of #55784 - meltinglava:master, r=KodrAus
Clarifying documentation for collections::hash_map::Entry::or_insert

Previous version does not show that or_insert does not insert the passed value, as the passed value was the same value as what was already in the map.
2018-11-22 10:37:46 +01:00
Andy Russell
4e35cbb22e
fix various typos in doc comments 2018-11-13 14:45:31 -05:00
Meltinglava
8b750a77fc The example values are now easyer to differenciate 2018-11-13 12:20:23 +01:00
Meltinglava
b937be87cb Clarifying documentation for collections::hash_map::Entry::or_insert
Previous version does not show that or_insert does not insert the
passed value, as the passed value was the same value as what was
already in the map.
2018-11-08 15:43:18 +01:00
kennytm
9d9146ad95
Rollup merge of #55734 - teresy:shorthand-fields, r=davidtwco
refactor: use shorthand fields

refactor: use shorthand for single fields everywhere (excluding tests).
2018-11-07 21:27:00 +08:00
teresy
eca11b99a7 refactor: use shorthand fields 2018-11-06 15:05:44 -05:00
bors
e800988579 Auto merge of #54043 - fintelia:raw_entry, r=alexcrichton
Add raw_entry API to HashMap

This is a continuation of #50821.
2018-11-02 07:04:07 +00:00
Jonathan Behrens
daf5bd564a A couple suggested edits 2018-10-31 15:15:20 -04:00
Florian Hartwig
51fdc2bf14 Add example of using the indexing operator to HashMap docs 2018-10-30 23:31:13 +01:00
bors
8a2dec6e58 Auto merge of #53804 - RalfJung:ptr-invalid, r=nagisa
fix some uses of pointer intrinsics with invalid pointers

[Found by miri](https://github.com/solson/miri/pull/446):

* `Vec::into_iter` calls `ptr::read` (and the underlying `copy_nonoverlapping`) with an unaligned pointer to a ZST. [According to LLVM devs](https://bugs.llvm.org/show_bug.cgi?id=38583), this is UB because it contradicts the metadata we are attaching to that pointer.
* `HashMap` creation calls `ptr:.write_bytes` on a NULL pointer with a count of 0. This is likely not currently UB *currently*, but it violates the rules we are setting in https://github.com/rust-lang/rust/pull/53783, and we might want to exploit those rules later (e.g. with more `nonnull` attributes for LLVM).

    Probably what `HashMap` really should do is use `NonNull::dangling()` instead of 0 for the empty case, but that would require a more careful analysis of the code.

It seems like ideally, we should do a review of usage of such intrinsics all over libstd to ensure that they use valid pointers even when the size is 0. Is it worth opening an issue for that?
2018-09-16 18:03:39 +00:00
Jonathan Behrens
a92594dfac
Entry is an enum not a struct 2018-09-13 21:21:53 -04:00
Jonathan Behrens
7220fbb713 Fix links in docs 2018-09-13 19:05:41 -04:00
Jonathan Behrens
e9583628b2
Eliminate unused variable warning 2018-09-13 16:48:09 -04:00
Jonathan Behrens
dc41726de3 Fix tests and update issue number 2018-09-13 16:19:40 -04:00
Jonathan Behrens
1ad0919fa9
Remove println!() statement from HashMap unit test 2018-09-13 14:58:13 -04:00
Jonathan Behrens
2c0f385d0c Fix formatting 2018-09-12 14:59:12 -04:00
Val
abe0f027ae
fix typos in growth algo description
modified to read "the first table overflows into the second, and the second into the first." plus smaller typos
2018-09-10 09:02:16 -07:00
Jonathan Behrens
ad6c7a9a31 Cleanup API somewhat 2018-09-07 16:47:19 -04:00
Guillaume Gomez
c1ad1b0338 Fix invalid urls 2018-09-06 23:32:30 +02:00
Alexis Beingessner
6089af72c0 disambiguate hashes 2018-09-05 12:10:09 -04:00
Alexis Beingessner
14ee4e468d fixup Debug bounds 2018-09-05 12:10:09 -04:00
Alexis Beingessner
9c566e64fa progress on raw_entry 2018-09-05 12:10:09 -04:00
Alexis Beingessner
6af55a7c61 WIP: add raw_entry API to HashMap 2018-09-05 12:10:09 -04:00
Ralf Jung
61f0a2b3fd fix some uses of pointer intrinsics with invalid pointers 2018-08-29 23:08:47 +02:00
Corey Farwell
993fb93464 Replace usages of ptr::offset with ptr::{add,sub}. 2018-08-20 07:28:34 -04:00
Simon Sapin
b0547cea0a Move core::alloc::CollectionAllocErr to alloc::collections 2018-06-29 14:01:33 +02:00
bors
d692ab406e Auto merge of #51543 - SimonSapin:oom, r=SimonSapin
Rename OOM to allocation error

The acronym is not descriptive unless one has seen it before.

* Rename the `oom` function to `handle_alloc_error`. It was **stabilized in 1.28**, so if we do this at all we need to land it this cycle.
* Rename `set_oom_hook` to `set_alloc_error_hook`
* Rename `take_oom_hook` to `take_alloc_error_hook`

Bikeshed: `on` v.s. `for`, `alloc` v.s. `allocator`, `error` v.s. `failure`
2018-06-19 19:22:12 +00:00
Simon Sapin
2b789bd057 Rename OOM to allocation error
The acronym is not descriptive unless one has seen it before.

* Rename the `oom` function to `handle_alloc_error`. It was **stabilized in 1.28**, so if we do this at all we need to land it this cycle.
* Rename `set_oom_hook` to `set_alloc_error_hook`
* Rename `take_oom_hook` to `take_alloc_error_hook`

Bikeshed: `alloc` v.s. `allocator`, `error` v.s. `failure`
2018-06-18 21:41:24 +02:00
Kornel
01e82f111e Prefer use of owned values in examples 2018-06-18 12:38:46 +01:00
Mike Hommey
f6ab74b8e7 Remove alloc::Opaque and use *mut u8 as pointer type for GlobalAlloc 2018-06-11 13:47:23 -07:00
Guillaume Gomez
861c7cb9fd Stabilize entry-or-default 2018-06-10 12:59:12 +02:00
Amanieu d'Antras
b69724f37c Optimize layout calculations in HashMap
This now produces the same assembly code as the previous implementation.
2018-06-04 16:00:08 +01:00
Corey Farwell
a86f556ee3 Add a couple lines describing differences between into_mut/get_mut. 2018-06-02 18:07:23 -04:00
Phlosioneer
ed1a8fff62 Fixed typo 2018-06-02 15:51:44 -04:00