Auto merge of #118051 - GuillaumeGomez:cleanup-rustdoc, r=notriddle
Remove unneeded `unknown` variable and `Symbol` creation when iterating over items in rustdoc rendering I realized that we were creating a `Symbol` but never actually used it since we check that `item.name` is always `Some()`. r? `@notriddle`
This commit is contained in:
commit
10a98e8bff
@ -1,5 +1,4 @@
|
|||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_span::Symbol;
|
|
||||||
|
|
||||||
use crate::clean;
|
use crate::clean;
|
||||||
use crate::config::RenderOptions;
|
use crate::config::RenderOptions;
|
||||||
@ -68,7 +67,6 @@ pub(crate) fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
|||||||
// Render the crate documentation
|
// Render the crate documentation
|
||||||
let mut work = vec![(format_renderer.make_child_renderer(), krate.module)];
|
let mut work = vec![(format_renderer.make_child_renderer(), krate.module)];
|
||||||
|
|
||||||
let unknown = Symbol::intern("<unknown item>");
|
|
||||||
while let Some((mut cx, item)) = work.pop() {
|
while let Some((mut cx, item)) = work.pop() {
|
||||||
if item.is_mod() && T::RUN_ON_MODULE {
|
if item.is_mod() && T::RUN_ON_MODULE {
|
||||||
// modules are special because they add a namespace. We also need to
|
// 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>>(
|
|||||||
cx.mod_item_out()?;
|
cx.mod_item_out()?;
|
||||||
// FIXME: checking `item.name.is_some()` is very implicit and leads to lots of special
|
// FIXME: checking `item.name.is_some()` is very implicit and leads to lots of special
|
||||||
// cases. Use an explicit match instead.
|
// cases. Use an explicit match instead.
|
||||||
} else if item.name.is_some() && !item.is_extern_crate() {
|
} else if let Some(item_name) = item.name
|
||||||
prof.generic_activity_with_arg("render_item", item.name.unwrap_or(unknown).as_str())
|
&& !item.is_extern_crate()
|
||||||
|
{
|
||||||
|
prof.generic_activity_with_arg("render_item", item_name.as_str())
|
||||||
.run(|| cx.item(item))?;
|
.run(|| cx.item(item))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user