File tree 3 files changed +30
-23
lines changed
3 files changed +30
-23
lines changed Original file line number Diff line number Diff line change @@ -38,10 +38,14 @@ crate trait FormatRenderer<'tcx>: Clone {
38
38
fn mod_item_out ( & mut self , item_name : & str ) -> Result < ( ) , Error > ;
39
39
40
40
/// Post processing hook for cleanup and dumping output to files.
41
- fn after_krate ( & mut self , krate : & clean:: Crate , cache : & Cache ) -> Result < ( ) , Error > ;
42
-
43
- /// Called after everything else to write out errors.
44
- fn after_run ( & mut self , diag : & rustc_errors:: Handler ) -> Result < ( ) , Error > ;
41
+ ///
42
+ /// A handler is available if the renderer wants to report errors.
43
+ fn after_krate (
44
+ & mut self ,
45
+ krate : & clean:: Crate ,
46
+ cache : & Cache ,
47
+ diag : & rustc_errors:: Handler ,
48
+ ) -> Result < ( ) , Error > ;
45
49
}
46
50
47
51
/// Main method for rendering a crate.
@@ -104,6 +108,5 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
104
108
}
105
109
}
106
110
107
- format_renderer. after_krate ( & krate, & cache) ?;
108
- format_renderer. after_run ( diag)
111
+ format_renderer. after_krate ( & krate, & cache, diag)
109
112
}
Original file line number Diff line number Diff line change @@ -523,17 +523,12 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
523
523
Ok ( ( cx, krate) )
524
524
}
525
525
526
- fn after_run ( & mut self , diag : & rustc_errors:: Handler ) -> Result < ( ) , Error > {
527
- Arc :: get_mut ( & mut self . shared ) . unwrap ( ) . fs . close ( ) ;
528
- let nb_errors = self . errors . iter ( ) . map ( |err| diag. struct_err ( & err) . emit ( ) ) . count ( ) ;
529
- if nb_errors > 0 {
530
- Err ( Error :: new ( io:: Error :: new ( io:: ErrorKind :: Other , "I/O error" ) , "" ) )
531
- } else {
532
- Ok ( ( ) )
533
- }
534
- }
535
-
536
- fn after_krate ( & mut self , krate : & clean:: Crate , cache : & Cache ) -> Result < ( ) , Error > {
526
+ fn after_krate (
527
+ & mut self ,
528
+ krate : & clean:: Crate ,
529
+ cache : & Cache ,
530
+ diag : & rustc_errors:: Handler ,
531
+ ) -> Result < ( ) , Error > {
537
532
let final_file = self . dst . join ( & * krate. name . as_str ( ) ) . join ( "all.html" ) ;
538
533
let settings_file = self . dst . join ( "settings.html" ) ;
539
534
let crate_name = krate. name ;
@@ -596,7 +591,15 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
596
591
& style_files,
597
592
) ;
598
593
self . shared . fs . write ( & settings_file, v. as_bytes ( ) ) ?;
599
- Ok ( ( ) )
594
+
595
+ // Flush pending errors.
596
+ Arc :: get_mut ( & mut self . shared ) . unwrap ( ) . fs . close ( ) ;
597
+ let nb_errors = self . errors . iter ( ) . map ( |err| diag. struct_err ( & err) . emit ( ) ) . count ( ) ;
598
+ if nb_errors > 0 {
599
+ Err ( Error :: new ( io:: Error :: new ( io:: ErrorKind :: Other , "I/O error" ) , "" ) )
600
+ } else {
601
+ Ok ( ( ) )
602
+ }
600
603
}
601
604
602
605
fn mod_item_in (
Original file line number Diff line number Diff line change @@ -199,7 +199,12 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
199
199
Ok ( ( ) )
200
200
}
201
201
202
- fn after_krate ( & mut self , krate : & clean:: Crate , cache : & Cache ) -> Result < ( ) , Error > {
202
+ fn after_krate (
203
+ & mut self ,
204
+ krate : & clean:: Crate ,
205
+ cache : & Cache ,
206
+ _diag : & rustc_errors:: Handler ,
207
+ ) -> Result < ( ) , Error > {
203
208
debug ! ( "Done with crate" ) ;
204
209
let mut index = ( * self . index ) . clone ( ) . into_inner ( ) ;
205
210
index. extend ( self . get_trait_items ( cache) ) ;
@@ -245,8 +250,4 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
245
250
serde_json:: ser:: to_writer ( & file, & output) . unwrap ( ) ;
246
251
Ok ( ( ) )
247
252
}
248
-
249
- fn after_run ( & mut self , _diag : & rustc_errors:: Handler ) -> Result < ( ) , Error > {
250
- Ok ( ( ) )
251
- }
252
253
}
You can’t perform that action at this time.
0 commit comments