@@ -15,6 +15,7 @@ use rustc::util::nodemap::FxHashSet;
1515use rustc_target:: spec:: abi:: Abi ;
1616
1717use crate :: clean:: { self , PrimitiveType } ;
18+ use crate :: html:: escape:: Escape ;
1819use crate :: html:: item_type:: ItemType ;
1920use crate :: html:: render:: { self , cache, CURRENT_DEPTH } ;
2021
@@ -314,8 +315,14 @@ impl clean::Lifetime {
314315}
315316
316317impl clean:: Constant {
317- crate fn print ( & self ) -> & str {
318- & self . expr
318+ crate fn print ( & self ) -> impl fmt:: Display + ' _ {
319+ display_fn ( move |f| {
320+ if f. alternate ( ) {
321+ f. write_str ( & self . expr )
322+ } else {
323+ write ! ( f, "{}" , Escape ( & self . expr) )
324+ }
325+ } )
319326 }
320327}
321328
@@ -689,7 +696,11 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) ->
689696 clean:: Array ( ref t, ref n) => {
690697 primitive_link ( f, PrimitiveType :: Array , "[" ) ?;
691698 fmt:: Display :: fmt ( & t. print ( ) , f) ?;
692- primitive_link ( f, PrimitiveType :: Array , & format ! ( "; {}]" , n) )
699+ if f. alternate ( ) {
700+ primitive_link ( f, PrimitiveType :: Array , & format ! ( "; {}]" , n) )
701+ } else {
702+ primitive_link ( f, PrimitiveType :: Array , & format ! ( "; {}]" , Escape ( n) ) )
703+ }
693704 }
694705 clean:: Never => primitive_link ( f, PrimitiveType :: Never , "!" ) ,
695706 clean:: RawPointer ( m, ref t) => {
0 commit comments