Rollup merge of #81184 - jyn514:combine-after, r=CraftSpider
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:
commit
0aeb2fcba1
@ -38,10 +38,14 @@ fn mod_item_in(
|
||||
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 @@ fn mod_item_in(
|
||||
}
|
||||
}
|
||||
|
||||
format_renderer.after_krate(&krate, &cache)?;
|
||||
format_renderer.after_run(diag)
|
||||
format_renderer.after_krate(&krate, &cache, diag)
|
||||
}
|
||||
|
@ -523,17 +523,12 @@ fn init(
|
||||
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,8 +591,16 @@ fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Err
|
||||
&style_files,
|
||||
);
|
||||
self.shared.fs.write(&settings_file, v.as_bytes())?;
|
||||
|
||||
// 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(
|
||||
&mut self,
|
||||
|
@ -199,7 +199,12 @@ fn mod_item_out(&mut self, _item_name: &str) -> Result<(), Error> {
|
||||
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 @@ fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Err
|
||||
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