summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2015-04-13Fix check for globally routable IPv4 addressAbhishek Chanda-15/+43
- Adds two more functions for broadcast address and special address classes reserved for documentation - Modifies the globally routable IP check to include these new functions Fixes #24314
2015-04-13De-stabilize `thread::scoped` and friendsAaron Turon-4/+8
Issue #24292 demonstrates that the `scoped` API as currently offered can be memory-unsafe: the `JoinGuard` can be moved into a context that will fail to execute destructors prior to the stack frame being popped (for example, by creating an `Rc` cycle). This commit reverts the APIs to `unstable` status while a long-term solution is worked out. (There are several possible ways to address this issue; it's not a fundamental problem with the `scoped` idea, but rather an indication that Rust doesn't currently provide a good way to ensure that destructors are run within a particular stack frame.) [breaking-change]
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-241/+241
2015-04-13Auto merge of #24198 - alexcrichton:windows-readlink, r=aturonbors-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-13Auto merge of #24362 - alexcrichton:issue-24334, r=huonwbors-3/+3
Make sure the unstable `scoped` modules isn't named the same as the `scoped` function. cc #24334
2015-04-13Auto merge of #24323 - rprichard:panic-line-type, r=alexcrichtonbors-6/+70
There are syntax extensions that call `std::rt::begin_unwind` passing it a `usize`. I updated the syntax extension to instead pass `u32`, but for bootstrapping reasons, I needed to create a `#[cfg(stage0)]` version of `std::rt::begin_unwind` and therefore also `panic!`.
2015-04-12std: Work around a stability bug in threadAlex Crichton-3/+3
Make sure the unstable `scoped` modules isn't named the same as the `scoped` function. cc #24334
2015-04-12References to `CString::from_vec` changed to `new`Theo Belaire-3/+4
It looks like `from_vec` was subsumed by new at some point, but the documentation still refers to it as `from_vec`. This updates the documentation for `from_vec_unchecked` so that it properly says that it's the unchecked version of `new`. Also, from_vec_unchecked requires a actual Vec<u8> while new can take anything that is Into<Vec<u8>>, so I also mention that in the documentation.
2015-04-12Fixed with_extension documentation bugTheo Belaire-1/+2
It was mistakenly calling it with "foo.txt" instead of "txt". I've also added an assert.
2015-04-11Rollup merge of #24304 - ihrwein:fix-some-typos, r=alexcrichtonManish Goregaokar-1/+1
Signed-off-by: Tibor Benke <ihrwein@gmail.com>
2015-04-11Rollup merge of #24283 - apasel422:patch-2, r=alexcrichtonManish Goregaokar-2/+2
2015-04-11Rollup merge of #24243 - frewsxcv:patch-13, r=steveklabnikManish Goregaokar-2/+2
2015-04-11Change the rt::unwind line argument type from usize to u32.Ryan Prichard-6/+70
2015-04-10std: Stabilize the Utf8Error typeAlex Crichton-4/+1
The meaning of each variant of this enum was somewhat ambiguous and it's uncler that we wouldn't even want to add more enumeration values in the future. As a result this error has been altered to instead become an opaque structure. Learning about the "first invalid byte index" is still an unstable feature, but the type itself is now stable.
2015-04-10Fix some typosTibor Benke-1/+1
Signed-off-by: Tibor Benke <ihrwein@gmail.com>
2015-04-10s/Panicks/Panics/Andrew Paseltiner-2/+2
2015-04-10Auto merge of #24177 - alexcrichton:rustdoc, r=aturonbors-282/+268
This commit series starts out with more official test harness support for rustdoc tests, and then each commit afterwards adds a test (where appropriate). Each commit should also test and finish independently of all others (they're all pretty separable). I've uploaded a [copy of the documentation](http://people.mozilla.org/~acrichton/doc/std/) generated after all these commits were applied, and a double check on issues being closed would be greatly appreciated! I'll also browse the docs a bit and make sure nothing regressed too horribly.
2015-04-10std: Unconditionally close all file descriptorsAlex Crichton-67/+85
The logic for only closing file descriptors >= 3 was inherited from quite some time ago and ends up meaning that some internal APIs are less consistent than they should be. By unconditionally closing everything entering a `FileDesc` we ensure that we're consistent in our behavior as well as robustly handling the stdio case.
2015-04-10Test fixes and review feedbackAlex Crichton-30/+30
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