about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan Prichard <ryan.prichard@gmail.com>2015-04-01 13:36:53 -0700
committerRyan Prichard <ryan.prichard@gmail.com>2015-04-12 22:01:55 -0700
commit9cdc9e9c614089c294cb19837919fdc0653c2b14 (patch)
tree17c5967c8a954c0214eb73d61adf39acd4b95ee0
parentbd26307411b336345bb5e5b3af3c2997b37fa65e (diff)
downloadrust-9cdc9e9c614089c294cb19837919fdc0653c2b14.tar.gz
rust-9cdc9e9c614089c294cb19837919fdc0653c2b14.zip
Destabilize format_args! internals.
Arguments, Formatters, and the various format traits remain stable. The
format_args! macro uses #[allow_internal_unstable] to allow it access to
the unstable things in core::fmt.

Destabilized things include a "v1" in their name:
 * core::fmt::rt
 * core::fmt::rt::v1 (the module and all contents)
 * core::fmt::ArgumentV1
 * core::fmt::ArgumentV1::new
 * core::fmt::ArgumentV1::from_usize
 * core::fmt::Arguments::new_v1
 * core::fmt::Arguments::new_v1_formatted

The unstable message was copied from that of std::io::_print.
-rw-r--r--src/libcore/fmt/mod.rs18
-rw-r--r--src/libcore/fmt/rt/v1.rs47
2 files changed, 36 insertions, 29 deletions
diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs
index 67781b73ae2..1c70f9941f7 100644
--- a/src/libcore/fmt/mod.rs
+++ b/src/libcore/fmt/mod.rs
@@ -38,7 +38,8 @@ mod num;
 mod float;
 mod builders;
 
-#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
+#[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
 #[doc(hidden)]
 pub mod rt {
     pub mod v1;
@@ -134,7 +135,8 @@ enum Void {}
 /// compile time it is ensured that the function and the value have the correct
 /// types, and then this struct is used to canonicalize arguments to one type.
 #[derive(Copy)]
-#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
+#[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
 #[doc(hidden)]
 pub struct ArgumentV1<'a> {
     value: &'a Void,
@@ -154,7 +156,8 @@ impl<'a> ArgumentV1<'a> {
     }
 
     #[doc(hidden)]
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
+    #[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
     pub fn new<'b, T>(x: &'b T,
                       f: fn(&T, &mut Formatter) -> Result) -> ArgumentV1<'b> {
         unsafe {
@@ -166,7 +169,8 @@ impl<'a> ArgumentV1<'a> {
     }
 
     #[doc(hidden)]
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
+    #[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
     pub fn from_usize(x: &usize) -> ArgumentV1 {
         ArgumentV1::new(x, ArgumentV1::show_usize)
     }
@@ -189,7 +193,8 @@ impl<'a> Arguments<'a> {
     /// When using the format_args!() macro, this function is used to generate the
     /// Arguments structure.
     #[doc(hidden)] #[inline]
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
+    #[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
     pub fn new_v1(pieces: &'a [&'a str],
                   args: &'a [ArgumentV1<'a>]) -> Arguments<'a> {
         Arguments {
@@ -206,7 +211,8 @@ impl<'a> Arguments<'a> {
     /// created with `argumentusize`. However, failing to do so doesn't cause
     /// unsafety, but will ignore invalid .
     #[doc(hidden)] #[inline]
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
+    #[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
     pub fn new_v1_formatted(pieces: &'a [&'a str],
                             args: &'a [ArgumentV1<'a>],
                             fmt: &'a [rt::v1::Argument]) -> Arguments<'a> {
diff --git a/src/libcore/fmt/rt/v1.rs b/src/libcore/fmt/rt/v1.rs
index d56ec6a74d4..0d851c1e897 100644
--- a/src/libcore/fmt/rt/v1.rs
+++ b/src/libcore/fmt/rt/v1.rs
@@ -14,68 +14,69 @@
 //! These definitions are similar to their `ct` equivalents, but differ in that
 //! these can be statically allocated and are slightly optimized for the runtime
 
-#![stable(feature = "rust1", since = "1.0.0")]
+#![cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
+#![cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
 
 #[derive(Copy, Clone)]
-#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
 pub struct Argument {
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     pub position: Position,
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     pub format: FormatSpec,
 }
 
 #[derive(Copy, Clone)]
-#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
 pub struct FormatSpec {
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     pub fill: char,
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     pub align: Alignment,
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     pub flags: u32,
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     pub precision: Count,
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     pub width: Count,
 }
 
 /// Possible alignments that can be requested as part of a formatting directive.
 #[derive(Copy, Clone, PartialEq)]
-#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
 pub enum Alignment {
     /// Indication that contents should be left-aligned.
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     Left,
     /// Indication that contents should be right-aligned.
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     Right,
     /// Indication that contents should be center-aligned.
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     Center,
     /// No alignment was requested.
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     Unknown,
 }
 
 #[derive(Copy, Clone)]
-#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
 pub enum Count {
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     Is(usize),
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     Param(usize),
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     NextParam,
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     Implied,
 }
 
 #[derive(Copy, Clone)]
-#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
 pub enum Position {
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     Next,
-    #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
     At(usize)
 }