@@ -34,7 +34,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3434use rustc_data_structures:: steal:: Steal ;
3535use rustc_data_structures:: sync:: { self , Lock , Lrc , WorkerLocal } ;
3636use rustc_data_structures:: vec_map:: VecMap ;
37- use rustc_errors:: { ErrorGuaranteed , LintDiagnosticBuilder , MultiSpan } ;
37+ use rustc_errors:: { DecorateLint , ErrorGuaranteed , LintDiagnosticBuilder , MultiSpan } ;
3838use rustc_hir as hir;
3939use rustc_hir:: def:: { DefKind , Res } ;
4040use rustc_hir:: def_id:: { CrateNum , DefId , DefIdMap , LocalDefId , LOCAL_CRATE } ;
@@ -2787,6 +2787,18 @@ impl<'tcx> TyCtxt<'tcx> {
27872787 }
27882788 }
27892789
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+
27902802 pub fn struct_span_lint_hir (
27912803 self ,
27922804 lint : & ' static Lint ,
@@ -2798,6 +2810,17 @@ impl<'tcx> TyCtxt<'tcx> {
27982810 struct_lint_level ( self . sess , lint, level, src, Some ( span. into ( ) ) , decorate) ;
27992811 }
28002812
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+
28012824 pub fn struct_lint_node (
28022825 self ,
28032826 lint : & ' static Lint ,
0 commit comments