@@ -14,7 +14,7 @@ use rustc_span::edition::Edition;
1414use rustc_span:: symbol:: Symbol ;
1515use rustc_span:: { BytePos , DUMMY_SP , Span } ;
1616
17- use super :: format;
17+ use super :: format:: { self , write_str , writeln_str } ;
1818use crate :: clean:: PrimitiveType ;
1919use crate :: html:: escape:: EscapeBodyText ;
2020use crate :: html:: render:: { Context , LinkFromSrc } ;
@@ -65,57 +65,63 @@ fn write_header(
6565 tooltip : Tooltip ,
6666 extra_classes : & [ String ] ,
6767) {
68- use super :: format:: write_str as write;
69-
70- write ! (
68+ write_str (
7169 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+ ) ,
8080 ) ;
8181
8282 if tooltip != Tooltip :: None {
8383 let edition_code;
84- write ! (
84+ write_str (
8585 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!( ) ,
9497 }
95- Tooltip :: None => unreachable!( ) ,
96- } ,
98+ ) ,
9799 ) ;
98100 }
99101
100102 if let Some ( extra) = extra_content {
101103 out. push_str ( & extra) ;
102104 }
103105 if class. is_empty ( ) {
104- write ! (
106+ write_str (
105107 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+ ) ,
109113 ) ;
110114 } else {
111- write ! (
115+ write_str (
112116 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+ ) ,
116122 ) ;
117123 }
118- write ! ( out, "<code>" ) ;
124+ write_str ( out, format_args ! ( "<code>" ) ) ;
119125}
120126
121127/// Check if two `Class` can be merged together. In the following rules, "unclassified" means `None`
@@ -325,8 +331,7 @@ pub(super) fn write_code(
325331}
326332
327333fn 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( ) ) ) ;
330335}
331336
332337/// How a span of text is classified. Mostly corresponds to token kinds.
0 commit comments