about summary refs log tree commit diff
path: root/src/libstd/lib.rs
AgeCommit message (Collapse)AuthorLines
2018-01-23Stabilized `#[repr(align(x))]` attribute (RFC 1358)Cameron Hart-1/+1
2018-01-20Stabilize std::ptr::NonNullSimon Sapin-1/+0
2018-01-20Mark Unique as perma-unstable, with the feature renamed to ptr_internals.Simon Sapin-1/+1
2018-01-20Rename std::ptr::Shared to NonNullSimon Sapin-1/+1
`Shared` is now a deprecated `type` alias. CC https://github.com/rust-lang/rust/issues/27730#issuecomment-352800629
2018-01-15Reexport -> re-export in prose and documentation commentsCarol (Nichols || Goulding)-3/+3
2018-01-13Auto merge of #46461 - zackmdavis:elemental_method_suggestion_jamboree, ↵bors-1/+1
r=estebank type error method suggestions use whitelisted identity-like conversions ![method_jamboree_summit](https://user-images.githubusercontent.com/1076988/33523646-e5c43184-d7c0-11e7-98e5-1bff426ade86.png) Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings: firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are pretty and good for RLS and friends. Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2018-01-07Replace empty array hack with repr(align)Robin Kruppe-1/+0
As a side effect, this fixes the warning about repr(C, simd) that has been reported during x86_64 windows builds since #47111 (see also: #47103)
2018-01-06type error method suggestions use whitelisted identity-like conversionsZack M. Davis-1/+1
Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings. Firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are preferred (because they're pretty, but also for RLS and friends). Also also, we make the E0055 autoderef recursion limit error use the one-time-diagnostics set, because we can potentially hit the limit a lot during probing. (Without this, test/ui/did_you_mean/recursion_limit_deref.rs would report "aborting due to 51 errors"). Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2017-12-31Auto merge of #46713 - Manishearth:memchr, r=blussbors-0/+1
Use memchr to speed up [u8]::contains 3x None
2017-12-26Adds termination_trait feature gateBastian Köcher-1/+1
2017-12-26Implements RFC 1937: `?` in `main`Bastian Köcher-0/+6
This is the first part of the RFC 1937 that supports new `Termination` trait in the rust `main` function.
2017-12-13Move rust memchr impl to libcoreManish Goregaokar-0/+1
2017-12-08Auto merge of #45837 - SimonSapin:file_read_write, r=dtolnaybors-0/+1
Add read, read_string, and write functions to std::fs New APIs in `std::fs`: ```rust pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> { … } pub fn read_string<P: AsRef<Path>>(path: P) -> io::Result<String> { … } pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> { ... } ``` (`read_string` is based on `read_to_string` and so returns an error on non-UTF-8 content.) Before: ```rust use std::fs::File; use std::io::Read; let mut bytes = Vec::new(); File::open(filename)?.read_to_end(&mut bytes)?; do_something_with(bytes) ``` After: ```rust use std::fs; do_something_with(fs::read(filename)?) ```
2017-11-26Stabilize const-calling existing const-fns in stdSimon Sapin-11/+0
Fixes #46038
2017-11-24std: Flag Windows TLS dtor symbol as #[used]Alex Crichton-0/+1
Turns out ThinLTO was internalizing this symbol and eliminating it. Worse yet if you compiled with LTO turns out no TLS destructors would run on Windows! The `#[used]` annotation should be a more bulletproof implementation (in the face of LTO) of preserving this symbol all the way through in LLVM and ensuring it makes it all the way to the linker which will take care of it.
2017-11-17add doc_highlight feature flag and testsQuietMisdreavus-0/+1
2017-11-08std: Remove `rand` crate and moduleAlex Crichton-15/+1
This commit removes the `rand` crate from the standard library facade as well as the `__rand` module in the standard library. Neither of these were used in any meaningful way in the standard library itself. The only need for randomness in libstd is to initialize the thread-local keys of a `HashMap`, and that unconditionally used `OsRng` defined in the standard library anyway. The cruft of the `rand` crate and the extra `rand` support in the standard library makes libstd slightly more difficult to port to new platforms, namely WebAssembly which doesn't have any randomness at all (without interfacing with JS). The purpose of this commit is to clarify and streamline randomness in libstd, focusing on how it's only required in one location, hashmap seeds. Note that the `rand` crate out of tree has almost always been a drop-in replacement for the `rand` crate in-tree, so any usage (accidental or purposeful) of the crate in-tree should switch to the `rand` crate on crates.io. This then also has the further benefit of avoiding duplication (mostly) between the two crates!
2017-11-07Move `File::{read,write}_contents` to `fs::{read,write}` free functions.Simon Sapin-1/+1
2017-11-07Add File::read_contents and File::write_contents convenience functions.Simon Sapin-0/+1
Before: ```rust use std::fs::File; use std::io::Read; let mut bytes = Vec::new(); File::open(filename)?.read_to_end(&mut bytes)?; do_something_with(bytes) ``` After: ```rust use std::fs::File; do_something_with(File::read_contents(filename)?) ```
2017-11-03Mark several ascii methods as unstable againLukas Kalbertodt-0/+1
We don't want to stabilize them now already. The goal of this set of commits is just to add inherent methods to the four types. Stabilizing all of those methods can be done later.
2017-10-31Auto merge of #44764 - nvzqz:master, r=alexcrichtonbors-0/+2
Implement TryFrom<&[T]> for &[T; N] There are many cases where a buffer with a static compile-time size is preferred over a slice with a dynamic size. This allows for performing a checked conversion from `&[T]` to `&[T; N]`. This may also lead to compile-time optimizations involving `[T; N]` such as loop unrolling. This is my first PR to Rust, so I'm not sure if discussion of this change should happen here or does it need its own RFC? I figured these changes would be a subset of #33417.
2017-10-26Bump to 1.23 and update bootstrapAlex Crichton-12/+11
This commit updates the bootstrap compiler, bumps the version to 1.23, updates Cargo, updates books, and updates crates.io dependencies
2017-10-01Improve performance of spsc_queue and stream.Joshua Lockerman-0/+2
This commit makes two main changes. 1. It switches the spsc_queue node caching strategy from keeping a shared counter of the number of nodes in the cache to keeping a consumer only counter of the number of node eligible to be cached. 2. It separate the consumer and producers fields of spsc_queue and stream into a producer cache line and consumer cache line.
2017-09-29Enable required features for core::array in libstdNikolai Vazquez-0/+2
2017-09-19Auto merge of #44026 - QuietMisdreavus:trimmed-std, r=steveklabnikbors-1/+7
hide internal types/traits from std docs via new #[doc(masked)] attribute Fixes #43701 (hopefully for good this time) This PR introduces a new parameter to the `#[doc]` attribute that rustdoc looks for on `extern crate` statements. When it sees `#[doc(masked)]` on such a statement, it hides traits and types from that crate from appearing in either the "Trait Implementations" section of many type pages, or the "Implementors" section of trait pages. This is then applied to the `libc`/`rand`/`compiler_builtins` imports in libstd to prevent those crates from creating broken links in the std docs. Like in #43348, this also introduces a feature gate, `doc_masked`, that controls the use of this parameter. To view the std docs generated with this change, head to https://tonberry.quietmisdreavus.net/std-43701/std/index.html.
2017-09-17Add `<*const T>::align_offset` and use it in `memchr`Oliver Schneider-0/+1
2017-09-16stabilized needs_drop (fixes #41890)Michal Budzynski-1/+0
2017-09-16change #![feature(const_fn)] to specific gatesAlex Burka-0/+12
2017-09-09Auto merge of #44438 - Xaeroxe:clamp, r=Mark-Simulacrumbors-1/+0
Revert clamp Revert clamp per https://github.com/rust-lang/rust/issues/44095#issuecomment-328218316 while we take time to assess the potential backwards compatibility damage done by it.
2017-09-08Revert "Add panic unit tests"Jacob Kiesel-1/+0
This reverts commit b762283e57ff71f6763effb9cfc7fc0c7967b6b0.
2017-09-06Rollup merge of #44097 - Xaeroxe:clamp, r=burntsushiMark Simulacrum-0/+1
Add clamp functions Implementation of clamp feature: Tracking issue: https://github.com/rust-lang/rust/issues/44095 RFC: https://github.com/rust-lang/rfcs/pull/1961
2017-09-05add feature gate doc_masked and testsQuietMisdreavus-0/+1
2017-09-05new attribute #[doc(masked)] to hide internal crates from std docsQuietMisdreavus-1/+6
2017-09-04Add panic unit testsJacob Kiesel-0/+1
2017-08-31Bring back stage0 allocator logic on MSVCAlex Crichton-2/+5
I think there may still be bugs preventing its removal..
2017-08-31Update Cargo to 0.23.0 and our lockfileAlex Crichton-0/+2
2017-08-31Bump to 1.22.0Alex Crichton-10/+3
2017-08-27Whitelist unwind import in stdTatsuyuki Ishi-2/+2
This is a part of libbacktrace linkage and thus the compiler cannot detect if it's used or not.
2017-08-27Move unused-extern-crate to late passTatsuyuki Ishi-1/+2
2017-08-25*: remove crate_{name,type} attributesTamir Duberstein-3/+0
Fixes #41701.
2017-08-13Docs: restore link text after renaming anchorRuud van Asseldonk-2/+2
The text does not need the hyphen, but the anchor name does.
2017-08-13Replace space in Markdown link labelRuud van Asseldonk-3/+3
With the space, the tidy check does not recognize it as a link label. See also the comment above in line_is_url() in src/tools/tidy/src/style.rs.
2017-08-13Point "deref coercions" links to new bookRuud van Asseldonk-1/+1
Currently the link on doc.rust-lang.org is semi-broken; it links to a page that links to the exact page in the first edition in the book, or to the index of the second edition of the book. If the second editions is the recommended one now, we should point the links at that one. It seems that in the mean time, the links have been updated to point directly to the first edition of the book, but that hasn't made it onto the stable channel yet. By the time this commit makes it onto the stable channel, the second edition of the book should be complete enough. At least the part about deref coercions is.
2017-08-13Auto merge of #43348 - kennytm:fix-24658-doc-every-platform, r=alexcrichtonbors-0/+1
Expose all OS-specific modules in libstd doc. 1. Uses the special `--cfg dox` configuration passed by rustbuild when running `rustdoc`. Changes the `#[cfg(platform)]` into `#[cfg(any(dox, platform))]` so that platform-specific API are visible to rustdoc. 2. Since platform-specific implementations often won't compile correctly on other platforms, `rustdoc` is changed to apply `everybody_loops` to the functions during documentation and doc-test harness. 3. Since platform-specific code are documented on all platforms now, it could confuse users who found a useful API but is non-portable. Also, their examples will be doc-tested, so must be excluded when not testing on the native platform. An undocumented attribute `#[doc(cfg(...))]` is introduced to serve the above purposed. Fixes #24658 (Does _not_ fully implement #1998).
2017-08-12Check #[thread_local] statics correctly in the compiler.Eduard-Mihai Burtescu-0/+1
2017-08-10Fix cross-crate global allocators on windowsAidan Hobson Sayers-4/+10
2017-08-10Exposed all platform-specific documentation.kennytm-0/+1
2017-08-07Make a disable-jemalloc build workAidan Hobson Sayers-0/+10
Fixes #43510
2017-07-26Auto merge of #43373 - alexcrichton:stabilize-1.20.0, r=aturonbors-2/+0
Stabilize more APIs for the 1.20.0 release In addition to the few stabilizations that have already landed, this cleans up the remaining APIs that are in `final-comment-period` right now to be stable by the 1.20.0 release
2017-07-25std: Stabilize the `str_{mut,box}_extras` featureAlex Crichton-1/+0
Stabilizes * `<&mut str>::as_bytes_mut` * `<Box<str>>::into_boxed_bytes` * `std::str::from_boxed_utf8_unchecked` * `std::str::from_utf8_mut` * `std::str::from_utf8_unchecked_mut` Closes #41119