@@ -34,7 +34,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
34
34
use rustc_data_structures:: steal:: Steal ;
35
35
use rustc_data_structures:: sync:: { self , Lock , Lrc , WorkerLocal } ;
36
36
use rustc_data_structures:: vec_map:: VecMap ;
37
- use rustc_errors:: { ErrorGuaranteed , LintDiagnosticBuilder , MultiSpan } ;
37
+ use rustc_errors:: { DecorateLint , ErrorGuaranteed , LintDiagnosticBuilder , MultiSpan } ;
38
38
use rustc_hir as hir;
39
39
use rustc_hir:: def:: { DefKind , Res } ;
40
40
use rustc_hir:: def_id:: { CrateNum , DefId , DefIdMap , LocalDefId , LOCAL_CRATE } ;
@@ -2787,6 +2787,18 @@ impl<'tcx> TyCtxt<'tcx> {
2787
2787
}
2788
2788
}
2789
2789
2790
+ /// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
2791
+ /// typically generated by `#[derive(LintDiagnostic)]`).
2792
+ pub fn emit_spanned_lint (
2793
+ self ,
2794
+ lint : & ' static Lint ,
2795
+ hir_id : HirId ,
2796
+ span : impl Into < MultiSpan > ,
2797
+ decorator : impl for < ' a > DecorateLint < ' a , ( ) > ,
2798
+ ) {
2799
+ self . struct_span_lint_hir ( lint, hir_id, span, |diag| decorator. decorate_lint ( diag) )
2800
+ }
2801
+
2790
2802
pub fn struct_span_lint_hir (
2791
2803
self ,
2792
2804
lint : & ' static Lint ,
@@ -2798,6 +2810,17 @@ impl<'tcx> TyCtxt<'tcx> {
2798
2810
struct_lint_level ( self . sess , lint, level, src, Some ( span. into ( ) ) , decorate) ;
2799
2811
}
2800
2812
2813
+ /// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically
2814
+ /// generated by `#[derive(LintDiagnostic)]`).
2815
+ pub fn emit_lint (
2816
+ self ,
2817
+ lint : & ' static Lint ,
2818
+ id : HirId ,
2819
+ decorator : impl for < ' a > DecorateLint < ' a , ( ) > ,
2820
+ ) {
2821
+ self . struct_lint_node ( lint, id, |diag| decorator. decorate_lint ( diag) )
2822
+ }
2823
+
2801
2824
pub fn struct_lint_node (
2802
2825
self ,
2803
2826
lint : & ' static Lint ,
0 commit comments