Skip to content

Commit bf4a373

Browse files
Auto merge of #144377 - camsteffen:simplify-impl-of-method, r=<try>
Simplify impl_of_method
2 parents 3c30dbb + e019fd7 commit bf4a373

File tree

1 file changed

+2
-7
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+2
-7
lines changed

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,13 +2004,8 @@ impl<'tcx> TyCtxt<'tcx> {
20042004
/// If the given `DefId` describes a method belonging to an impl, returns the
20052005
/// `DefId` of the impl that the method belongs to; otherwise, returns `None`.
20062006
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
2007-
if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = self.def_kind(def_id) {
2008-
let parent = self.parent(def_id);
2009-
if let DefKind::Impl { .. } = self.def_kind(parent) {
2010-
return Some(parent);
2011-
}
2012-
}
2013-
None
2007+
self.opt_parent(def_id)
2008+
.filter(|parent| matches!(self.def_kind(parent), DefKind::Impl { .. }))
20142009
}
20152010

20162011
pub fn is_exportable(self, def_id: DefId) -> bool {

0 commit comments

Comments
 (0)