@@ -919,7 +919,7 @@ impl Handler {
919
919
self . inner . borrow_mut ( ) . force_print_diagnostic ( db)
920
920
}
921
921
922
- pub fn emit_diagnostic ( & self , diagnostic : & Diagnostic ) -> Option < ErrorGuaranteed > {
922
+ pub fn emit_diagnostic ( & self , diagnostic : & mut Diagnostic ) -> Option < ErrorGuaranteed > {
923
923
self . inner . borrow_mut ( ) . emit_diagnostic ( diagnostic)
924
924
}
925
925
@@ -993,25 +993,25 @@ impl HandlerInner {
993
993
self . taught_diagnostics . insert ( code. clone ( ) )
994
994
}
995
995
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) ;
998
998
}
999
999
1000
1000
/// Emit all stashed diagnostics.
1001
1001
fn emit_stashed_diagnostics ( & mut self ) -> Option < ErrorGuaranteed > {
1002
1002
let diags = self . stashed_diagnostics . drain ( ..) . map ( |x| x. 1 ) . collect :: < Vec < _ > > ( ) ;
1003
1003
let mut reported = None ;
1004
- diags . iter ( ) . for_each ( | diag| {
1004
+ for mut diag in diags {
1005
1005
if diag. is_error ( ) {
1006
1006
reported = Some ( ErrorGuaranteed ( ( ) ) ) ;
1007
1007
}
1008
- self . emit_diagnostic ( diag) ;
1009
- } ) ;
1008
+ self . emit_diagnostic ( & mut diag) ;
1009
+ }
1010
1010
reported
1011
1011
}
1012
1012
1013
1013
// 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 > {
1015
1015
if diagnostic. level == Level :: DelayedBug {
1016
1016
// FIXME(eddyb) this should check for `has_errors` and stop pushing
1017
1017
// once *any* errors were emitted (and truncate `delayed_span_bugs`
@@ -1221,22 +1221,22 @@ impl HandlerInner {
1221
1221
let mut diagnostic = Diagnostic :: new ( Level :: DelayedBug , msg) ;
1222
1222
diagnostic. set_span ( sp. into ( ) ) ;
1223
1223
diagnostic. note ( & format ! ( "delayed at {}" , std:: panic:: Location :: caller( ) ) ) ;
1224
- self . emit_diagnostic ( & diagnostic) . unwrap ( )
1224
+ self . emit_diagnostic ( & mut diagnostic) . unwrap ( )
1225
1225
}
1226
1226
1227
1227
// FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`, that's
1228
1228
// where the explanation of what "good path" is (also, it should be renamed).
1229
1229
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) ;
1231
1231
if self . flags . report_delayed_bugs {
1232
- self . emit_diagnostic ( & diagnostic) ;
1232
+ self . emit_diagnostic ( & mut diagnostic) ;
1233
1233
}
1234
1234
let backtrace = std:: backtrace:: Backtrace :: force_capture ( ) ;
1235
1235
self . delayed_good_path_bugs . push ( DelayedDiagnostic :: with_backtrace ( diagnostic, backtrace) ) ;
1236
1236
}
1237
1237
1238
1238
fn failure ( & mut self , msg : & str ) {
1239
- self . emit_diagnostic ( & Diagnostic :: new ( FailureNote , msg) ) ;
1239
+ self . emit_diagnostic ( & mut Diagnostic :: new ( FailureNote , msg) ) ;
1240
1240
}
1241
1241
1242
1242
fn fatal ( & mut self , msg : & str ) -> FatalError {
@@ -1253,11 +1253,11 @@ impl HandlerInner {
1253
1253
if self . treat_err_as_bug ( ) {
1254
1254
self . bug ( msg) ;
1255
1255
}
1256
- self . emit_diagnostic ( & Diagnostic :: new ( level, msg) ) . unwrap ( )
1256
+ self . emit_diagnostic ( & mut Diagnostic :: new ( level, msg) ) . unwrap ( )
1257
1257
}
1258
1258
1259
1259
fn bug ( & mut self , msg : & str ) -> ! {
1260
- self . emit_diagnostic ( & Diagnostic :: new ( Bug , msg) ) ;
1260
+ self . emit_diagnostic ( & mut Diagnostic :: new ( Bug , msg) ) ;
1261
1261
panic:: panic_any ( ExplicitBug ) ;
1262
1262
}
1263
1263
@@ -1267,7 +1267,7 @@ impl HandlerInner {
1267
1267
if no_bugs {
1268
1268
// Put the overall explanation before the `DelayedBug`s, to
1269
1269
// 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) ) ;
1271
1271
no_bugs = false ;
1272
1272
}
1273
1273
@@ -1283,7 +1283,7 @@ impl HandlerInner {
1283
1283
}
1284
1284
bug. level = Level :: Bug ;
1285
1285
1286
- self . emit_diagnostic ( & bug) ;
1286
+ self . emit_diagnostic ( & mut bug) ;
1287
1287
}
1288
1288
1289
1289
// Panic with `ExplicitBug` to avoid "unexpected panic" messages.
0 commit comments