summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2015-04-09std: Clean up process spawn impl on unixAlex Crichton-250/+214
* De-indent quite a bit by removing usage of FnOnce closures * Clearly separate code for the parent/child after the fork * Use `fs2::{File, OpenOptions}` instead of calling `open` manually * Use RAII to close I/O objects wherever possible * Remove loop for closing all file descriptors, all our own ones are now `CLOEXEC` by default so they cannot be inherited
2015-04-09std: Set CLOEXEC for all fds opened on unixAlex Crichton-30/+50
This commit starts to set the CLOEXEC flag for all files and sockets opened by the standard library by default on all unix platforms. There are a few points of note in this commit: * The implementation is not 100% satisfactory in the face of threads. File descriptors only have the `F_CLOEXEC` flag set *after* they are opened, allowing for a fork/exec to happen in the middle and leak the descriptor. Some platforms do support atomically opening a descriptor while setting the `CLOEXEC` flag, and it is left as a future extension to bind these apis as it is unclear how to do so nicely at this time. * The implementation does not offer a method of opting into the old behavior of not setting `CLOEXEC`. This will possibly be added in the future through extensions on `OpenOptions`, for example. * This change does not yet audit any Windows APIs to see if the handles are inherited by default by accident. This is a breaking change for users who call `fork` or `exec` outside of the standard library itself and expect file descriptors to be inherted. All file descriptors created by the standard library will no longer be inherited. [breaking-change]
2015-04-09std: Make FromRawFd::from_raw_fd an unsafe methodAlex Crichton-13/+28
As pointed out in [RFC issue 1043][rfc] it is quite useful to have the standard I/O types to provide the contract that they are the sole owner of the underlying object they represent. This guarantee enables writing safe interfaces like the `MemoryMap` API sketched out in that issue. [rfc]: https://github.com/rust-lang/rfcs/issues/1043 As constructing objects from these raw handles may end up violating these ownership gurantees, the functions for construction are now marked unsafe. [breaking-change] Closes rust-lang/rfcs#1043
2015-04-09Indicate keyword in doc comment is code-likeCorey Farwell-2/+2
2015-04-10Rollup merge of #24216 - alexcrichton:stabilize-from-raw-os-error, r=aturonManish Goregaokar-6/+12
This commit stabilizes the old `io::Error::from_os_error` after being renamed to use the `raw_os_error` terminology instead. This function is often useful when writing bindings to OS functions but only actually converting to an I/O error at a later point.
2015-04-10Rollup merge of #24212 - alexcrichton:destabilize-begin-unwind, r=huonwManish Goregaokar-3/+1
Now that we have a `#[allow_internal_unstable]` attribute for macros there's no need for these two `begin_unwind` functions to be stable. Right now the `panic!` interface is the only one we wish to stabilize, so remove the stability markers from these functions. While this is a breaking change, it is highly unlikely to break any actual code. It is recommended to use the `panic!` macro instead if it breaks explicit calls into `std::rt`. [breaking-change] cc #24208
2015-04-09Auto merge of #24176 - kballard:bufreader-seek-impl, r=aturonbors-2/+131
2015-04-09Rollup merge of #24176 - kballard:bufreader-seek-impl, r=aturonManish Goregaokar-2/+131
2015-04-09Rollup merge of #24175 - dhuseby:bitrig_fixing_tests_2, r=alexcrichtonManish Goregaokar-1/+2
I'm not sure why this is failing. This patch disables this test until I can figure out what is wrong.
2015-04-08Implement io::Seek for io::BufWriter<W> where W: io::SeekKevin Ballard-0/+22
Seeking the `BufWriter` writes out its internal buffer before seeking.
2015-04-08Implement io::Seek for io::BufReader<R> where R: io::SeekKevin Ballard-2/+109
Seeking the `BufReader` discards the internal buffer (and adjusts the offset appropriately when seeking with `SeekFrom::Current(_)`).
2015-04-08std: Stabilize io::Error::from_raw_os_errorAlex Crichton-6/+12
This commit stabilizes the old `io::Error::from_os_error` after being renamed to use the `raw_os_error` terminology instead. This function is often useful when writing bindings to OS functions but only actually converting to an I/O error at a later point.
2015-04-08std: Destabilize the internals of panic!Alex Crichton-3/+1
Now that we have a `#[allow_internal_unstable]` attribute for macros there's no need for these two `begin_unwind` functions to be stable. Right now the `panic!` interface is the only one we wish to stabilize, so remove the stability markers from these functions. While this is a breaking change, it is highly unlikely to break any actual code. It is recommended to use the `panic!` macro instead if it breaks explicit calls into `std::rt`. [breaking-change] cc #24208
2015-04-08Auto merge of #24029 - nagisa:print-locking, r=alexcrichtonbors-34/+398
write_fmt calls write for each formatted field. The default implementation of write_fmt is used, which will call write on not-yet-locked stdout (and write locking after), therefore making print! in multithreaded environment still interleave contents of two separate prints. I’m not sure whether we want to do this change, though, because it has the same deadlock hazard which we tried to avoid by not locking inside write_fmt itself (see [this comment](https://github.com/rust-lang/rust/blob/80def6c2447d23a624e611417f24cf0ab2a5a676/src/libstd/io/stdio.rs#L267)). Spotted on [reddit]. cc @alexcrichton [reddit]: http://www.reddit.com/r/rust/comments/31comh/println_with_multiple_threads/
2015-04-08std: Fix fs::read_link behavior on WindowsAlex Crichton-14/+63
The current implementation of using GetFinalPathNameByHandle actually reads all intermediate links instead of just looking at the current link. This commit alters the behavior of the function to use a different API which correctly reads only one level of the soft link. [breaking-change]
2015-04-08Implement reentrant mutexes and make stdio use themSimonas Kazlauskas-34/+398
write_fmt calls write for each formatted field. The default implementation of write_fmt is used, which will call write on not-yet-locked stdout (and write locking after), therefore making print! in multithreaded environment still interleave contents of two separate prints. This patch implements reentrant mutexes, changes stdio handles to use these mutexes and overrides write_fmt to lock the stdio handle for the whole duration of the call.
2015-04-08Rollup merge of #24167 - hauleth:remove-incorrect-example-from-mpsc, ↵Steve Klabnik-52/+0
r=steveklabnik As beta is now released and is "suggested" version of `rustc` then there should be no code (in documentation) that will not compile with it. This one does not. So according to [this great talk](http://delete-your-code.herokuapp.com/), I am doing what should be done.
2015-04-07std: Reorganize thread::local a bitAlex Crichton-28/+26
Make the structure more amenable to what rustdoc is expecting to ensure that everything renders all nice and pretty in the output. Closes #23705 Closes #23910
2015-04-07std: Deny most warnings in doctestsAlex Crichton-224/+212
Allow a few specific ones but otherwise this helps ensure that our examples are squeaky clean! Closes #18199
2015-04-08Auto merge of #23293 - tbu-:pr_additive_multiplicative, r=alexcrichtonbors-6/+4
Previously it could not be implemented for types outside `libcore/iter.rs` due to coherence issues.
2015-04-07disabling a test that is failing on bitrig.Dave Huseby-1/+2
2015-04-08Make `sum` and `product` inherent methods on `Iterator`Tobias Bucher-6/+4
In addition to being nicer, this also allows you to use `sum` and `product` for iterators yielding custom types aside from the standard integers. Due to removing the `AdditiveIterator` and `MultiplicativeIterator` trait, this is a breaking change. [breaking-change]
2015-04-07Remove another invalid exampleŁukasz Niemier-26/+0
2015-04-07Remove incorrect example from docsŁukasz Niemier-26/+0
2015-04-06Add `Sync` to the bounds in `io::Error`Kevin Ballard-10/+15
This allows `io::Error` values to be stored in `Arc` properly. Because this requires `Sync` of any value passed to `io::Error::new()` and modifies the relevant `convert::From` impls, this is a [breaking-change] Fixes #24049.
2015-04-06Remove outdated notice from BufRead::lines docs.Matt Brubeck-3/+0
There is no `read_string` function, and `lines` never returns an error.
2015-04-04fixing some tests and temporarily disabling others to get Bitrig build ↵Dave Huseby-1/+2
working 100%
2015-04-04Rollup merge of #24022 - steveklabnik:hn_fix, r=nikomatsakisManish Goregaokar-3/+2
from https://news.ycombinator.com/item?id=9317822
2015-04-04Rollup merge of #23979 - Ryman:error_from_string, r=alexcrichtonManish Goregaokar-3/+10
2015-04-03Don't speak of old_ioSteve Klabnik-3/+2
from https://news.ycombinator.com/item?id=9317822
2015-04-03Auto merge of #23832 - petrochenkov:usize, r=aturonbors-10/+10
These constants are small and can fit even in `u8`, but semantically they have type `usize` because they denote sizes and are almost always used in `usize` context. The change of their type to `u32` during the integer audit led only to the large amount of `as usize` noise (see the second commit, which removes this noise). This is a minor [breaking-change] to an unstable interface. r? @aturon
2015-04-02std: impl From<String> for Box<Error + Send>Kevin Butler-3/+10
2015-04-02Auto merge of #23931 - steveklabnik:doc_std_fs, r=alexcrichtonbors-42/+306
2015-04-02Auto merge of #23877 - richo:gardening, r=Manishearthbors-2/+1
I also wanted to unignore https://github.com/rust-lang/rust/blob/master/src/libsyntax/ext/expand.rs#L1768-L1777 since the issue it references is closed, but the test fails, and it's internals aren't super clear to me.
2015-04-02Add more examples and documentation for std::fsSteve Klabnik-42/+306
2015-04-02Tweak relese notes + rebase fixesAlex Crichton-6/+6
2015-04-01Test fixes and rebase conflicts, round 2Alex Crichton-25/+25
2015-04-01rollup merge of #23176: huonw/rm-boundsAlex Crichton-34/+36
2015-04-01rollup merge of #23860: nikomatsakis/copy-requires-cloneAlex Crichton-18/+24
Conflicts: src/test/compile-fail/coherence-impls-copy.rs
2015-04-01rollup merge of #23945: pnkfelix/gate-u-negateAlex Crichton-3/+3
Feature-gate unsigned unary negate. Discussed in weekly meeting here: https://github.com/rust-lang/meeting-minutes/blob/master/weekly-meetings/2015-03-31.md#feature-gate--expr and also in the internals thread here: http://internals.rust-lang.org/t/forbid-unsigned-integer/752
2015-04-02Test fixes and rebase conflicts, round 2Alex Crichton-2/+2
Conflicts: src/libcore/num/mod.rs
2015-04-01rollup merge of #23949: aturon/stab-timeoutAlex Crichton-28/+54
This commit renames and stabilizes: * `Condvar::wait_timeout_ms` (renamed from `wait_timeout`) * `thread::park_timeout_ms` (renamed from `park_timeout`) * `thread::sleep_ms` (renamed from `sleep`) In each case, the timeout is taken as a `u32` number of milliseconds, rather than a `Duration`. These functions are likely to be deprecated once a stable form of `Duration` is available, but there is little cost to having these named variants around, and it's crucial functionality for 1.0. [breaking-change] r? @alexcrichton cc @sfackler @carllerche
2015-04-01Stabilize basic timeout functionalityAaron Turon-28/+54
This commit renames and stabilizes: * `Condvar::wait_timeout_ms` (renamed from `wait_timeout`) * `thread::park_timeout_ms` (renamed from `park_timeout`) * `thread::sleep_ms` (renamed from `sleep`) In each case, the timeout is taken as a `u32` number of milliseconds, rather than a `Duration`. These functions are likely to be deprecated once a stable form of `Duration` is available, but there is little cost to having these named variants around, and it's crucial functionality for 1.0. [breaking-change]
2015-04-01fallout from feature-gating unary negation on unsigned integers.Felix S. Klock II-1/+1
2015-04-01rollup merge of #23939: nikomatsakis/fn-boxAlex Crichton-57/+27
Conflicts: src/liballoc/boxed.rs
2015-04-01rollup merge of #23951: alexcrichton/splitnAlex Crichton-3/+3
This commit is an implementation of [RFC 979][rfc] which changes the meaning of the count parameter to the `splitn` function on strings and slices. The parameter now means the number of items that are returned from the iterator, not the number of splits that are made. [rfc]: https://github.com/rust-lang/rfcs/pull/979 Closes #23911 [breaking-change]
2015-04-01std: Changing the meaning of the count to splitnAlex Crichton-3/+3
This commit is an implementation of [RFC 979][rfc] which changes the meaning of the count parameter to the `splitn` function on strings and slices. The parameter now means the number of items that are returned from the iterator, not the number of splits that are made. [rfc]: https://github.com/rust-lang/rfcs/pull/979 Closes #23911 [breaking-change]
2015-04-01rollup merge of #23942: vhbit/ios-randAlex Crichton-2/+2
2015-04-01rollup merge of #23867: nikomatsakis/issue-23086-take-3Alex Crichton-1/+153
This PR implements rust-lang/rfcs#1023. In the process it fixes #23086 and #23516. A few impls in libcore had to be updated, but the impact is generally pretty minimal. Most of the fallout is in the tests that probed the limits of today's coherence. I tested and we were able to build the most popular crates along with iron (modulo errors around errors being sendable). Fixes #23918.
2015-04-01Collect the definition of the `Error` trait into `libstd` for now. ThisNiko Matsakis-1/+153
sidesteps a coherence difficulty where `liballoc` had to prove that `&str: !Error`, which didn't involve any local types.