]> git.lizzy.rs Git - rust.git/blobdiff - src/libcore/fmt/mod.rs
auto merge of #17159 : brson/rust/snaps, r=alexcrichton
[rust.git] / src / libcore / fmt / mod.rs
index 3244a72897fbb1eeb75fd2a0fb16233b5068a78a..f41d02070c9ee720c56c6ff2dff8c579a2066bf0 100644 (file)
@@ -113,7 +113,6 @@ impl<'a> Arguments<'a> {
     /// Arguments structure. The compiler inserts an `unsafe` block to call this,
     /// which is valid because the compiler performs all necessary validation to
     /// ensure that the resulting call to format/write would be safe.
-    #[cfg(not(stage0))]
     #[doc(hidden)] #[inline]
     pub unsafe fn new<'a>(pieces: &'static [&'static str],
                           args: &'a [Argument<'a>]) -> Arguments<'a> {
@@ -127,7 +126,6 @@ pub unsafe fn new<'a>(pieces: &'static [&'static str],
     /// This function is used to specify nonstandard formatting parameters.
     /// The `pieces` array must be at least as long as `fmt` to construct
     /// a valid Arguments structure.
-    #[cfg(not(stage0))]
     #[doc(hidden)] #[inline]
     pub unsafe fn with_placeholders<'a>(pieces: &'static [&'static str],
                                         fmt: &'static [rt::Argument<'static>],
@@ -138,13 +136,6 @@ pub unsafe fn with_placeholders<'a>(pieces: &'static [&'static str],
             args: args
         }
     }
-
-    #[cfg(stage0)]
-    #[doc(hidden)] #[inline]
-    pub unsafe fn new<'a>(fmt: &'static [rt::Piece<'static>],
-                          args: &'a [Argument<'a>]) -> Arguments<'a> {
-        Arguments{ fmt: mem::transmute(fmt), args: args }
-    }
 }
 
 /// This structure represents a safely precompiled version of a format string
@@ -156,7 +147,6 @@ pub unsafe fn new<'a>(fmt: &'static [rt::Piece<'static>],
 /// and pass it to a function or closure, passed as the first argument. The
 /// macro validates the format string at compile-time so usage of the `write`
 /// and `format` functions can be safely performed.
-#[cfg(not(stage0))]
 pub struct Arguments<'a> {
     // Format string pieces to print.
     pieces: &'a [&'a str],
@@ -169,12 +159,6 @@ pub struct Arguments<'a> {
     args: &'a [Argument<'a>],
 }
 
-#[cfg(stage0)] #[doc(hidden)]
-pub struct Arguments<'a> {
-    fmt: &'a [rt::Piece<'a>],
-    args: &'a [Argument<'a>],
-}
-
 impl<'a> Show for Arguments<'a> {
     fn fmt(&self, fmt: &mut Formatter) -> Result {
         write(fmt.buf, self)
@@ -296,7 +280,6 @@ pub fn $name<T: $trait_>(x: &T, fmt: &mut Formatter) -> Result {
     secret_upper_exp, UpperExp;
 }
 
-#[cfg(not(stage0))]
 static DEFAULT_ARGUMENT: rt::Argument<'static> = rt::Argument {
     position: rt::ArgumentNext,
     format: rt::FormatSpec {
@@ -316,7 +299,6 @@ pub fn $name<T: $trait_>(x: &T, fmt: &mut Formatter) -> Result {
 ///
 ///   * output - the buffer to write output to
 ///   * args - the precompiled arguments generated by `format_args!`
-#[cfg(not(stage0))]
 pub fn write(output: &mut FormatWriter, args: &Arguments) -> Result {
     let mut formatter = Formatter {
         flags: 0,
@@ -360,30 +342,11 @@ pub fn write(output: &mut FormatWriter, args: &Arguments) -> Result {
     Ok(())
 }
 
-#[cfg(stage0)] #[doc(hidden)]
-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(),
-    };
-    for piece in args.fmt.iter() {
-        try!(formatter.run(piece));
-    }
-    Ok(())
-}
-
 impl<'a> Formatter<'a> {
 
     // First up is the collection of functions used to execute a format string
     // at runtime. This consumes all of the compile-time statics generated by
     // the format! syntax extension.
-    #[cfg(not(stage0))]
     fn run(&mut self, arg: &rt::Argument) -> Result {
         // Fill in the format parameters into the formatter
         self.fill = arg.format.fill;
@@ -402,30 +365,6 @@ fn run(&mut self, arg: &rt::Argument) -> Result {
         (value.formatter)(value.value, self)
     }
 
-    #[cfg(stage0)] #[doc(hidden)]
-    fn run(&mut self, piece: &rt::Piece) -> Result {
-        match *piece {
-            rt::String(s) => self.buf.write(s.as_bytes()),
-            rt::Argument(ref arg) => {
-                // Fill in the format parameters into the formatter
-                self.fill = arg.format.fill;
-                self.align = arg.format.align;
-                self.flags = arg.format.flags;
-                self.width = self.getcount(&arg.format.width);
-                self.precision = self.getcount(&arg.format.precision);
-
-                // Extract the correct argument
-                let value = match arg.position {
-                    rt::ArgumentNext => { *self.curarg.next().unwrap() }
-                    rt::ArgumentIs(i) => self.args[i],
-                };
-
-                // Then actually do some printing
-                (value.formatter)(value.value, self)
-            }
-        }
-    }
-
     fn getcount(&mut self, cnt: &rt::Count) -> Option<uint> {
         match *cnt {
             rt::CountIs(n) => { Some(n) }