Remove unnecessary after_run
function
It's called at the same time and in the same place as `after_krate`, so they can be combined.
This commit is contained in:
parent
1f0fc02cc8
commit
d926147ccb
@ -38,10 +38,14 @@ crate trait FormatRenderer<'tcx>: Clone {
|
||||
fn mod_item_out(&mut self, item_name: &str) -> Result<(), Error>;
|
||||
|
||||
/// Post processing hook for cleanup and dumping output to files.
|
||||
fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Error>;
|
||||
|
||||
/// Called after everything else to write out errors.
|
||||
fn after_run(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error>;
|
||||
///
|
||||
/// A handler is available if the renderer wants to report errors.
|
||||
fn after_krate(
|
||||
&mut self,
|
||||
krate: &clean::Crate,
|
||||
cache: &Cache,
|
||||
diag: &rustc_errors::Handler,
|
||||
) -> Result<(), Error>;
|
||||
}
|
||||
|
||||
/// Main method for rendering a crate.
|
||||
@ -104,6 +108,5 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
||||
}
|
||||
}
|
||||
|
||||
format_renderer.after_krate(&krate, &cache)?;
|
||||
format_renderer.after_run(diag)
|
||||
format_renderer.after_krate(&krate, &cache, diag)
|
||||
}
|
||||
|
@ -523,17 +523,12 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
||||
Ok((cx, krate))
|
||||
}
|
||||
|
||||
fn after_run(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error> {
|
||||
Arc::get_mut(&mut self.shared).unwrap().fs.close();
|
||||
let nb_errors = self.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
|
||||
if nb_errors > 0 {
|
||||
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Error> {
|
||||
fn after_krate(
|
||||
&mut self,
|
||||
krate: &clean::Crate,
|
||||
cache: &Cache,
|
||||
diag: &rustc_errors::Handler,
|
||||
) -> Result<(), Error> {
|
||||
let final_file = self.dst.join(&*krate.name.as_str()).join("all.html");
|
||||
let settings_file = self.dst.join("settings.html");
|
||||
let crate_name = krate.name;
|
||||
@ -596,7 +591,15 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
||||
&style_files,
|
||||
);
|
||||
self.shared.fs.write(&settings_file, v.as_bytes())?;
|
||||
Ok(())
|
||||
|
||||
// Flush pending errors.
|
||||
Arc::get_mut(&mut self.shared).unwrap().fs.close();
|
||||
let nb_errors = self.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
|
||||
if nb_errors > 0 {
|
||||
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn mod_item_in(
|
||||
|
@ -199,7 +199,12 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Error> {
|
||||
fn after_krate(
|
||||
&mut self,
|
||||
krate: &clean::Crate,
|
||||
cache: &Cache,
|
||||
_diag: &rustc_errors::Handler,
|
||||
) -> Result<(), Error> {
|
||||
debug!("Done with crate");
|
||||
let mut index = (*self.index).clone().into_inner();
|
||||
index.extend(self.get_trait_items(cache));
|
||||
@ -245,8 +250,4 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
||||
serde_json::ser::to_writer(&file, &output).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn after_run(&mut self, _diag: &rustc_errors::Handler) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user