Commit Graph

219 Commits

Author SHA1 Message Date
Trevor Spiteri 2b718e8d9c use ManuallyDrop instead of forget inside collections
This commit changes some usage of mem::forget into mem::ManuallyDrop
in some Vec, VecDeque, BTreeMap and Box methods.

Before the commit, the generated IR for some of the methods was
longer, and even after optimization, some unwinding artifacts were
still present.
2020-04-04 14:30:33 +02:00
bors 127a11a344 Auto merge of #70362 - TimDiekmann:alloc-overhaul, r=Amanieu
Overhaul of the `AllocRef` trait to match allocator-wg's latest consens; Take 2

GitHub won't let me reopen #69889 so I make a new PR.

In addition to #69889 this fixes the unsoundness of `RawVec::into_box` when using allocators supporting overallocating. Also it uses `MemoryBlock` in `AllocRef` to unify `_in_place` methods by passing `&mut MemoryBlock`. Additionally, `RawVec` now checks for `size_of::<T>()` again and ignore every ZST. The internal capacity of `RawVec` isn't used by ZSTs anymore, as `into_box` now requires a length to be specified.

r? @Amanieu

fixes rust-lang/wg-allocators#38
fixes rust-lang/wg-allocators#41
fixes rust-lang/wg-allocators#44
fixes rust-lang/wg-allocators#51
2020-04-02 06:08:35 +00:00
Mazdak Farrokhzad c51fcb5f38 Rollup merge of #68692 - jyn514:vec-from-array, r=LukasKalbertodt
impl From<[T; N]> for Vec<T>

Closes https://github.com/rust-lang/rust/issues/67963
2020-03-29 11:50:10 +02:00
Tim Diekmann 2526accdd3 Fix issues from review and unsoundness of RawVec::into_box 2020-03-26 17:11:47 +01:00
Tim Diekmann 56cbf2f22a Overhaul of the AllocRef trait to match allocator-wg's latest consens 2020-03-26 17:10:54 +01:00
Kornel 2f7d7c0333 must_use on split_off 2020-03-20 14:40:35 +00:00
Mazdak Farrokhzad 080d41391d Rollup merge of #69828 - RalfJung:vec-leak, r=kennytm
fix memory leak when vec::IntoIter panics during drop

Fixes https://github.com/rust-lang/rust/issues/69770
2020-03-11 14:03:47 +01:00
Joshua Nelson 3477e67a92 Allow vec.rs to be over 3000 lines :( 2020-03-10 23:49:45 +00:00
Joshua Nelson 8212584c9e Bump release cutoff 2020-03-10 23:44:46 +00:00
Joshua Nelson 1ac4a46142 make the impl a little prettier 2020-03-10 23:44:46 +00:00
Joshua Nelson 96794d86f1 fix test failure 2020-03-10 23:44:46 +00:00
Joshua Nelson f267d9dc19 limit From impl to LengthAtMost32
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2020-03-10 23:44:46 +00:00
Joshua Nelson daeb8ece8c fix error compiling stage2
Co-Authored-By: lzutao <taolzu@gmail.com>
2020-03-10 23:44:46 +00:00
Joshua Nelson 62722735fb impl From<[T; N]> for Vec<T> 2020-03-10 23:44:46 +00:00
Christopher Durham a56196205b Vec::new is const tstable in 1.39 not 1.32 2020-03-09 23:07:04 -04:00
Ralf Jung 528cbc4879 fix memory leak when vec::IntoIter panics during drop 2020-03-08 16:43:03 +01:00
Mazdak Farrokhzad 10f999b72d Rollup merge of #69773 - matthiaskrgr:typos, r=petrochenkov
fix various typos
2020-03-07 17:27:32 +01:00
Matthias Krüger 83980aca20 Don't redundantly repeat field names (clippy::redundant_field_names) 2020-03-06 19:42:18 +01:00
Matthias Krüger 136ad015b6 fix various typos 2020-03-06 15:19:31 +01:00
Dylan DPC 55d0a8b201 Rollup merge of #69568 - JOE1994:patch-2, r=Dylan-DPC
Clarify explanation of Vec<T> 'fn resize'

1. Clarified on what should implement `Clone` trait.
2. Minor grammar fix:
to be able clone => to be able **to** clone
2020-03-01 17:23:29 +01:00
Ralf Jung 0edc90cd18 clarify alignment requirements in Vec::from_raw_parts 2020-02-29 14:07:20 +01:00
Youngsuk Kim 6e265c5bc5 Remove trailing whitespace
Removed trailing whitespace which caused to fail pretty-check
2020-02-29 00:55:05 -05:00
Youngsuk Kim fb46d2b82e Update src/liballoc/vec.rs
Following suggestion from @jonas-schievink

Co-Authored-By: Jonas Schievink <jonasschievink@gmail.com>
2020-02-29 00:52:32 -05:00
Youngsuk Kim 2ad52cd16d Clarify explanation of 'fn resize'
1. Clarified on what should implement 'Clone' trait.
2. Minor grammar fix:
to be able clone => to be able to clone
2020-02-28 19:28:26 -05:00
bors 892cb143e5 Auto merge of #67290 - jonas-schievink:leak-audit, r=KodrAus
Audit liballoc for leaks in `Drop` impls when user destructor panics

Inspired by https://github.com/rust-lang/rust/pull/67243 and https://github.com/rust-lang/rust/pull/67235, this audits and hopefully fixes the remaining `Drop` impls in liballoc for resource leaks in the presence of panics in destructors called by the affected `Drop` impl.

This does not touch `Hash{Map,Set}` since they live in hashbrown. They have similar issues though.

r? @KodrAus
2020-02-26 12:48:53 +00:00
hman523 346920c3c8 Fixed issue 68593 2020-01-31 13:41:07 -06:00
Pedro de Brito 074cfcbf2d fix: typo in vec.rs 2020-01-28 07:59:07 +01:00
Jonas Schievink 52d6c90488 Update comments in Drains Drop impl 2020-01-19 20:28:47 +01:00
Jonas Schievink 163ed23f00 Fix leak in vec::IntoIter when a destructor panics 2020-01-19 20:24:08 +01:00
Jonas Schievink 5d04790dd2 Avoid leak in vec::Drain when item drop panics 2020-01-19 20:23:41 +01:00
Lzu Tao 7ba25acd7a Revert "Rollup merge of #67727 - Dylan-DPC:stabilise/remove_item, r=alexcrichton"
This reverts commit 4ed415b547, reversing
changes made to 3cce950743.
2020-01-11 03:04:39 +00:00
Yuki Okushi 2c25ad5d28 Rollup merge of #67929 - mgrachev:patch-1, r=jonas-schievink
Formatting an example for method Vec.retain
2020-01-07 13:46:10 +09:00
dylan_DPC 6bec8e9972 stabilise it 2020-01-06 20:37:49 +05:30
dylan_DPC 24c6cd80c3 stabilise remove_item 2020-01-06 19:36:46 +05:30
Grachev Mikhail e6d95ce0b8 Formatting an example for method Vec.retain 2020-01-06 15:18:03 +03:00
dylan_DPC 358b8983f2 removed blank line 2020-01-05 00:00:40 +05:30
dylan_DPC f744ea03b4 ef em ti ... :P 2020-01-04 23:57:34 +05:30
dylan_DPC c09dac1073 add partial eq bound to remove_item 2020-01-04 23:31:32 +05:30
Matthew Kraai 21e636f188 Remove redundant link texts 2019-12-26 05:04:46 -08:00
Mark Rousskov a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Mark Rousskov 82184440ec Propagate cfg bootstrap 2019-12-18 12:16:19 -05:00
Mazdak Farrokhzad 64f83915de Rollup merge of #67300 - aloucks:issue-65970, r=rkruppe
Restore original implementation of Vec::retain

This PR reverts #48065, which aimed to optimize `Vec::retain` by making use of `Vec::drain_filter`. Unfortunately at that time, `drain_filter` was unsound.

The soundness hole in `Vec::drain_filter` was fixed in #61224 by guaranteeing that cleanup logic runs via a nested `Drop`, even in the event of a panic. Implementing this nested drop affects codegen (apparently?) and results in slower code.

Fixes #65970
2019-12-15 05:57:27 +01:00
Aaron Loucks 7ea6c46a6d Restore original implementation of Vec::retain
This PR reverts #48065, which aimed to optimize `Vec::retain` by
making use of `Vec::drain_filter`. Unfortunately at that time,
`drain_filter` was unsound.

The soundness hole in `Vec::drain_filter` was fixed in #61224 by
guaranteeing that cleanup logic runs via a nested `Drop`, even in
the event of a panic. Implementing this nested drop affects codegen
(apparently?) and results in slower code.

Fixes #65970
2019-12-14 12:38:45 -05:00
Oliver Scherer 5e17e39881 Require stable/unstable annotations for the constness of all stable functions with a const modifier 2019-12-13 11:27:02 +01:00
Jakub Kądziołka ecd930717b doc: Use .copied() instead of .cloned() in Vec example 2019-12-09 19:48:18 +01:00
Mazdak Farrokhzad 9ae7fb3e71 Rollup merge of #66759 - CAD97:patch-3, r=KodrAus
impl TrustedLen for vec::Drain

The iterator methods just forward to `slice::Iter`, which is `TrustedLen`.

This can probably be applied to other `Drain` structs as well.
2019-11-30 16:56:49 +01:00
Tyler Mandry 999fd561ba Rollup merge of #66798 - bwignall:typo, r=varkor
Fix spelling typos

Should be non-semantic.

Uses https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines to find likely typos.
2019-11-27 15:28:53 -06:00
Brian Wignall 16fabd8efd Fix spelling typos 2019-11-26 22:19:54 -05:00
Christopher Durham f8a4b6d2ba impl TrustedLen for vec::Drain 2019-11-25 17:55:26 -05:00
Christian Duerr 73b467da89 Fix shrink_to panic documentation
While the potential for panicking is already documented for the
`Vec::shrink_to` method, it is not clearly labeled with the usual
`# Panics` heading.
2019-11-25 15:49:40 +01:00