Skip to content

Commit

Permalink
Remove some unnecessary uses of FieldDef::ident
Browse files Browse the repository at this point in the history
  • Loading branch information
camelid committed Jan 12, 2022
1 parent 72e74d7 commit c84f2b2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
}
match tcx.type_of(did).kind() {
ty::Adt(def, _) if def.is_enum() => {
if let Some(field) =
def.all_fields().find(|f| f.ident(tcx).name == variant_field_name)
if let Some(field) = def.all_fields().find(|f| f.name == variant_field_name)
{
Ok((ty_res, Some(ItemFragment(FragmentKind::VariantField, field.did))))
} else {
Expand Down Expand Up @@ -770,11 +769,8 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
ty::Adt(def, _) if !def.is_enum() => def,
_ => return None,
};
let field = def
.non_enum_variant()
.fields
.iter()
.find(|item| item.ident(tcx).name == item_name)?;
let field =
def.non_enum_variant().fields.iter().find(|item| item.name == item_name)?;
Some((root_res, ItemFragment(FragmentKind::StructField, field.did)))
}
Res::Def(DefKind::Trait, did) => tcx
Expand Down

0 comments on commit c84f2b2

Please sign in to comment.