Skip to content

Commit 9cdc9e9

Browse files
committed
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.
1 parent bd26307 commit 9cdc9e9

File tree

2 files changed

+36
-29
lines changed

2 files changed

+36
-29
lines changed

src/libcore/fmt/mod.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ mod num;
3838
mod float;
3939
mod builders;
4040

41-
#[stable(feature = "rust1", since = "1.0.0")]
41+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
42+
#[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
4243
#[doc(hidden)]
4344
pub mod rt {
4445
pub mod v1;
@@ -134,7 +135,8 @@ enum Void {}
134135
/// compile time it is ensured that the function and the value have the correct
135136
/// types, and then this struct is used to canonicalize arguments to one type.
136137
#[derive(Copy)]
137-
#[stable(feature = "rust1", since = "1.0.0")]
138+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
139+
#[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
138140
#[doc(hidden)]
139141
pub struct ArgumentV1<'a> {
140142
value: &'a Void,
@@ -154,7 +156,8 @@ impl<'a> ArgumentV1<'a> {
154156
}
155157

156158
#[doc(hidden)]
157-
#[stable(feature = "rust1", since = "1.0.0")]
159+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
160+
#[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
158161
pub fn new<'b, T>(x: &'b T,
159162
f: fn(&T, &mut Formatter) -> Result) -> ArgumentV1<'b> {
160163
unsafe {
@@ -166,7 +169,8 @@ impl<'a> ArgumentV1<'a> {
166169
}
167170

168171
#[doc(hidden)]
169-
#[stable(feature = "rust1", since = "1.0.0")]
172+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
173+
#[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
170174
pub fn from_usize(x: &usize) -> ArgumentV1 {
171175
ArgumentV1::new(x, ArgumentV1::show_usize)
172176
}
@@ -189,7 +193,8 @@ impl<'a> Arguments<'a> {
189193
/// When using the format_args!() macro, this function is used to generate the
190194
/// Arguments structure.
191195
#[doc(hidden)] #[inline]
192-
#[stable(feature = "rust1", since = "1.0.0")]
196+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
197+
#[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
193198
pub fn new_v1(pieces: &'a [&'a str],
194199
args: &'a [ArgumentV1<'a>]) -> Arguments<'a> {
195200
Arguments {
@@ -206,7 +211,8 @@ impl<'a> Arguments<'a> {
206211
/// created with `argumentusize`. However, failing to do so doesn't cause
207212
/// unsafety, but will ignore invalid .
208213
#[doc(hidden)] #[inline]
209-
#[stable(feature = "rust1", since = "1.0.0")]
214+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
215+
#[cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
210216
pub fn new_v1_formatted(pieces: &'a [&'a str],
211217
args: &'a [ArgumentV1<'a>],
212218
fmt: &'a [rt::v1::Argument]) -> Arguments<'a> {

src/libcore/fmt/rt/v1.rs

+24-23
Original file line numberDiff line numberDiff line change
@@ -14,68 +14,69 @@
1414
//! These definitions are similar to their `ct` equivalents, but differ in that
1515
//! these can be statically allocated and are slightly optimized for the runtime
1616
17-
#![stable(feature = "rust1", since = "1.0.0")]
17+
#![cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
18+
#![cfg_attr(not(stage0), unstable(feature = "core", reason = "internal to format_args!"))]
1819

1920
#[derive(Copy, Clone)]
20-
#[stable(feature = "rust1", since = "1.0.0")]
21+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
2122
pub struct Argument {
22-
#[stable(feature = "rust1", since = "1.0.0")]
23+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
2324
pub position: Position,
24-
#[stable(feature = "rust1", since = "1.0.0")]
25+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
2526
pub format: FormatSpec,
2627
}
2728

2829
#[derive(Copy, Clone)]
29-
#[stable(feature = "rust1", since = "1.0.0")]
30+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
3031
pub struct FormatSpec {
31-
#[stable(feature = "rust1", since = "1.0.0")]
32+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
3233
pub fill: char,
33-
#[stable(feature = "rust1", since = "1.0.0")]
34+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
3435
pub align: Alignment,
35-
#[stable(feature = "rust1", since = "1.0.0")]
36+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
3637
pub flags: u32,
37-
#[stable(feature = "rust1", since = "1.0.0")]
38+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
3839
pub precision: Count,
39-
#[stable(feature = "rust1", since = "1.0.0")]
40+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
4041
pub width: Count,
4142
}
4243

4344
/// Possible alignments that can be requested as part of a formatting directive.
4445
#[derive(Copy, Clone, PartialEq)]
45-
#[stable(feature = "rust1", since = "1.0.0")]
46+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
4647
pub enum Alignment {
4748
/// Indication that contents should be left-aligned.
48-
#[stable(feature = "rust1", since = "1.0.0")]
49+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
4950
Left,
5051
/// Indication that contents should be right-aligned.
51-
#[stable(feature = "rust1", since = "1.0.0")]
52+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
5253
Right,
5354
/// Indication that contents should be center-aligned.
54-
#[stable(feature = "rust1", since = "1.0.0")]
55+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
5556
Center,
5657
/// No alignment was requested.
57-
#[stable(feature = "rust1", since = "1.0.0")]
58+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
5859
Unknown,
5960
}
6061

6162
#[derive(Copy, Clone)]
62-
#[stable(feature = "rust1", since = "1.0.0")]
63+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
6364
pub enum Count {
64-
#[stable(feature = "rust1", since = "1.0.0")]
65+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
6566
Is(usize),
66-
#[stable(feature = "rust1", since = "1.0.0")]
67+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
6768
Param(usize),
68-
#[stable(feature = "rust1", since = "1.0.0")]
69+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
6970
NextParam,
70-
#[stable(feature = "rust1", since = "1.0.0")]
71+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
7172
Implied,
7273
}
7374

7475
#[derive(Copy, Clone)]
75-
#[stable(feature = "rust1", since = "1.0.0")]
76+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
7677
pub enum Position {
77-
#[stable(feature = "rust1", since = "1.0.0")]
78+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
7879
Next,
79-
#[stable(feature = "rust1", since = "1.0.0")]
80+
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
8081
At(usize)
8182
}

0 commit comments

Comments
 (0)