Skip to content

Commit 6526e5c

Browse files
committed
Auto merge of #80889 - cjgillot:asa, r=oli-obk
Do not query the HIR directly in `opt_associated_item`. Papercut found by `@Aaron1011.`
2 parents a2cd91c + 21e1963 commit 6526e5c

File tree

1 file changed

+4
-12
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+4
-12
lines changed

compiler/rustc_middle/src/ty/mod.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -2897,19 +2897,11 @@ impl<'tcx> TyCtxt<'tcx> {
28972897
}
28982898

28992899
pub fn opt_associated_item(self, def_id: DefId) -> Option<&'tcx AssocItem> {
2900-
let is_associated_item = if let Some(def_id) = def_id.as_local() {
2901-
matches!(
2902-
self.hir().get(self.hir().local_def_id_to_hir_id(def_id)),
2903-
Node::TraitItem(_) | Node::ImplItem(_)
2904-
)
2900+
if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = self.def_kind(def_id) {
2901+
Some(self.associated_item(def_id))
29052902
} else {
2906-
matches!(
2907-
self.def_kind(def_id),
2908-
DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy
2909-
)
2910-
};
2911-
2912-
is_associated_item.then(|| self.associated_item(def_id))
2903+
None
2904+
}
29132905
}
29142906

29152907
pub fn field_index(self, hir_id: hir::HirId, typeck_results: &TypeckResults<'_>) -> usize {

0 commit comments

Comments
 (0)