Do not query the HIR in opt_associated_item
.
This commit is contained in:
parent
34628e5b53
commit
21e1963e9c
@ -2897,19 +2897,11 @@ pub fn opt_item_name(self, def_id: DefId) -> Option<Ident> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn opt_associated_item(self, def_id: DefId) -> Option<&'tcx AssocItem> {
|
pub fn opt_associated_item(self, def_id: DefId) -> Option<&'tcx AssocItem> {
|
||||||
let is_associated_item = if let Some(def_id) = def_id.as_local() {
|
if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = self.def_kind(def_id) {
|
||||||
matches!(
|
Some(self.associated_item(def_id))
|
||||||
self.hir().get(self.hir().local_def_id_to_hir_id(def_id)),
|
|
||||||
Node::TraitItem(_) | Node::ImplItem(_)
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
matches!(
|
None
|
||||||
self.def_kind(def_id),
|
}
|
||||||
DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
is_associated_item.then(|| self.associated_item(def_id))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn field_index(self, hir_id: hir::HirId, typeck_results: &TypeckResults<'_>) -> usize {
|
pub fn field_index(self, hir_id: hir::HirId, typeck_results: &TypeckResults<'_>) -> usize {
|
||||||
|
Loading…
Reference in New Issue
Block a user