summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-205/+11
2016-08-24memrchr: Use a conditional instead of subtracting a complicated minUlrik Sverdrup-1/+1
This makes the critical calculation easier to understand.
2016-08-24memrchr: Correct aligned offset computationUlrik Sverdrup-1/+23
The memrchr fallback did not compute the offset correctly. It was intentioned to land on usize-aligned addresses but did not. This was suspected to resulted in a crash on ARMv7 platform! This bug affected non-linux platforms. I think like this, if we have a slice with pointer `ptr` and length `len`, we want to find the last usize-aligned offset in the slice. The correct computation should be: For example if ptr = 1 and len = 6, and size_of::<usize>() is 4: [ x x x x x x ] 1 2 3 4 5 6 ^-- last aligned address at offset 3 from the start. The last aligned address is ptr + len - (ptr + len) % usize_size. Compute offset from the start as: offset = len - (ptr + len) % usize_size = 6 - (1 + 6) % 4 = 6 - 3 = 3. I believe the function's return value was always correct previously, if the platform supported unaligned addresses.
2016-08-24Remove drop flags from structs and enums implementing Drop.Eduard Burtescu-3/+3
2016-08-24Restore old ordering of `io::ErrorKind`sTobias Bucher-3/+4
2016-08-23Auto merge of #35656 - Stebalien:fused, r=alexcrichtonbors-3/+55
Implement 1581 (FusedIterator) * [ ] Implement on patterns. See https://github.com/rust-lang/rust/issues/27721#issuecomment-239638642. * [ ] Handle OS Iterators. A bunch of iterators (`Args`, `Env`, etc.) in libstd wrap platform specific iterators. The current ones all appear to be well-behaved but can we assume that future ones will be? * [ ] Does someone want to audit this? On first glance, all of the iterators on which I implemented `FusedIterator` appear to be well-behaved but there are a *lot* of them so a second pair of eyes would be nice. * I haven't touched rustc internal iterators (or the internal rand) because rustc doesn't actually call `fuse()`. * `FusedIterator` can't be implemented on `std::io::{Bytes, Chars}`. Closes: #35602 (Tracking Issue) Implements: rust-lang/rfcs#1581
2016-08-23Implement more traits for `std::io::ErrorKind`Tobias Bucher-6/+6
This makes it possible to use it as key in various maps.
2016-08-22Rollup merge of #35842 - apasel422:typo, r=GuillaumeGomezJonathan Turner-2/+2
Fix typos in unix/rwlock.rs r? @steveklabnik
2016-08-22Auto merge of #35871 - bluss:cstring-new, r=alexcrichtonbors-0/+1
cstring: avoid excessive growth just to 0-terminate Based on following what happens in CString::new("string literal"): 1. Using `Into<Vec<u8>>`, a Vec is allocated with capacity exactly equal to the string's input length. 2. By `v.push(0)`, the Vec is grown to twice capacity, since it was full. 3. By `v.into_boxed_slice()`, the Vec capacity is shrunk to fit the length again. If we use `.reserve_exact(1)` just before the push, then we avoid the capacity doubling that we're going to have to shrink anyway. Growing by just 1 byte means that the step (2) is less likely to have to move the memory to a larger allocation chunk, and that the step (3) does not have to reallocate. Addresses part of #35838
2016-08-21Use the kernel arc4rand for FreeBSD OsRng.Aaron Gallagher-1/+52
This means that /dev/urandom doesn't have to be opened.
2016-08-21Reduce duplication in std::sys::unix::rand.Aaron Gallagher-29/+25
There were a bunch of more-of-less the same few lines for doing a fill_bytes+transmute, and I didn't want to copy-paste it yet again.
2016-08-21cstring: avoid excessive growth just to 0-terminateUlrik Sverdrup-0/+1
Based on following what happens in CString::new("string literal"): 1. Using `Into<Vec<u8>>`, a Vec is allocated with capacity exactly equal to the string's input length. 2. By `v.push(0)`, the Vec is grown to twice capacity, since it was full. 3. By `v.into_boxed_slice()`, the Vec capacity is shrunk to fit the length again. If we use `.reserve_exact(1)` just before the push, then we avoid the capacity doubling that we're going to have to shrink anyway. Growing by just 1 byte means that the step (2) is less likely to have to move the memory to a larger allocation chunk, and that the step (3) does not have to reallocate.
2016-08-20Rollup merge of #35775 - frewsxcv:os-str-doc-examples, r=GuillaumeGomezJonathan Turner-0/+32
Add a few doc examples for `std::ffi::OsStr`.
2016-08-20Rollup merge of #35234 - nrc:rustdoc-macros, r=steveklabnikJonathan Turner-5/+5
rustdoc: remove the `!` from macro URLs and titles Because the `!` is part of a macro use, not the macro's name. E.g., you write `macro_rules! foo` not `macro_rules! foo!`, also `#[macro_import(foo)]`. (Pulled out of #35020).
2016-08-19Fix typos in unix/rwlock.rsAndrew Paseltiner-2/+2
2016-08-19std: Stabilize APIs for the 1.12 releaseAlex Crichton-24/+23
Stabilized * `Cell::as_ptr` * `RefCell::as_ptr` * `IpAddr::is_{unspecified,loopback,multicast}` * `Ipv6Addr::octets` * `LinkedList::contains` * `VecDeque::contains` * `ExitStatusExt::from_raw` - both on Unix and Windows * `Receiver::recv_timeout` * `RecvTimeoutError` * `BinaryHeap::peek_mut` * `PeekMut` * `iter::Product` * `iter::Sum` * `OccupiedEntry::remove_entry` * `VacantEntry::into_key` Deprecated * `Cell::as_unsafe_cell` * `RefCell::as_unsafe_cell` * `OccupiedEntry::remove_pair` Closes #27708 cc #27709 Closes #32313 Closes #32630 Closes #32713 Closes #34029 Closes #34392 Closes #34285 Closes #34529
2016-08-19Document that Condvar makes the best effort to use monotonic clock.Tomasz Miąsko-0/+8
2016-08-18Add a FusedIterator trait.Steven Allen-3/+55
This trait can be used to avoid the overhead of a fuse wrapper when an iterator is already well-behaved. Conforming to: RFC 1581 Closes: #35602
2016-08-18Add a few doc examples for `std::ffi::OsStr`.Corey Farwell-0/+32
* `std::ffi::OsStr::new`. * `std::ffi::OsStr::is_empty`. * `std::ffi::OsStr::len`.
2016-08-18Fix linksNick Cameron-5/+5
2016-08-17Rollup merge of #35621 - frewsxcv:cstring-from-vec-doc, r=peschkajJonathan Turner-0/+11
Add doc example for `std::ffi::CString::from_vec_unchecked`. None
2016-08-17Rollup merge of #35613 - matthew-piziak:array-docs-trait-justification, ↵Jonathan Turner-3/+8
r=steveklabnik provide additional justification for array interface design Explain why Rust does not implement traits for large arrays. Explain why most methods are implemented on slices rather than arrays. Note: I'm dipping my toes in the water with a tiny PR. Especially looking for feedback on wording and style. Points of concern: appropriate level of top-level explanation; foreshadowing (is it appropriate to imply that we expect Rust's type system to eventually support size-generic arrays?); using `Foo` and `Bar` as type variables instead of e.g. `T` and `S`. @peschkaj
2016-08-17Rollup merge of #35610 - JessRudder:33637-doc-update-for-str-representaton, ↵Jonathan Turner-0/+4
r=steveklabnik Add note to docs for &str that example is to demo internals only r? @steveklabnik This adds a note below the &str representation example explaining that the example provided should not be used under normal circumstances.. Would it make sense to point people in the direction of the method(s) they should use instead? I left it out in the interest of not complicating the documentation, but, there's definitely an argument to be made for adding a bit of guidance in there.
2016-08-16Auto merge of #35354 - tomgarcia:covariant-drain, r=alexcrichtonbors-6/+13
Made vec_deque::Drain, hash_map::Drain, and hash_set::Drain covariant Fixed the rest of the Drain iterators.
2016-08-14Rollup merge of #35574 - badboy:emscripten-test-fixes, r=brsonEduard-Mihai Burtescu-8/+9
Emscripten test fixes This picks up parts of #31623 to disable certain tests that emscripten can't run, as threads/processes are not supported. I re-applied @tomaka's changes manually, I can rebase those commits with his credentials if he wants. It also disables jemalloc for emscripten (at least in Rustbuild, I have to check if there is another setting for the same thing in the old makefile approach). This should not impact anything for normal builds.
2016-08-14Rollup merge of #35444 - alexcrichton:optimize-catch-unwind, r=brsonEduard-Mihai Burtescu-36/+68
std: Optimize panic::catch_unwind slightly The previous implementation of this function was overly conservative with liberal usage of `Option` and `.unwrap()` which in theory never triggers. This commit essentially removes the `Option`s in favor of unsafe implementations, improving the code generation of the fast path for LLVM to see through what's happening more clearly. cc #34727
2016-08-14Rollup merge of #34941 - qolop:patch-2, r=apasel422Eduard-Mihai Burtescu-2/+2
Fix typo (privledge->privilege)
2016-08-12provide additional justification for array interface designMatthew Piziak-3/+8
Explain why Rust does not implement traits for large arrays. Explain why most methods are implemented on slices rather than arrays.
2016-08-12Update note to include recommendation to use `.as_slice()`JessRudder-1/+2
2016-08-12Add doc example for `std::ffi::CString::from_vec_unchecked`.Corey Farwell-0/+11
2016-08-11Fix typoPatrick McCann-1/+1
Didn't see this one at first.
2016-08-11Add note to docs for &str that example is to demo internals onlyJessRudder-0/+3
2016-08-11std: Optimize panic::catch_unwind slightlyAlex Crichton-36/+68
The previous implementation of this function was overly conservative with liberal usage of `Option` and `.unwrap()` which in theory never triggers. This commit essentially removes the `Option`s in favor of unsafe implementations, improving the code generation of the fast path for LLVM to see through what's happening more clearly. cc #34727
2016-08-11Rollup merge of #35569 - pietroalbini:fix-typo, r=steveklabnikJonathan Turner-1/+1
Fix docs typo in std::os::unix::net::SocketAddr::is_unnamed
2016-08-11Rollup merge of #35482 - frewsxcv:patch-31, r=GuillaumeGomezJonathan Turner-17/+9
Remove unnecessary `main` functions in doc examples.
2016-08-11Auto merge of #34866 - cynicaldevil:panic-counter, r=alexcrichtonbors-23/+40
Refactored code to access TLS only in case of panic (II) Fixes #34787 r? @alexcrichton Do it **very** carefully this time!
2016-08-10Auto merge of #35525 - jonathandturner:rollup, r=jonathandturnerbors-7/+6
Rollup of 15 pull requests - Successful merges: #35371, #35396, #35446, #35449, #35452, #35458, #35465, #35466, #35470, #35475, #35477, #35484, #35504, #35507, #35524 - Failed merges: #35395, #35415
2016-08-10Added an update_panic_count function to handle access to PANIC_COUNTNikhil Shagrithaya-23/+28
2016-08-10Added a shim around rust_panic to update panic counterNikhil Shagrithaya-1/+11
2016-08-10Refactored code to access TLS only in case of panicNikhil Shagrithaya-9/+11
2016-08-10Clarify std::os::unix::net::SocketAddr::is_unnamed's docstringPietro Albini-1/+1
2016-08-10Fix docs typo in std::os::unix::net::SocketAddr::is_unnamedPietro Albini-1/+1
2016-08-10[emscripten] Disable code paths that don't work on emscriptenJan-Erik Rediger-8/+9
2016-08-09Auto merge of #35426 - frewsxcv:os-sys-env-args-phantoms, r=alexcrichtonbors-6/+7
Utilize `PhantomData` to enforce `!Sync` and `!Send` field. None
2016-08-09Auto merge of #35425 - apasel422:refcell, r=alexcrichtonbors-0/+16
Implement `RefCell::{try_borrow, try_borrow_mut}` CC #35070 r? @alexcrichton
2016-08-08Implement `RefCell::{try_borrow, try_borrow_mut}`Andrew Paseltiner-0/+16
2016-08-08Rollup merge of #35371 - mgattozzi:master, r=steveklabnikJonathan Turner-7/+6
Update HashMap docs regarding DoS protection Because of changes to how Rust acquires randomness HashMap is not guaranteed to be DoS resistant. This commit reflects these changes in the docs themselves and provides an alternative method to creating a hash that is resistant if needed. This fixes #33817 and includes relevant information regarding changes made in #33086
2016-08-08Remove unnecessary `main` functions in doc examples.Corey Farwell-17/+9
2016-08-07Rollup merge of #35436 - frewsxcv:into-vec, r=GuillaumeGomezJonathan Turner-0/+9
Add doc example for `std::ffi::NulError::into_vec`. None
2016-08-07Rollup merge of #35433 - mneumann:dragonfly-fix-libstd-errno-location, ↵Jonathan Turner-0/+1
r=alexcrichton Fix build on DragonFly (unused function errno_location) Function errno_location() is not used on DragonFly. As warnings are errors, this breaks the build.