From 262c1efe6352a3e4dba4d8aebc4d9bd96849cd71 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 29 Dec 2014 19:40:57 -0800 Subject: Register new snapshots --- src/libcore/fmt/float.rs | 9 ----- src/libcore/fmt/mod.rs | 85 ----------------------------------------- src/libcore/macros.rs | 53 -------------------------- src/libcore/ops.rs | 99 ------------------------------------------------ src/libcore/panicking.rs | 49 ------------------------ 5 files changed, 295 deletions(-) (limited to 'src/libcore') diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index 329fe7c7b49..3787ae33fda 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -325,18 +325,9 @@ pub fn float_to_str_bytes_common( let mut filler = Filler { buf: &mut buf, end: &mut end }; match sign { - // NOTE(stage0): Remove cfg after a snapshot - #[cfg(not(stage0))] SignNeg => { let _ = fmt::write(&mut filler, format_args!("{:-}", exp)); } - // NOTE(stage0): Remove match arm after a snapshot - #[cfg(stage0)] - SignNeg => { - let _ = format_args!(|args| { - fmt::write(&mut filler, args) - }, "{:-}", exp); - } } } } diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index b050b98de2f..9d275c9da9c 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -70,21 +70,11 @@ pub trait FormatWriter { /// This function will return an instance of `FormatError` on error. fn write(&mut self, bytes: &[u8]) -> Result; - // NOTE(stage0): Remove cfg after a snapshot - #[cfg(not(stage0))] /// Glue for usage of the `write!` macro with implementers of this trait. /// /// This method should generally not be invoked manually, but rather through /// the `write!` macro itself. fn write_fmt(&mut self, args: Arguments) -> Result { write(self, args) } - - // NOTE(stage0): Remove method after a snapshot - #[cfg(stage0)] - /// Glue for usage of the `write!` macro with implementers of this trait. - /// - /// This method should generally not be invoked manually, but rather through - /// the `write!` macro itself. - fn write_fmt(&mut self, args: &Arguments) -> Result { write(self, args) } } /// A struct to represent both where to emit formatting strings to and how they @@ -204,17 +194,9 @@ pub struct Arguments<'a> { } impl<'a> Show for Arguments<'a> { - // NOTE(stage0): Remove cfg after a snapshot - #[cfg(not(stage0))] fn fmt(&self, fmt: &mut Formatter) -> Result { write(fmt.buf, *self) } - - // NOTE(stage0): Remove method after a snapshot - #[cfg(stage0)] - fn fmt(&self, fmt: &mut Formatter) -> Result { - write(fmt.buf, self) - } } /// When a format is not otherwise specified, types are formatted by ascribing @@ -287,8 +269,6 @@ static DEFAULT_ARGUMENT: rt::Argument<'static> = rt::Argument { } }; -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// The `write` function takes an output stream, a precompiled format string, /// and a list of arguments. The arguments will be formatted according to the /// specified format string into the output stream provided. @@ -342,61 +322,6 @@ pub fn write(output: &mut FormatWriter, args: Arguments) -> Result { Ok(()) } -// NOTE(stage0): Remove function after a snapshot -#[cfg(stage0)] -/// The `write` function takes an output stream, a precompiled format string, -/// and a list of arguments. The arguments will be formatted according to the -/// specified format string into the output stream provided. -/// -/// # Arguments -/// -/// * output - the buffer to write output to -/// * args - the precompiled arguments generated by `format_args!` -#[experimental = "libcore and I/O have yet to be reconciled, and this is an \ - implementation detail which should not otherwise be exported"] -pub fn write(output: &mut FormatWriter, args: &Arguments) -> Result { - let mut formatter = Formatter { - flags: 0, - width: None, - precision: None, - buf: output, - align: rt::AlignUnknown, - fill: ' ', - args: args.args, - curarg: args.args.iter(), - }; - - let mut pieces = args.pieces.iter(); - - match args.fmt { - None => { - // We can use default formatting parameters for all arguments. - for _ in range(0, args.args.len()) { - try!(formatter.buf.write(pieces.next().unwrap().as_bytes())); - try!(formatter.run(&DEFAULT_ARGUMENT)); - } - } - Some(fmt) => { - // Every spec has a corresponding argument that is preceded by - // a string piece. - for (arg, piece) in fmt.iter().zip(pieces.by_ref()) { - try!(formatter.buf.write(piece.as_bytes())); - try!(formatter.run(arg)); - } - } - } - - // There can be only one trailing string piece left. - match pieces.next() { - Some(piece) => { - try!(formatter.buf.write(piece.as_bytes())); - } - None => {} - } - - Ok(()) -} - impl<'a> Formatter<'a> { // First up is the collection of functions used to execute a format string @@ -603,22 +528,12 @@ impl<'a> Formatter<'a> { self.buf.write(data) } - // NOTE(stage0): Remove cfg after a snapshot - #[cfg(not(stage0))] /// Writes some formatted information into this instance #[unstable = "reconciling core and I/O may alter this definition"] pub fn write_fmt(&mut self, fmt: Arguments) -> Result { write(self.buf, fmt) } - // NOTE(stage0): Remove method after a snapshot - #[cfg(stage0)] - /// Writes some formatted information into this instance - #[unstable = "reconciling core and I/O may alter this definition"] - pub fn write_fmt(&mut self, fmt: &Arguments) -> Result { - write(self.buf, fmt) - } - /// Flags for formatting (packed version of rt::Flag) #[experimental = "return type may change and method was just created"] pub fn flags(&self) -> uint { self.flags } diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 781dbb0e55a..e8fbd9d930f 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -10,8 +10,6 @@ #![macro_escape] -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// Entry point of task panic, for details, see std::macros #[macro_export] macro_rules! panic { @@ -32,44 +30,6 @@ macro_rules! panic { }); } -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -/// Entry point of task panic, for details, see std::macros -#[macro_export] -macro_rules! panic { - () => ( - panic!("{}", "explicit panic") - ); - ($msg:expr) => ({ - static _MSG_FILE_LINE: (&'static str, &'static str, uint) = ($msg, file!(), line!()); - ::core::panicking::panic(&_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!()); - ::core::panicking::panic_fmt(fmt, &_FILE_LINE) - } - format_args!(_run_fmt, $fmt, $($arg)*) - }); -} - /// Runtime assertion, for details see std::macros #[macro_export] macro_rules! assert { @@ -119,25 +79,12 @@ macro_rules! try { ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) }) } -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] /// Writing a formatted string into a writer #[macro_export] macro_rules! write { ($dst:expr, $($arg:tt)*) => ((&mut *$dst).write_fmt(format_args!($($arg)*))) } -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -/// Writing a formatted string into a writer -#[macro_export] -macro_rules! write { - ($dst:expr, $($arg:tt)*) => ({ - let dst = &mut *$dst; - format_args!(|args| { dst.write_fmt(args) }, $($arg)*) - }) -} - /// Writing a formatted string plus a newline into a writer #[macro_export] macro_rules! writeln { diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index f6b79ccc42b..af07869e95f 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -292,58 +292,6 @@ rem_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 } rem_float_impl! { f32, fmodf } rem_float_impl! { f64, fmod } -/// The `Neg` trait is used to specify the functionality of unary `-`. -/// -/// # Example -/// -/// A trivial implementation of `Neg`. When `-Foo` happens, it ends up calling -/// `neg`, and therefore, `main` prints `Negating!`. -/// -/// ``` -/// #[deriving(Copy)] -/// struct Foo; -/// -/// impl Neg for Foo { -/// fn neg(&self) -> Foo { -/// println!("Negating!"); -/// *self -/// } -/// } -/// -/// fn main() { -/// -Foo; -/// } -/// ``` -// NOTE(stage0): Remove trait after a snapshot -#[cfg(stage0)] -#[lang="neg"] -pub trait Neg for Sized? { - /// The method for the unary `-` operator - fn neg(&self) -> Result; -} - -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -macro_rules! neg_impl { - ($($t:ty)*) => ($( - impl Neg<$t> for $t { - #[inline] - fn neg(&self) -> $t { -*self } - } - )*) -} - -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -macro_rules! neg_uint_impl { - ($t:ty, $t_signed:ty) => { - impl Neg<$t> for $t { - #[inline] - fn neg(&self) -> $t { -(*self as $t_signed) as $t } - } - } -} - /// The `Neg` trait is used to specify the functionality of unary `-`. /// /// # Example @@ -367,14 +315,12 @@ macro_rules! neg_uint_impl { /// -Foo; /// } /// ``` -#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot #[lang="neg"] pub trait Neg { /// The method for the unary `-` operator fn neg(self) -> Result; } -#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot macro_rules! neg_impl { ($($t:ty)*) => ($( impl Neg<$t> for $t { @@ -384,7 +330,6 @@ macro_rules! neg_impl { )*) } -#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot macro_rules! neg_uint_impl { ($t:ty, $t_signed:ty) => { impl Neg<$t> for $t { @@ -403,48 +348,6 @@ neg_uint_impl! { u32, i32 } neg_uint_impl! { u64, i64 } -/// The `Not` trait is used to specify the functionality of unary `!`. -/// -/// # Example -/// -/// A trivial implementation of `Not`. When `!Foo` happens, it ends up calling -/// `not`, and therefore, `main` prints `Not-ing!`. -/// -/// ``` -/// #[deriving(Copy)] -/// struct Foo; -/// -/// impl Not for Foo { -/// fn not(&self) -> Foo { -/// println!("Not-ing!"); -/// *self -/// } -/// } -/// -/// fn main() { -/// !Foo; -/// } -/// ``` -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -#[lang="not"] -pub trait Not for Sized? { - /// The method for the unary `!` operator - fn not(&self) -> Result; -} - - -// NOTE(stage0): Remove macro after a snapshot -#[cfg(stage0)] -macro_rules! not_impl { - ($($t:ty)*) => ($( - impl Not<$t> for $t { - #[inline] - fn not(&self) -> $t { !*self } - } - )*) -} - /// The `Not` trait is used to specify the functionality of unary `!`. /// /// # Example @@ -468,14 +371,12 @@ macro_rules! not_impl { /// !Foo; /// } /// ``` -#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot #[lang="not"] pub trait Not { /// The method for the unary `!` operator fn not(self) -> Result; } -#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot macro_rules! not_impl { ($($t:ty)*) => ($( impl Not<$t> for $t { diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 32f09a4c17f..61b4284e1dd 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -31,11 +31,7 @@ #![allow(dead_code, missing_docs)] use fmt; -// NOTE(stage0): Remove import after a snapshot -#[cfg(stage0)] use intrinsics; -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] #[cold] #[inline(never)] // this is the slow path, always #[lang="panic"] pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! { @@ -43,22 +39,6 @@ pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! { panic_fmt(format_args!("{}", expr), &(file, line)) } -// NOTE(stage0): Remove function after a snapshot -#[cfg(stage0)] -#[cold] #[inline(never)] // this is the slow path, always -#[lang="panic"] -pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! { - let (expr, file, line) = *expr_file_line; - let ref file_line = (file, line); - format_args!(|args| -> () { - panic_fmt(args, file_line); - }, "{}", expr); - - unsafe { intrinsics::abort() } -} - -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] #[cold] #[inline(never)] #[lang="panic_bounds_check"] fn panic_bounds_check(file_line: &(&'static str, uint), @@ -67,20 +47,6 @@ fn panic_bounds_check(file_line: &(&'static str, uint), len, index), file_line) } -// NOTE(stage0): Remove function after a snapshot -#[cfg(stage0)] -#[cold] #[inline(never)] -#[lang="panic_bounds_check"] -fn panic_bounds_check(file_line: &(&'static str, uint), - index: uint, len: uint) -> ! { - format_args!(|args| -> () { - panic_fmt(args, file_line); - }, "index out of bounds: the len is {} but the index is {}", len, index); - unsafe { intrinsics::abort() } -} - -// NOTE(stage0): Remove cfg after a snapshot -#[cfg(not(stage0))] #[cold] #[inline(never)] pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, uint)) -> ! { #[allow(improper_ctypes)] @@ -91,18 +57,3 @@ pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, uint)) -> ! { let (file, line) = *file_line; unsafe { panic_impl(fmt, file, line) } } - -// NOTE(stage0): Remove function after a snapshot -#[cfg(stage0)] -#[cold] #[inline(never)] -pub fn panic_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! { - #[allow(improper_ctypes)] - extern { - #[lang = "panic_fmt"] - fn panic_impl(fmt: &fmt::Arguments, file: &'static str, - line: uint) -> !; - - } - let (file, line) = *file_line; - unsafe { panic_impl(fmt, file, line) } -} -- cgit 1.4.1-3-g733a5