@@ -14,7 +14,7 @@ use rustc_span::edition::Edition;
14
14
use rustc_span:: symbol:: Symbol ;
15
15
use rustc_span:: { BytePos , DUMMY_SP , Span } ;
16
16
17
- use super :: format;
17
+ use super :: format:: { self , write_str , writeln_str } ;
18
18
use crate :: clean:: PrimitiveType ;
19
19
use crate :: html:: escape:: EscapeBodyText ;
20
20
use crate :: html:: render:: { Context , LinkFromSrc } ;
@@ -65,57 +65,63 @@ fn write_header(
65
65
tooltip : Tooltip ,
66
66
extra_classes : & [ String ] ,
67
67
) {
68
- use super :: format:: write_str as write;
69
-
70
- write ! (
68
+ write_str (
71
69
out,
72
- "<div class=\" example-wrap{}\" >" ,
73
- match tooltip {
74
- Tooltip :: Ignore => " ignore" ,
75
- Tooltip :: CompileFail => " compile_fail" ,
76
- Tooltip :: ShouldPanic => " should_panic" ,
77
- Tooltip :: Edition ( _) => " edition" ,
78
- Tooltip :: None => "" ,
79
- } ,
70
+ format_args ! (
71
+ "<div class=\" example-wrap{}\" >" ,
72
+ match tooltip {
73
+ Tooltip :: Ignore => " ignore" ,
74
+ Tooltip :: CompileFail => " compile_fail" ,
75
+ Tooltip :: ShouldPanic => " should_panic" ,
76
+ Tooltip :: Edition ( _) => " edition" ,
77
+ Tooltip :: None => "" ,
78
+ }
79
+ ) ,
80
80
) ;
81
81
82
82
if tooltip != Tooltip :: None {
83
83
let edition_code;
84
- write ! (
84
+ write_str (
85
85
out,
86
- "<a href=\" #\" class=\" tooltip\" title=\" {}\" >ⓘ</a>" ,
87
- match tooltip {
88
- Tooltip :: Ignore => "This example is not tested" ,
89
- Tooltip :: CompileFail => "This example deliberately fails to compile" ,
90
- Tooltip :: ShouldPanic => "This example panics" ,
91
- Tooltip :: Edition ( edition) => {
92
- edition_code = format!( "This example runs with edition {edition}" ) ;
93
- & edition_code
86
+ format_args ! (
87
+ "<a href=\" #\" class=\" tooltip\" title=\" {}\" >ⓘ</a>" ,
88
+ match tooltip {
89
+ Tooltip :: Ignore => "This example is not tested" ,
90
+ Tooltip :: CompileFail => "This example deliberately fails to compile" ,
91
+ Tooltip :: ShouldPanic => "This example panics" ,
92
+ Tooltip :: Edition ( edition) => {
93
+ edition_code = format!( "This example runs with edition {edition}" ) ;
94
+ & edition_code
95
+ }
96
+ Tooltip :: None => unreachable!( ) ,
94
97
}
95
- Tooltip :: None => unreachable!( ) ,
96
- } ,
98
+ ) ,
97
99
) ;
98
100
}
99
101
100
102
if let Some ( extra) = extra_content {
101
103
out. push_str ( & extra) ;
102
104
}
103
105
if class. is_empty ( ) {
104
- write ! (
106
+ write_str (
105
107
out,
106
- "<pre class=\" rust{}{}\" >" ,
107
- if extra_classes. is_empty( ) { "" } else { " " } ,
108
- extra_classes. join( " " ) ,
108
+ format_args ! (
109
+ "<pre class=\" rust{}{}\" >" ,
110
+ if extra_classes. is_empty( ) { "" } else { " " } ,
111
+ extra_classes. join( " " )
112
+ ) ,
109
113
) ;
110
114
} else {
111
- write ! (
115
+ write_str (
112
116
out,
113
- "<pre class=\" rust {class}{}{}\" >" ,
114
- if extra_classes. is_empty( ) { "" } else { " " } ,
115
- extra_classes. join( " " ) ,
117
+ format_args ! (
118
+ "<pre class=\" rust {class}{}{}\" >" ,
119
+ if extra_classes. is_empty( ) { "" } else { " " } ,
120
+ extra_classes. join( " " )
121
+ ) ,
116
122
) ;
117
123
}
118
- write ! ( out, "<code>" ) ;
124
+ write_str ( out, format_args ! ( "<code>" ) ) ;
119
125
}
120
126
121
127
/// Check if two `Class` can be merged together. In the following rules, "unclassified" means `None`
@@ -325,8 +331,7 @@ pub(super) fn write_code(
325
331
}
326
332
327
333
fn write_footer ( out : & mut String , playground_button : Option < & str > ) {
328
- use super :: format:: writeln_str as writeln;
329
- writeln ! ( out, "</code></pre>{}</div>" , playground_button. unwrap_or_default( ) ) ;
334
+ writeln_str ( out, format_args ! ( "</code></pre>{}</div>" , playground_button. unwrap_or_default( ) ) ) ;
330
335
}
331
336
332
337
/// How a span of text is classified. Mostly corresponds to token kinds.
0 commit comments