@@ -19,10 +19,8 @@ use rustc_hir::{self as hir, AmbigArg, FieldDef, Item, ItemKind, TraitRef, Ty, T
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:: {
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 } ;
26
24
use rustc_middle:: ty:: TyCtxt ;
27
25
use rustc_middle:: ty:: print:: with_no_trimmed_paths;
28
26
use rustc_session:: lint;
@@ -317,12 +315,12 @@ fn lookup_const_stability(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ConstSt
317
315
}
318
316
319
317
/// A private tree-walker for producing an `Index`.
320
- struct Annotator < ' a , ' tcx > {
318
+ struct Annotator < ' tcx > {
321
319
tcx : TyCtxt < ' tcx > ,
322
- index : & ' a mut Index ,
320
+ implications : UnordMap < Symbol , Symbol > ,
323
321
}
324
322
325
- impl < ' a , ' tcx > Annotator < ' a , ' tcx > {
323
+ impl < ' tcx > Annotator < ' tcx > {
326
324
/// Determine the stability for a node based on its attributes and inherited stability. The
327
325
/// stability is recorded in the index and used as the parent. If the node is a function,
328
326
/// `fn_sig` is its signature.
@@ -335,18 +333,18 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
335
333
if let Some ( stability) = self . tcx . lookup_stability ( def_id)
336
334
&& let StabilityLevel :: Unstable { implied_by : Some ( implied_by) , .. } = stability. level
337
335
{
338
- self . index . implications . insert ( implied_by, stability. feature ) ;
336
+ self . implications . insert ( implied_by, stability. feature ) ;
339
337
}
340
338
341
339
if let Some ( stability) = self . tcx . lookup_const_stability ( def_id)
342
340
&& let StabilityLevel :: Unstable { implied_by : Some ( implied_by) , .. } = stability. level
343
341
{
344
- self . index . implications . insert ( implied_by, stability. feature ) ;
342
+ self . implications . insert ( implied_by, stability. feature ) ;
345
343
}
346
344
}
347
345
}
348
346
349
- impl < ' a , ' tcx > Visitor < ' tcx > for Annotator < ' a , ' tcx > {
347
+ impl < ' tcx > Visitor < ' tcx > for Annotator < ' tcx > {
350
348
/// Because stability levels are scoped lexically, we want to walk
351
349
/// nested items in the context of the outer item, so enable
352
350
/// deep-walking.
@@ -610,12 +608,11 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
610
608
}
611
609
}
612
610
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 ( ) } ;
616
613
annotator. annotate ( CRATE_DEF_ID ) ;
617
614
tcx. hir_walk_toplevel_module ( & mut annotator) ;
618
- index
615
+ annotator . implications
619
616
}
620
617
621
618
/// 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) {
627
624
pub ( crate ) fn provide ( providers : & mut Providers ) {
628
625
* providers = Providers {
629
626
check_mod_unstable_api_usage,
630
- stability_index,
631
- stability_implications : |tcx, _| tcx. stability ( ) . implications . clone ( ) ,
627
+ stability_implications,
632
628
lookup_stability,
633
629
lookup_const_stability,
634
630
lookup_default_body_stability,
0 commit comments