about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2019-06-20Arc: refactor data_offset{_sized}.Mazdak Farrokhzad-8/+9
2019-06-20Arc: refactor away PhantomData noise.Mazdak Farrokhzad-15/+21
2019-06-20shared_from_iter/Rc: Use specialization to elide allocation.Mazdak Farrokhzad-39/+168
2019-06-20Rc: reduce duplicate calls.Mazdak Farrokhzad-4/+8
2019-06-20Rc: refactor data_offset{_sized}.Mazdak Farrokhzad-6/+7
2019-06-20Rc: refactor away PhantomData noise.Mazdak Farrokhzad-23/+30
2019-06-20Add basic 'shared_from_iter' impls.Mazdak Farrokhzad-0/+14
2019-06-17Rollup merge of #61893 - chpio:weak_ptr_eq_methods, r=rkruppeMazdak Farrokhzad-14/+14
make `Weak::ptr_eq`s into methods This makes the `Weak::ptr_eq`s associated function into methods. There's no reason for methods on `Weak`s to be associated functions, as there is no `Dered` thus no possibility of a collision. Also: methods can be called using the associated function syntax. follow up on https://github.com/rust-lang/rust/pull/55987 [Tracking issue for weak_ptr_eq](https://github.com/rust-lang/rust/issues/55981)
2019-06-16make `Weak::ptr_eq`s into methodsThomas Heck-14/+14
2019-06-16Separate liballoc modulechansuke-1/+1
2019-06-16Rollup merge of #61447 - scottmcm:vec-vecdeque, r=sfacklerMazdak Farrokhzad-0/+31
Add some Vec <-> VecDeque documentation These are more than just `.into_iter().collect()`, so talk about some of their nuances. For VecDeque -> Vec I'm trying to intentionally not write a guarantee for people making their own `Vec`s, since the rules are more complicated than I think we want to commit to forever. The "Vec -> VecDeque doesn't reallocate" guarantee seems reasonable, though. (And I'm intentionally ambiguous about when it's O(1) instead of O(n).)
2019-06-15Make the Weak::{into,as}_raw methodsMichal 'vorner' Vaner-30/+30
Because Weak doesn't Deref, so there's no reason for them to be only associated methods.
2019-06-14Auto merge of #61421 - vorner:string-in-rc-into-raw-docs, r=RalfJungbors-28/+28
docs: Use String in Rc::into_raw examples It is unclear if accessing an integer after `drop_in_place` has been called on it is undefined behaviour or not, as demonstrated by the discussion in https://github.com/rust-lang/rust/pull/60766#pullrequestreview-243414222. Avoid these uncertainties by using String which frees memory in its `drop_in_place` to make sure this is undefined behaviour. The message in the docs should be to watch out and not access the data after that, not discussing when one maybe could get away with it O:-).
2019-06-13docs: Use String in Rc::into_raw examplesMichal 'vorner' Vaner-28/+28
It is unclear if accessing an integer after `drop_in_place` has been called on it is undefined behaviour or not, as demonstrated by the discussion in https://github.com/rust-lang/rust/pull/60766#pullrequestreview-243414222. Avoid these uncertainties by using String which frees memory in its `drop_in_place` to make sure this is undefined behaviour. The message in the docs should be to watch out and not access the data after that, not discussing when one maybe could get away with it O:-).
2019-06-12Hygienize macros in the standard libraryVadim Petrochenkov-1/+1
2019-06-11Remove the questionably-useful exampleScott McMurray-22/+0
2019-06-08Add hyperlinks to Vec and VecDequeScott McMurray-2/+2
Let's try the auto-linking instead, since the relative ones don't work.
2019-06-08Apply suggestions from code reviewscottmcm-1/+1
Co-Authored-By: Joe ST <joe@fbstj.net>
2019-06-08Put the docs on the methods instead of the implsScott McMurray-53/+53
Since simulacrum suggested (on Discord) they're better there.
2019-06-08Apply suggestions from code reviewscottmcm-10/+10
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-06-08Add some Vec <-> VecDeque documentationScott McMurray-0/+53
These are more than just `.into_iter().collect()`, so talk about some of their nuances.
2019-06-08Turn `#[allocator]` into a built-in attribute and rename it to ↵Vadim Petrochenkov-2/+3
`#[rustc_allocator]`
2019-06-04Rollup merge of #61420 - felixrabe:patch-2, r=dtolnayMazdak Farrokhzad-6/+4
Succinctify splice docs
2019-06-04Rollup merge of #61419 - scottmcm:casing-is-on-strings, r=cramertjMazdak Farrokhzad-0/+7
Add an unusual-conversion example to to_uppercase Like how to_lowercase has ὈΔΥΣΣΕΎΣ.
2019-06-04Rollup merge of #61135 - czipperz:rc-make_mut-weak-doc, r=Mark-SimulacrumMazdak Farrokhzad-7/+27
Fix documentation of `Rc::make_mut` regarding `rc::Weak`. Closes #60961
2019-06-01Succinctify splice docsFelix Rabe-6/+4
2019-06-01Add an unusual-conversion example to to_uppercaseScott McMurray-0/+7
Like how to_lowercase has ὈΔΥΣΣΕΎΣ.
2019-05-30Stabilize iter_nth_back featureLzu Tao-1/+0
2019-05-30Rollup merge of #61244 - RalfJung:box, r=rkruppeMazdak Farrokhzad-5/+4
Box::into_vec: use Box::into_raw instead of mem::forget `Box::into_raw` does, in one step, turn the `Box` into a raw ptr and avoid deallocation. Seems cleaner than separating the two. Also, `mem::forget` gets the `Box` with a `noalias` argument, but it is not actually correct that this is an exclusive pointer. So a stricter version of Stacked Borrows would complain here. (I can't actually make Stacked Borrows that strict yet though due to other issues.)
2019-05-29Rollup merge of #60766 - vorner:weak-into-raw, r=sfacklerMazdak Farrokhzad-12/+314
Weak::into_raw Hello This is my first shot at #60728. I'd like to consult it a bit before moving further. The biggest question I have is if this API makes sense. My motivation for it is to be able to store the `Weak` in `AtomicPtr`. For that I don't actually need for the pointer to point to the `T`, any pointer (maybe casted to `usize`) would be good enough, but this mirrors what `Arc` does and could be useful for other things too (like comparing if Arc and Weak point to the same thing without playing with the counts), while some opaque pointer wouldn't. Some secondary questions, if this is deemed desirable are: * The weak pointer may be dangling if it is created by `Weak::new()`. It would make sense to treat this as NULL, but that is incompatible with `T: ?Sized` ‒ both `new()` and `ptr::null()` are available only for sized types. The current implementation is therefore also available only for sized `T`s. It would be possible to allow `?Sized` if the API would be `fn into_raw(self) -> Option<NonNull<T>>` and `fn from_raw(NonNull<T>)`, but that's different API than `Arc` has. What would be preferred? * There's a FIXME in my code about what I suspect could be UB. Is it really UB & how to get the pointer correctly? Is manual offsetting of the pointer the only way? * Am I missing some other necessary thing around the feature gates and such? * Is the documentation understandable? I know writing docs is not my strongest skill :-|. Thinks I'd like to do as part of the PR, but are not yet done: * Turn the referenced issue into tracking issue for the feature flag. * Once the `sync::Weak` is considered reasonable, I'd do the equivalent for `rc::Weak`. * This might call for few more tests than what is currently part of the documentation.
2019-05-27Box::into_vec: use Box::into_raw instead of mem::forgetRalf Jung-5/+4
2019-05-27Update src/liballoc/boxed.rsAleksey Kladov-0/+1
Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-05-27make Box<str>::clone simpler & saferAleksey Kladov-4/+2
2019-05-27Disable drain_filter tests that require catch_unwind on miriAaron Loucks-0/+2
2019-05-27Refactor DrainFilter::next and update commentsAaron Loucks-16/+13
2019-05-27Add drain_filter_unconsumed testAaron Loucks-0/+8
2019-05-27Fix formatting nitAaron Loucks-2/+1
2019-05-27avoid materializing unintialized Boxes in RawVecAleksey Kladov-7/+12
2019-05-26Prevent Vec::drain_filter from double dropping on panicAaron Loucks-10/+162
Fixes: #60977
2019-05-26rc::Weak::{as,from,into}_rawMichal 'vorner' Vaner-6/+156
Methods on the Weak to access it as a raw pointer to the data.
2019-05-26sync::Weak::{as,from,into}_rawMichal 'vorner' Vaner-6/+158
Methods on the Weak to access it as raw pointer to the data.
2019-05-26Rollup merge of #61114 - RalfJung:vec, r=GankroMazdak Farrokhzad-7/+92
Vec: avoid creating slices to the elements Instead of `self.deref_mut().as_mut_ptr()` to get a raw pointer to the buffer, use `self.buf.ptr_mut()`. This (a) avoids creating a unique reference to all existing elements without any need, and (b) creates a pointer that can actually be used for the *entire* buffer, and not just for the part of it covered by `self.deref_mut()`. I also got worried about `RawVec::ptr` returning a `*mut T` from an `&self`, so I added both a mutable and an immutable version. Cc @Gankro in particular for the `assume` changes -- I don't know why that is not in `Unique`, but I moved it up from `Vec::deref` to `RawVec::ptr` to avoid having to repeat it everywhere. Fixes https://github.com/rust-lang/rust/issues/60847
2019-05-25shadow as_ptr as as_mut_ptr in Vec to avoid going through DerefRalf Jung-7/+71
2019-05-25add test checking that Vec push/pop does not invalidate pointersRalf Jung-0/+21
2019-05-24Remove unused import in doctestChris Gregory-1/+1
2019-05-24Reword `are not other` to `are no other`Chris Gregory-1/+1
Co-Authored-By: Jonas Schievink <jonasschievink@gmail.com>
2019-05-24SliceConcatExt::connect defaults to calling joinChris Gregory-9/+3
2019-05-24Fix documentation of `Rc::make_mut` regarding `rc::Weak`.Chris Gregory-7/+27
2019-05-24Deprecate `FnBox`. `Box<dyn FnOnce()>` can be called directly, since 1.35Simon Sapin-9/+33
FCP completion: https://github.com/rust-lang/rust/issues/28796#issuecomment-439731515
2019-05-24Rollup merge of #61086 - RalfJung:box, r=alexcrichtonMazdak Farrokhzad-5/+6
Box::into_unique: do the reborrow-to-raw *after* destroying the Box Currently we first "reborrow" the box to a raw pointer, and then `forget` it. When tracking raw pointers more strictly (something I am experimenting with locally in Miri), the "use" induced by passing the box to `forget` invalidates the previously created raw pointer. So adjust my hack from https://github.com/rust-lang/rust/pull/58429 to reorder the two operations.