5757    } 
5858
5959    // Graph label 
60-     let  label = get_graph_label ( tcx,  body) ; 
60+     let  mut  label = String :: from ( "" ) ; 
61+     // FIXME: remove this unwrap 
62+     write_graph_label ( tcx,  body,  & mut  label) . unwrap ( ) ; 
6163    let  g = mir_fn_to_generic_graph ( tcx,  body,  subgraph) ; 
6264    let  settings = GraphvizSettings  { 
6365        graph_attrs :  Some ( graph_attrs. join ( " " ) ) , 
@@ -71,42 +73,47 @@ where
7173/// Write the graphviz DOT label for the overall graph. This is essentially a block of text that 
7274/// will appear below the graph, showing the type of the `fn` this MIR represents and the types of 
7375/// all the variables and temporaries. 
74- fn  get_graph_label < ' tcx > ( tcx :  TyCtxt < ' tcx > ,  body :  & Body < ' _ > )  -> String  { 
76+ fn  write_graph_label < ' tcx ,  W :  std:: fmt:: Write > ( 
77+     tcx :  TyCtxt < ' tcx > , 
78+     body :  & Body < ' _ > , 
79+     w :  & mut  W , 
80+ )  -> std:: fmt:: Result  { 
7581    let  def_id = body. source . def_id ( ) ; 
76-     let  mut  label:  Vec < String >  = Vec :: new ( ) ; 
7782
78-     label . push ( format ! ( "fn {}(" ,  dot:: escape_html( & tcx. def_path_str( def_id) ) ) ) ; 
83+     write ! ( w ,   "fn {}(" ,  dot:: escape_html( & tcx. def_path_str( def_id) ) ) ? ; 
7984
8085    // fn argument types. 
8186    for  ( i,  arg)  in  body. args_iter ( ) . enumerate ( )  { 
8287        if  i > 0  { 
83-             label . push ( ", " . to_owned ( ) ) ; 
88+             write ! ( w ,   ", " ) ? ; 
8489        } 
85-         label . push ( format ! ( "{:?}: {}" ,  Place :: from( arg) ,  escape( & body. local_decls[ arg] . ty) ) ) ; 
90+         write ! ( w ,   "{:?}: {}" ,  Place :: from( arg) ,  escape( & body. local_decls[ arg] . ty) ) ? ; 
8691    } 
8792
88-     label . push ( format ! ( ") -> {}" ,  escape( & body. return_ty( ) ) ) ) ; 
89-     label . push ( r#"<br align="left"/>"# . to_owned ( ) ) ; 
93+     write ! ( w ,   ") -> {}" ,  escape( & body. return_ty( ) ) ) ? ; 
94+     write ! ( w ,   r#"<br align="left"/>"# ) ? ; 
9095
9196    for  local in  body. vars_and_temps_iter ( )  { 
9297        let  decl = & body. local_decls [ local] ; 
9398
94-         label . push ( "let " . to_owned ( ) ) ; 
99+         write ! ( w ,   "let " ) ? ; 
95100        if  decl. mutability  == Mutability :: Mut  { 
96-             label . push ( "mut " . to_owned ( ) ) ; 
101+             write ! ( w ,   "mut " ) ? ; 
97102        } 
98103
99-         label . push ( format ! ( r#"{:?}: {};<br align="left"/>"# ,  Place :: from( local) ,  escape( & decl. ty) ) ) ; 
104+         write ! ( w ,   r#"{:?}: {};<br align="left"/>"# ,  Place :: from( local) ,  escape( & decl. ty) ) ? ; 
100105    } 
101106
102107    for  var_debug_info in  & body. var_debug_info  { 
103-         label. push ( format ! ( 
108+         write ! ( 
109+             w, 
104110            r#"debug {} => {};<br align="left"/>"# , 
105111            var_debug_info. name, 
106112            escape( & var_debug_info. place) 
107-         ) ) ; 
113+         ) ? ; 
108114    } 
109-     label. join ( "" ) 
115+ 
116+     Ok ( ( ) ) 
110117} 
111118
112119fn  escape < T :  Debug > ( t :  & T )  -> String  { 
0 commit comments