@@ -86,9 +86,6 @@ crate struct Item {
8686 crate visibility : Visibility ,
8787 crate kind : ItemKind ,
8888 crate def_id : DefId ,
89- crate stability : Option < Stability > ,
90- crate deprecation : Option < Deprecation > ,
91- crate const_stability : Option < ConstStability > ,
9289}
9390
9491impl fmt:: Debug for Item {
@@ -102,13 +99,23 @@ impl fmt::Debug for Item {
10299 . field ( "kind" , & self . kind )
103100 . field ( "visibility" , & self . visibility )
104101 . field ( "def_id" , def_id)
105- . field ( "stability" , & self . stability )
106- . field ( "deprecation" , & self . deprecation )
107102 . finish ( )
108103 }
109104}
110105
111106impl 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+
112119 /// Finds the `doc` attribute as a NameValue and returns the corresponding
113120 /// value found.
114121 crate fn doc_value ( & self ) -> Option < & str > {
@@ -150,9 +157,6 @@ impl Item {
150157 source : source. clean ( cx) ,
151158 attrs : cx. tcx . get_attrs ( def_id) . clean ( cx) ,
152159 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 ( ) ,
156160 }
157161 }
158162
@@ -236,32 +240,32 @@ impl Item {
236240 }
237241 }
238242
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| {
241245 let mut classes = Vec :: with_capacity ( 2 ) ;
242246
243247 if s. level . is_unstable ( ) {
244248 classes. push ( "unstable" ) ;
245249 }
246250
247251 // FIXME: what about non-staged API items that are deprecated?
248- if self . deprecation . is_some ( ) {
252+ if self . deprecation ( tcx ) . is_some ( ) {
249253 classes. push ( "deprecated" ) ;
250254 }
251255
252256 if !classes. is_empty ( ) { Some ( classes. join ( " " ) ) } else { None }
253257 } )
254258 }
255259
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 {
258262 StabilityLevel :: Stable { since, .. } => Some ( since. as_str ( ) ) ,
259263 StabilityLevel :: Unstable { .. } => None ,
260264 }
261265 }
262266
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 {
265269 StabilityLevel :: Stable { since, .. } => Some ( since. as_str ( ) ) ,
266270 StabilityLevel :: Unstable { .. } => None ,
267271 }
0 commit comments