@@ -20,14 +20,17 @@ use rustc_hir::def_id::{CrateNum, DefId};
2020use rustc_hir:: definitions:: { DefPathData , DisambiguatedDefPathData } ;
2121use rustc_hir:: { Pat , PatKind } ;
2222use rustc_middle:: bug;
23- use rustc_middle:: lint:: LevelSpec ;
23+ use rustc_middle:: lint:: { LevelSpec , StableLevelSpec , UnstableLevelSpec } ;
2424use rustc_middle:: middle:: privacy:: EffectiveVisibilities ;
2525use rustc_middle:: ty:: layout:: { LayoutError , LayoutOfHelpers , TyAndLayout } ;
2626use rustc_middle:: ty:: print:: { PrintError , PrintTraitRefExt as _, Printer , with_no_trimmed_paths} ;
2727use rustc_middle:: ty:: {
2828 self , GenericArg , RegisteredTools , Ty , TyCtxt , TypingEnv , TypingMode , Unnormalized ,
2929} ;
30- use rustc_session:: lint:: { FutureIncompatibleInfo , Lint , LintExpectationId , LintId } ;
30+ use rustc_session:: lint:: {
31+ FutureIncompatibleInfo , Lint , LintExpectationId , LintId , StableLintExpectationId ,
32+ UnstableLintExpectationId ,
33+ } ;
3134use rustc_session:: { DynLintStore , Session } ;
3235use rustc_span:: edit_distance:: find_best_match_for_names;
3336use rustc_span:: { Ident , Span , Symbol , sym} ;
@@ -510,6 +513,8 @@ pub struct EarlyContext<'a> {
510513}
511514
512515pub trait LintContext {
516+ type LintExpectationId : Copy + Into < LintExpectationId > ;
517+
513518 fn sess ( & self ) -> & Session ;
514519
515520 // FIXME: These methods should not take an Into<MultiSpan> -- instead, callers should need to
@@ -538,7 +543,7 @@ pub trait LintContext {
538543 }
539544
540545 /// This returns the lint level spec for the given lint at the current location.
541- fn get_lint_level_spec ( & self , lint : & ' static Lint ) -> LevelSpec ;
546+ fn get_lint_level_spec ( & self , lint : & ' static Lint ) -> LevelSpec < Self :: LintExpectationId > ;
542547
543548 /// This function can be used to manually fulfill an expectation. This can
544549 /// be used for lints which contain several spans, and should be suppressed,
@@ -547,7 +552,7 @@ pub trait LintContext {
547552 /// Note that this function should only be called for [`LintExpectationId`]s
548553 /// retrieved from the current lint pass. Buffered or manually created ids can
549554 /// cause ICEs.
550- fn fulfill_expectation ( & self , expectation : LintExpectationId ) {
555+ fn fulfill_expectation ( & self , expectation : Self :: LintExpectationId ) {
551556 // We need to make sure that submitted expectation ids are correctly fulfilled suppressed
552557 // and stored between compilation sessions. To not manually do these steps, we simply create
553558 // a dummy diagnostic and emit it as usual, which will be suppressed and stored like a
@@ -556,7 +561,7 @@ pub trait LintContext {
556561 . dcx ( )
557562 . struct_expect (
558563 "this is a dummy diagnostic, to submit and store an expectation" ,
559- expectation,
564+ expectation. into ( ) ,
560565 )
561566 . emit ( ) ;
562567 }
@@ -585,6 +590,8 @@ impl<'a> EarlyContext<'a> {
585590}
586591
587592impl < ' tcx > LintContext for LateContext < ' tcx > {
593+ type LintExpectationId = StableLintExpectationId ;
594+
588595 /// Gets the overall compiler `Session` object.
589596 fn sess ( & self ) -> & Session {
590597 self . tcx . sess
@@ -604,12 +611,14 @@ impl<'tcx> LintContext for LateContext<'tcx> {
604611 }
605612 }
606613
607- fn get_lint_level_spec ( & self , lint : & ' static Lint ) -> LevelSpec {
614+ fn get_lint_level_spec ( & self , lint : & ' static Lint ) -> StableLevelSpec {
608615 self . tcx . lint_level_spec_at_node ( lint, self . last_node_with_lint_attrs )
609616 }
610617}
611618
612619impl LintContext for EarlyContext < ' _ > {
620+ type LintExpectationId = UnstableLintExpectationId ;
621+
613622 /// Gets the overall compiler `Session` object.
614623 fn sess ( & self ) -> & Session {
615624 self . builder . sess ( )
@@ -624,7 +633,7 @@ impl LintContext for EarlyContext<'_> {
624633 self . builder . opt_span_lint ( lint, span. map ( |s| s. into ( ) ) , decorator)
625634 }
626635
627- fn get_lint_level_spec ( & self , lint : & ' static Lint ) -> LevelSpec {
636+ fn get_lint_level_spec ( & self , lint : & ' static Lint ) -> UnstableLevelSpec {
628637 self . builder . lint_level_spec ( lint)
629638 }
630639}
0 commit comments