@@ -19,15 +19,15 @@ use rustc_hir::{FieldDef, Item, ItemKind, TraitRef, Ty, TyKind, Variant};
19
19
use rustc_middle:: hir:: nested_filter;
20
20
use rustc_middle:: middle:: lib_features:: { FeatureStability , LibFeatures } ;
21
21
use rustc_middle:: middle:: privacy:: EffectiveVisibilities ;
22
- use rustc_middle:: middle:: stability:: { AllowUnstable , DeprecationEntry , Index } ;
22
+ use rustc_middle:: middle:: stability:: { AllowUnstable , Index , RawDeprecationEntry } ;
23
23
use rustc_middle:: query:: Providers ;
24
24
use rustc_middle:: ty:: TyCtxt ;
25
25
use rustc_session:: lint;
26
26
use rustc_session:: lint:: builtin:: { INEFFECTIVE_UNSTABLE_TRAIT_IMPL , USELESS_DEPRECATED } ;
27
27
use rustc_span:: Span ;
28
28
use rustc_span:: symbol:: { Symbol , sym} ;
29
29
use rustc_target:: spec:: abi:: Abi ;
30
- use tracing:: { debug, info } ;
30
+ use tracing:: debug;
31
31
32
32
use crate :: errors;
33
33
@@ -128,19 +128,16 @@ fn annotation_kind(tcx: TyCtxt<'_>, def_id: LocalDefId) -> AnnotationKind {
128
128
}
129
129
}
130
130
131
- fn lookup_deprecation_entry ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> Option < DeprecationEntry > {
131
+ fn lookup_deprecation_entry_raw ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> RawDeprecationEntry {
132
132
let attrs = tcx. hir ( ) . attrs ( tcx. local_def_id_to_hir_id ( def_id) ) ;
133
133
134
134
let depr = attr:: find_deprecation ( & tcx. sess , tcx. features ( ) , attrs) ;
135
135
let Some ( ( depr, span) ) = & depr else {
136
- if inherit_deprecation ( tcx. def_kind ( def_id) ) . yes ( ) {
137
- let parent_id = tcx. opt_local_parent ( def_id) ?;
138
- let parent_depr = tcx. lookup_deprecation_entry ( parent_id) ?;
139
- info ! ( "tagging child {:?} as deprecated from parent" , def_id) ;
140
- return Some ( parent_depr) ;
141
- }
142
-
143
- return None ;
136
+ return if inherit_deprecation ( tcx. def_kind ( def_id) ) . yes ( ) {
137
+ RawDeprecationEntry :: Inherited
138
+ } else {
139
+ RawDeprecationEntry :: None
140
+ } ;
144
141
} ;
145
142
146
143
let kind = annotation_kind ( tcx, def_id) ;
@@ -155,7 +152,7 @@ fn lookup_deprecation_entry(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<Depre
155
152
}
156
153
157
154
// `Deprecation` is just two pointers, no need to intern it
158
- Some ( DeprecationEntry :: local ( * depr, def_id) )
155
+ RawDeprecationEntry :: local ( * depr, def_id)
159
156
}
160
157
161
158
/// A private tree-walker for producing an `Index`.
@@ -184,7 +181,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
184
181
) where
185
182
F : FnOnce ( & mut Self ) ,
186
183
{
187
- let depr = self . tcx . lookup_deprecation_entry ( def_id) ;
184
+ let depr = self . tcx . lookup_deprecation ( def_id. to_def_id ( ) ) ;
188
185
let is_deprecated = depr. is_some ( ) ;
189
186
190
187
if !self . tcx . features ( ) . staged_api {
@@ -237,7 +234,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
237
234
}
238
235
}
239
236
240
- if stab. is_none ( ) && depr. map_or ( false , |d| d. attr . is_since_rustc_version ( ) ) {
237
+ if stab. is_none ( ) && depr. map_or ( false , |d| d. is_since_rustc_version ( ) ) {
241
238
if let Some ( attr) = attrs. iter ( ) . find ( |attr| attr. has_name ( sym:: deprecated) ) {
242
239
self . tcx . dcx ( ) . emit_err ( errors:: DeprecatedAttribute { span : attr. span } ) ;
243
240
}
@@ -263,7 +260,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
263
260
// Check if deprecated_since < stable_since. If it is,
264
261
// this is *almost surely* an accident.
265
262
if let Some ( depr) = depr
266
- && let DeprecatedSince :: RustcVersion ( dep_since) = depr. attr . since
263
+ && let DeprecatedSince :: RustcVersion ( dep_since) = depr. since
267
264
&& let attr:: Stable { since : stab_since, .. } = stab. level
268
265
{
269
266
match stab_since {
@@ -707,7 +704,7 @@ pub(crate) fn provide(providers: &mut Providers) {
707
704
lookup_stability : |tcx, id| tcx. stability ( ) . local_stability ( id) ,
708
705
lookup_const_stability : |tcx, id| tcx. stability ( ) . local_const_stability ( id) ,
709
706
lookup_default_body_stability : |tcx, id| tcx. stability ( ) . local_default_body_stability ( id) ,
710
- lookup_deprecation_entry ,
707
+ lookup_deprecation_entry_raw ,
711
708
..* providers
712
709
} ;
713
710
}
0 commit comments