@@ -64,15 +64,6 @@ macro_rules! vec {
64
64
( $( $x: expr, ) * ) => ( vec![ $( $x) ,* ] )
65
65
}
66
66
67
- // HACK(jubilee): Shim for specializing format! It is possible to manually
68
- // implement ToString, bypassing Display. "{}" normally formats in terms of
69
- // Display. NeedsDisplay enforces equally strict type boundarie.
70
- #[ unstable( feature = "display_type_guard" , issue = "none" ) ]
71
- #[ allow( dead_code) ]
72
- struct NeedsDisplay < T : crate :: fmt:: Display > {
73
- inner : T ,
74
- }
75
-
76
67
/// Creates a `String` using interpolation of runtime expressions.
77
68
///
78
69
/// The first argument `format!` receives is a format string. This must be a string
@@ -108,15 +99,12 @@ struct NeedsDisplay<T: crate::fmt::Display> {
108
99
/// format!("hello {}", "world!");
109
100
/// format!("x = {}, y = {y}", 10, y = 30);
110
101
/// ```
111
- #[ allow_internal_unstable( display_type_guard) ]
112
102
#[ macro_export]
113
103
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
114
104
macro_rules! format {
115
105
// A faster path for simple format! calls.
116
- ( "{}" , $( $arg: tt, ?) +) => { {
117
- let fast = |t: NeedsDisplay <_> | $crate:: string:: ToString :: to_string( t. inner) ;
118
- // This TokenTree must resolve to a Displayable value to be valid.
119
- fast( NeedsDisplay { inner: & { $( $arg) * } } )
106
+ ( "{}" , $arg: ident) => { {
107
+ $crate:: fmt:: Display :: to_string( & $arg)
120
108
} } ;
121
109
( $( $arg: tt) * ) => { {
122
110
let res = $crate:: fmt:: format( $crate:: __export:: format_args!( $( $arg) * ) ) ;
0 commit comments