Skip to content

Commit 1e55fc1

Browse files
Remove unneeded unknown variable and Symbol creation when iterating over items in rustdoc rendering
1 parent 28345f0 commit 1e55fc1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/librustdoc/formats/renderer.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use rustc_middle::ty::TyCtxt;
2-
use rustc_span::Symbol;
32

43
use crate::clean;
54
use crate::config::RenderOptions;
@@ -68,7 +67,6 @@ pub(crate) fn run_format<'tcx, T: FormatRenderer<'tcx>>(
6867
// Render the crate documentation
6968
let mut work = vec![(format_renderer.make_child_renderer(), krate.module)];
7069

71-
let unknown = Symbol::intern("<unknown item>");
7270
while let Some((mut cx, item)) = work.pop() {
7371
if item.is_mod() && T::RUN_ON_MODULE {
7472
// modules are special because they add a namespace. We also need to
@@ -90,8 +88,10 @@ pub(crate) fn run_format<'tcx, T: FormatRenderer<'tcx>>(
9088
cx.mod_item_out()?;
9189
// FIXME: checking `item.name.is_some()` is very implicit and leads to lots of special
9290
// cases. Use an explicit match instead.
93-
} else if item.name.is_some() && !item.is_extern_crate() {
94-
prof.generic_activity_with_arg("render_item", item.name.unwrap_or(unknown).as_str())
91+
} else if let Some(item_name) = item.name
92+
&& !item.is_extern_crate()
93+
{
94+
prof.generic_activity_with_arg("render_item", item_name.as_str())
9595
.run(|| cx.item(item))?;
9696
}
9797
}

0 commit comments

Comments
 (0)