about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2018-11-20Incorporate `dyn` into more comments and docs.Corey Farwell-2/+2
2018-11-19Rollup merge of #56059 - alexcrichton:fix-tests, r=sfacklerkennytm-1/+1
Increase `Duration` approximate equal threshold to 1us Previously this threshold when testing was 100ns, but the Windows documentation states: > which is a high resolution (<1us) time stamp which presumably means that we could have up to 1us resolution, which means that 100ns doesn't capture "equivalent" time intervals due to various bits of rounding here and there. It's hoped that this.. Closes #56034
2018-11-19Rollup merge of #56011 - CBenoit:master, r=QuietMisdreavusPietro Albini-1/+1
Replace data.clone() by Arc::clone(&data) in mutex doc. Arc::clone(&from) is considered as more idiomatic because it conveys more explicitly the meaning of the code. Since this clone is visible in the official documentation, I thought it could be better to use the more idiomatic version.
2018-11-18Increase `Duration` approximate equal threshold to 1usAlex Crichton-1/+1
Previously this threshold when testing was 100ns, but the Windows documentation states: > which is a high resolution (<1us) time stamp which presumably means that we could have up to 1us resolution, which means that 100ns doesn't capture "equivalent" time intervals due to various bits of rounding here and there. It's hoped that this.. Closes #56034
2018-11-17std: Add debugging for a failing test on appveyorAlex Crichton-1/+5
I'm not sure why this is failing, so let's hopefully get some more information to help investigation!
2018-11-16Replace data.clone() by Arc::clone(&data) in mutex doc.Benoît C-1/+1
Arc::clone(&from) is considered as more idiomatic because it conveys more explicitly the meaning of the code.
2018-11-15use ? operator instead of matchSebastian Geisler-20/+6
2018-11-15Rename checked_add_duration to checked_add and make it take the duration by ↵Sebastian Geisler-5/+5
value
2018-11-15Implement checked_add_duration for SystemTimeSebastian Geisler-22/+92
Since SystemTime is opaque there is no way to check if the result of an addition will be in bounds. That makes the Add<Duration> trait completely unusable with untrusted data. This is a big problem because adding a Duration to UNIX_EPOCH is the standard way of constructing a SystemTime from a unix timestamp. This commit implements checked_add_duration(&self, &Duration) -> Option<SystemTime> for std::time::SystemTime and as a prerequisite also for all platform specific time structs. This also led to the refactoring of many add_duration(&self, &Duration) -> SystemTime functions to avoid redundancy (they now unwrap the result of checked_add_duration). Some basic unit tests for the newly introduced function were added too.
2018-11-15Rollup merge of #55901 - euclio:speling, r=petrochenkovPietro Albini-11/+11
fix various typos in doc comments
2018-11-15Rollup merge of #55865 - RalfJung:unix-rwlock, r=alexcrichtonPietro Albini-3/+3
Unix RwLock: avoid racy access to write_locked We should only access `write_locked` if we really got the lock.
2018-11-15Rollup merge of #55622 - jakllsch:netbsd-librt, r=alexcrichtonPietro Albini-1/+4
NetBSD: link libstd with librt in addition to libpthread Some aio(3) and mq(3) functions in the libc crate actually come from NetBSD librt, not libc or libpthread.
2018-11-15Rollup merge of #55211 - fintelia:bufwriter-buffer, r=shepmasterPietro Albini-10/+38
Add BufWriter::buffer method CC #45323
2018-11-15Rollup merge of #55182 - jD91mZM2:rebased, r=alexcrichtonPietro Albini-63/+235
Redox: Update to new changes These are all cherry-picked from our fork: - Remove the `env:` scheme - Update `execve` system call to `fexec` - Interpret shebangs: these are no longer handled by the kernel, which like usual tries to be as minimal as possible
2018-11-14std: Synchronize access to global env during `exec`Alex Crichton-16/+60
This commit, after reverting #55359, applies a different fix for #46775 while also fixing #55775. The basic idea was to go back to pre-#55359 libstd, and then fix #46775 in a way that doesn't expose #55775. The issue described in #46775 boils down to two problems: * First, the global environment is reset during `exec` but, but if the `exec` call fails then the global environment was a dangling pointer into free'd memory as the block of memory was deallocated when `Command` is dropped. This is fixed in this commit by installing a `Drop` stack object which ensures that the `environ` pointer is preserved on a failing `exec`. * Second, the global environment was accessed in an unsynchronized fashion during `exec`. This was fixed by ensuring that the Rust-specific environment lock is acquired for these system-level operations. Thanks to Alex Gaynor for pioneering the solution here! Closes #55775 Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2018-11-14Revert "Fixes #46775 -- don't mutate the process's environment in Command::exec"Alex Crichton-99/+8
This reverts commit 36fe3b605a7a7143a14565272140ba1b43c1b041.
2018-11-13fix various typos in doc commentsAndy Russell-11/+11
2018-11-13Rollup merge of #55889 - RalfJung:global-alloc, r=alexcrichtonkennytm-0/+5
global allocators: add a few comments These comments answer some questions that came up when I tried to understand how the control flow works for the global allocator, `Global` and `System`. r? @alexcrichton
2018-11-13Rollup merge of #55863 - dwijnand:patch-1, r=blusskennytm-1/+1
Fix a typo in std::panic
2018-11-13The example values are now easyer to differenciateMeltinglava-8/+8
2018-11-13Rollup merge of #55754 - spastorino:fix-process-output-docs, r=alexcrichtonkennytm-3/+6
Avoid converting bytes to UTF-8 strings to print, just pass bytes to stdout/err r? @nikomatsakis
2018-11-12Auto merge of #55278 - Centril:constification-1, r=alexcrichtonbors-4/+3
Minor standard library constification This PR makes some bits of the standard library into `const fn`s. I've tried to be as aggressive as I possibly could in the constification. The list is rather small due to how restrictive `const fn` is at the moment. r? @oli-obk cc @rust-lang/libs Stable public APIs affected: + [x] `Cell::as_ptr` + [x] `UnsafeCell::get` + [x] `char::is_ascii` + [x] `iter::empty` + [x] `ManuallyDrop::{new, into_inner}` + [x] `RangeInclusive::{start, end}` + [x] `NonNull::as_ptr` + [x] `{[T], str}::as_ptr` + [x] `Duration::{as_secs, subsec_millis, subsec_micros, subsec_nanos}` + [x] `CStr::as_ptr` + [x] `Ipv4Addr::is_unspecified` + [x] `Ipv6Addr::new` + [x] `Ipv6Addr::octets` Unstable public APIs affected: + [x] `Duration::{as_millis, as_micros, as_nanos, as_float_secs}` + [x] `Wrapping::{count_ones, count_zeros, trailing_zeros, rotate_left, rotate_right, swap_bytes, reverse_bits, from_be, from_le, to_be, to_le, leading_zeros, is_positive, is_negative, leading_zeros}` + [x] `core::convert::identity` -------------------------- ## Removed from list in first pass: Stable public APIs affected: + [ ] `BTree{Map, Set}::{len, is_empty}` + [ ] `VecDeque::is_empty` + [ ] `String::{is_empty, len}` + [ ] `FromUtf8Error::utf8_error` + [ ] `Vec<T>::{is_empty, len}` + [ ] `Layout::size` + [ ] `DecodeUtf16Error::unpaired_surrogate` + [ ] `core::fmt::{fill, width, precision, sign_plus, sign_minus, alternate, sign_aware_zero_pad}` + [ ] `panic::Location::{file, line, column}` + [ ] `{ChunksExact, RChunksExact}::remainder` + [ ] `Utf8Error::valid_up_to` + [ ] `VacantEntry::key` + [ ] `NulError::nul_position` + [ ] `IntoStringError::utf8_error` + [ ] `IntoInnerError::error` + [ ] `io::Chain::get_ref` + [ ] `io::Take::{limit, get_ref}` + [ ] `SocketAddrV6::{flowinfo, scope_id}` + [ ] `PrefixComponent::{kind, as_os_str}` + [ ] `Path::{ancestors, display}` + [ ] `WaitTimeoutResult::timed_out` + [ ] `Receiver::{iter, try_iter}` + [ ] `thread::JoinHandle::thread` + [ ] `SystemTimeError::duration` Unstable public APIs affected: + [ ] `core::fmt::Arguments::new_v1` + [ ] `core::fmt::Arguments::new_v1_formatted` + [ ] `Pin::{get_ref, into_ref}` + [ ] `Utf8Lossy::chunks` + [ ] `LocalWaker::as_waker` + [ ] `panic::PanicInfo::{internal_constructor, message, location}` + [ ] `panic::Location::{internal_constructor }` ## Removed from list in 2nd pass: Stable public APIs affected: + [ ] `LinkedList::{new, iter, is_empty, len}` + [ ] `mem::forget` + [ ] `Cursor::{new, get_ref, position}` + [ ] `io::{empty, repeat, sink}` + [ ] `PoisonError::new` + [ ] `thread::Builder::new` + [ ] `process::Stdio::{piped, inherit, null}` Unstable public APIs affected: + [ ] `io::Initializer::{zeroing, should_initialize}`
2018-11-12global allocators: add a few commentsRalf Jung-0/+5
2018-11-11std: Delete the `alloc_system` crateAlex Crichton-6/+438
This commit deletes the `alloc_system` crate from the standard distribution. This unstable crate is no longer needed in the modern stable global allocator world, but rather its functionality is folded directly into the standard library. The standard library was already the only stable location to access this crate, and as a result this should not affect any stable code.
2018-11-11do not skip return code check in release buildsRalf Jung-1/+1
2018-11-11Unix RwLock: avoid racy access to write_lockedRalf Jung-2/+2
2018-11-11Fix a typo in std::panicDale Wijnand-1/+1
2018-11-10Avoid converting bytes to UTF-8 strings to print, just pass bytes to stdout/errSantiago Pastorino-3/+6
2018-11-10Fix documentation typos.Bruce Mitchener-2/+2
2018-11-10revert some more constification.Mazdak Farrokhzad-11/+11
2018-11-10revert making internal APIs const fn.Mazdak Farrokhzad-18/+18
2018-11-10reduce list to functions callable in const ctx.Mazdak Farrokhzad-20/+20
2018-11-10constify parts of libstd.Mazdak Farrokhzad-53/+52
2018-11-08Deprecate channel selectionStjepan Glavina-4/+6
2018-11-08Clarifying documentation for collections::hash_map::Entry::or_insertMeltinglava-2/+2
Previous version does not show that or_insert does not insert the passed value, as the passed value was the same value as what was already in the map.
2018-11-08Auto merge of #55366 - Amanieu:stable_layout, r=Amanieubors-0/+1
Add tracking issue for Layout methods (and some API changes) These methods are already useful when used with the stable global allocator API (stabilized in #51241). ```rust pub fn align_to(&self, align: usize) -> Result<Layout, LayoutErr>; pub fn padding_needed_for(&self, align: usize) -> usize; pub fn repeat(&self, n: usize) -> Result<(Layout, usize), LayoutErr>; pub fn extend(&self, next: Layout) -> Result<(Layout, usize), LayoutErr>; pub fn repeat_packed(&self, n: usize) -> Result<Layout, LayoutErr>; pub fn extend_packed(&self, next: Layout) -> Result<Layout, LayoutErr>; pub fn array<T>(n: usize) -> Result<Layout, LayoutErr>; ``` cc #32838 r? @SimonSapin
2018-11-07Rollup merge of #55734 - teresy:shorthand-fields, r=davidtwcokennytm-23/+23
refactor: use shorthand fields refactor: use shorthand for single fields everywhere (excluding tests).
2018-11-06Add a tracking issue for extra Layout methodsAmanieu d'Antras-0/+1
2018-11-06refactor: use shorthand fieldsteresy-23/+23
2018-11-06Rollup merge of #55621 - GuillaumeGomez:create-dir, r=QuietMisdreavuskennytm-0/+7
Add precision for create_dir function Took me a while to find the other equivalent so it seems to be necessary. r? @QuietMisdreavus
2018-11-06Rollup merge of #55597 - alexcrichton:thread-local-inner, r=KodrAuskennytm-4/+4
std: Enable usage of `thread_local!` through imports The `thread_local!` macro delegated to an internal macro but it didn't do so in a macros-and-the-module-system compatible fashion, meaning if a `#![no_std]` crate imported `std` and tried to use `thread_local!` it would fail due to missing a lookup of an internal macro. This commit switches the macro to instead use `$crate` to invoke other macros, ensuring that it'll work when `thread_local!` is imported alone.
2018-11-06Auto merge of #55518 - alexcrichton:smaller-wasm, r=sfacklerbors-1/+10
std: Improve codegen size of accessing TLS Some code in the TLS implementation in libstd stores `Some(val)` into an `&mut Option<T>` (effectively) and then pulls out `&T`, but it currently uses `.unwrap()` which can codegen into a panic even though it can never panic. With sufficient optimizations enabled (like LTO) the compiler can see through this but this commit helps it along in normal mode (`--release` with Cargo by default) to avoid codegen'ing the panic path. This ends up improving the optimized codegen on wasm by ensuring that a call to panic pulling in more file size doesn't stick around.
2018-11-05Auto merge of #55410 - nagisa:atomic-align, r=pnkfelixbors-0/+6
Correct alignment of atomic types and (re)add Atomic{I,U}128 This is a updated https://github.com/rust-lang/rust/pull/53514 to also make atomic types `repr(C)` as per comment in https://github.com/rust-lang/rust/pull/53514#issuecomment-431042767. Fixes #39590 Closes #53514 r? @pnkfelix
2018-11-05Do not Atomic{I,U}128 in stage0Simonas Kazlauskas-2/+2
2018-11-04Add precision for create_dir functionGuillaume Gomez-0/+7
2018-11-02NetBSD: link libstd with librt in addition to libpthreadJonathan A. Kollasch-1/+4
2018-11-02Fix compile errors in testJonathan Behrens-9/+9
2018-11-02Suggested editsJonathan Behrens-24/+24
2018-11-02Add some testsJonathan Behrens-11/+20
2018-11-02Add BufWriter::buffer methodJonathan Behrens-0/+19