diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-29 19:40:57 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-30 15:04:43 -0800 |
| commit | 262c1efe6352a3e4dba4d8aebc4d9bd96849cd71 (patch) | |
| tree | 4096f26993c2db2e0c95181170ef63f46cf3cb7e /src/libstd | |
| parent | 023dfb0c898d851dee6ace2f8339b73b5287136b (diff) | |
| download | rust-262c1efe6352a3e4dba4d8aebc4d9bd96849cd71.tar.gz rust-262c1efe6352a3e4dba4d8aebc4d9bd96849cd71.zip | |
Register new snapshots
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/bitflags.rs | 11 | ||||
| -rw-r--r-- | src/libstd/fmt.rs | 27 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 41 | ||||
| -rw-r--r-- | src/libstd/io/stdio.rs | 20 | ||||
| -rw-r--r-- | src/libstd/macros.rs | 140 | ||||
| -rw-r--r-- | src/libstd/rt/macros.rs | 18 | ||||
| -rw-r--r-- | src/libstd/rt/unwind.rs | 47 | ||||
| -rw-r--r-- | src/libstd/rt/util.rs | 16 | ||||
| -rw-r--r-- | src/libstd/thread_local/mod.rs | 23 | ||||
| -rw-r--r-- | src/libstd/time/duration.rs | 14 |
10 files changed, 2 insertions, 355 deletions
diff --git a/src/libstd/bitflags.rs b/src/libstd/bitflags.rs index a46b8a9ad90..aeb4df402a2 100644 --- a/src/libstd/bitflags.rs +++ b/src/libstd/bitflags.rs @@ -241,17 +241,6 @@ macro_rules! bitflags { } } - // NOTE(stage0): Remove impl after a snapshot - #[cfg(stage0)] - impl Not<$BitFlags> for $BitFlags { - /// Returns the complement of this set of flags. - #[inline] - fn not(&self) -> $BitFlags { - $BitFlags { bits: !self.bits } & $BitFlags::all() - } - } - - #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot impl Not<$BitFlags> for $BitFlags { /// Returns the complement of this set of flags. #[inline] diff --git a/src/libstd/fmt.rs b/src/libstd/fmt.rs index b75cf9a196b..957dd54a037 100644 --- a/src/libstd/fmt.rs +++ b/src/libstd/fmt.rs @@ -406,8 +406,6 @@ pub use core::fmt::{Argument, Arguments, write, radix, Radix, RadixFmt}; #[doc(hidden)] pub use core::fmt::{argument, argumentuint}; -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// The format function takes a precompiled format string and a list of /// arguments, to return the resulting formatted string. /// @@ -431,31 +429,6 @@ pub fn format(args: Arguments) -> string::String { string::String::from_utf8(output).unwrap() } -// NOTE(stage0): Remove function after a snapshot -#[cfg(stage0)] -/// The format function takes a precompiled format string and a list of -/// arguments, to return the resulting formatted string. -/// -/// # Arguments -/// -/// * args - a structure of arguments generated via the `format_args!` macro. -/// -/// # Example -/// -/// ```rust -/// use std::fmt; -/// -/// let s = format_args!(fmt::format, "Hello, {}!", "world"); -/// assert_eq!(s, "Hello, world!".to_string()); -/// ``` -#[experimental = "this is an implementation detail of format! and should not \ - be called directly"] -pub fn format(args: &Arguments) -> string::String { - let mut output = Vec::new(); - let _ = write!(&mut output as &mut Writer, "{}", args); - string::String::from_utf8(output).unwrap() -} - impl<'a> Writer for Formatter<'a> { fn write(&mut self, b: &[u8]) -> io::IoResult<()> { match (*self).write(b) { diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 7a25360e695..8d5b125bb08 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1017,8 +1017,6 @@ pub trait Writer { /// decide whether their stream needs to be buffered or not. fn flush(&mut self) -> IoResult<()> { Ok(()) } - // NOTE(stage0): Remove cfg after a snapshot - #[cfg(not(stage0))] /// Writes a formatted string into this writer, returning any error /// encountered. /// @@ -1057,45 +1055,6 @@ pub trait Writer { } - // NOTE(stage0): Remove method after a snapshot - #[cfg(stage0)] - /// Writes a formatted string into this writer, returning any error - /// encountered. - /// - /// This method is primarily used to interface with the `format_args!` - /// macro, but it is rare that this should explicitly be called. The - /// `write!` macro should be favored to invoke this method instead. - /// - /// # Errors - /// - /// This function will return any I/O error reported while formatting. - fn write_fmt(&mut self, fmt: &fmt::Arguments) -> IoResult<()> { - // Create a shim which translates a Writer to a FormatWriter and saves - // off I/O errors. instead of discarding them - struct Adaptor<'a, T:'a> { - inner: &'a mut T, - error: IoResult<()>, - } - - impl<'a, T: Writer> fmt::FormatWriter for Adaptor<'a, T> { - fn write(&mut self, bytes: &[u8]) -> fmt::Result { - match self.inner.write(bytes) { - Ok(()) => Ok(()), - Err(e) => { - self.error = Err(e); - Err(fmt::Error) - } - } - } - } - - let mut output = Adaptor { inner: self, error: Ok(()) }; - match fmt::write(&mut output, fmt) { - Ok(()) => Ok(()), - Err(..) => output.error - } - } - /// Write a rust string into this sink. /// /// The bytes written will be the UTF-8 encoded version of the input string. diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 6c8e4eea40f..43d2e078035 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -378,38 +378,18 @@ pub fn println(s: &str) { }) } -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// Similar to `print`, but takes a `fmt::Arguments` structure to be compatible /// with the `format_args!` macro. pub fn print_args(fmt: fmt::Arguments) { with_task_stdout(|io| write!(io, "{}", fmt)) } -// NOTE(stage0): Remove function after a snapshot -#[cfg(stage0)] -/// Similar to `print`, but takes a `fmt::Arguments` structure to be compatible -/// with the `format_args!` macro. -pub fn print_args(fmt: &fmt::Arguments) { - with_task_stdout(|io| write!(io, "{}", fmt)) -} - -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// Similar to `println`, but takes a `fmt::Arguments` structure to be /// compatible with the `format_args!` macro. pub fn println_args(fmt: fmt::Arguments) { with_task_stdout(|io| writeln!(io, "{}", fmt)) } -// NOTE(stage0): Remove function after a snapshot -#[cfg(stage0)] -/// Similar to `println`, but takes a `fmt::Arguments` structure to be -/// compatible with the `format_args!` macro. -pub fn println_args(fmt: &fmt::Arguments) { - with_task_stdout(|io| writeln!(io, "{}", fmt)) -} - /// Representation of a reader of a standard input stream pub struct StdReader { inner: StdSource diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index edb6218c5cc..ebb64bc2f2d 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -17,8 +17,6 @@ #![experimental] #![macro_escape] -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// The entry point for panic of Rust tasks. /// /// This macro is used to inject panic into a Rust task, causing the task to @@ -59,63 +57,6 @@ macro_rules! panic { }); } -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -/// The entry point for panic of Rust tasks. -/// -/// This macro is used to inject panic into a Rust task, causing the task to -/// unwind and panic entirely. Each task's panic can be reaped as the -/// `Box<Any>` type, and the single-argument form of the `panic!` macro will be -/// the value which is transmitted. -/// -/// The multi-argument form of this macro panics with a string and has the -/// `format!` syntax for building a string. -/// -/// # Example -/// -/// ```should_fail -/// # #![allow(unreachable_code)] -/// panic!(); -/// panic!("this is a terrible mistake!"); -/// panic!(4i); // panic with the value of 4 to be collected elsewhere -/// panic!("this is a {} {message}", "fancy", message = "message"); -/// ``` -#[macro_export] -macro_rules! panic { - () => ({ - panic!("explicit panic") - }); - ($msg:expr) => ({ - // static requires less code at runtime, more constant data - static _FILE_LINE: (&'static str, uint) = (file!(), line!()); - ::std::rt::begin_unwind($msg, &_FILE_LINE) - }); - ($fmt:expr, $($arg:tt)*) => ({ - // a closure can't have return type !, so we need a full - // function to pass to format_args!, *and* we need the - // file and line numbers right here; so an inner bare fn - // is our only choice. - // - // LLVM doesn't tend to inline this, presumably because begin_unwind_fmt - // is #[cold] and #[inline(never)] and because this is flagged as cold - // as returning !. We really do want this to be inlined, however, - // because it's just a tiny wrapper. Small wins (156K to 149K in size) - // were seen when forcing this to be inlined, and that number just goes - // up with the number of calls to panic!() - // - // The leading _'s are to avoid dead code warnings if this is - // used inside a dead function. Just `#[allow(dead_code)]` is - // insufficient, since the user may have - // `#[forbid(dead_code)]` and which cannot be overridden. - #[inline(always)] - fn _run_fmt(fmt: &::std::fmt::Arguments) -> ! { - static _FILE_LINE: (&'static str, uint) = (file!(), line!()); - ::std::rt::begin_unwind_fmt(fmt, &_FILE_LINE) - } - format_args!(_run_fmt, $fmt, $($arg)*) - }); -} - /// Ensure that a boolean expression is `true` at runtime. /// /// This will invoke the `panic!` macro if the provided expression cannot be @@ -289,8 +230,6 @@ macro_rules! unimplemented { () => (panic!("not yet implemented")) } -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// Use the syntax described in `std::fmt` to create a value of type `String`. /// See `std::fmt` for more information. /// @@ -307,28 +246,6 @@ macro_rules! format { ($($arg:tt)*) => (::std::fmt::format(format_args!($($arg)*))) } -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -/// Use the syntax described in `std::fmt` to create a value of type `String`. -/// See `std::fmt` for more information. -/// -/// # Example -/// -/// ``` -/// format!("test"); -/// format!("hello {}", "world!"); -/// format!("x = {}, y = {y}", 10i, y = 30i); -/// ``` -#[macro_export] -#[stable] -macro_rules! format { - ($($arg:tt)*) => ( - format_args!(::std::fmt::format, $($arg)*) - ) -} - -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// Use the `format!` syntax to write data into a buffer of type `&mut Writer`. /// See `std::fmt` for more information. /// @@ -347,29 +264,6 @@ macro_rules! write { ($dst:expr, $($arg:tt)*) => ((&mut *$dst).write_fmt(format_args!($($arg)*))) } -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -/// Use the `format!` syntax to write data into a buffer of type `&mut Writer`. -/// See `std::fmt` for more information. -/// -/// # Example -/// -/// ``` -/// # #![allow(unused_must_use)] -/// -/// let mut w = Vec::new(); -/// write!(&mut w, "test"); -/// write!(&mut w, "formatted {}", "arguments"); -/// ``` -#[macro_export] -#[stable] -macro_rules! write { - ($dst:expr, $($arg:tt)*) => ({ - let dst = &mut *$dst; - format_args!(|args| { dst.write_fmt(args) }, $($arg)*) - }) -} - /// Equivalent to the `write!` macro, except that a newline is appended after /// the message is written. #[macro_export] @@ -380,8 +274,6 @@ macro_rules! writeln { ) } -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// Equivalent to the `println!` macro except that a newline is not printed at /// the end of the message. #[macro_export] @@ -390,18 +282,6 @@ macro_rules! print { ($($arg:tt)*) => (::std::io::stdio::print_args(format_args!($($arg)*))) } -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -/// Equivalent to the `println!` macro except that a newline is not printed at -/// the end of the message. -#[macro_export] -#[stable] -macro_rules! print { - ($($arg:tt)*) => (format_args!(::std::io::stdio::print_args, $($arg)*)) -} - -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// Macro for printing to a task's stdout handle. /// /// Each task can override its stdout handle via `std::io::stdio::set_stdout`. @@ -420,26 +300,6 @@ macro_rules! println { ($($arg:tt)*) => (::std::io::stdio::println_args(format_args!($($arg)*))) } -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -/// Macro for printing to a task's stdout handle. -/// -/// Each task can override its stdout handle via `std::io::stdio::set_stdout`. -/// The syntax of this macro is the same as that used for `format!`. For more -/// information, see `std::fmt` and `std::io::stdio`. -/// -/// # Example -/// -/// ``` -/// println!("hello there!"); -/// println!("format {} arguments", "some"); -/// ``` -#[macro_export] -#[stable] -macro_rules! println { - ($($arg:tt)*) => (format_args!(::std::io::stdio::println_args, $($arg)*)) -} - /// Helper macro for unwrapping `Result` values while returning early with an /// error if the value of the expression is `Err`. For more information, see /// `std::io`. diff --git a/src/libstd/rt/macros.rs b/src/libstd/rt/macros.rs index 095a27203f9..0f35500a04a 100644 --- a/src/libstd/rt/macros.rs +++ b/src/libstd/rt/macros.rs @@ -15,22 +15,12 @@ #![macro_escape] -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] macro_rules! rterrln { ($fmt:expr $($arg:tt)*) => ( { ::rt::util::dumb_print(format_args!(concat!($fmt, "\n") $($arg)*)) } ) } -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -macro_rules! rterrln { - ($fmt:expr $($arg:tt)*) => ( { - format_args!(::rt::util::dumb_print, concat!($fmt, "\n") $($arg)*) - } ) -} - // Some basic logging. Enabled by passing `--cfg rtdebug` to the libstd build. macro_rules! rtdebug { ($($arg:tt)*) => ( { @@ -50,14 +40,6 @@ macro_rules! rtassert { } ) } -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] macro_rules! rtabort { ($($arg:tt)*) => (::rt::util::abort(format_args!($($arg)*))) } - -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -macro_rules! rtabort { - ($($arg:tt)*) => (format_args!(::rt::util::abort, $($arg)*)) -} diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index 9b57dcc9e18..c273c52dacc 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -477,8 +477,6 @@ pub mod eabi { } } -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] #[cfg(not(test))] /// Entry point of panic from the libcore crate. #[lang = "panic_fmt"] @@ -487,18 +485,6 @@ pub extern fn rust_begin_unwind(msg: fmt::Arguments, begin_unwind_fmt(msg, &(file, line)) } -// NOTE(stage0): Remove function after a snapshot -#[cfg(stage0)] -#[cfg(not(test))] -/// Entry point of panic from the libcore crate. -#[lang = "panic_fmt"] -pub extern fn rust_begin_unwind(msg: &fmt::Arguments, - file: &'static str, line: uint) -> ! { - begin_unwind_fmt(msg, &(file, line)) -} - -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// The entry point for unwinding with a formatted message. /// /// This is designed to reduce the amount of code required at the call @@ -530,39 +516,6 @@ pub fn begin_unwind_fmt(msg: fmt::Arguments, file_line: &(&'static str, uint)) - begin_unwind_inner(msg, file_line) } -// NOTE(stage0): Remove function after a snapshot -#[cfg(stage0)] -/// The entry point for unwinding with a formatted message. -/// -/// This is designed to reduce the amount of code required at the call -/// site as much as possible (so that `panic!()` has as low an impact -/// on (e.g.) the inlining of other functions as possible), by moving -/// the actual formatting into this shared place. -#[inline(never)] #[cold] -pub fn begin_unwind_fmt(msg: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! { - use fmt::FormatWriter; - - // We do two allocations here, unfortunately. But (a) they're - // required with the current scheme, and (b) we don't handle - // panic + OOM properly anyway (see comment in begin_unwind - // below). - - struct VecWriter<'a> { v: &'a mut Vec<u8> } - - impl<'a> fmt::FormatWriter for VecWriter<'a> { - fn write(&mut self, buf: &[u8]) -> fmt::Result { - self.v.push_all(buf); - Ok(()) - } - } - - let mut v = Vec::new(); - let _ = write!(&mut VecWriter { v: &mut v }, "{}", msg); - - let msg = box String::from_utf8_lossy(v.as_slice()).into_owned(); - begin_unwind_inner(msg, file_line) -} - /// This is the entry point of unwinding for panic!() and assert!(). #[inline(never)] #[cold] // avoid code bloat at the call sites as much as possible pub fn begin_unwind<M: Any + Send>(msg: M, file_line: &(&'static str, uint)) -> ! { diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs index 6b007056a51..5448af3f753 100644 --- a/src/libstd/rt/util.rs +++ b/src/libstd/rt/util.rs @@ -112,25 +112,11 @@ impl fmt::FormatWriter for Stdio { } } -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] pub fn dumb_print(args: fmt::Arguments) { let _ = Stderr.write_fmt(args); } -// NOTE(stage0): Remove function after a snapshot -#[cfg(stage0)] -pub fn dumb_print(args: &fmt::Arguments) { - let mut w = Stderr; - let _ = write!(&mut w, "{}", args); -} - -// NOTE(stage0): Remove wrappers after a snapshot -#[cfg(not(stage0))] pub fn abort(args: fmt::Arguments) -> ! { abort_(&args) } -#[cfg(stage0)] pub fn abort(args: &fmt::Arguments) -> ! { abort_(args) } - -// NOTE(stage0): Change to `pub fn abort(args: fmt::Arguments) -> !` after a snapshot -fn abort_(args: &fmt::Arguments) -> ! { +pub fn abort(args: fmt::Arguments) -> ! { use fmt::FormatWriter; struct BufWriter<'a> { diff --git a/src/libstd/thread_local/mod.rs b/src/libstd/thread_local/mod.rs index 4cfa2709352..14dd2a1ac9b 100644 --- a/src/libstd/thread_local/mod.rs +++ b/src/libstd/thread_local/mod.rs @@ -189,22 +189,7 @@ macro_rules! __thread_local_inner { } }; - #[cfg(all(stage0, not(any(target_os = "macos", target_os = "linux"))))] - const INIT: ::std::thread_local::KeyInner<$t> = { - unsafe extern fn __destroy(ptr: *mut u8) { - ::std::thread_local::destroy_value::<$t>(ptr); - } - - ::std::thread_local::KeyInner { - inner: ::std::cell::UnsafeCell { value: $init }, - os: ::std::thread_local::OsStaticKey { - inner: ::std::thread_local::OS_INIT_INNER, - dtor: ::std::option::Option::Some(__destroy), - }, - } - }; - - #[cfg(all(not(stage0), not(any(target_os = "macos", target_os = "linux"))))] + #[cfg(all(not(any(target_os = "macos", target_os = "linux"))))] const INIT: ::std::thread_local::KeyInner<$t> = { unsafe extern fn __destroy(ptr: *mut u8) { ::std::thread_local::destroy_value::<$t>(ptr); @@ -346,16 +331,10 @@ mod imp { // *should* be the case that this loop always terminates because we // provide the guarantee that a TLS key cannot be set after it is // flagged for destruction. - #[cfg(not(stage0))] static DTORS: os::StaticKey = os::StaticKey { inner: os::INIT_INNER, dtor: Some(run_dtors as unsafe extern "C" fn(*mut u8)), }; - #[cfg(stage0)] - static DTORS: os::StaticKey = os::StaticKey { - inner: os::INIT_INNER, - dtor: Some(run_dtors), - }; type List = Vec<(*mut u8, unsafe extern fn(*mut u8))>; if DTORS.get().is_null() { let v: Box<List> = box Vec::new(); diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index f7351c9580f..51564b53976 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -262,20 +262,6 @@ impl Duration { } } -// NOTE(stage0): Remove impl after a snapshot -#[cfg(stage0)] -impl Neg<Duration> for Duration { - #[inline] - fn neg(&self) -> Duration { - if self.nanos == 0 { - Duration { secs: -self.secs, nanos: 0 } - } else { - Duration { secs: -self.secs - 1, nanos: NANOS_PER_SEC - self.nanos } - } - } -} - -#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot impl Neg<Duration> for Duration { #[inline] fn neg(self) -> Duration { |
