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> {
1992
1992
/// returns the `DefId` of the trait that the trait item belongs to;
1993
1993
/// otherwise, returns `None`.
1994
1994
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 ) )
2002
1997
}
2003
1998
2004
1999
/// If the given `DefId` describes a method belonging to an impl, returns the
2005
2000
/// `DefId` of the impl that the method belongs to; otherwise, returns `None`.
2006
2001
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 { .. } ) )
2014
2004
}
2015
2005
2016
2006
pub fn is_exportable ( self , def_id : DefId ) -> bool {
You can’t perform that action at this time.
0 commit comments