@@ -96,6 +96,20 @@ impl AssocItem {
96
96
}
97
97
}
98
98
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
+ }
99
113
pub fn is_type ( & self ) -> bool {
100
114
matches ! ( self . kind, ty:: AssocKind :: Type { .. } )
101
115
}
@@ -153,23 +167,6 @@ pub enum AssocKind {
153
167
} ,
154
168
}
155
169
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
-
173
170
impl std:: fmt:: Display for AssocKind {
174
171
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
175
172
match self {
@@ -250,7 +247,7 @@ impl AssocItems {
250
247
parent_def_id : DefId ,
251
248
) -> Option < & ty:: AssocItem > {
252
249
self . filter_by_name_unhygienic ( ident. name )
253
- . filter ( |item| item. kind . namespace ( ) == ns)
250
+ . filter ( |item| item. namespace ( ) == ns)
254
251
. find ( |item| tcx. hygienic_eq ( ident, item. ident ( tcx) , parent_def_id) )
255
252
}
256
253
}
0 commit comments