Remove unnecessary diag
parameter to after_krate
This commit is contained in:
parent
f435f7185b
commit
68db5869e3
@ -41,9 +41,7 @@ fn init(
|
||||
fn mod_item_out(&mut self, item_name: &str) -> Result<(), Error>;
|
||||
|
||||
/// Post processing hook for cleanup and dumping output to files.
|
||||
///
|
||||
/// A handler is available if the renderer wants to report errors.
|
||||
fn after_krate(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error>;
|
||||
fn after_krate(&mut self) -> Result<(), Error>;
|
||||
|
||||
fn cache(&self) -> &Cache;
|
||||
}
|
||||
@ -53,7 +51,6 @@ fn init(
|
||||
krate: clean::Crate,
|
||||
options: RenderOptions,
|
||||
cache: Cache,
|
||||
diag: &rustc_errors::Handler,
|
||||
edition: Edition,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> Result<(), Error> {
|
||||
@ -101,5 +98,5 @@ fn init(
|
||||
}
|
||||
}
|
||||
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 @@ fn make_child_renderer(&self) -> Self {
|
||||
}
|
||||
}
|
||||
|
||||
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 final_file = self.dst.join(&*crate_name.as_str()).join("all.html");
|
||||
let settings_file = self.dst.join("settings.html");
|
||||
@ -569,7 +569,8 @@ fn after_krate(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error> {
|
||||
|
||||
// Flush pending errors.
|
||||
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 {
|
||||
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
|
||||
} else {
|
||||
|
@ -204,7 +204,7 @@ fn mod_item_out(&mut self, _item_name: &str) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn after_krate(&mut self, _diag: &rustc_errors::Handler) -> Result<(), Error> {
|
||||
fn after_krate(&mut self) -> Result<(), Error> {
|
||||
debug!("Done with crate");
|
||||
let mut index = (*self.index).clone().into_inner();
|
||||
index.extend(self.get_trait_items());
|
||||
|
@ -656,14 +656,14 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>(
|
||||
krate: clean::Crate,
|
||||
renderopts: config::RenderOptions,
|
||||
cache: formats::cache::Cache,
|
||||
diag: &rustc_errors::Handler,
|
||||
edition: rustc_span::edition::Edition,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> MainResult {
|
||||
match formats::run_format::<T>(krate, renderopts, cache, &diag, edition, tcx) {
|
||||
match formats::run_format::<T>(krate, renderopts, cache, edition, tcx) {
|
||||
Ok(_) => Ok(()),
|
||||
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();
|
||||
if file.is_empty() {
|
||||
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,
|
||||
// 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 run_check = options.run_check;
|
||||
|
||||
@ -758,15 +758,12 @@ fn main_options(options: config::Options) -> MainResult {
|
||||
}
|
||||
|
||||
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 {
|
||||
config::OutputFormat::Html => sess.time("render_html", || {
|
||||
run_renderer::<html::render::Context<'_>>(
|
||||
krate,
|
||||
render_opts,
|
||||
cache,
|
||||
&diag,
|
||||
edition,
|
||||
tcx,
|
||||
)
|
||||
@ -776,7 +773,6 @@ fn main_options(options: config::Options) -> MainResult {
|
||||
krate,
|
||||
render_opts,
|
||||
cache,
|
||||
&diag,
|
||||
edition,
|
||||
tcx,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user