@@ -2,7 +2,7 @@ use std::cmp;
22
33use rustc_data_structures:: fx:: FxIndexMap ;
44use rustc_data_structures:: sorted_map:: SortedMap ;
5- use rustc_errors:: { Diag , Diagnostic , MultiSpan } ;
5+ use rustc_errors:: { Diag , DiagLocation , Diagnostic , MultiSpan } ;
66use rustc_hir:: { HirId , ItemLocalId } ;
77use rustc_lint_defs:: EditionFcw ;
88use rustc_macros:: { Decodable , Encodable , HashStable } ;
@@ -502,6 +502,8 @@ pub fn diag_lint_level<'a, D: Diagnostic<'a, ()> + 'a>(
502502 span : Option < MultiSpan > ,
503503 decorate : D ,
504504) {
505+ let caller = DiagLocation :: caller ( ) ;
506+
505507 // Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
506508 // the "real" work.
507509 #[ track_caller]
@@ -513,6 +515,7 @@ pub fn diag_lint_level<'a, D: Diagnostic<'a, ()> + 'a>(
513515 decorate : Box <
514516 dyn FnOnce ( rustc_errors:: DiagCtxtHandle < ' a > , rustc_errors:: Level ) -> Diag < ' a , ( ) > + ' a ,
515517 > ,
518+ caller : DiagLocation ,
516519 ) {
517520 let LevelAndSource { level, lint_id, src } = level;
518521
@@ -602,6 +605,8 @@ pub fn diag_lint_level<'a, D: Diagnostic<'a, ()> + 'a>(
602605 } else {
603606 Diag :: new ( sess. dcx ( ) , err_level, "" )
604607 } ;
608+ err. emitted_at = caller;
609+
605610 if let Some ( span) = span
606611 && err. span . primary_span ( ) . is_none ( )
607612 {
@@ -692,5 +697,6 @@ pub fn diag_lint_level<'a, D: Diagnostic<'a, ()> + 'a>(
692697 level,
693698 span,
694699 Box :: new ( move |dcx, level| decorate. into_diag ( dcx, level) ) ,
700+ caller,
695701 ) ;
696702}
0 commit comments