Skip to content

Commit 68db586

Browse files
committed
Remove unnecessary diag parameter to after_krate
1 parent f435f71 commit 68db586

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

src/librustdoc/formats/renderer.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ crate trait FormatRenderer<'tcx>: Sized {
4141
fn mod_item_out(&mut self, item_name: &str) -> Result<(), Error>;
4242

4343
/// Post processing hook for cleanup and dumping output to files.
44-
///
45-
/// A handler is available if the renderer wants to report errors.
46-
fn after_krate(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error>;
44+
fn after_krate(&mut self) -> Result<(), Error>;
4745

4846
fn cache(&self) -> &Cache;
4947
}
@@ -53,7 +51,6 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
5351
krate: clean::Crate,
5452
options: RenderOptions,
5553
cache: Cache,
56-
diag: &rustc_errors::Handler,
5754
edition: Edition,
5855
tcx: TyCtxt<'tcx>,
5956
) -> Result<(), Error> {
@@ -101,5 +98,5 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
10198
}
10299
}
103100
prof.extra_verbose_generic_activity("renderer_after_krate", T::descr())
104-
.run(|| format_renderer.after_krate(diag))
101+
.run(|| format_renderer.after_krate())
105102
}

src/librustdoc/html/render/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
494494
}
495495
}
496496

497-
fn after_krate(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error> {
497+
fn after_krate(&mut self) -> Result<(), Error> {
498498
let crate_name = self.tcx().crate_name(LOCAL_CRATE);
499499
let final_file = self.dst.join(&*crate_name.as_str()).join("all.html");
500500
let settings_file = self.dst.join("settings.html");
@@ -569,7 +569,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
569569

570570
// Flush pending errors.
571571
Rc::get_mut(&mut self.shared).unwrap().fs.close();
572-
let nb_errors = self.shared.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
572+
let nb_errors =
573+
self.shared.errors.iter().map(|err| self.tcx().sess.struct_err(&err).emit()).count();
573574
if nb_errors > 0 {
574575
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
575576
} else {

src/librustdoc/json/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
204204
Ok(())
205205
}
206206

207-
fn after_krate(&mut self, _diag: &rustc_errors::Handler) -> Result<(), Error> {
207+
fn after_krate(&mut self) -> Result<(), Error> {
208208
debug!("Done with crate");
209209
let mut index = (*self.index).clone().into_inner();
210210
index.extend(self.get_trait_items());

src/librustdoc/lib.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -656,14 +656,14 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>(
656656
krate: clean::Crate,
657657
renderopts: config::RenderOptions,
658658
cache: formats::cache::Cache,
659-
diag: &rustc_errors::Handler,
660659
edition: rustc_span::edition::Edition,
661660
tcx: TyCtxt<'tcx>,
662661
) -> MainResult {
663-
match formats::run_format::<T>(krate, renderopts, cache, &diag, edition, tcx) {
662+
match formats::run_format::<T>(krate, renderopts, cache, edition, tcx) {
664663
Ok(_) => Ok(()),
665664
Err(e) => {
666-
let mut msg = diag.struct_err(&format!("couldn't generate documentation: {}", e.error));
665+
let mut msg =
666+
tcx.sess.struct_err(&format!("couldn't generate documentation: {}", e.error));
667667
let file = e.file.display().to_string();
668668
if file.is_empty() {
669669
msg.emit()
@@ -692,7 +692,7 @@ fn main_options(options: config::Options) -> MainResult {
692692

693693
// need to move these items separately because we lose them by the time the closure is called,
694694
// but we can't create the Handler ahead of time because it's not Send
695-
let diag_opts = (options.error_format, options.edition, options.debugging_opts.clone());
695+
let edition = options.edition;
696696
let show_coverage = options.show_coverage;
697697
let run_check = options.run_check;
698698

@@ -758,15 +758,12 @@ fn main_options(options: config::Options) -> MainResult {
758758
}
759759

760760
info!("going to format");
761-
let (error_format, edition, debugging_options) = diag_opts;
762-
let diag = core::new_handler(error_format, None, &debugging_options);
763761
match output_format {
764762
config::OutputFormat::Html => sess.time("render_html", || {
765763
run_renderer::<html::render::Context<'_>>(
766764
krate,
767765
render_opts,
768766
cache,
769-
&diag,
770767
edition,
771768
tcx,
772769
)
@@ -776,7 +773,6 @@ fn main_options(options: config::Options) -> MainResult {
776773
krate,
777774
render_opts,
778775
cache,
779-
&diag,
780776
edition,
781777
tcx,
782778
)

0 commit comments

Comments
 (0)