about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
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.
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