@@ -509,11 +509,11 @@ pub enum StashKey {
509
509
Cycle ,
510
510
}
511
511
512
- fn default_track_diagnostic ( d : & mut Diagnostic , f : & mut dyn FnMut ( & mut Diagnostic ) ) {
513
- ( * f) ( d )
512
+ fn default_track_diagnostic ( diag : Diagnostic , f : & mut dyn FnMut ( Diagnostic ) ) {
513
+ ( * f) ( diag )
514
514
}
515
515
516
- pub static TRACK_DIAGNOSTICS : AtomicRef < fn ( & mut Diagnostic , & mut dyn FnMut ( & mut Diagnostic ) ) > =
516
+ pub static TRACK_DIAGNOSTICS : AtomicRef < fn ( Diagnostic , & mut dyn FnMut ( Diagnostic ) ) > =
517
517
AtomicRef :: new ( & ( default_track_diagnostic as _ ) ) ;
518
518
519
519
#[ derive( Copy , Clone , Default ) ]
@@ -1074,17 +1074,8 @@ impl DiagCtxt {
1074
1074
self . inner . borrow_mut ( ) . emitter . emit_diagnostic ( & db) ;
1075
1075
}
1076
1076
1077
- pub fn emit_diagnostic ( & self , mut diagnostic : Diagnostic ) -> Option < ErrorGuaranteed > {
1078
- self . emit_diagnostic_without_consuming ( & mut diagnostic)
1079
- }
1080
-
1081
- // It's unfortunate this exists. `emit_diagnostic` is preferred, because it
1082
- // consumes the diagnostic, thus ensuring it is emitted just once.
1083
- pub ( crate ) fn emit_diagnostic_without_consuming (
1084
- & self ,
1085
- diagnostic : & mut Diagnostic ,
1086
- ) -> Option < ErrorGuaranteed > {
1087
- self . inner . borrow_mut ( ) . emit_diagnostic_without_consuming ( diagnostic)
1077
+ pub fn emit_diagnostic ( & self , diagnostic : Diagnostic ) -> Option < ErrorGuaranteed > {
1078
+ self . inner . borrow_mut ( ) . emit_diagnostic ( diagnostic)
1088
1079
}
1089
1080
1090
1081
#[ track_caller]
@@ -1273,13 +1264,6 @@ impl DiagCtxtInner {
1273
1264
}
1274
1265
1275
1266
fn emit_diagnostic ( & mut self , mut diagnostic : Diagnostic ) -> Option < ErrorGuaranteed > {
1276
- self . emit_diagnostic_without_consuming ( & mut diagnostic)
1277
- }
1278
-
1279
- fn emit_diagnostic_without_consuming (
1280
- & mut self ,
1281
- diagnostic : & mut Diagnostic ,
1282
- ) -> Option < ErrorGuaranteed > {
1283
1267
if matches ! ( diagnostic. level, Error | Fatal ) && self . treat_err_as_bug ( ) {
1284
1268
diagnostic. level = Bug ;
1285
1269
}
@@ -1335,7 +1319,7 @@ impl DiagCtxtInner {
1335
1319
}
1336
1320
1337
1321
let mut guaranteed = None ;
1338
- ( * TRACK_DIAGNOSTICS ) ( diagnostic, & mut |diagnostic| {
1322
+ ( * TRACK_DIAGNOSTICS ) ( diagnostic, & mut |mut diagnostic| {
1339
1323
if let Some ( ref code) = diagnostic. code {
1340
1324
self . emitted_diagnostic_codes . insert ( code. clone ( ) ) ;
1341
1325
}
@@ -1371,7 +1355,7 @@ impl DiagCtxtInner {
1371
1355
) ;
1372
1356
}
1373
1357
1374
- self . emitter . emit_diagnostic ( diagnostic) ;
1358
+ self . emitter . emit_diagnostic ( & diagnostic) ;
1375
1359
if diagnostic. is_error ( ) {
1376
1360
self . deduplicated_err_count += 1 ;
1377
1361
} else if let Warning ( _) = diagnostic. level {
0 commit comments