@@ -25,11 +25,6 @@ pub struct AssocItem {
25
25
/// If this is an item in an impl of a trait then this is the `DefId` of
26
26
/// the associated item on the trait that this implements.
27
27
pub trait_item_def_id : Option < DefId > ,
28
-
29
- /// `Some` if the associated item (an associated type) comes from the
30
- /// return-position `impl Trait` in trait desugaring. The `ImplTraitInTraitData`
31
- /// provides additional information about its source.
32
- pub opt_rpitit_info : Option < ty:: ImplTraitInTraitData > ,
33
28
}
34
29
35
30
impl AssocItem {
@@ -81,7 +76,7 @@ impl AssocItem {
81
76
// regions just fine, showing `fn(&MyType)`.
82
77
tcx. fn_sig ( self . def_id ) . instantiate_identity ( ) . skip_binder ( ) . to_string ( )
83
78
}
84
- ty:: AssocKind :: Type => format ! ( "type {};" , self . name) ,
79
+ ty:: AssocKind :: Type { .. } => format ! ( "type {};" , self . name) ,
85
80
ty:: AssocKind :: Const => {
86
81
format ! (
87
82
"const {}: {:?};" ,
@@ -97,10 +92,14 @@ impl AssocItem {
97
92
ty:: AssocKind :: Const => "associated const" ,
98
93
ty:: AssocKind :: Fn { has_self : true } => "method" ,
99
94
ty:: AssocKind :: Fn { has_self : false } => "associated function" ,
100
- ty:: AssocKind :: Type => "associated type" ,
95
+ ty:: AssocKind :: Type { .. } => "associated type" ,
101
96
}
102
97
}
103
98
99
+ pub fn is_type ( & self ) -> bool {
100
+ matches ! ( self . kind, ty:: AssocKind :: Type { .. } )
101
+ }
102
+
104
103
pub fn is_fn ( & self ) -> bool {
105
104
matches ! ( self . kind, ty:: AssocKind :: Fn { .. } )
106
105
}
@@ -113,12 +112,12 @@ impl AssocItem {
113
112
match self . kind {
114
113
AssocKind :: Const => AssocTag :: Const ,
115
114
AssocKind :: Fn { .. } => AssocTag :: Fn ,
116
- AssocKind :: Type => AssocTag :: Type ,
115
+ AssocKind :: Type { .. } => AssocTag :: Type ,
117
116
}
118
117
}
119
118
120
119
pub fn is_impl_trait_in_trait ( & self ) -> bool {
121
- self . opt_rpitit_info . is_some ( )
120
+ matches ! ( self . kind , AssocKind :: Type { opt_rpitit_info: Some ( _ ) } )
122
121
}
123
122
124
123
/// Returns true if:
@@ -143,14 +142,21 @@ impl AssocItem {
143
142
#[ derive( Copy , Clone , PartialEq , Debug , HashStable , Eq , Hash , Encodable , Decodable ) ]
144
143
pub enum AssocKind {
145
144
Const ,
146
- Fn { has_self : bool } ,
147
- Type ,
145
+ Fn {
146
+ has_self : bool ,
147
+ } ,
148
+ Type {
149
+ /// `Some` if the associated type comes from an RPITIT. The
150
+ /// `ImplTraitInTraitData` provides additional information about its
151
+ /// source.
152
+ opt_rpitit_info : Option < ty:: ImplTraitInTraitData > ,
153
+ } ,
148
154
}
149
155
150
156
impl AssocKind {
151
157
pub fn namespace ( & self ) -> Namespace {
152
158
match * self {
153
- ty:: AssocKind :: Type => Namespace :: TypeNS ,
159
+ ty:: AssocKind :: Type { .. } => Namespace :: TypeNS ,
154
160
ty:: AssocKind :: Const | ty:: AssocKind :: Fn { .. } => Namespace :: ValueNS ,
155
161
}
156
162
}
@@ -159,7 +165,7 @@ impl AssocKind {
159
165
match self {
160
166
AssocKind :: Const => DefKind :: AssocConst ,
161
167
AssocKind :: Fn { .. } => DefKind :: AssocFn ,
162
- AssocKind :: Type => DefKind :: AssocTy ,
168
+ AssocKind :: Type { .. } => DefKind :: AssocTy ,
163
169
}
164
170
}
165
171
}
@@ -170,7 +176,7 @@ impl std::fmt::Display for AssocKind {
170
176
AssocKind :: Fn { has_self : true } => write ! ( f, "method" ) ,
171
177
AssocKind :: Fn { has_self : false } => write ! ( f, "associated function" ) ,
172
178
AssocKind :: Const => write ! ( f, "associated const" ) ,
173
- AssocKind :: Type => write ! ( f, "associated type" ) ,
179
+ AssocKind :: Type { .. } => write ! ( f, "associated type" ) ,
174
180
}
175
181
}
176
182
}
0 commit comments