Rollup merge of #92799 - rust-lang:followup-from-92533, r=Aaron1011

Remove some unnecessary uses of `FieldDef::ident`

Followup from #92533.

cc ``@Aaron1011`` ``@petrochenkov``
This commit is contained in:
Matthias Krüger 2022-01-17 06:08:11 +01:00 committed by GitHub
commit 3de7276689
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -436,8 +436,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 {
@ -806,11 +805,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