@@ -22,12 +22,13 @@ use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS;
22
22
use rustc_data_structures:: fx:: FxHashMap ;
23
23
use rustc_data_structures:: sync;
24
24
use rustc_errors:: { add_elided_lifetime_in_path_suggestion, struct_span_err} ;
25
- use rustc_errors:: { Applicability , MultiSpan , SuggestionStyle } ;
25
+ use rustc_errors:: {
26
+ Applicability , DecorateLint , LintDiagnosticBuilder , MultiSpan , SuggestionStyle ,
27
+ } ;
26
28
use rustc_hir as hir;
27
29
use rustc_hir:: def:: Res ;
28
30
use rustc_hir:: def_id:: { CrateNum , DefId } ;
29
31
use rustc_hir:: definitions:: { DefPathData , DisambiguatedDefPathData } ;
30
- use rustc_middle:: lint:: LintDiagnosticBuilder ;
31
32
use rustc_middle:: middle:: privacy:: AccessLevels ;
32
33
use rustc_middle:: middle:: stability;
33
34
use rustc_middle:: ty:: layout:: { LayoutError , LayoutOfHelpers , TyAndLayout } ;
@@ -871,6 +872,17 @@ pub trait LintContext: Sized {
871
872
decorate : impl for < ' a > FnOnce ( LintDiagnosticBuilder < ' a , ( ) > ) ,
872
873
) ;
873
874
875
+ /// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
876
+ /// typically generated by `#[derive(LintDiagnostic)]`).
877
+ fn emit_spanned_lint < S : Into < MultiSpan > > (
878
+ & self ,
879
+ lint : & ' static Lint ,
880
+ span : S ,
881
+ decorator : impl for < ' a > DecorateLint < ' a , ( ) > ,
882
+ ) {
883
+ self . lookup ( lint, Some ( span) , |diag| decorator. decorate_lint ( diag) ) ;
884
+ }
885
+
874
886
fn struct_span_lint < S : Into < MultiSpan > > (
875
887
& self ,
876
888
lint : & ' static Lint ,
@@ -879,6 +891,13 @@ pub trait LintContext: Sized {
879
891
) {
880
892
self . lookup ( lint, Some ( span) , decorate) ;
881
893
}
894
+
895
+ /// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically
896
+ /// generated by `#[derive(LintDiagnostic)]`).
897
+ fn emit_lint ( & self , lint : & ' static Lint , decorator : impl for < ' a > DecorateLint < ' a , ( ) > ) {
898
+ self . lookup ( lint, None as Option < Span > , |diag| decorator. decorate_lint ( diag) ) ;
899
+ }
900
+
882
901
/// Emit a lint at the appropriate level, with no associated span.
883
902
fn lint (
884
903
& self ,
0 commit comments