@@ -919,7 +919,7 @@ impl Handler {
919919 self . inner . borrow_mut ( ) . force_print_diagnostic ( db)
920920 }
921921
922- pub fn emit_diagnostic ( & self , diagnostic : & Diagnostic ) -> Option < ErrorGuaranteed > {
922+ pub fn emit_diagnostic ( & self , diagnostic : & mut Diagnostic ) -> Option < ErrorGuaranteed > {
923923 self . inner . borrow_mut ( ) . emit_diagnostic ( diagnostic)
924924 }
925925
@@ -993,25 +993,25 @@ impl HandlerInner {
993993 self . taught_diagnostics . insert ( code. clone ( ) )
994994 }
995995
996- fn force_print_diagnostic ( & mut self , db : Diagnostic ) {
997- self . emitter . emit_diagnostic ( & db) ;
996+ fn force_print_diagnostic ( & mut self , mut db : Diagnostic ) {
997+ self . emitter . emit_diagnostic ( & mut db) ;
998998 }
999999
10001000 /// Emit all stashed diagnostics.
10011001 fn emit_stashed_diagnostics ( & mut self ) -> Option < ErrorGuaranteed > {
10021002 let diags = self . stashed_diagnostics . drain ( ..) . map ( |x| x. 1 ) . collect :: < Vec < _ > > ( ) ;
10031003 let mut reported = None ;
1004- diags . iter ( ) . for_each ( | diag| {
1004+ for mut diag in diags {
10051005 if diag. is_error ( ) {
10061006 reported = Some ( ErrorGuaranteed ( ( ) ) ) ;
10071007 }
1008- self . emit_diagnostic ( diag) ;
1009- } ) ;
1008+ self . emit_diagnostic ( & mut diag) ;
1009+ }
10101010 reported
10111011 }
10121012
10131013 // FIXME(eddyb) this should ideally take `diagnostic` by value.
1014- fn emit_diagnostic ( & mut self , diagnostic : & Diagnostic ) -> Option < ErrorGuaranteed > {
1014+ fn emit_diagnostic ( & mut self , diagnostic : & mut Diagnostic ) -> Option < ErrorGuaranteed > {
10151015 if diagnostic. level == Level :: DelayedBug {
10161016 // FIXME(eddyb) this should check for `has_errors` and stop pushing
10171017 // once *any* errors were emitted (and truncate `delayed_span_bugs`
@@ -1221,22 +1221,22 @@ impl HandlerInner {
12211221 let mut diagnostic = Diagnostic :: new ( Level :: DelayedBug , msg) ;
12221222 diagnostic. set_span ( sp. into ( ) ) ;
12231223 diagnostic. note ( & format ! ( "delayed at {}" , std:: panic:: Location :: caller( ) ) ) ;
1224- self . emit_diagnostic ( & diagnostic) . unwrap ( )
1224+ self . emit_diagnostic ( & mut diagnostic) . unwrap ( )
12251225 }
12261226
12271227 // FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`, that's
12281228 // where the explanation of what "good path" is (also, it should be renamed).
12291229 fn delay_good_path_bug ( & mut self , msg : & str ) {
1230- let diagnostic = Diagnostic :: new ( Level :: DelayedBug , msg) ;
1230+ let mut diagnostic = Diagnostic :: new ( Level :: DelayedBug , msg) ;
12311231 if self . flags . report_delayed_bugs {
1232- self . emit_diagnostic ( & diagnostic) ;
1232+ self . emit_diagnostic ( & mut diagnostic) ;
12331233 }
12341234 let backtrace = std:: backtrace:: Backtrace :: force_capture ( ) ;
12351235 self . delayed_good_path_bugs . push ( DelayedDiagnostic :: with_backtrace ( diagnostic, backtrace) ) ;
12361236 }
12371237
12381238 fn failure ( & mut self , msg : & str ) {
1239- self . emit_diagnostic ( & Diagnostic :: new ( FailureNote , msg) ) ;
1239+ self . emit_diagnostic ( & mut Diagnostic :: new ( FailureNote , msg) ) ;
12401240 }
12411241
12421242 fn fatal ( & mut self , msg : & str ) -> FatalError {
@@ -1253,11 +1253,11 @@ impl HandlerInner {
12531253 if self . treat_err_as_bug ( ) {
12541254 self . bug ( msg) ;
12551255 }
1256- self . emit_diagnostic ( & Diagnostic :: new ( level, msg) ) . unwrap ( )
1256+ self . emit_diagnostic ( & mut Diagnostic :: new ( level, msg) ) . unwrap ( )
12571257 }
12581258
12591259 fn bug ( & mut self , msg : & str ) -> ! {
1260- self . emit_diagnostic ( & Diagnostic :: new ( Bug , msg) ) ;
1260+ self . emit_diagnostic ( & mut Diagnostic :: new ( Bug , msg) ) ;
12611261 panic:: panic_any ( ExplicitBug ) ;
12621262 }
12631263
@@ -1267,7 +1267,7 @@ impl HandlerInner {
12671267 if no_bugs {
12681268 // Put the overall explanation before the `DelayedBug`s, to
12691269 // frame them better (e.g. separate warnings from them).
1270- self . emit_diagnostic ( & Diagnostic :: new ( Bug , explanation) ) ;
1270+ self . emit_diagnostic ( & mut Diagnostic :: new ( Bug , explanation) ) ;
12711271 no_bugs = false ;
12721272 }
12731273
@@ -1283,7 +1283,7 @@ impl HandlerInner {
12831283 }
12841284 bug. level = Level :: Bug ;
12851285
1286- self . emit_diagnostic ( & bug) ;
1286+ self . emit_diagnostic ( & mut bug) ;
12871287 }
12881288
12891289 // Panic with `ExplicitBug` to avoid "unexpected panic" messages.
0 commit comments