From f435f7185b634733834a61418dc4cba6a58aa1ec Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 22 Apr 2021 19:27:37 -0400 Subject: [PATCH 1/6] Remove unnecessary `crate_name` parameter to `after_krate` It's always `tcx.crate_name(LOCAL_CRATE)`, it doesn't need to be passed in separately. --- src/librustdoc/formats/renderer.rs | 9 ++------- src/librustdoc/html/render/context.rs | 9 +++------ src/librustdoc/json/mod.rs | 8 ++------ 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index ae97cd64fb5fb..94f860739dfe4 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -43,11 +43,7 @@ crate trait FormatRenderer<'tcx>: Sized { /// 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, - crate_name: Symbol, - diag: &rustc_errors::Handler, - ) -> Result<(), Error>; + fn after_krate(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error>; fn cache(&self) -> &Cache; } @@ -73,7 +69,6 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( } // Render the crate documentation - let crate_name = krate.name; let mut work = vec![(format_renderer.make_child_renderer(), krate.module)]; let unknown = Symbol::intern(""); @@ -106,5 +101,5 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( } } prof.extra_verbose_generic_activity("renderer_after_krate", T::descr()) - .run(|| format_renderer.after_krate(crate_name, diag)) + .run(|| format_renderer.after_krate(diag)) } diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 0aa7aa763c2af..9a4d02114ccaf 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -11,7 +11,7 @@ use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_span::edition::Edition; use rustc_span::source_map::FileName; -use rustc_span::{symbol::sym, Symbol}; +use rustc_span::symbol::sym; use super::cache::{build_index, ExternalLocation}; use super::print_item::{full_path, item_path, print_item}; @@ -494,11 +494,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { } } - fn after_krate( - &mut self, - crate_name: Symbol, - diag: &rustc_errors::Handler, - ) -> Result<(), Error> { + fn after_krate(&mut self, diag: &rustc_errors::Handler) -> 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"); diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index db3a0c5ceb167..da5a6d7af13e6 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -14,7 +14,7 @@ use std::rc::Rc; use rustc_data_structures::fx::FxHashMap; use rustc_middle::ty::TyCtxt; use rustc_session::Session; -use rustc_span::{edition::Edition, Symbol}; +use rustc_span::edition::Edition; use rustdoc_json_types as types; @@ -204,11 +204,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { Ok(()) } - fn after_krate( - &mut self, - _crate_name: Symbol, - _diag: &rustc_errors::Handler, - ) -> Result<(), Error> { + fn after_krate(&mut self, _diag: &rustc_errors::Handler) -> Result<(), Error> { debug!("Done with crate"); let mut index = (*self.index).clone().into_inner(); index.extend(self.get_trait_items()); From 68db5869e3b64ed13390454484bb977d2e202afa Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 22 Apr 2021 19:32:24 -0400 Subject: [PATCH 2/6] Remove unnecessary `diag` parameter to `after_krate` --- src/librustdoc/formats/renderer.rs | 7 ++----- src/librustdoc/html/render/context.rs | 5 +++-- src/librustdoc/json/mod.rs | 2 +- src/librustdoc/lib.rs | 12 ++++-------- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index 94f860739dfe4..e6d97499b2c40 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -41,9 +41,7 @@ crate trait FormatRenderer<'tcx>: Sized { 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 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( krate: clean::Crate, options: RenderOptions, cache: Cache, - diag: &rustc_errors::Handler, edition: Edition, tcx: TyCtxt<'tcx>, ) -> Result<(), Error> { @@ -101,5 +98,5 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( } } prof.extra_verbose_generic_activity("renderer_after_krate", T::descr()) - .run(|| format_renderer.after_krate(diag)) + .run(|| format_renderer.after_krate()) } diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 9a4d02114ccaf..afdba5f0579f5 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -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 final_file = self.dst.join(&*crate_name.as_str()).join("all.html"); let settings_file = self.dst.join("settings.html"); @@ -569,7 +569,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { // 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 { diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index da5a6d7af13e6..58b43c83a9d59 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -204,7 +204,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { 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()); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 2a51d78f64a39..eefb8ced7af47 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -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::(krate, renderopts, cache, &diag, edition, tcx) { + match formats::run_format::(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::>( 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, ) From 640cc741e0ecd54d0365772675727b98584d4465 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 22 Apr 2021 19:35:20 -0400 Subject: [PATCH 3/6] Remove unnecessary `edition` parameter to renderer --- src/librustdoc/formats/renderer.rs | 6 ++---- src/librustdoc/html/render/context.rs | 3 +-- src/librustdoc/json/mod.rs | 2 -- src/librustdoc/lib.rs | 20 +++----------------- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index e6d97499b2c40..6c5c53b7d1acb 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -1,5 +1,5 @@ use rustc_middle::ty::TyCtxt; -use rustc_span::{edition::Edition, Symbol}; +use rustc_span::Symbol; use crate::clean; use crate::config::RenderOptions; @@ -23,7 +23,6 @@ crate trait FormatRenderer<'tcx>: Sized { fn init( krate: clean::Crate, options: RenderOptions, - edition: Edition, cache: Cache, tcx: TyCtxt<'tcx>, ) -> Result<(Self, clean::Crate), Error>; @@ -51,7 +50,6 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( krate: clean::Crate, options: RenderOptions, cache: Cache, - edition: Edition, tcx: TyCtxt<'tcx>, ) -> Result<(), Error> { let prof = &tcx.sess.prof; @@ -59,7 +57,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( let emit_crate = options.should_emit_crate(); let (mut format_renderer, krate) = prof .extra_verbose_generic_activity("create_renderer", T::descr()) - .run(|| T::init(krate, options, edition, cache, tcx))?; + .run(|| T::init(krate, options, cache, tcx))?; if !emit_crate { return Ok(()); diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index afdba5f0579f5..9e05fa599a762 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -346,7 +346,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { fn init( mut krate: clean::Crate, options: RenderOptions, - edition: Edition, mut cache: Cache, tcx: TyCtxt<'tcx>, ) -> Result<(Self, clean::Crate), Error> { @@ -435,7 +434,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { resource_suffix, static_root_path, fs: DocFS::new(sender), - edition, + edition: tcx.sess.edition(), codes: ErrorCodes::from(unstable_features.is_nightly_build()), playground, all: RefCell::new(AllTypes::new()), diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 58b43c83a9d59..0023f6c4c0ba8 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -14,7 +14,6 @@ use std::rc::Rc; use rustc_data_structures::fx::FxHashMap; use rustc_middle::ty::TyCtxt; use rustc_session::Session; -use rustc_span::edition::Edition; use rustdoc_json_types as types; @@ -134,7 +133,6 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { fn init( krate: clean::Crate, options: RenderOptions, - _edition: Edition, cache: Cache, tcx: TyCtxt<'tcx>, ) -> Result<(Self, clean::Crate), Error> { diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index eefb8ced7af47..26aaf0db6f620 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -656,10 +656,9 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>( krate: clean::Crate, renderopts: config::RenderOptions, cache: formats::cache::Cache, - edition: rustc_span::edition::Edition, tcx: TyCtxt<'tcx>, ) -> MainResult { - match formats::run_format::(krate, renderopts, cache, edition, tcx) { + match formats::run_format::(krate, renderopts, cache, tcx) { Ok(_) => Ok(()), Err(e) => { let mut msg = @@ -692,7 +691,6 @@ 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 edition = options.edition; let show_coverage = options.show_coverage; let run_check = options.run_check; @@ -760,22 +758,10 @@ fn main_options(options: config::Options) -> MainResult { info!("going to format"); match output_format { config::OutputFormat::Html => sess.time("render_html", || { - run_renderer::>( - krate, - render_opts, - cache, - edition, - tcx, - ) + run_renderer::>(krate, render_opts, cache, tcx) }), config::OutputFormat::Json => sess.time("render_json", || { - run_renderer::>( - krate, - render_opts, - cache, - edition, - tcx, - ) + run_renderer::>(krate, render_opts, cache, tcx) }), } }) From 423963c07b2873c9f2b38ac88398187deb4b5437 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 22 Apr 2021 19:38:20 -0400 Subject: [PATCH 4/6] Remove unnecessary `edition` field on SharedContext --- src/librustdoc/html/render/context.rs | 7 ++++--- src/librustdoc/html/render/mod.rs | 8 ++++---- src/librustdoc/html/render/write_shared.rs | 2 +- src/librustdoc/html/sources.rs | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 9e05fa599a762..75174e84a08da 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -111,8 +111,6 @@ crate struct SharedContext<'tcx> { crate static_root_path: Option, /// The fs handle we are working with. crate fs: DocFS, - /// The default edition used to parse doctests. - crate edition: Edition, pub(super) codes: ErrorCodes, pub(super) playground: Option, all: RefCell, @@ -141,6 +139,10 @@ impl SharedContext<'_> { crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option { if self.collapsed { item.collapsed_doc_value() } else { item.doc_value() } } + + crate fn edition(&self) -> Edition { + self.tcx.sess.edition() + } } impl<'tcx> Context<'tcx> { @@ -434,7 +436,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { resource_suffix, static_root_path, fs: DocFS::new(sender), - edition: tcx.sess.edition(), codes: ErrorCodes::from(unstable_features.is_nightly_build()), playground, all: RefCell::new(AllTypes::new()), diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index d773f37ad90a3..6cf4bedadcc93 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -530,7 +530,7 @@ fn render_markdown( &links, &mut ids, cx.shared.codes, - cx.shared.edition, + cx.shared.edition(), &cx.shared.playground ) .into_string() @@ -660,7 +660,7 @@ fn short_item_info( ¬e, &mut ids, error_codes, - cx.shared.edition, + cx.shared.edition(), &cx.shared.playground, ); message.push_str(&format!(": {}", html.into_string())); @@ -702,7 +702,7 @@ fn short_item_info( &unstable_reason.as_str(), &mut ids, error_codes, - cx.shared.edition, + cx.shared.edition(), &cx.shared.playground, ) .into_string() @@ -1358,7 +1358,7 @@ fn render_impl( &i.impl_item.links(cx), &mut ids, cx.shared.codes, - cx.shared.edition, + cx.shared.edition(), &cx.shared.playground ) .into_string() diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 78bcd40af7538..8e10c696df05d 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -425,7 +425,7 @@ pub(super) fn write_shared( md_opts.output = cx.dst.clone(); md_opts.external_html = (*cx.shared).layout.external_html.clone(); - crate::markdown::render(&index_page, md_opts, cx.shared.edition) + crate::markdown::render(&index_page, md_opts, cx.shared.edition()) .map_err(|e| Error::new(e, &index_page))?; } else { let dst = cx.dst.join("index.html"); diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index 001c8b090448b..5a2a165191a60 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -129,7 +129,7 @@ impl SourceCollector<'_, 'tcx> { &self.scx.layout, &page, "", - |buf: &mut _| print_src(buf, contents, self.scx.edition), + |buf: &mut _| print_src(buf, contents, self.scx.edition()), &self.scx.style_files, ); self.scx.fs.write(&cur, v.as_bytes())?; From 7f6d540440fea578d760eb47158d1e0a9de5eb19 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 22 Apr 2021 19:46:53 -0400 Subject: [PATCH 5/6] Remove unnecessary `item_name` parameter to `mod_item_out` --- src/librustdoc/formats/renderer.rs | 6 ++++-- src/librustdoc/html/render/context.rs | 2 +- src/librustdoc/json/mod.rs | 4 ---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index 6c5c53b7d1acb..25a4129fdd1c7 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -37,7 +37,9 @@ crate trait FormatRenderer<'tcx>: Sized { fn mod_item_in(&mut self, item: &clean::Item, item_name: &str) -> Result<(), Error>; /// Runs after recursively rendering all sub-items of a module. - fn mod_item_out(&mut self, item_name: &str) -> Result<(), Error>; + fn mod_item_out(&mut self) -> Result<(), Error> { + Ok(()) + } /// Post processing hook for cleanup and dumping output to files. fn after_krate(&mut self) -> Result<(), Error>; @@ -87,7 +89,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( work.push((cx.make_child_renderer(), it)); } - cx.mod_item_out(&name)?; + cx.mod_item_out()?; // FIXME: checking `item.name.is_some()` is very implicit and leads to lots of special // cases. Use an explicit match instead. } else if item.name.is_some() && !item.is_extern_crate() { diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 75174e84a08da..d3ef97c0d59f9 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -617,7 +617,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { Ok(()) } - fn mod_item_out(&mut self, _item_name: &str) -> Result<(), Error> { + fn mod_item_out(&mut self) -> Result<(), Error> { info!("Recursed; leaving {}", self.dst.display()); // Go back to where we were at diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 0023f6c4c0ba8..346d44511594f 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -198,10 +198,6 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { Ok(()) } - fn mod_item_out(&mut self, _item_name: &str) -> Result<(), Error> { - Ok(()) - } - fn after_krate(&mut self) -> Result<(), Error> { debug!("Done with crate"); let mut index = (*self.index).clone().into_inner(); From edb60a9243c204d9e281b34a7216fe0c94bb743c Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 22 Apr 2021 19:53:38 -0400 Subject: [PATCH 6/6] Remove unnecessary item_name parameter to `mod_item_in` --- src/librustdoc/formats/renderer.rs | 11 ++++------- src/librustdoc/html/render/context.rs | 7 ++++--- src/librustdoc/json/mod.rs | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index 25a4129fdd1c7..b8ef3384c5908 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -34,7 +34,7 @@ crate trait FormatRenderer<'tcx>: Sized { fn item(&mut self, item: clean::Item) -> Result<(), Error>; /// Renders a module (should not handle recursing into children). - fn mod_item_in(&mut self, item: &clean::Item, item_name: &str) -> Result<(), Error>; + fn mod_item_in(&mut self, item: &clean::Item) -> Result<(), Error>; /// Runs after recursively rendering all sub-items of a module. fn mod_item_out(&mut self) -> Result<(), Error> { @@ -73,13 +73,10 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( if item.is_mod() && T::RUN_ON_MODULE { // modules are special because they add a namespace. We also need to // recurse into the items of the module as well. - let name = item.name.as_ref().unwrap().to_string(); - if name.is_empty() { - panic!("Unexpected module with empty name"); - } - let _timer = prof.generic_activity_with_arg("render_mod_item", name.as_str()); + let _timer = + prof.generic_activity_with_arg("render_mod_item", item.name.unwrap().to_string()); - cx.mod_item_in(&item, &name)?; + cx.mod_item_in(&item)?; let module = match *item.kind { clean::StrippedItem(box clean::ModuleItem(m)) | clean::ModuleItem(m) => m, _ => unreachable!(), diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index d3ef97c0d59f9..9cffcef9749f8 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -578,7 +578,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { } } - fn mod_item_in(&mut self, item: &clean::Item, item_name: &str) -> Result<(), Error> { + fn mod_item_in(&mut self, item: &clean::Item) -> Result<(), Error> { // Stripped modules survive the rustdoc passes (i.e., `strip-private`) // if they contain impls for public types. These modules can also // contain items such as publicly re-exported structures. @@ -590,8 +590,9 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { self.render_redirect_pages = item.is_stripped(); } let scx = &self.shared; - self.dst.push(item_name); - self.current.push(item_name.to_owned()); + let item_name = item.name.as_ref().unwrap().to_string(); + self.dst.push(&item_name); + self.current.push(item_name); info!("Recursing into {}", self.dst.display()); diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 346d44511594f..b048e7f919fa4 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -181,7 +181,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { Ok(()) } - fn mod_item_in(&mut self, item: &clean::Item, _module_name: &str) -> Result<(), Error> { + fn mod_item_in(&mut self, item: &clean::Item) -> Result<(), Error> { use clean::types::ItemKind::*; if let ModuleItem(m) = &*item.kind { for item in &m.items {