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}\
\
{docs}
", - name = *myitem.name.as_ref().unwrap(), + name = myitem.name.unwrap(), stab_tags = extra_info_tags(myitem, item, cx.tcx()), docs = MarkdownSummaryLine(&doc_value, &myitem.links(cx)).into_string(), class = myitem.type_(), @@ -460,7 +460,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean:: let asyncness = f.header.asyncness.print_with_space(); let unsafety = f.header.unsafety.print_with_space(); let abi = print_abi_with_space(f.header.abi).to_string(); - let name = it.name.as_ref().unwrap(); + let name = it.name.unwrap(); let generics_len = format!("{:#}", f.generics.print(cx)).len(); let header_len = "fn ".len() @@ -516,7 +516,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra it.visibility.print_with_space(it.def_id, cx), t.unsafety.print_with_space(), if t.is_auto { "auto " } else { "" }, - it.name.as_ref().unwrap(), + it.name.unwrap(), t.generics.print(cx), bounds ); @@ -657,7 +657,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra } fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item) { - let name = m.name.as_ref().unwrap(); + let name = m.name.unwrap(); info!("Documenting {} on {:?}", name, t.name); let item_type = m.type_(); let id = cx.derive_id(format!("{}.{}", item_type, name)); @@ -867,7 +867,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra join_with_slash(None, &path[..path.len() - 1]) }, ty = it.type_(), - name = *it.name.as_ref().unwrap() + name = it.name.unwrap() ); } @@ -878,7 +878,7 @@ fn item_trait_alias(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clea write!( w, "trait {}{}{} = {};", - it.name.as_ref().unwrap(), + it.name.unwrap(), t.generics.print(cx), print_where_clause(&t.generics, cx, 0, true), bounds(&t.bounds, true, cx) @@ -902,7 +902,7 @@ fn item_opaque_ty(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean: write!( w, "type {}{}{where_clause} = impl {bounds};", - it.name.as_ref().unwrap(), + it.name.unwrap(), t.generics.print(cx), where_clause = print_where_clause(&t.generics, cx, 0, true), bounds = bounds(&t.bounds, false, cx), @@ -941,7 +941,7 @@ fn item_typedef( write!( w, "type {}{}{where_clause} = {type_};", - it.name.as_ref().unwrap(), + it.name.unwrap(), t.generics.print(cx), where_clause = print_where_clause(&t.generics, cx, 0, true), type_ = t.type_.print(cx), @@ -994,7 +994,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni Fields" ); for (field, ty) in fields { - let name = field.name.as_ref().expect("union field name"); + let name = field.name.expect("union field name"); let id = format!("{}.{}", ItemType::StructField, name); write!( w, @@ -1039,7 +1039,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum w, "{}enum {}{}{}", it.visibility.print_with_space(it.def_id, cx), - it.name.as_ref().unwrap(), + it.name.unwrap(), e.generics.print(cx), print_where_clause(&e.generics, cx, 0, true), ); @@ -1054,7 +1054,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum } for v in &e.variants { w.write_str(" "); - let name = v.name.as_ref().unwrap(); + let name = v.name.unwrap(); match *v.kind { clean::VariantItem(ref var) => match var { clean::Variant::CLike => write!(w, "{}", name), @@ -1103,15 +1103,14 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum ); document_non_exhaustive(w, it); for variant in &e.variants { - let id = - cx.derive_id(format!("{}.{}", ItemType::Variant, variant.name.as_ref().unwrap())); + let id = cx.derive_id(format!("{}.{}", ItemType::Variant, variant.name.unwrap())); write!( w, "

\ \ {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), ); }