@@ -96,6 +96,20 @@ impl AssocItem {
9696 }
9797 }
9898
99+ pub fn namespace ( & self ) -> Namespace {
100+ match self . kind {
101+ ty:: AssocKind :: Type { .. } => Namespace :: TypeNS ,
102+ ty:: AssocKind :: Const | ty:: AssocKind :: Fn { .. } => Namespace :: ValueNS ,
103+ }
104+ }
105+
106+ pub fn as_def_kind ( & self ) -> DefKind {
107+ match self . kind {
108+ AssocKind :: Const => DefKind :: AssocConst ,
109+ AssocKind :: Fn { .. } => DefKind :: AssocFn ,
110+ AssocKind :: Type { .. } => DefKind :: AssocTy ,
111+ }
112+ }
99113 pub fn is_type ( & self ) -> bool {
100114 matches ! ( self . kind, ty:: AssocKind :: Type { .. } )
101115 }
@@ -153,23 +167,6 @@ pub enum AssocKind {
153167 } ,
154168}
155169
156- impl AssocKind {
157- pub fn namespace ( & self ) -> Namespace {
158- match * self {
159- ty:: AssocKind :: Type { .. } => Namespace :: TypeNS ,
160- ty:: AssocKind :: Const | ty:: AssocKind :: Fn { .. } => Namespace :: ValueNS ,
161- }
162- }
163-
164- pub fn as_def_kind ( & self ) -> DefKind {
165- match self {
166- AssocKind :: Const => DefKind :: AssocConst ,
167- AssocKind :: Fn { .. } => DefKind :: AssocFn ,
168- AssocKind :: Type { .. } => DefKind :: AssocTy ,
169- }
170- }
171- }
172-
173170impl std:: fmt:: Display for AssocKind {
174171 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
175172 match self {
@@ -250,7 +247,7 @@ impl AssocItems {
250247 parent_def_id : DefId ,
251248 ) -> Option < & ty:: AssocItem > {
252249 self . filter_by_name_unhygienic ( ident. name )
253- . filter ( |item| item. kind . namespace ( ) == ns)
250+ . filter ( |item| item. namespace ( ) == ns)
254251 . find ( |item| tcx. hygienic_eq ( ident, item. ident ( tcx) , parent_def_id) )
255252 }
256253}
0 commit comments