summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2019-05-29Rollup merge of #61157 - ↵Mazdak Farrokhzad-0/+35
czipperz:BufReader-Seek-remove-extra-discard_buffer, r=nikomatsakis BufReader: In Seek impl, remove extra discard_buffer call As far as I can tell, this code does nothing. I'm not sure why it even is there.
2019-05-27Stabilize bufreader_buffer featureLzu Tao-4/+2
2019-05-26Document tuple's Ord behavior as sequentialChris Gregory-0/+4
2019-05-26Print file mode of PermissionExt in octal in Examplesoberien-2/+2
2019-05-25std: Depend on `backtrace` crate from crates.ioAlex Crichton-2134/+165
This commit removes all in-tree support for generating backtraces in favor of depending on the `backtrace` crate on crates.io. This resolves a very longstanding piece of duplication where the standard library has long contained the ability to generate a backtrace on panics, but the code was later extracted and duplicated on crates.io with the `backtrace` crate. Since that fork each implementation has seen various improvements one way or another, but typically `backtrace`-the-crate has lagged behind libstd in one way or another. The goal here is to remove this duplication of a fairly critical piece of code and ensure that there's only one source of truth for generating backtraces between the standard library and the crate on crates.io. Recently I've been working to bring the `backtrace` crate on crates.io up to speed with the support in the standard library which includes: * Support for `StackWalkEx` on MSVC to recover inline frames with debuginfo. * Using `libbacktrace` by default on MinGW targets. * Supporting `libbacktrace` on OSX as an option. * Ensuring all the requisite support in `backtrace`-the-crate compiles with `#![no_std]`. * Updating the `libbacktrace` implementation in `backtrace`-the-crate to initialize the global state with the correct filename where necessary. After reviewing the code in libstd the `backtrace` crate should be at exact feature parity with libstd today. The backtraces generated should have the same symbols and same number of frames in general, and there's not known divergence from libstd currently. Note that one major difference between libstd's backtrace support and the `backtrace` crate is that on OSX the crates.io crate enables the `coresymbolication` feature by default. This feature, however, uses private internal APIs that aren't published for OSX. While they provide more accurate backtraces this isn't appropriate for libstd distributed as a binary, so libstd's dependency on the `backtrace` crate explicitly disables this feature and forces OSX to use `libbacktrace` as a symbolication strategy. The long-term goal of this refactoring is to eventually move us towards a world where we can drop `libbacktrace` entirely and simply use Gimli and the surrounding crates for backtrace support. That's still aways off but hopefully will much more easily enabled by having the source of truth for backtraces live in crates.io! Procedurally if we go forward with this I'd like to transfer the `backtrace-rs` crate to the rust-lang GitHub organization as well, but I figured I'd hold off on that until we get closer to merging.
2019-05-25Annotate test with #[test]Chris Gregory-0/+1
2019-05-25Add test that impl Seek for BufReader correctly invalidates buffer between seeksChris Gregory-0/+34
2019-05-23Fix typo "spit_paths", add linkBrent Kerby-1/+3
2019-05-23Rollup merge of #61057 - sfackler:revert-next-back, r=alexcrichtonMazdak Farrokhzad-24/+0
Revert "Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators." This changed observable behavior for several iterator types. r? @alexcrichton
2019-05-22Revert "Add implementations of last in terms of next_back on a bunch of ↵Steven Fackler-24/+0
DoubleEndedIterators." This reverts commit 3e86cf36b5114f201868bf459934fe346a76a2d4.
2019-05-22Bump compiler-builtins to 0.1.15Alex Crichton-3/+3
This commit bumps the `compiler-builtins` dependency to 0.1.15 which expects to have the source for `compiler-rt` provided externally if the `c` feature is enabled. This then plumbs through the necessary support in the build system to ensure that if the `llvm-project` directory is checked out and present that we enable the `c` feature of `compiler-builtins` and compile in all the C intrinsics.
2019-05-22Rollup merge of #60581 - hellow554:fix_60580, r=alexcrichtonMazdak Farrokhzad-57/+46
convert custom try macro to `?` resolves #60580 r? @frewsxcv
2019-05-20Rollup merge of #60511 - taiki-e:libstd-intra-doc, r=Dylan-DPCMazdak Farrokhzad-2/+50
Fix intra-doc link resolution failure on re-exporting libstd Currently, re-exporting libstd items as below will [occur a lot of failures](https://gist.github.com/taiki-e/e33e0e8631ef47f65a74a3b69f456366). ```rust pub use std::*; ``` Until the underlying issue (#56922) fixed, we can fix that so they don't propagate to downstream crates. Related: https://github.com/rust-lang/rust/pull/56941 (That PR fixed failures that occur when re-exporting from libcore to libstd.) r? @QuietMisdreavus
2019-05-20Rollup merge of #60453 - tbu-:pr_getrandom_enoperm, r=sfacklerMazdak Farrokhzad-1/+6
Fall back to `/dev/urandom` on `EPERM` for `getrandom` This can happen because of seccomp or some VMs. Fixes #52609.
2019-05-20Auto merge of #60445 - RalfJung:maybe-uninit, r=Centrilbors-1/+0
stabilize core parts of MaybeUninit and deprecate mem::uninitialized in the future (1.40.0). This is part of implementing https://github.com/rust-lang/rfcs/pull/1892. Also expand the documentation a bit. This type is currently primarily useful when dealing with partially initialized arrays. In libstd, it is used e.g. in `BTreeMap` (with some unstable APIs that however can all be replaced, less ergonomically, by stable ones). What we stabilize should also be enough for `SmallVec` (Cc @bluss). Making this useful for structs requires https://github.com/rust-lang/rfcs/pull/2582 or a commitment that references to uninitialized data are not insta-UB.
2019-05-20stabilize core parts of MaybeUninit and deprecate mem::uninitialized in the ↵Ralf Jung-1/+0
future Also expand the documentation a bit
2019-05-20Auto merge of #60921 - cuviper:remove-mpsc_select, r=SimonSapinbors-1093/+9
Remove the unstable and deprecated mpsc_select This removes macro `select!` and `std::sync::mpsc::{Handle, Select}`, which were all unstable and have been deprecated since 1.32. Closes #27800 r? @SimonSapin
2019-05-18Simplify BufRead doc example using NLLBrent Kerby-9/+4
2019-05-17Auto merge of #60920 - Manishearth:rollup-p4xp4gk, r=Manishearthbors-2/+10
Rollup of 4 pull requests Successful merges: - #60791 (Update books) - #60891 (Allow claiming issues with triagebot) - #60901 (Handle more string addition cases with appropriate suggestions) - #60902 (Prevent Error::type_id overrides) Failed merges: r? @ghost
2019-05-17Remove the unstable and deprecated mpsc_selectJosh Stone-1093/+9
This removes macro `select!` and `std::sync::mpsc::{Handle, Select}`, which were all unstable and have been deprecated since 1.32.
2019-05-17Rollup merge of #60902 - sfackler:fix-error-soudness, r=alexcrichtonManish Goregaokar-2/+10
Prevent Error::type_id overrides type_id now takes an argument that can't be named outside of the std::error module, which prevents any implementations from overriding it. It's a pretty grody solution, and there's no way we can stabilize the method with this API, but it avoids the soudness issue! Closes #60784 r? @alexcrichton
2019-05-17Update the compiler_builtins crateAlex Crichton-2/+2
This updates to 0.1.13 for `compiler_builtins`, published to fix a few issues. The feature changes here are updated because `compiler_builtins` no longer enables the `c` feature by default but we want to do so through our build still. Closes #60747 Closes #60782
2019-05-17Auto merge of #60899 - cuviper:RawEntryMut-origin-story, r=Centrilbors-2/+4
doc: correct the origin of RawEntryMut
2019-05-17Auto merge of #60817 - ecstatic-morse:issue-60779, r=Centrilbors-15/+279
Add stubs to keyword docs Resolves #60779. This commit gives each stable keyword a short entry in the "Keywords" section in the docs for `std`. The newly added entries are only a single line each and contain the main purpose of the keyword. I changed some of the existing summary lines for consistency's sake. Each line is either an imperative ("name the type of a trait object" for `dyn`), or an object ("An abstract data type" for `enum`). I tried to avoid using the keyword itself or the word "keyword" in the summary. Later commits can flesh out each keyword with an example for each context in which it can appear as well as a link to the appropriate part of the rust book. **edit:** Here's the list of keywords and summaries (sans formatting) to ease reviewing. I'll try to keep this up to date as I make changes: keyword | summary -- | -- Self | The implementing type within a `trait` or `impl` block, or the current type within a type definition. as | Cast between types, or rename an import. async | ExperimentalReturn a Future instead of blocking the current thread. await | ExperimentalSuspend execution until the result of a Future is ready. break | Exit early from a loop. const | Compile-time constants and deterministic functions. continue | Skip to the next iteration of a loop. crate | A Rust binary or library. dyn | Name the type of a trait object. else | What to do when an if condition does not hold. enum | A type that can be any one of several variants. extern | Link to or import external code. false | A value of type bool representing logical false. fn | A function or function pointer. for | Iteration with in, trait implementation with impl, or higher-ranked trait bounds (for<'a>). if | Evaluate a block if a condition holds. impl | Implement some functionality for a type. in | Iterate over a series of values with for. let | Bind a value to a variable. loop | Loop indefinitely. match | Control flow based on pattern matching. mod | Organize code into modules. move | Capture a closure's environment by value. mut | A mutable binding, reference, or pointer. pub | Make an item visible to others. ref | Bind by reference during pattern matching. return | Return a value from a function. self | The receiver of a method, or the current module. static | A place that is valid for the duration of a program. struct | A type that is composed of other types. super | The parent of the current module. trait | A common interface for a class of types. true | A value of type bool representing logical true. type | Define an alias for an existing type. union | The Rust equivalent of a C-style union. unsafe | Code or interfaces whose memory safety cannot be verified by the type system. use | Import or rename items from other crates or modules. where | Add constraints that must be upheld to use an item. while | Loop while a condition is upheld.
2019-05-16Update src/libstd/error.rsSteven Fackler-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-05-16Prevent Error::type_id overridesSteven Fackler-2/+10
type_id now takes an argument that can't be named outside of the std::error module, which prevents any implementations from overriding it. It's a pretty grody solution, and there's no way we can stabilize the method with this API, but it avoids the soudness issue! Closes #60784
2019-05-16doc: correct the origin of RawEntryMutJosh Stone-2/+4
2019-05-17Rollup merge of #60894 - cuviper:hash_set_entry, r=cramertj,CentrilMazdak Farrokhzad-0/+56
Add entry-like methods to HashSet * `HashSet::get_or_insert` * `HashSet::get_or_insert_with` These provide a simplification of the `Entry` API for `HashSet`, with names chosen to match the similar methods on `Option`.
2019-05-17Rollup merge of #60685 - dtolnay:spdx, r=nikomatsakisMazdak Farrokhzad-1/+1
Switch to SPDX 2.1 license expression [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. The notation with slashes is deprecated in favor of explicit AND or OR. As I understand it, Rust's license is MIT *OR* Apache-2.0 matching the meaning of *OR* defined by [SPDX Specification 2.1](https://spdx.org/spdx-specification-21-web-version): > If presented with a choice between two or more licenses, use the disjunctive binary "OR" operator to construct a new license expression, where both the left and right operands are valid license expression values.
2019-05-16error: remove StringError from Debug outputSean McArthur-1/+7
Seeing `StringError("something something")` in debug output can cause someone to think there was an error dealing with `String`s, not that the error type is just a string. So, remove that noise.
2019-05-16Comment why get_or_insert returns &TJosh Stone-0/+4
2019-05-16Add a hash_set_entry tracking issueJosh Stone-2/+2
2019-05-16Add entry-like methods to HashSetJosh Stone-0/+52
* `HashSet::get_or_insert` * `HashSet::get_or_insert_with` These provide a simplification of the `Entry` API for `HashSet`, with names chosen to match the similar methods on `Option`.
2019-05-16Add all keywords to keyword docsDylan MacKenzie-15/+279
This commit gives each stable keyword a short entry in the "Keywords" section in the docs for `std`. The newly added entries are a single summary line and a note that the documentation is not yet complete. I changed some of the existing summary lines for consistency's sake. Each line is either a verb phrase ("name the type of a trait object" for `dyn`), or an object ("A value of type `bool` representing logical true" for `true`). I tried to avoid using the keyword itself or the word "keyword" in the summary. Later PRs can flesh out each keyword with an example of each context in which a keyword can appear and a link to the rust book. Keywords which are not close to stable rust such as `box` (which is getting unstabilized) or `try` are ignored in this PR.
2019-05-15fix wasm unused import in thread local implementationtyler-1/+0
2019-05-15llvm makes good inlining choices with only the #[cold] attributetyler-19/+15
2019-05-15remove trailing whitespacetyler-1/+1
2019-05-15cold was necessary on try_initialize_nodrop to get more straight line asmtyler-0/+1
2019-05-15- remove unnecessary inlinestyler-21/+18
- add comment explaining that the fast::Key data structure was carefully constructed for fast access on OSX - remove inline(never) from the initializer for types where `needs_drop::<T>()` is false
2019-05-15add #[allow(unused)]tyler-0/+1
2019-05-15restructure thread_local! for better codegen (especially on macos)tyler-98/+189
2019-05-15Revert "ensure fast thread local lookups occur once per access on macos"tyler-32/+6
This reverts commit d252f3b77f3b7d4cd59620588f9d026633c05816.
2019-05-15ensure fast thread local lookups occur once per access on macostyler-6/+32
2019-05-15redox had a copy of fast thread local (oversight?)tyler-104/+1
2019-05-15remove dead code: requires_move_before_droptyler-24/+3
2019-05-15Auto merge of #60775 - hellow554:no_bitrig, r=joshtriplettbors-262/+18
Remove bitrig support from rust Resolves #60743 using `find` and `rg` I delete every occurence of "bitrig" in the sources, expect for the llvm submodule (is this correct?). There's also this file https://github.com/rust-lang/rls/blob/5b8e99bb61958ca8abcb7c5eda70521726be1065/rls-analysis/test_data/rust-analysis/libstd-af9bacceee784405.json which contains a bitrig string in it. What to do with that?
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.