diff options
| author | bors <bors@rust-lang.org> | 2015-03-13 20:22:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-13 20:22:16 +0000 |
| commit | 3e4be02b80a3dd27bce20870958fe0aef7e7336d (patch) | |
| tree | 156b54e84eeb1df2818be29b53ab7f35b5bc80f0 /src/libstd/sys/common | |
| parent | 9eb69abad8ffbce840e7dc7038ddea434dc987f1 (diff) | |
| parent | 981bf5f690d1d7c5cf3e1419ac7a7c86dbc7a4d5 (diff) | |
| download | rust-3e4be02b80a3dd27bce20870958fe0aef7e7336d.tar.gz rust-3e4be02b80a3dd27bce20870958fe0aef7e7336d.zip | |
Auto merge of #23292 - alexcrichton:stabilize-io, r=aturon
The new `std::io` module has had some time to bake now, and this commit
stabilizes its functionality. There are still portions of the module which
remain unstable, and below contains a summart of the actions taken.
This commit also deprecates the entire contents of the `old_io` module in a
blanket fashion. All APIs should now have a reasonable replacement in the
new I/O modules.
Stable APIs:
* `std::io` (the name)
* `std::io::prelude` (the name)
* `Read`
* `Read::read`
* `Read::{read_to_end, read_to_string}` after being modified to return a `usize`
for the number of bytes read.
* `ReadExt`
* `Write`
* `Write::write`
* `Write::{write_all, write_fmt}`
* `WriteExt`
* `BufRead`
* `BufRead::{fill_buf, consume}`
* `BufRead::{read_line, read_until}` after being modified to return a `usize`
for the number of bytes read.
* `BufReadExt`
* `BufReader`
* `BufReader::{new, with_capacity}`
* `BufReader::{get_ref, get_mut, into_inner}`
* `{Read,BufRead} for BufReader`
* `BufWriter`
* `BufWriter::{new, with_capacity}`
* `BufWriter::{get_ref, get_mut, into_inner}`
* `Write for BufWriter`
* `IntoInnerError`
* `IntoInnerError::{error, into_inner}`
* `{Error,Display} for IntoInnerError`
* `LineWriter`
* `LineWriter::{new, with_capacity}` - `with_capacity` was added
* `LineWriter::{get_ref, get_mut, into_inner}` - `get_mut` was added)
* `Write for LineWriter`
* `BufStream`
* `BufStream::{new, with_capacities}`
* `BufStream::{get_ref, get_mut, into_inner}`
* `{BufRead,Read,Write} for BufStream`
* `stdin`
* `Stdin`
* `Stdin::lock`
* `Stdin::read_line` - added method
* `StdinLock`
* `Read for Stdin`
* `{Read,BufRead} for StdinLock`
* `stdout`
* `Stdout`
* `Stdout::lock`
* `StdoutLock`
* `Write for Stdout`
* `Write for StdoutLock`
* `stderr`
* `Stderr`
* `Stderr::lock`
* `StderrLock`
* `Write for Stderr`
* `Write for StderrLock`
* `io::Result`
* `io::Error`
* `io::Error::last_os_error`
* `{Display, Error} for Error`
Unstable APIs:
(reasons can be found in the commit itself)
* `Write::flush`
* `Seek`
* `ErrorKind`
* `Error::new`
* `Error::from_os_error`
* `Error::kind`
Deprecated APIs
* `Error::description` - available via the `Error` trait
* `Error::detail` - available via the `Display` implementation
* `thread::Builder::{stdout, stderr}`
Changes in functionality:
* `old_io::stdio::set_stderr` is now a noop as the infrastructure for printing
backtraces has migrated to `std::io`.
[breaking-change]
Diffstat (limited to 'src/libstd/sys/common')
| -rw-r--r-- | src/libstd/sys/common/backtrace.rs | 41 | ||||
| -rw-r--r-- | src/libstd/sys/common/mod.rs | 5 |
2 files changed, 26 insertions, 20 deletions
diff --git a/src/libstd/sys/common/backtrace.rs b/src/libstd/sys/common/backtrace.rs index 50a9f204799..c42a755b444 100644 --- a/src/libstd/sys/common/backtrace.rs +++ b/src/libstd/sys/common/backtrace.rs @@ -9,8 +9,9 @@ // except according to those terms. use prelude::v1::*; +use io::prelude::*; -use old_io::IoResult; +use io; #[cfg(target_pointer_width = "64")] pub const HEX_WIDTH: uint = 18; @@ -35,7 +36,7 @@ pub const HEX_WIDTH: uint = 10; // Note that this demangler isn't quite as fancy as it could be. We have lots // of other information in our symbols like hashes, version, type information, // etc. Additionally, this doesn't handle glue symbols at all. -pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> { +pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> { // First validate the symbol. If it doesn't look like anything we're // expecting, we just print it literally. Note that we must handle non-rust // symbols because we could have any function in the backtrace. @@ -72,12 +73,12 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> { // Alright, let's do this. if !valid { - try!(writer.write_str(s)); + try!(writer.write_all(s.as_bytes())); } else { let mut first = true; while inner.len() > 0 { if !first { - try!(writer.write_str("::")); + try!(writer.write_all(b"::")); } else { first = false; } @@ -93,11 +94,11 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> { macro_rules! demangle { ($($pat:expr, => $demangled:expr),*) => ({ $(if rest.starts_with($pat) { - try!(writer.write_str($demangled)); + try!(writer.write_all($demangled)); rest = &rest[$pat.len()..]; } else)* { - try!(writer.write_str(rest)); + try!(writer.write_all(rest.as_bytes())); break; } @@ -106,29 +107,29 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> { // see src/librustc/back/link.rs for these mappings demangle! ( - "$SP$", => "@", - "$BP$", => "*", - "$RF$", => "&", - "$LT$", => "<", - "$GT$", => ">", - "$LP$", => "(", - "$RP$", => ")", - "$C$", => ",", + "$SP$", => b"@", + "$BP$", => b"*", + "$RF$", => b"&", + "$LT$", => b"<", + "$GT$", => b">", + "$LP$", => b"(", + "$RP$", => b")", + "$C$", => b",", // in theory we can demangle any Unicode code point, but // for simplicity we just catch the common ones. - "$u7e$", => "~", - "$u20$", => " ", - "$u27$", => "'", - "$u5b$", => "[", - "$u5d$", => "]" + "$u7e$", => b"~", + "$u20$", => b" ", + "$u27$", => b"'", + "$u5b$", => b"[", + "$u5d$", => b"]" ) } else { let idx = match rest.find('$') { None => rest.len(), Some(i) => i, }; - try!(writer.write_str(&rest[..idx])); + try!(writer.write_all(rest[..idx].as_bytes())); rest = &rest[idx..]; } } diff --git a/src/libstd/sys/common/mod.rs b/src/libstd/sys/common/mod.rs index 9a89b290980..29c05b1e0d8 100644 --- a/src/libstd/sys/common/mod.rs +++ b/src/libstd/sys/common/mod.rs @@ -37,6 +37,7 @@ pub mod wtf8; // common error constructors +#[allow(deprecated)] pub fn eof() -> IoError { IoError { kind: old_io::EndOfFile, @@ -45,6 +46,7 @@ pub fn eof() -> IoError { } } +#[allow(deprecated)] pub fn timeout(desc: &'static str) -> IoError { IoError { kind: old_io::TimedOut, @@ -53,6 +55,7 @@ pub fn timeout(desc: &'static str) -> IoError { } } +#[allow(deprecated)] pub fn short_write(n: uint, desc: &'static str) -> IoError { IoError { kind: if n == 0 { old_io::TimedOut } else { old_io::ShortWrite(n) }, @@ -61,6 +64,7 @@ pub fn short_write(n: uint, desc: &'static str) -> IoError { } } +#[allow(deprecated)] pub fn unimpl() -> IoError { IoError { kind: old_io::IoUnavailable, @@ -70,6 +74,7 @@ pub fn unimpl() -> IoError { } // unix has nonzero values as errors +#[allow(deprecated)] pub fn mkerr_libc<T: Int>(ret: T) -> IoResult<()> { if ret != Int::zero() { Err(last_error()) |
