about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2019-05-14Rollup merge of #60780 - RalfJung:miri, r=oli-obkMazdak Farrokhzad-4/+1
fix Miri This reverts https://github.com/rust-lang/rust/pull/60156, which turned out to be a dead end (see https://github.com/rust-lang/rust/pull/60469). r? @oli-obk
2019-05-14Rollup merge of #60443 - RalfJung:as_ptr, r=SimonSapinMazdak Farrokhzad-2/+7
as_ptr returns a read-only pointer Add comments to `as_ptr` methods to warn that these are read-only pointers, and writing to them is UB. [It was pointed out](https://internals.rust-lang.org/t/as-ptr-vs-as-mut-ptr/9940) that `CStr` does not even have an `as_mut_ptr`. I originally was going to add one, but there is no method at all that would mutate a `CStr`. Was that a deliberate choice or should I add an `as_mut_ptr` (similar to [what I did for `str`](https://github.com/rust-lang/rust/pull/58200))?
2019-05-14Rollup merge of #60130 - khuey:efficient_last, r=sfacklerMazdak Farrokhzad-0/+24
Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators Provided a `DoubleEndedIterator` has finite length, `Iterator::last` is equivalent to `DoubleEndedIterator::next_back`. But searching forwards through the iterator when it's unnecessary is obviously not good for performance. I ran into this on one of the collection iterators. I tried adding appropriate overloads for a bunch of the iterator adapters like filter, map, etc, but I ran into a lot of type inference failures after doing so. The other interesting case is what to do with `Repeat`. Do we consider it part of the contract that `Iterator::last` will loop forever on it? The docs do say that the iterator will be evaluated until it returns None. This is also relevant for the adapters, it's trivially easy to observe whether a `Map` adapter invoked its closure a zillion times or just once for the last element.
2019-05-13Destabilize the `Error::type_id` functionAlex Crichton-1/+4
This commit destabilizes the `Error::type_id` function in the standard library. This does so by effectively reverting #58048, restoring the `#[unstable]` attribute. The security mailing list has recently been notified of a vulnerability relating to the stabilization of this function. First stabilized in Rust 1.34.0, a stable function here allows users to implement a custom return value for this function: struct MyType; impl Error for MyType { fn type_id(&self) -> TypeId { // Enable safe casting to `String` by accident. TypeId::of::<String>() } } This, when combined with the `Error::downcast` family of functions, allows safely casting a type to any other type, clearly a memory safety issue! A security announcement will be shortly posted to the security mailing list as well as the Rust Blog, and when those links are available they'll be filled in for this PR as well. This commit simply destabilizes the `Error::type_id` which, although breaking for users since Rust 1.34.0, is hoped to have little impact and has been deemed sufficient to mitigate this issue for the stable channel. The long-term fate of the `Error::type_id` API will be discussed at #60784.
2019-05-13Revert "use SecRandomCopyBytes on macOS in Miri"Ralf Jung-4/+1
This reverts commit 54aefc6a2d076b74921a8d78c5d8c68c13bfa4a7.
2019-05-13Remove bitrig support from rustMarcel Hellwig-262/+18
2019-05-10Auto merge of #60684 - jethrogb:jb/sgx-test, r=joshtriplettbors-0/+1
Fix cfg(test) build on SGX Introduced in #60657 r? @joshtriplett
2019-05-09Switch to SPDX 2.1 license expressionDavid Tolnay-1/+1
According to the Cargo Reference: https://doc.rust-lang.org/cargo/reference/manifest.html > This is an SPDX 2.1 license expression for this package. Currently > crates.io will validate the license provided against a whitelist of > known license and exception identifiers from the SPDX license list > 2.4. Parentheses are not currently supported. > > Multiple licenses can be separated with a `/`, although that usage > is deprecated. Instead, use a license expression with AND and OR > operators to get more explicit semantics.
2019-05-09Fix cfg(test) build on SGXJethro Beekman-0/+1
2019-05-09Rollup merge of #60675 - cramertj:no-await-macro, r=nikomatsakis,CentrilMazdak Farrokhzad-23/+0
Remove the old await! macro This doesn't work anymore, and its continued presence is cause for confusion. `yield` can no longer be used to return `Pending` from an `async` body. cc https://github.com/rust-lang/rust/issues/60660 cc @taiki-e cc https://github.com/tokio-rs/tokio/pull/1080
2019-05-09Rollup merge of #60234 - tesaguri:cursor-default, r=AmanieuMazdak Farrokhzad-1/+1
std: Derive `Default` for `io::Cursor` I think this change is quite obvious, so made it insta-stable, but I won't insist on that.
2019-05-09Remove the old await! macroTaylor Cramer-23/+0
This doesn't work anymore, and its continued presence is cause for confusion.
2019-05-09Rollup merge of #60657 - JohnTitor:stabilize-array, r=SimonSapinMazdak Farrokhzad-1/+2
Stabilize and re-export core::array in std Fixes #60014
2019-05-09Rollup merge of #60656 - petertodd:2019-inline-cursor-over-slice, r=sfacklerMazdak Farrokhzad-0/+6
Inline some Cursor calls for slices (Partially) brings back https://github.com/rust-lang/rust/pull/33921 I've noticed in some serialization code I was writing that writes to slices produce much, much, worse code than you'd expect even with optimizations turned on. For example, you'd expect something like this to be zero cost: ``` use std::io::{self, Cursor, Write}; pub fn serialize((a, b): (u64, u64)) -> [u8;8+8] { let mut r = [0u8;16]; { let mut w = Cursor::new(&mut r[..]); w.write(&a.to_le_bytes()).unwrap(); w.write(&b.to_le_bytes()).unwrap(); } r } ``` ...but it compiles down to [dozens of instructions](https://rust.godbolt.org/z/bdwDzb) because the `slice_write()` calls aren't inlined, which in turn means `unwrap()` can't be optimized away, and so on. To be clear, this pull-req isn't sufficient by itself: if we want to go down that path we also need to add `#[inline]`'s to the default implementations for functions like `write_all()` in the `Write` trait and so on, or implement them separately in the `Cursor` impls. But I figured I'd start a conversation about what tradeoffs we're expecting here.
2019-05-09Stabilize and re-export core::arrayYuki OKUSHI-1/+2
2019-05-08Inline some Cursor calls for slicesPeter Todd-0/+6
(Partially) brings back https://github.com/rust-lang/rust/pull/33921
2019-05-08std: Update compiler-builtins crateAlex Crichton-1/+1
Pulls in a fix for ensuring that wasm targets have code in compiler-builtins for `ldexp` which LLVM can generate references to.
2019-05-06use exhaustive_patterns to be able to use `?`Marcel Hellwig-12/+15
2019-05-06convert custom try macro to `?`Marcel Hellwig-45/+31
resolves #60580
2019-05-05Rollup merge of #60536 - brainplot:fix-unicode-character, r=dtolnayManish Goregaokar-1/+1
Correct code points to match their textual description Probably due to a copy-paste error, in the sentence > For example, despite looking similar, the 'é' character is one Unicode code point while 'é' is two Unicode code points: the two `é`'s were actually the same character in the text (i.e. the same Unicode character U+00E9). The code listing below instead had two different Unicode characters for the two `é`s, as it was supposed to. The example shown wasn't clear at first so I started inspecting the text and found this out. I simply copied the character from the code listing to the description surrounding the code. It's a minor thing but I thought it would make things clearer for others, especially since the example is about how Rust handles `char`s.
2019-05-04Fix intra-doc link resolution failure on re-exporting libstdTaiki Endo-2/+50
2019-05-03Categorize WASI as an "OS" rather than as an "environment".Dan Gohman-2/+2
This distinction is fairly abstract, but in practice, the main advantage here is that LLVM's triple code considers WASI to be an OS, so this makes rustc agree with that.
2019-05-04Correct code points to match their textual descriptionGianluca Recchia-1/+1
2019-05-03Auto merge of #60496 - jethrogb:jb/address-integer-overflow, r=alexcrichtonbors-7/+17
Fix potential integer overflow in SGX memory range calculation. Thanks to Eduard Marin and David Oswald at the University of Burmingham, and Jo Van Bulck at KU Leuven for discovering this issue.
2019-05-03Rollup merge of #60373 - rasendubi:lang-features-sort-since, r=CentrilMazdak Farrokhzad-41/+41
Tidy: ensure lang features are sorted by since This is the tidy side of https://github.com/rust-lang/rust/issues/60361. What is left is actually splitting features into groups and sorting by since. This PR also likely to produce a small (a couple of lines) merge conflict with https://github.com/rust-lang/rust/pull/60362. r? @Centril
2019-05-03Auto merge of #59883 - ebarnard:clonefile, r=sfacklerbors-21/+71
Make `std::fs::copy` attempt to create copy-on-write clones of files on MacOS The behaviour of MacOS now matches Linux which uses `copy_file_range` to perform CoW file copies where available and supported by the underlying filesystem.
2019-05-02Fix potential integer overflow in SGX memory range calculation.Jethro Beekman-7/+17
Thanks to Eduard Marin and David Oswald at the University of Burmingham, and Jo Van Bulck at KU Leuven for discovering this issue.
2019-05-02Make tidy::version::Version a [u32; 3]Alexey Shmalko-41/+41
2019-05-02Make `std::fs::copy` attempt to create copy-on-write clones of files on MacOS.Edward Barnard-21/+71
2019-05-02Auto merge of #60156 - RalfJung:macos-rand, r=oli-obk,alexcrichtonbors-1/+4
use SecRandomCopyBytes on macOS in Miri This is a hack to fix https://github.com/rust-lang/miri/issues/686: on macOS, rustc will open `/dev/urandom` to initialize a `HashMap`. That's quite hard to emulate properly in Miri without a full-blown implementation of file descriptors. However, Miri needs an implementation of `SecRandomCopyBytes` anyway to support [getrandom](https://crates.io/crates/getrandom), so using it here should work just as well. This will only have an effect when libstd is compiled specifically for Miri, but that will generally be the case when people use `cargo miri`. This is clearly a hack, so I am opening this to start a discussion about whether we are okay with such a hack or not. Cc @oli-obk
2019-05-01Fall back to `/dev/urandom` on `EPERM` for `getrandom`Tobias Bucher-1/+6
This can happen because of seccomp or some VMs. Fixes #52609.
2019-05-01as_ptr returns a read-only pointerRalf Jung-2/+7
2019-05-01doc: Warn about possible zombie apocalypseMichal 'vorner' Vaner-0/+12
Extend the std::process::Child docs with warning about possible zombies. The previous version mentioned that when dropping the Child, the process is not killed. However, the wording gave the impression that such behaviour is fine to do (leaving the reader believe low-level details like reaping zombies of the dead processes is taken over by std somehow; or simply leaving the reader unaware about the problem).
2019-04-30Auto merge of #60204 - jethrogb:jb/rtunwrap-debug-print, r=alexcrichtonbors-4/+6
Debug-print error when using rtunwrap When I added this macro a while back I didn't have a way to make it print the failure for all types that you might want to unwrap. Now, I came up with a solution.
2019-04-29SGX target: implemented vectored I/OJethro Beekman-13/+50
2019-04-29SGX target: don't unwind on usercall index out of boundsJethro Beekman-2/+10
2019-04-29Rollup merge of #60334 - sfackler:stable-iovec, r=alexcrichtonMazdak Farrokhzad-278/+292
Stabilized vectored IO This renames `std::io::IoVec` to `std::io::IoSlice` and `std::io::IoVecMut` to `std::io::IoSliceMut`, and stabilizes `std::io::IoSlice`, `std::io::IoSliceMut`, `std::io::Read::read_vectored`, and `std::io::Write::write_vectored`. Closes #58452 r? @alexcrichton
2019-04-28Rollup merge of #60022 - nathankleyn:fix-issue-59543, r=CentrilMazdak Farrokhzad-1/+7
Document `Item` type in `std::env::SplitPaths` iterator. Previously there wasn't any documentation to show what the type of `Item` was inside `std::env::SplitPaths`. Now, in the same format as other examples of docs in `std` for `Iterator#Item`, we mention the type. This fixes #59543. r? @steveklabnik
2019-04-27Rename .cap() methods to .capacity()Matthias Geier-7/+7
... but leave the old names in there for backwards compatibility.
2019-04-27tidySteven Fackler-10/+24
2019-04-27Stabilized vectored IOSteven Fackler-276/+276
This renames `std::io::IoVec` to `std::io::IoSlice` and `std::io::IoVecMut` to `std::io::IoSliceMut`, and stabilizes `std::io::IoSlice`, `std::io::IoSliceMut`, `std::io::Read::read_vectored`, and `std::io::Write::write_vectored`. Closes #58452
2019-04-26Use "capacity" as parameter name in with_capacity() methodsMatthias Geier-10/+10
Closes #60271.
2019-04-26Remove feature gates from std and testsChristopher Serr-1/+0
2019-04-25ignore-tidy-filelength on all files with greater than 3000 linesvarkor-0/+8
2019-04-25Rollup merge of #60185 - NieDzejkob:int-error-kind-reexport, r=rkruppeMazdak Farrokhzad-0/+7
Reexport IntErrorKind in std Currently `IntErrorKind` can only be found in `core`. @Centril confirmed on Discord that this is unintentional (should I r? him in this situation?). Should there be a test for this? As far as this *specific* situation goes, I don't think so, I'll risk it and say that there's no way this regresses. However, it might be a good idea to have some tool detect public items in `core` that are not reexported in `std`. Does this belong in tidy, or should that be a separate tool? Is there some rustc-specific *linter*? Unless that's entirely a dumb idea, this should probably get an issue. Note: My local build hasn't finished yet, but it's well past the point where I would expect problems.
2019-04-24std: Derive `Default` for `io::Cursor`Daiki Mizukami-1/+1
2019-04-24Rollup merge of #59739 - cramertj:stabilize, r=withoutboatsMazdak Farrokhzad-8/+5
Stabilize futures_api cc https://github.com/rust-lang/rust/issues/59725. Based on https://github.com/rust-lang/rust/pull/59733 and https://github.com/rust-lang/rust/pull/59119 -- only the last two commits here are relevant. r? @withoutboats , @oli-obk for the introduction of `rustc_allow_const_fn_ptr`.
2019-04-24Auto merge of #58623 - Amanieu:hashbrown3, r=alexcrichtonbors-2395/+475
Replace HashMap implementation with SwissTable (as an external crate) This is the same as #56241 except that it imports `hashbrown` as an external crate instead of copying the implementation into libstd. This includes a few API changes (all unstable): - `try_reserve` is added to `HashSet`. - Some trait bounds have been changed in the `raw_entry` API. - `search_bucket` has been removed from the `raw_entry` API (doesn't work with SwissTable).
2019-04-23Stabilize futures_apiTaylor Cramer-8/+5
2019-04-24Update hashbrown to 0.3.0Amanieu d'Antras-1/+1