diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 6f7ba8aff5d..dacaeac78f2 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -263,7 +263,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl indices.dedup_by_key(|i| { ( items[*i].def_id, - if items[*i].name.as_ref().is_some() { Some(full_path(cx, &items[*i])) } else { None }, + if items[*i].name.is_some() { Some(full_path(cx, &items[*i])) } else { None }, items[*i].type_(), if items[*i].is_import() { *i } else { 0 }, ) @@ -310,13 +310,13 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl "
{}extern crate {} as {};",
myitem.visibility.print_with_space(myitem.def_id, cx),
anchor(myitem.def_id.expect_def_id(), src, cx),
- myitem.name.as_ref().unwrap(),
+ myitem.name.unwrap(),
),
None => write!(
w,
"{}extern crate {};",
myitem.visibility.print_with_space(myitem.def_id, cx),
- anchor(myitem.def_id.expect_def_id(), *myitem.name.as_ref().unwrap(), cx),
+ anchor(myitem.def_id.expect_def_id(), myitem.name.unwrap(), cx),
),
}
w.write_str("
");
@@ -388,7 +388,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
{stab_tags}\
{name}",
id = id,
- name = variant.name.as_ref().unwrap()
+ name = variant.name.unwrap()
);
if let clean::VariantItem(clean::Variant::Tuple(ref s)) = *variant.kind {
w.write_str("(");
@@ -1137,11 +1136,8 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
};
if let Some((heading, fields)) = heading_and_fields {
- let variant_id = cx.derive_id(format!(
- "{}.{}.fields",
- ItemType::Variant,
- variant.name.as_ref().unwrap()
- ));
+ let variant_id =
+ cx.derive_id(format!("{}.{}.fields", ItemType::Variant, variant.name.unwrap()));
write!(w, "", id = variant_id);
write!(w, "{heading}
", heading = heading);
document_non_exhaustive(w, variant);
@@ -1151,8 +1147,8 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
clean::StructFieldItem(ref ty) => {
let id = cx.derive_id(format!(
"variant.{}.field.{}",
- variant.name.as_ref().unwrap(),
- field.name.as_ref().unwrap()
+ variant.name.unwrap(),
+ field.name.unwrap()
));
write!(
w,
@@ -1162,7 +1158,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
{f}: {t}
\
",
id = id,
- f = field.name.as_ref().unwrap(),
+ f = field.name.unwrap(),
t = ty.print(cx)
);
document(w, cx, field, Some(variant), HeadingOffset::H5);
@@ -1201,7 +1197,7 @@ fn item_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Mac
fn item_proc_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, m: &clean::ProcMacro) {
wrap_into_docblock(w, |w| {
- let name = it.name.as_ref().expect("proc-macros always have names");
+ let name = it.name.expect("proc-macros always have names");
match m.kind {
MacroKind::Bang => {
wrap_item(w, "macro", |w| {
@@ -1245,7 +1241,7 @@ fn item_constant(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, c: &clean::
w,
"{vis}const {name}: {typ}",
vis = it.visibility.print_with_space(it.def_id, cx),
- name = it.name.as_ref().unwrap(),
+ name = it.name.unwrap(),
typ = c.type_.print(cx),
);
@@ -1338,7 +1334,7 @@ fn item_static(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
"{vis}static {mutability}{name}: {typ}",
vis = it.visibility.print_with_space(it.def_id, cx),
mutability = s.mutability.print_with_space(),
- name = it.name.as_ref().unwrap(),
+ name = it.name.unwrap(),
typ = s.type_.print(cx)
);
});
@@ -1355,7 +1351,7 @@ fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) {
w,
" {}type {};\n}}",
it.visibility.print_with_space(it.def_id, cx),
- it.name.as_ref().unwrap(),
+ it.name.unwrap(),
);
});
});
@@ -1523,12 +1519,7 @@ fn render_union(
tab: &str,
cx: &Context<'_>,
) {
- write!(
- w,
- "{}union {}",
- it.visibility.print_with_space(it.def_id, cx),
- it.name.as_ref().unwrap()
- );
+ write!(w, "{}union {}", it.visibility.print_with_space(it.def_id, cx), it.name.unwrap());
if let Some(g) = g {
write!(w, "{}", g.print(cx));
write!(w, "{}", print_where_clause(g, cx, 0, true));
@@ -1548,7 +1539,7 @@ fn render_union(
w,
" {}{}: {},\n{}",
field.visibility.print_with_space(field.def_id, cx),
- field.name.as_ref().unwrap(),
+ field.name.unwrap(),
ty.print(cx),
tab
);
@@ -1579,7 +1570,7 @@ fn render_struct(
"{}{}{}",
it.visibility.print_with_space(it.def_id, cx),
if structhead { "struct " } else { "" },
- it.name.as_ref().unwrap()
+ it.name.unwrap()
);
if let Some(g) = g {
write!(w, "{}", g.print(cx))
@@ -1604,7 +1595,7 @@ fn render_struct(
"\n{} {}{}: {},",
tab,
field.visibility.print_with_space(field.def_id, cx),
- field.name.as_ref().unwrap(),
+ field.name.unwrap(),
ty.print(cx),
);
}