@@ -18,6 +18,7 @@ mod float;
18
18
#[ cfg( no_fp_fmt_parse) ]
19
19
mod nofloat;
20
20
mod num;
21
+ mod rt;
21
22
22
23
#[ stable( feature = "fmt_flags_align" , since = "1.28.0" ) ]
23
24
#[ cfg_attr( not( test) , rustc_diagnostic_item = "Alignment" ) ]
@@ -38,12 +39,6 @@ pub enum Alignment {
38
39
#[ stable( feature = "debug_builders" , since = "1.2.0" ) ]
39
40
pub use self :: builders:: { DebugList , DebugMap , DebugSet , DebugStruct , DebugTuple } ;
40
41
41
- #[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" , issue = "none" ) ]
42
- #[ doc( hidden) ]
43
- pub mod rt {
44
- pub mod v1;
45
- }
46
-
47
42
/// The type returned by formatter methods.
48
43
///
49
44
/// # Examples
@@ -227,7 +222,7 @@ impl<W: Write + ?Sized> Write for &mut W {
227
222
pub struct Formatter < ' a > {
228
223
flags : u32 ,
229
224
fill : char ,
230
- align : rt:: v1 :: Alignment ,
225
+ align : rt:: Alignment ,
231
226
width : Option < usize > ,
232
227
precision : Option < usize > ,
233
228
@@ -248,7 +243,7 @@ impl<'a> Formatter<'a> {
248
243
Formatter {
249
244
flags : 0 ,
250
245
fill : ' ' ,
251
- align : rt:: v1 :: Alignment :: Unknown ,
246
+ align : rt:: Alignment :: Unknown ,
252
247
width : None ,
253
248
precision : None ,
254
249
buf,
@@ -433,17 +428,17 @@ impl<'a> Arguments<'a> {
433
428
/// An `UnsafeArg` is required because the following invariants must be held
434
429
/// in order for this function to be safe:
435
430
/// 1. The `pieces` slice must be at least as long as `fmt`.
436
- /// 2. Every [`rt::v1:: Argument::position`] value within `fmt` must be a
431
+ /// 2. Every [`rt::Argument::position`] value within `fmt` must be a
437
432
/// valid index of `args`.
438
- /// 3. Every [`rt::v1:: Count::Param`] within `fmt` must contain a valid index of
433
+ /// 3. Every [`rt::Count::Param`] within `fmt` must contain a valid index of
439
434
/// `args`.
440
435
#[ doc( hidden) ]
441
436
#[ inline]
442
437
#[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" , issue = "none" ) ]
443
438
pub fn new_v1_formatted (
444
439
pieces : & ' a [ & ' static str ] ,
445
440
args : & ' a [ ArgumentV1 < ' a > ] ,
446
- fmt : & ' a [ rt:: v1 :: Argument ] ,
441
+ fmt : & ' a [ rt:: Argument ] ,
447
442
_unsafe_arg : UnsafeArg ,
448
443
) -> Arguments < ' a > {
449
444
Arguments { pieces, fmt : Some ( fmt) , args }
@@ -505,7 +500,7 @@ pub struct Arguments<'a> {
505
500
pieces : & ' a [ & ' static str ] ,
506
501
507
502
// Placeholder specs, or `None` if all specs are default (as in "{}{}").
508
- fmt : Option < & ' a [ rt:: v1 :: Argument ] > ,
503
+ fmt : Option < & ' a [ rt:: Argument ] > ,
509
504
510
505
// Dynamic arguments for interpolation, to be interleaved with string
511
506
// pieces. (Every argument is preceded by a string piece.)
@@ -1281,7 +1276,7 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
1281
1276
Ok ( ( ) )
1282
1277
}
1283
1278
1284
- unsafe fn run ( fmt : & mut Formatter < ' _ > , arg : & rt:: v1 :: Argument , args : & [ ArgumentV1 < ' _ > ] ) -> Result {
1279
+ unsafe fn run ( fmt : & mut Formatter < ' _ > , arg : & rt:: Argument , args : & [ ArgumentV1 < ' _ > ] ) -> Result {
1285
1280
fmt. fill = arg. format . fill ;
1286
1281
fmt. align = arg. format . align ;
1287
1282
fmt. flags = arg. format . flags ;
@@ -1302,11 +1297,11 @@ unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::v1::Argument, args: &[ArgumentV
1302
1297
( value. formatter ) ( value. value , fmt)
1303
1298
}
1304
1299
1305
- unsafe fn getcount ( args : & [ ArgumentV1 < ' _ > ] , cnt : & rt:: v1 :: Count ) -> Option < usize > {
1300
+ unsafe fn getcount ( args : & [ ArgumentV1 < ' _ > ] , cnt : & rt:: Count ) -> Option < usize > {
1306
1301
match * cnt {
1307
- rt:: v1 :: Count :: Is ( n) => Some ( n) ,
1308
- rt:: v1 :: Count :: Implied => None ,
1309
- rt:: v1 :: Count :: Param ( i) => {
1302
+ rt:: Count :: Is ( n) => Some ( n) ,
1303
+ rt:: Count :: Implied => None ,
1304
+ rt:: Count :: Param ( i) => {
1310
1305
debug_assert ! ( i < args. len( ) ) ;
1311
1306
// SAFETY: cnt and args come from the same Arguments,
1312
1307
// which guarantees this index is always within bounds.
@@ -1449,7 +1444,7 @@ impl<'a> Formatter<'a> {
1449
1444
// is zero
1450
1445
Some ( min) if self . sign_aware_zero_pad ( ) => {
1451
1446
let old_fill = crate :: mem:: replace ( & mut self . fill , '0' ) ;
1452
- let old_align = crate :: mem:: replace ( & mut self . align , rt:: v1 :: Alignment :: Right ) ;
1447
+ let old_align = crate :: mem:: replace ( & mut self . align , rt:: Alignment :: Right ) ;
1453
1448
write_prefix ( self , sign, prefix) ?;
1454
1449
let post_padding = self . padding ( min - width, Alignment :: Right ) ?;
1455
1450
self . buf . write_str ( buf) ?;
@@ -1553,10 +1548,10 @@ impl<'a> Formatter<'a> {
1553
1548
default : Alignment ,
1554
1549
) -> result:: Result < PostPadding , Error > {
1555
1550
let align = match self . align {
1556
- rt:: v1 :: Alignment :: Unknown => default,
1557
- rt:: v1 :: Alignment :: Left => Alignment :: Left ,
1558
- rt:: v1 :: Alignment :: Right => Alignment :: Right ,
1559
- rt:: v1 :: Alignment :: Center => Alignment :: Center ,
1551
+ rt:: Alignment :: Unknown => default,
1552
+ rt:: Alignment :: Left => Alignment :: Left ,
1553
+ rt:: Alignment :: Right => Alignment :: Right ,
1554
+ rt:: Alignment :: Center => Alignment :: Center ,
1560
1555
} ;
1561
1556
1562
1557
let ( pre_pad, post_pad) = match align {
@@ -1788,10 +1783,10 @@ impl<'a> Formatter<'a> {
1788
1783
#[ stable( feature = "fmt_flags_align" , since = "1.28.0" ) ]
1789
1784
pub fn align ( & self ) -> Option < Alignment > {
1790
1785
match self . align {
1791
- rt:: v1 :: Alignment :: Left => Some ( Alignment :: Left ) ,
1792
- rt:: v1 :: Alignment :: Right => Some ( Alignment :: Right ) ,
1793
- rt:: v1 :: Alignment :: Center => Some ( Alignment :: Center ) ,
1794
- rt:: v1 :: Alignment :: Unknown => None ,
1786
+ rt:: Alignment :: Left => Some ( Alignment :: Left ) ,
1787
+ rt:: Alignment :: Right => Some ( Alignment :: Right ) ,
1788
+ rt:: Alignment :: Center => Some ( Alignment :: Center ) ,
1789
+ rt:: Alignment :: Unknown => None ,
1795
1790
}
1796
1791
}
1797
1792
0 commit comments