File tree Expand file tree Collapse file tree 1 file changed +4
-14
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Original file line number Diff line number Diff line change @@ -1992,25 +1992,15 @@ impl<'tcx> TyCtxt<'tcx> {
19921992 /// returns the `DefId` of the trait that the trait item belongs to;
19931993 /// otherwise, returns `None`.
19941994 pub fn trait_of_item ( self , def_id : DefId ) -> Option < DefId > {
1995- if let DefKind :: AssocConst | DefKind :: AssocFn | DefKind :: AssocTy = self . def_kind ( def_id) {
1996- let parent = self . parent ( def_id) ;
1997- if let DefKind :: Trait | DefKind :: TraitAlias = self . def_kind ( parent) {
1998- return Some ( parent) ;
1999- }
2000- }
2001- None
1995+ self . opt_parent ( def_id)
1996+ . filter ( |parent| matches ! ( self . def_kind( parent) , DefKind :: Trait | DefKind :: TraitAlias ) )
20021997 }
20031998
20041999 /// If the given `DefId` describes a method belonging to an impl, returns the
20052000 /// `DefId` of the impl that the method belongs to; otherwise, returns `None`.
20062001 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
2002+ self . opt_parent ( def_id)
2003+ . filter ( |parent| matches ! ( self . def_kind( parent) , DefKind :: Impl { .. } ) )
20142004 }
20152005
20162006 pub fn is_exportable ( self , def_id : DefId ) -> bool {
You can’t perform that action at this time.
0 commit comments