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 {