Remove unnecessary diag parameter to after_krate
This commit is contained in:
@@ -41,9 +41,7 @@ crate trait FormatRenderer<'tcx>: Sized {
|
|||||||
fn mod_item_out(&mut self, item_name: &str) -> Result<(), Error>;
|
fn mod_item_out(&mut self, item_name: &str) -> Result<(), Error>;
|
||||||
|
|
||||||
/// Post processing hook for cleanup and dumping output to files.
|
/// Post processing hook for cleanup and dumping output to files.
|
||||||
///
|
fn after_krate(&mut self) -> Result<(), Error>;
|
||||||
/// A handler is available if the renderer wants to report errors.
|
|
||||||
fn after_krate(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error>;
|
|
||||||
|
|
||||||
fn cache(&self) -> &Cache;
|
fn cache(&self) -> &Cache;
|
||||||
}
|
}
|
||||||
@@ -53,7 +51,6 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
|||||||
krate: clean::Crate,
|
krate: clean::Crate,
|
||||||
options: RenderOptions,
|
options: RenderOptions,
|
||||||
cache: Cache,
|
cache: Cache,
|
||||||
diag: &rustc_errors::Handler,
|
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
@@ -101,5 +98,5 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
prof.extra_verbose_generic_activity("renderer_after_krate", T::descr())
|
prof.extra_verbose_generic_activity("renderer_after_krate", T::descr())
|
||||||
.run(|| format_renderer.after_krate(diag))
|
.run(|| format_renderer.after_krate())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_krate(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error> {
|
fn after_krate(&mut self) -> Result<(), Error> {
|
||||||
let crate_name = self.tcx().crate_name(LOCAL_CRATE);
|
let crate_name = self.tcx().crate_name(LOCAL_CRATE);
|
||||||
let final_file = self.dst.join(&*crate_name.as_str()).join("all.html");
|
let final_file = self.dst.join(&*crate_name.as_str()).join("all.html");
|
||||||
let settings_file = self.dst.join("settings.html");
|
let settings_file = self.dst.join("settings.html");
|
||||||
@@ -569,7 +569,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
|||||||
|
|
||||||
// Flush pending errors.
|
// Flush pending errors.
|
||||||
Rc::get_mut(&mut self.shared).unwrap().fs.close();
|
Rc::get_mut(&mut self.shared).unwrap().fs.close();
|
||||||
let nb_errors = self.shared.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
|
let nb_errors =
|
||||||
|
self.shared.errors.iter().map(|err| self.tcx().sess.struct_err(&err).emit()).count();
|
||||||
if nb_errors > 0 {
|
if nb_errors > 0 {
|
||||||
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
|
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_krate(&mut self, _diag: &rustc_errors::Handler) -> Result<(), Error> {
|
fn after_krate(&mut self) -> Result<(), Error> {
|
||||||
debug!("Done with crate");
|
debug!("Done with crate");
|
||||||
let mut index = (*self.index).clone().into_inner();
|
let mut index = (*self.index).clone().into_inner();
|
||||||
index.extend(self.get_trait_items());
|
index.extend(self.get_trait_items());
|
||||||
|
|||||||
@@ -656,14 +656,14 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>(
|
|||||||
krate: clean::Crate,
|
krate: clean::Crate,
|
||||||
renderopts: config::RenderOptions,
|
renderopts: config::RenderOptions,
|
||||||
cache: formats::cache::Cache,
|
cache: formats::cache::Cache,
|
||||||
diag: &rustc_errors::Handler,
|
|
||||||
edition: rustc_span::edition::Edition,
|
edition: rustc_span::edition::Edition,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
) -> MainResult {
|
) -> MainResult {
|
||||||
match formats::run_format::<T>(krate, renderopts, cache, &diag, edition, tcx) {
|
match formats::run_format::<T>(krate, renderopts, cache, edition, tcx) {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let mut msg = diag.struct_err(&format!("couldn't generate documentation: {}", e.error));
|
let mut msg =
|
||||||
|
tcx.sess.struct_err(&format!("couldn't generate documentation: {}", e.error));
|
||||||
let file = e.file.display().to_string();
|
let file = e.file.display().to_string();
|
||||||
if file.is_empty() {
|
if file.is_empty() {
|
||||||
msg.emit()
|
msg.emit()
|
||||||
@@ -692,7 +692,7 @@ fn main_options(options: config::Options) -> MainResult {
|
|||||||
|
|
||||||
// need to move these items separately because we lose them by the time the closure is called,
|
// need to move these items separately because we lose them by the time the closure is called,
|
||||||
// but we can't create the Handler ahead of time because it's not Send
|
// but we can't create the Handler ahead of time because it's not Send
|
||||||
let diag_opts = (options.error_format, options.edition, options.debugging_opts.clone());
|
let edition = options.edition;
|
||||||
let show_coverage = options.show_coverage;
|
let show_coverage = options.show_coverage;
|
||||||
let run_check = options.run_check;
|
let run_check = options.run_check;
|
||||||
|
|
||||||
@@ -758,15 +758,12 @@ fn main_options(options: config::Options) -> MainResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
info!("going to format");
|
info!("going to format");
|
||||||
let (error_format, edition, debugging_options) = diag_opts;
|
|
||||||
let diag = core::new_handler(error_format, None, &debugging_options);
|
|
||||||
match output_format {
|
match output_format {
|
||||||
config::OutputFormat::Html => sess.time("render_html", || {
|
config::OutputFormat::Html => sess.time("render_html", || {
|
||||||
run_renderer::<html::render::Context<'_>>(
|
run_renderer::<html::render::Context<'_>>(
|
||||||
krate,
|
krate,
|
||||||
render_opts,
|
render_opts,
|
||||||
cache,
|
cache,
|
||||||
&diag,
|
|
||||||
edition,
|
edition,
|
||||||
tcx,
|
tcx,
|
||||||
)
|
)
|
||||||
@@ -776,7 +773,6 @@ fn main_options(options: config::Options) -> MainResult {
|
|||||||
krate,
|
krate,
|
||||||
render_opts,
|
render_opts,
|
||||||
cache,
|
cache,
|
||||||
&diag,
|
|
||||||
edition,
|
edition,
|
||||||
tcx,
|
tcx,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user