summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
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
2018-08-23attempt to work around Box<T> not being recognized as local typeNiv Kaminer-7/+8
2018-08-23add top-level documentation to the std pin moduleNiv Kaminer-0/+4
2018-08-23move PinBox into pin module and export through stdNiv Kaminer-202/+226
2018-08-23move PinMut into pin module and export through stdNiv Kaminer-1/+2
2018-08-22Add a test for issue #53529MaloJaffre-0/+17
2018-08-22Fix unsoundness in VecDeque Debug implsMaloJaffre-8/+8
Fixes #53566.
2018-08-22Revert "Auto merge of #52553 - Pazzaz:vecdeque-append, r=SimonSapin"MaloJaffre-159/+2
This partially reverts commit d5b6b95aef94169b5dbe4dbb1357d4bab1fc9800, reversing changes made to 6b1ff19af36f7bbf1974579ec1b9bf2c8ccd595e. Fixes #53529. Cc: #53564.
2018-08-22docs: std::string::String.repeat(): slightly rephrase to be more in-line ↵Matthias Krüger-4/+4
with other descriptions. add ticks around a few keywords in other descriptions.
2018-08-21Auto merge of #53530 - kennytm:rollup, r=kennytmbors-80/+82
Rollup of 17 pull requests Successful merges: - #53030 (Updated RELEASES.md for 1.29.0) - #53104 (expand the documentation on the `Unpin` trait) - #53213 (Stabilize IP associated constants) - #53296 (When closure with no arguments was expected, suggest wrapping) - #53329 (Replace usages of ptr::offset with ptr::{add,sub}.) - #53363 (add individual docs to `core::num::NonZero*`) - #53370 (Stabilize macro_vis_matcher) - #53393 (Mark libserialize functions as inline) - #53405 (restore the page title after escaping out of a search) - #53452 (Change target triple used to check for lldb in build-manifest) - #53462 (Document Box::into_raw returns non-null ptr) - #53465 (Remove LinkMeta struct) - #53492 (update lld submodule to include RISCV patch) - #53496 (Fix typos found by codespell.) - #53521 (syntax: Optimize some literal parsing) - #53540 (Moved issue-53157.rs into src/test/ui/consts/const-eval/) - #53551 (Avoid some Place clones.) Failed merges: r? @ghost