@@ -86,9 +86,6 @@ crate struct Item {
86
86
crate visibility : Visibility ,
87
87
crate kind : ItemKind ,
88
88
crate def_id : DefId ,
89
- crate stability : Option < Stability > ,
90
- crate deprecation : Option < Deprecation > ,
91
- crate const_stability : Option < ConstStability > ,
92
89
}
93
90
94
91
impl fmt:: Debug for Item {
@@ -102,13 +99,23 @@ impl fmt::Debug for Item {
102
99
. field ( "kind" , & self . kind )
103
100
. field ( "visibility" , & self . visibility )
104
101
. field ( "def_id" , def_id)
105
- . field ( "stability" , & self . stability )
106
- . field ( "deprecation" , & self . deprecation )
107
102
. finish ( )
108
103
}
109
104
}
110
105
111
106
impl Item {
107
+ crate fn stability < ' tcx > ( & self , tcx : TyCtxt < ' tcx > ) -> Option < & ' tcx Stability > {
108
+ if self . is_fake ( ) { None } else { tcx. lookup_stability ( self . def_id ) }
109
+ }
110
+
111
+ crate fn const_stability < ' tcx > ( & self , tcx : TyCtxt < ' tcx > ) -> Option < & ' tcx ConstStability > {
112
+ if self . is_fake ( ) { None } else { tcx. lookup_const_stability ( self . def_id ) }
113
+ }
114
+
115
+ crate fn deprecation ( & self , tcx : TyCtxt < ' _ > ) -> Option < Deprecation > {
116
+ if self . is_fake ( ) { None } else { tcx. lookup_deprecation ( self . def_id ) }
117
+ }
118
+
112
119
/// Finds the `doc` attribute as a NameValue and returns the corresponding
113
120
/// value found.
114
121
crate fn doc_value ( & self ) -> Option < & str > {
@@ -150,9 +157,6 @@ impl Item {
150
157
source : source. clean ( cx) ,
151
158
attrs : cx. tcx . get_attrs ( def_id) . clean ( cx) ,
152
159
visibility : cx. tcx . visibility ( def_id) . clean ( cx) ,
153
- stability : cx. tcx . lookup_stability ( def_id) . cloned ( ) ,
154
- deprecation : cx. tcx . lookup_deprecation ( def_id) ,
155
- const_stability : cx. tcx . lookup_const_stability ( def_id) . cloned ( ) ,
156
160
}
157
161
}
158
162
@@ -236,32 +240,32 @@ impl Item {
236
240
}
237
241
}
238
242
239
- crate fn stability_class ( & self ) -> Option < String > {
240
- self . stability . as_ref ( ) . and_then ( |ref s| {
243
+ crate fn stability_class ( & self , tcx : TyCtxt < ' _ > ) -> Option < String > {
244
+ self . stability ( tcx ) . as_ref ( ) . and_then ( |ref s| {
241
245
let mut classes = Vec :: with_capacity ( 2 ) ;
242
246
243
247
if s. level . is_unstable ( ) {
244
248
classes. push ( "unstable" ) ;
245
249
}
246
250
247
251
// FIXME: what about non-staged API items that are deprecated?
248
- if self . deprecation . is_some ( ) {
252
+ if self . deprecation ( tcx ) . is_some ( ) {
249
253
classes. push ( "deprecated" ) ;
250
254
}
251
255
252
256
if !classes. is_empty ( ) { Some ( classes. join ( " " ) ) } else { None }
253
257
} )
254
258
}
255
259
256
- crate fn stable_since ( & self ) -> Option < SymbolStr > {
257
- match self . stability ?. level {
260
+ crate fn stable_since ( & self , tcx : TyCtxt < ' _ > ) -> Option < SymbolStr > {
261
+ match self . stability ( tcx ) ?. level {
258
262
StabilityLevel :: Stable { since, .. } => Some ( since. as_str ( ) ) ,
259
263
StabilityLevel :: Unstable { .. } => None ,
260
264
}
261
265
}
262
266
263
- crate fn const_stable_since ( & self ) -> Option < SymbolStr > {
264
- match self . const_stability ?. level {
267
+ crate fn const_stable_since ( & self , tcx : TyCtxt < ' _ > ) -> Option < SymbolStr > {
268
+ match self . const_stability ( tcx ) ?. level {
265
269
StabilityLevel :: Stable { since, .. } => Some ( since. as_str ( ) ) ,
266
270
StabilityLevel :: Unstable { .. } => None ,
267
271
}
0 commit comments