Remove some unnecessary uses of FieldDef::ident

This commit is contained in:
Noah Lev 2022-01-11 16:23:19 -08:00
parent 72e74d7b9c
commit c84f2b27d3

View File

@ -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 {
@ -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