Skip to content

Commit

Permalink
Remove unnecessary item_name parameter to mod_item_in
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Apr 22, 2021
1 parent 7f6d540 commit edb60a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
11 changes: 4 additions & 7 deletions src/librustdoc/formats/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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!(),
Expand Down
7 changes: 4 additions & 3 deletions src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit edb60a9

Please sign in to comment.