@@ -19,10 +19,8 @@ use rustc_hir::{self as hir, AmbigArg, FieldDef, Item, ItemKind, TraitRef, Ty, T
1919use rustc_middle:: hir:: nested_filter;
2020use rustc_middle:: middle:: lib_features:: { FeatureStability , LibFeatures } ;
2121use rustc_middle:: middle:: privacy:: EffectiveVisibilities ;
22- use rustc_middle:: middle:: stability:: {
23- AllowUnstable , Deprecated , DeprecationEntry , EvalResult , Index ,
24- } ;
25- use rustc_middle:: query:: Providers ;
22+ use rustc_middle:: middle:: stability:: { AllowUnstable , Deprecated , DeprecationEntry , EvalResult } ;
23+ use rustc_middle:: query:: { LocalCrate , Providers } ;
2624use rustc_middle:: ty:: TyCtxt ;
2725use rustc_middle:: ty:: print:: with_no_trimmed_paths;
2826use rustc_session:: lint;
@@ -317,12 +315,12 @@ fn lookup_const_stability(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ConstSt
317315}
318316
319317/// A private tree-walker for producing an `Index`.
320- struct Annotator < ' a , ' tcx > {
318+ struct Annotator < ' tcx > {
321319 tcx : TyCtxt < ' tcx > ,
322- index : & ' a mut Index ,
320+ implications : UnordMap < Symbol , Symbol > ,
323321}
324322
325- impl < ' a , ' tcx > Annotator < ' a , ' tcx > {
323+ impl < ' tcx > Annotator < ' tcx > {
326324 /// Determine the stability for a node based on its attributes and inherited stability. The
327325 /// stability is recorded in the index and used as the parent. If the node is a function,
328326 /// `fn_sig` is its signature.
@@ -335,18 +333,18 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
335333 if let Some ( stability) = self . tcx . lookup_stability ( def_id)
336334 && let StabilityLevel :: Unstable { implied_by : Some ( implied_by) , .. } = stability. level
337335 {
338- self . index . implications . insert ( implied_by, stability. feature ) ;
336+ self . implications . insert ( implied_by, stability. feature ) ;
339337 }
340338
341339 if let Some ( stability) = self . tcx . lookup_const_stability ( def_id)
342340 && let StabilityLevel :: Unstable { implied_by : Some ( implied_by) , .. } = stability. level
343341 {
344- self . index . implications . insert ( implied_by, stability. feature ) ;
342+ self . implications . insert ( implied_by, stability. feature ) ;
345343 }
346344 }
347345}
348346
349- impl < ' a , ' tcx > Visitor < ' tcx > for Annotator < ' a , ' tcx > {
347+ impl < ' tcx > Visitor < ' tcx > for Annotator < ' tcx > {
350348 /// Because stability levels are scoped lexically, we want to walk
351349 /// nested items in the context of the outer item, so enable
352350 /// deep-walking.
@@ -610,12 +608,11 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
610608 }
611609}
612610
613- fn stability_index ( tcx : TyCtxt < ' _ > , ( ) : ( ) ) -> Index {
614- let mut index = Index { implications : Default :: default ( ) } ;
615- let mut annotator = Annotator { tcx, index : & mut index } ;
611+ fn stability_implications ( tcx : TyCtxt < ' _ > , LocalCrate : LocalCrate ) -> UnordMap < Symbol , Symbol > {
612+ let mut annotator = Annotator { tcx, implications : Default :: default ( ) } ;
616613 annotator. annotate ( CRATE_DEF_ID ) ;
617614 tcx. hir_walk_toplevel_module ( & mut annotator) ;
618- index
615+ annotator . implications
619616}
620617
621618/// Cross-references the feature names of unstable APIs with enabled
@@ -627,8 +624,7 @@ fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
627624pub ( crate ) fn provide ( providers : & mut Providers ) {
628625 * providers = Providers {
629626 check_mod_unstable_api_usage,
630- stability_index,
631- stability_implications : |tcx, _| tcx. stability ( ) . implications . clone ( ) ,
627+ stability_implications,
632628 lookup_stability,
633629 lookup_const_stability,
634630 lookup_default_body_stability,
0 commit comments