about summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
2015-03-28Remove IteratorExtSteven Fackler-1/+1
All methods are inlined into Iterator with `Self: Sized` bounds to make sure Iterator is still object safe. [breaking-change]
2015-03-27std: Don't deadlock/panic on recursive printsAlex Crichton-11/+13
Previously a panic was generated for recursive prints due to a double-borrow of a `RefCell`. This was solved by the second borrow's output being directed towards the global stdout instead of the per-thread stdout (still experimental functionality). After this functionality was altered, however, recursive prints still deadlocked due to the overridden `write_fmt` method which locked itself first and then wrote all the data. This was fixed by removing the override of the `write_fmt` method. This means that unlocked usage of `write!` on a `Stdout`/`Stderr` may be slower due to acquiring more locks, but it's easy to make more performant with a call to `.lock()`. Closes #23781
2015-03-27rollup merge of #23741: alexcrichton/remove-int-uintAlex Crichton-2/+2
Conflicts: src/librustc/middle/ty.rs src/librustc_trans/trans/adt.rs src/librustc_typeck/check/mod.rs src/libserialize/json.rs src/test/run-pass/spawn-fn.rs
2015-03-27rollup merge of #23769: alexcrichton/stabilize-splitAlex Crichton-4/+3
Now that `<[_]>::split` is an inherent method, it will trump `BufRead::split` when `BufRead` is in scope, so there is no longer a conflict. As a result, calling `slice.split()` will probably always give you precisely what you want!
2015-03-27rollup merge of #23752: alexcrichton/remove-should-failAlex Crichton-1/+1
This attribute has been deprecated in favor of #[should_panic]. This also updates rustdoc to no longer accept the `should_fail` directive and instead renames it to `should_panic`.
2015-03-26std: Stabilize BufRead::splitAlex Crichton-4/+3
Now that `<[_]>::split` is an inherent method, it will trump `BufRead::split` when `BufRead` is in scope, so there is no longer a conflict. As a result, calling `slice.split()` will probably always give you precisely what you want!
2015-03-26syntax: Remove support for #[should_fail]Alex Crichton-1/+1
This attribute has been deprecated in favor of #[should_panic]. This also updates rustdoc to no longer accept the `should_fail` directive and instead renames it to `should_panic`.
2015-03-26Mass rename uint/int to usize/isizeAlex Crichton-2/+2
Now that support has been removed, all lingering use cases are renamed.
2015-03-26Auto merge of #23680 - erickt:inline, r=cmrbors-0/+113
before: test bench_read_slice ... bench: 68 ns/iter (+/- 56) test bench_read_vec ... bench: 78 ns/iter (+/- 21) test bench_write_slice ... bench: 133 ns/iter (+/- 46) test bench_write_vec ... bench: 308 ns/iter (+/- 69) after: test bench_read_slice ... bench: 32 ns/iter (+/- 10) test bench_read_vec ... bench: 32 ns/iter (+/- 8) test bench_write_slice ... bench: 53 ns/iter (+/- 12) test bench_write_vec ... bench: 247 ns/iter (+/- 172)
2015-03-25Speed up reading/writing slices with #[inline]Erick Tryzelaar-0/+113
When built with `rustc -O`: before: test bench_read_slice ... bench: 68 ns/iter (+/- 56) test bench_read_vec ... bench: 78 ns/iter (+/- 21) test bench_write_slice ... bench: 133 ns/iter (+/- 46) test bench_write_vec ... bench: 308 ns/iter (+/- 69) after: test bench_read_slice ... bench: 32 ns/iter (+/- 10) test bench_read_vec ... bench: 32 ns/iter (+/- 8) test bench_write_slice ... bench: 53 ns/iter (+/- 12) test bench_write_vec ... bench: 247 ns/iter (+/- 172)
2015-03-25Rollup merge of #23664 - bluss:std-docs, r=steveklabnikManish Goregaokar-16/+16
Main motivation was to update docs for the removal or "demotion" of certain extension traits. The update to the slice docs was larger, since the text was largely outdated.
2015-03-24rollup merge of #23638: pnkfelix/fsk-reject-specialized-dropsAlex Crichton-9/+9
Reject specialized Drop impls. See Issue #8142 for discussion. This makes it illegal for a Drop impl to be more specialized than the original item. So for example, all of the following are now rejected (when they would have been blindly accepted before): ```rust struct S<A> { ... }; impl Drop for S<i8> { ... } // error: specialized to concrete type struct T<'a> { ... }; impl Drop for T<'static> { ... } // error: specialized to concrete region struct U<A> { ... }; impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement struct V<'a,'b>; impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement ``` Due to examples like the above, this is a [breaking-change]. (The fix is to either remove the specialization from the `Drop` impl, or to transcribe the requirements into the struct/enum definition; examples of both are shown in the PR's fixed to `libstd`.) ---- This is likely to be the last thing blocking the removal of the `#[unsafe_destructor]` attribute. Fix #8142 Fix #23584
2015-03-24rollup merge of #23668: alexcrichton/io-zeroAlex Crichton-30/+14
This commit alters the behavior of the `Read::read_to_end()` method to zero all memory instead of passing an uninitialized buffer to `read`. This change is motivated by the [discussion on the internals forum][discuss] where the conclusion has been that the standard library will not expose uninitialized memory. [discuss]: http://internals.rust-lang.org/t/uninitialized-memory/1652 Closes #20314
2015-03-24rollup merge of #23592: alexcrichton/tweak-at-exitAlex Crichton-8/+16
There have been some recent panics on the bots and this commit is an attempt to appease them. Previously it was considered invalid to run `rt::at_exit` after the handlers had already started running. Due to the multithreaded nature of applications, however, it is not always possible to guarantee this. For example [this program][ex] will show off the abort. [ex]: https://gist.github.com/alexcrichton/56300b87af6fa554e52d The semantics of the `rt::at_exit` function have been modified as such: * It is now legal to call `rt::at_exit` at any time. The return value now indicates whether the closure was successfully registered or not. Callers must now decide what to do with this information. * The `rt::at_exit` handlers will now be run for a fixed number of iterations. Common cases (such as the example shown) may end up registering a new handler while others are running perhaps once or twice, so this common condition is covered by re-running the handlers a fixed number of times, after which new registrations are forbidden. Some usage of `rt::at_exit` was updated to handle these new semantics, but deprecated or unstable libraries calling `rt::at_exit` were not updated.
2015-03-24Added `Write` bounds to avoid a specialized Drop impl for `BufWriter`.Felix S. Klock II-9/+9
2015-03-24std: Update docs for removal of ReadExt, WriteExtUlrik Sverdrup-16/+16
2015-03-24std: Zero memory when calling `read_to_end()`Alex Crichton-30/+14
This commit alters the behavior of the `Read::read_to_end()` method to zero all memory instead of passing an uninitialized buffer to `read`. This change is motivated by the [discussion on the internals forum][discuss] where the conclusion has been that the standard library will not expose uninitialized memory. [discuss]: http://internals.rust-lang.org/t/uninitialized-memory/1652 Closes #20314
2015-03-23rollup merge of #23622: steveklabnik/gh23196Alex Crichton-0/+6
Fixes #23196
2015-03-23rollup merge of #23608: nagisa/refine-cursor-docstringAlex Crichton-8/+5
r? @steveklabnik
2015-03-23rollup merge of #23607: mahkoh/cursorAlex Crichton-0/+1
Closes #23599 r? @alexcrichton
2015-03-23rollup merge of #23541: aturon/stab-errorAlex Crichton-1/+1
This small commit stabilizes the `Error` trait as-is, except that `Send` and `Debug` are added as constraints. The `Send` constraint is because most uses of `Error` will be for trait objects, and by default we would like these objects to be transferrable between threads. The `Debug` constraint is to ensure that e.g. `Box<Error>` is `Debug`, and because types that implement `Display` should certainly implement `Debug` in any case. In the near future we expect to add `Any`-like downcasting features to `Error`, but this is waiting on some additional mechanisms (`Reflect`). It will be added before 1.0 via default methods. [breaking-change] r? @alexcrichton Closes #21790
2015-03-23Stabilize the Error traitAaron Turon-1/+1
This small commit stabilizes the `Error` trait as-is, except that `Send` and `Debug` are added as constraints. The `Send` constraint is because most uses of `Error` will be for trait objects, and by default we would like these objects to be transferrable between threads. The `Debug` constraint is to ensure that e.g. `Box<Error>` is `Debug`, and because types that implement `Display` should certainly implement `Debug` in any case. In the near future we expect to add `Any`-like downcasting features to `Error`, but this is waiting on some additional mechanisms (`Reflect`). It will be added before 1.0 via default methods. [breaking-change]
2015-03-23Beef up BufRead::consume documentation.Steve Klabnik-0/+6
Fixes #23196
2015-03-23derive missing trait implementations for cursorJulian Orth-0/+1
2015-03-22Refine Cursor docstringSimonas Kazlauskas-8/+5
2015-03-21std: Tweak rt::at_exit behaviorAlex Crichton-8/+16
There have been some recent panics on the bots and this commit is an attempt to appease them. Previously it was considered invalid to run `rt::at_exit` after the handlers had already started running. Due to the multithreaded nature of applications, however, it is not always possible to guarantee this. For example [this program][ex] will show off the abort. [ex]: https://gist.github.com/alexcrichton/56300b87af6fa554e52d The semantics of the `rt::at_exit` function have been modified as such: * It is now legal to call `rt::at_exit` at any time. The return value now indicates whether the closure was successfully registered or not. Callers must now decide what to do with this information. * The `rt::at_exit` handlers will now be run for a fixed number of iterations. Common cases (such as the example shown) may end up registering a new handler while others are running perhaps once or twice, so this common condition is covered by re-running the handlers a fixed number of times, after which new registrations are forbidden. Some usage of `rt::at_exit` was updated to handle these new semantics, but deprecated or unstable libraries calling `rt::at_exit` were not updated.
2015-03-21Auto merge of #23470 - alexcrichton:less-prelude, r=aturonbors-4/+1
This commit removes the reexports of `old_io` traits as well as `old_path` types and traits from the prelude. This functionality is now all deprecated and needs to be removed to make way for other functionality like `Seek` in the `std::io` module (currently reexported as `NewSeek` in the io prelude). Closes #23377 Closes #23378
2015-03-20std: Remove old_io/old_path from the preludeAlex Crichton-4/+1
This commit removes the reexports of `old_io` traits as well as `old_path` types and traits from the prelude. This functionality is now all deprecated and needs to be removed to make way for other functionality like `Seek` in the `std::io` module (currently reexported as `NewSeek` in the io prelude). Closes #23377 Closes #23378
2015-03-20Auto merge of #23512 - oli-obk:result_ok_unwrap, r=alexcrichtonbors-1/+1
because then the call to `unwrap()` will not print the error object.
2015-03-20don't use Result::ok just to be able to use unwrap/unwrap_orOliver Schneider-1/+1
2015-03-20Rollup merge of #23499 - mbrubeck:doc-edit, r=huonwManish Goregaokar-1/+2
Multiple people have been suprised by this aspect of read_line's behavior, which is not obvious from the docs.
2015-03-19Auto merge of #23430 - alexcrichton:io-error, r=aturonbors-21/+58
This commit stabilizes the `ErrorKind` enumeration which is consumed by and generated by the `io::Error` type. The purpose of this type is to serve as a cross-platform namespace to categorize errors into. Two specific issues are addressed as part of this stablization: * The naming of each variant was scrutinized and some were tweaked. An example is how `FileNotFound` was renamed to simply `NotFound`. These names should not show either a Unix or Windows bias and the set of names is intended to grow over time. For now the names will likely largely consist of those errors generated by the I/O APIs in the standard library. * The mapping of OS error codes onto kinds has been altered. Coalescing no longer occurs (multiple error codes become one kind). It is intended that each OS error code, if bound, corresponds to only one `ErrorKind`. The current set of error kinds was expanded slightly to include some networking errors. This commit also adds a `raw_os_error` function which returns an `Option<i32>` to extract the underlying raw error code from the `Error`. Closes #16666 [breaking-change]
2015-03-19std: Stablize io::ErrorKindAlex Crichton-21/+58
This commit stabilizes the `ErrorKind` enumeration which is consumed by and generated by the `io::Error` type. The purpose of this type is to serve as a cross-platform namespace to categorize errors into. Two specific issues are addressed as part of this stablization: * The naming of each variant was scrutinized and some were tweaked. An example is how `FileNotFound` was renamed to simply `NotFound`. These names should not show either a Unix or Windows bias and the set of names is intended to grow over time. For now the names will likely largely consist of those errors generated by the I/O APIs in the standard library. * The mapping of OS error codes onto kinds has been altered. Coalescing no longer occurs (multiple error codes become one kind). It is intended that each OS error code, if bound, corresponds to only one `ErrorKind`. The current set of error kinds was expanded slightly to include some networking errors. This commit also adds a `raw_os_error` function which returns an `Option<i32>` to extract the underlying raw error code from the `Error`.
2015-03-19Auto merge of #23507 - jbcrail:fix-comment-spelling, r=alexcrichtonbors-1/+1
I corrected misspelled comments in several crates.
2015-03-19Fix spelling errors in comments.Joseph Crail-1/+1
I corrected misspelled comments in several crates.
2015-03-19Rollup merge of #23468 - sfackler:stdio-panic, r=alexcrichtonManish Goregaokar-3/+29
Nothing inside of the read/write interface itself can panic, so any poison must have been the result of user code which the lock isn't protecting. This seems safe to me, but if we don't want to go this route we should update the docs to indicate that these methods can panic. r? @alexcrichton
2015-03-18Clarify in docs that BufRead::read_line appendsMatt Brubeck-1/+2
Multiple people have been suprised by this aspect of read_line's behavior, which is not obvious from the docs.
2015-03-18Register new snapshotsAlex Crichton-8/+0
2015-03-18Add a testSteven Fackler-0/+26
2015-03-18Remove the newly introduced trait impls for fixed-size arrays and use ↵Vadim Petrochenkov-22/+18
&b"..."[..] instead.
2015-03-17Ignore stdio mutex poison stateSteven Fackler-3/+3
Nothing inside of the read/write interface itself can panic, so any poison must have been the result of user code which the lock isn't protecting.
2015-03-18Avoid metadata bloat by using trait FixedSizeArrayVadim Petrochenkov-20/+7
2015-03-18Fixed-size byte string literals (RFC 339)Vadim Petrochenkov-2/+19
2015-03-17Rollup merge of #23432 - mzabaluev:io-into-inner-doc, r=alexcrichtonManish Goregaokar-14/+15
Resolves #23386.
2015-03-17Rollup merge of #23415 - alexcrichton:stabilize-flush, r=aturonManish Goregaokar-1/+1
The [associated RFC][rfc] for possibly splitting out `flush` has been closed and as a result there are no more blockers for stabilizing this method, so this commit marks the method as such. [rfc]: https://github.com/rust-lang/rfcs/pull/950
2015-03-17std::io::buffered: Don't use 'flush' in documentation of into_innerMikhail Zabaluev-14/+15
The word 'flush' may be misinterpreted as if `flush` is called on the underlying writer, which is not the case.
2015-03-16impl<T> *const T, impl<T> *mut TJorge Aparicio-0/+1
2015-03-16impl<T> [T]Jorge Aparicio-0/+3
2015-03-16impl strJorge Aparicio-0/+3
2015-03-16std: Stabilize the Write::flush methodAlex Crichton-1/+1
The [associated RFC][rfc] for possibly splitting out `flush` has been closed and as a result there are no more blockers for stabilizing this method, so this commit marks the method as such. [rfc]: https://github.com/rust-lang/rfcs/pull/950