about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2018-09-23Auto merge of #54339 - cramertj:no-cx, r=aturonbors-67/+4
Remove spawning from task::Context r? @aturon cc https://github.com/rust-lang-nursery/wg-net/issues/56
2018-09-23Make the `Vec::dedup` method use `slice::partition_dedup` internallyClément Renault-84/+7
2018-09-23Introduce the partition_dedup/by/by_key methods for slicesClément Renault-5/+5
2018-09-22address RalfJung's commentJorge Aparicio-6/+6
2018-09-22alloc: fix deprecated warningsJorge Aparicio-20/+21
2018-09-20std: Check for overflow in `str::repeat`Alex Crichton-1/+28
This commit fixes a buffer overflow issue in the standard library discovered by Scott McMurray where if a large number was passed to `str::repeat` it may cause and out of bounds write to the buffer of a `Vec`. This bug was accidentally introduced in #48657 when optimizing the `str::repeat` function. The bug affects stable Rust releases 1.26.0 to 1.29.0. We plan on backporting this fix to create a 1.29.1 release, and the 1.30.0 release onwards will include this fix. The fix in this commit is to introduce a deterministic panic in the case of capacity overflow. When repeating a slice where the resulting length is larger than the address space, there’s no way it can succeed anyway! The standard library and surrounding libraries were briefly checked to see if there were othere instances of preallocating a vector with a calculation that may overflow. No instances of this bug (out of bounds write due to a calculation overflow) were found at this time. Note that this commit is the first steps towards fixing this issue, we'll be making a formal post to the Rust security list once these commits have been merged.
2018-09-19Remove spawning from task::ContextTaylor Cramer-67/+4
2018-09-19Auto merge of #53877 - withoutboats:compositional-pin, r=aturonbors-313/+44
Update to a new pinning API. ~~Blocked on #53843 because of method resolution problems with new pin type.~~ @r? @cramertj cc @RalfJung @pythonesque anyone interested in #49150
2018-09-17Cleanup and fix method resolution issueTaylor Cramer-1/+5
2018-09-16Auto merge of #53804 - RalfJung:ptr-invalid, r=nagisabors-6/+4
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-16use mem::zeroed to make up ZST valuesRalf Jung-4/+4
2018-09-11stabalize infer outlives requirements (RFC 2093).toidiu-1/+0
Co-authored-by: nikomatsakis
2018-09-08Auto merge of #51885 - GuillaumeGomez:trait-impl-show-docs, ↵bors-15/+7
r=Mark-Simulacrum,QuietMisdreavus Trait impl show docs Fixes #51834. <img width="1440" alt="screen shot 2018-06-29 at 00 14 33" src="https://user-images.githubusercontent.com/3050060/42063323-6e6e8cc8-7b31-11e8-88ef-4dd2229df76c.png"> (You can see both commit changes in the screenshot 😄) r? @QuietMisdreavus
2018-09-07Rollup merge of #53874 - withoutboats:pin-ptr-impls, r=RalfJungkennytm-2/+33
Implement Unpin for Box, Rc, and Arc Per the discussion in #49150, these should implement `Unpin` even if what they point to does not.
2018-09-06Fix invalid urlsGuillaume Gomez-15/+7
2018-09-06Fix typos.Without Boats-2/+2
2018-09-05Auto merge of #52994 - varkor:trim_direction, r=alexcrichtonbors-30/+38
Add trim_start, trim_end etc.; deprecate trim_left, trim_right, etc. in future Adds the methods: `trim_start`, `trim_end`, `trim_start_matches` and `trim_end_matches`. Deprecates `trim_left`, `trim_right`, `trim_left_matches` and `trim_right_matches` starting from Rust 1.33.0, three versions from when they'll initially be marked as being deprecated, using the future deprecation from https://github.com/rust-lang/rust/issues/30785 and https://github.com/rust-lang/rust/pull/51681. Fixes https://github.com/rust-lang/rust/issues/30459.
2018-09-05Add comment.Without Boats-0/+22
2018-09-04Breaking change upgradesMark Rousskov-4/+5
2018-09-01Auto merge of #53884 - kennytm:rollup, r=kennytmbors-4/+5
Rollup of 9 pull requests Successful merges: - #53076 (set cfg(rustdoc) when rustdoc is running on a crate) - #53622 (cleanup: Add main functions to some UI tests) - #53769 (Also link Clippy repo in the CONTRIBUTING.md file) - #53774 (Add rust-gdbgui script.) - #53781 (bench: libcore: fix build failure of any.rs benchmark (use "dyn Any")) - #53782 (Make Arc cloning mechanics clearer in module docs) - #53790 (Add regression test for issue #52060) - #53801 (Prevent duplicated impl on foreign types) - #53850 (Nuke the `const_to_allocation` query)
2018-09-01Rollup merge of #53782 - rask:task/arc-docs-adjustment, r=cramertjkennytm-4/+5
Make Arc cloning mechanics clearer in module docs Add some more wording to module documentation regarding how `Arc::clone()` works, as some users have assumed cloning Arc's to work via dereferencing to inner value as follows: use std::sync::Arc; let myarc = Arc::new(1); let myarcref = myarc.clone(); assert!(1 == myarcref); Instead of the actual mechanic of referencing the existing Arc value: use std::sync::Arg; let myarc = Arc::new(1); let myarcref = myarc.clone(); assert!(myarcref == &myarc); // not sure if assert could assert this in the real world
2018-09-01Update to a new pinning API.Without Boats-313/+40
2018-09-01Fix Rc impl.Without Boats-1/+1
2018-09-01Implement Unpin for Box, Rc, and ArcWithout Boats-2/+11
2018-08-31Add clearer wording to Arc clone example codeOtto Rask-1/+1
2018-08-31Restrict most uses of `const_fn` to `min_const_fn`Oliver Schneider-2/+4
2018-08-30Rollup merge of #53113 - kpp:more_docs_for_cow, r=GuillaumeGomezPietro Albini-0/+35
Add example for Cow Add one more example that shows how to keep `Cow` in a struct. Link to playground: https://play.rust-lang.org/?gist=a9256bdd034b44bc3cdd0044bbcdbb7c&version=stable&mode=debug&edition=2015 Users ask this question in [ruRust](https://gitter.im/ruRust/general) chat time to time and it is not obvious to add `ToOwned<Owned=Target>` to requirements of generic params.
2018-08-30Rephrase Arc documentation changes regarding clonesOtto Rask-4/+4
Make it clearer that `Arc::clone()` in fact creates a whole new Arc with the internal pointer pointing to the same location as the source Arc.
2018-08-29fix some uses of pointer intrinsics with invalid pointersRalf Jung-6/+4
2018-08-29Auto merge of #53564 - MaloJaffre:vecdeque, r=gnzlbgbors-5/+47
Reoptimize VecDeque::append ~Unfortunately, I don't know if these changes fix the unsoundness mentioned in #53529, so it is stil a WIP. This is also completely untested. The VecDeque code contains other unsound code: one example : [reading unitialized memory](https://play.rust-lang.org/?gist=6ff47551769af61fd8adc45c44010887&version=nightly&mode=release&edition=2015) (detected by MIRI), so I think this code will need a bigger refactor to make it clearer and safer.~ Note: this is based on #53571. r? @SimonSapin Cc: #53529 #52553 @YorickPeterse @jonas-schievink @Pazzaz @shepmaster.
2018-08-29Add another assertMaloJaffre-0/+4
2018-08-29Make Arc cloning mechanics clearer in module docsOtto Rask-4/+5
Add some more wording to module documentation regarding how `Arc::clone()` works, as some users have assumed cloning Arc's to work via dereferencing to inner value as follows: use std::sync::Arc; let myarc = Arc::new(1); let myarcref = myarc.clone(); assert!(1 == myarcref); Instead of the actual mechanic of referencing the existing Arc value: use std::sync::Arg; let myarc = Arc::new(1); let myarcref = myarc.clone(); assert!(myarcref == &myarc); // not sure if assert could assert this in the real world
2018-08-28Fix tidyMaloJaffre-1/+2
2018-08-28Add docs and debug assertsMaloJaffre-11/+23
2018-08-27Auto merge of #53227 - nivkner:pin_move, r=RalfJungbors-202/+312
move the Pin API into its own module for centralized documentation This implements the change proposed by @withoutboats in #49150, as suggested by @RalfJung in the review of #53104, along with the documentation that was originally in it, that was deemed more appropriate in module-level documentation. r? @RalfJung
2018-08-27Auto merge of #53441 - toidiu:ak-fix53419, r=nikomatsakisbors-0/+1
fix for late-bound regions Fix for https://github.com/rust-lang/rust/issues/53419 r? @nikomatsakis
2018-08-24check that adding infer-outlives requirement to all crates worksNiko Matsakis-0/+1
2018-08-25remove copyright headers now that they are not madatoryNiv Kaminer-10/+0
2018-08-24Auto merge of #53662 - kennytm:rollup, r=kennytmbors-4/+4
Rollup of 16 pull requests Successful merges: - #53311 (Window Mutex: Document that we properly initialize the SRWLock) - #53503 (Discourage overuse of mem::forget) - #53545 (Fix #50865: ICE on impl-trait returning functions reaching private items) - #53559 (add macro check for lint) - #53562 (Lament the invincibility of the Turbofish) - #53563 (use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into()) - #53592 (docs: minor stylistic changes to str/string docs) - #53594 (Update RELEASES.md to include clippy-preview) - #53600 (Fix a grammatical mistake in "expected generic arguments" errors) - #53614 (update nomicon and book) - #53617 (tidy: Stop requiring a license header) - #53618 (Add missing fmt examples) - #53636 (Prefer `.nth(n)` over `.skip(n).next()`.) - #53644 (Use SmallVec for SmallCStr) - #53664 (Remove unnecessary closure in rustc_mir/build/mod.rs) - #53666 (Added rustc_codegen_llvm to compiler documentation.)
2018-08-24Optimize VecDeque::appendMaloJaffre-2/+27
2018-08-24Slightly refactor VecDeque implementationMaloJaffre-3/+3
2018-08-24Rollup merge of #53592 - matthiaskrgr:str_doc, r=alexcrichtonkennytm-4/+4
docs: minor stylistic changes to str/string docs std::string::String.repeat(): slightly rephrase to be more in-line with other descriptions. add ticks around a few keywords in other descriptions.
2018-08-23Stabilize 'attr_literals' feature.Sergio Benitez-1/+0
2018-08-23link to items in pin module to std docsNiv Kaminer-3/+3
2018-08-23reexport Unpin into pin moduleNiv Kaminer-1/+2
2018-08-23add more info on Unpin and connect paragraphs betterNiv Kaminer-7/+14
2018-08-23allow unused mut for pinning explanationNiv Kaminer-0/+1
2018-08-23deemphasize immutability and improve swap explanation in pin moduleNiv Kaminer-13/+9
2018-08-23expand the documentation on PinBoxNiv Kaminer-0/+9
2018-08-23move pin module to liballoc and reexport thatNiv Kaminer-3/+79