@@ -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 ) ]
@@ -1079,17 +1079,8 @@ impl DiagCtxt {
1079
1079
self . inner . borrow_mut ( ) . emitter . emit_diagnostic ( & db) ;
1080
1080
}
1081
1081
1082
- pub fn emit_diagnostic ( & self , mut diagnostic : Diagnostic ) -> Option < ErrorGuaranteed > {
1083
- self . emit_diagnostic_without_consuming ( & mut diagnostic)
1084
- }
1085
-
1086
- // It's unfortunate this exists. `emit_diagnostic` is preferred, because it
1087
- // consumes the diagnostic, thus ensuring it is emitted just once.
1088
- pub ( crate ) fn emit_diagnostic_without_consuming (
1089
- & self ,
1090
- diagnostic : & mut Diagnostic ,
1091
- ) -> Option < ErrorGuaranteed > {
1092
- self . inner . borrow_mut ( ) . emit_diagnostic_without_consuming ( diagnostic)
1082
+ pub fn emit_diagnostic ( & self , diagnostic : Diagnostic ) -> Option < ErrorGuaranteed > {
1083
+ self . inner . borrow_mut ( ) . emit_diagnostic ( diagnostic)
1093
1084
}
1094
1085
1095
1086
#[ track_caller]
@@ -1278,13 +1269,6 @@ impl DiagCtxtInner {
1278
1269
}
1279
1270
1280
1271
fn emit_diagnostic ( & mut self , mut diagnostic : Diagnostic ) -> Option < ErrorGuaranteed > {
1281
- self . emit_diagnostic_without_consuming ( & mut diagnostic)
1282
- }
1283
-
1284
- fn emit_diagnostic_without_consuming (
1285
- & mut self ,
1286
- diagnostic : & mut Diagnostic ,
1287
- ) -> Option < ErrorGuaranteed > {
1288
1272
if matches ! ( diagnostic. level, Error | Fatal ) && self . treat_err_as_bug ( ) {
1289
1273
diagnostic. level = Bug ;
1290
1274
}
@@ -1340,7 +1324,7 @@ impl DiagCtxtInner {
1340
1324
}
1341
1325
1342
1326
let mut guaranteed = None ;
1343
- ( * TRACK_DIAGNOSTICS ) ( diagnostic, & mut |diagnostic| {
1327
+ ( * TRACK_DIAGNOSTICS ) ( diagnostic, & mut |mut diagnostic| {
1344
1328
if let Some ( ref code) = diagnostic. code {
1345
1329
self . emitted_diagnostic_codes . insert ( code. clone ( ) ) ;
1346
1330
}
@@ -1376,7 +1360,7 @@ impl DiagCtxtInner {
1376
1360
) ;
1377
1361
}
1378
1362
1379
- self . emitter . emit_diagnostic ( diagnostic) ;
1363
+ self . emitter . emit_diagnostic ( & diagnostic) ;
1380
1364
if diagnostic. is_error ( ) {
1381
1365
self . deduplicated_err_count += 1 ;
1382
1366
} else if let Warning ( _) = diagnostic. level {
0 commit comments