Skip to content

Commit edb60a9

Browse files
committed
Remove unnecessary item_name parameter to mod_item_in
1 parent 7f6d540 commit edb60a9

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/librustdoc/formats/renderer.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ crate trait FormatRenderer<'tcx>: Sized {
3434
fn item(&mut self, item: clean::Item) -> Result<(), Error>;
3535

3636
/// Renders a module (should not handle recursing into children).
37-
fn mod_item_in(&mut self, item: &clean::Item, item_name: &str) -> Result<(), Error>;
37+
fn mod_item_in(&mut self, item: &clean::Item) -> Result<(), Error>;
3838

3939
/// Runs after recursively rendering all sub-items of a module.
4040
fn mod_item_out(&mut self) -> Result<(), Error> {
@@ -73,13 +73,10 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
7373
if item.is_mod() && T::RUN_ON_MODULE {
7474
// modules are special because they add a namespace. We also need to
7575
// recurse into the items of the module as well.
76-
let name = item.name.as_ref().unwrap().to_string();
77-
if name.is_empty() {
78-
panic!("Unexpected module with empty name");
79-
}
80-
let _timer = prof.generic_activity_with_arg("render_mod_item", name.as_str());
76+
let _timer =
77+
prof.generic_activity_with_arg("render_mod_item", item.name.unwrap().to_string());
8178

82-
cx.mod_item_in(&item, &name)?;
79+
cx.mod_item_in(&item)?;
8380
let module = match *item.kind {
8481
clean::StrippedItem(box clean::ModuleItem(m)) | clean::ModuleItem(m) => m,
8582
_ => unreachable!(),

src/librustdoc/html/render/context.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
578578
}
579579
}
580580

581-
fn mod_item_in(&mut self, item: &clean::Item, item_name: &str) -> Result<(), Error> {
581+
fn mod_item_in(&mut self, item: &clean::Item) -> Result<(), Error> {
582582
// Stripped modules survive the rustdoc passes (i.e., `strip-private`)
583583
// if they contain impls for public types. These modules can also
584584
// contain items such as publicly re-exported structures.
@@ -590,8 +590,9 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
590590
self.render_redirect_pages = item.is_stripped();
591591
}
592592
let scx = &self.shared;
593-
self.dst.push(item_name);
594-
self.current.push(item_name.to_owned());
593+
let item_name = item.name.as_ref().unwrap().to_string();
594+
self.dst.push(&item_name);
595+
self.current.push(item_name);
595596

596597
info!("Recursing into {}", self.dst.display());
597598

src/librustdoc/json/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
181181
Ok(())
182182
}
183183

184-
fn mod_item_in(&mut self, item: &clean::Item, _module_name: &str) -> Result<(), Error> {
184+
fn mod_item_in(&mut self, item: &clean::Item) -> Result<(), Error> {
185185
use clean::types::ItemKind::*;
186186
if let ModuleItem(m) = &*item.kind {
187187
for item in &m.items {

0 commit comments

Comments
 (0)