@@ -55,7 +55,6 @@ pub use diagnostic_impls::{
55
55
} ;
56
56
pub use emitter:: ColorConfig ;
57
57
use emitter:: { DynEmitter , Emitter , is_case_difference, is_different} ;
58
- use registry:: Registry ;
59
58
use rustc_data_structures:: AtomicRef ;
60
59
use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
61
60
use rustc_data_structures:: stable_hasher:: { Hash128 , StableHasher } ;
@@ -77,6 +76,8 @@ pub use snippet::Style;
77
76
pub use termcolor:: { Color , ColorSpec , WriteColor } ;
78
77
use tracing:: debug;
79
78
79
+ use crate :: registry:: Registry ;
80
+
80
81
pub mod annotate_snippet_emitter_writer;
81
82
pub mod codes;
82
83
mod diagnostic;
@@ -483,6 +484,8 @@ impl<'a> std::ops::Deref for DiagCtxtHandle<'a> {
483
484
struct DiagCtxtInner {
484
485
flags : DiagCtxtFlags ,
485
486
487
+ registry : Registry ,
488
+
486
489
/// The error guarantees from all emitted errors. The length gives the error count.
487
490
err_guars : Vec < ErrorGuaranteed > ,
488
491
/// The error guarantee from all emitted lint errors. The length gives the
@@ -664,6 +667,11 @@ impl DiagCtxt {
664
667
self
665
668
}
666
669
670
+ pub fn with_registry ( mut self , registry : Registry ) -> Self {
671
+ self . inner . get_mut ( ) . registry = registry;
672
+ self
673
+ }
674
+
667
675
pub fn new ( emitter : Box < DynEmitter > ) -> Self {
668
676
Self { inner : Lock :: new ( DiagCtxtInner :: new ( emitter) ) }
669
677
}
@@ -694,7 +702,7 @@ impl DiagCtxt {
694
702
struct FalseEmitter ;
695
703
696
704
impl Emitter for FalseEmitter {
697
- fn emit_diagnostic ( & mut self , _: DiagInner ) {
705
+ fn emit_diagnostic ( & mut self , _: DiagInner , _ : & Registry ) {
698
706
unimplemented ! ( "false emitter must only used during `wrap_emitter`" )
699
707
}
700
708
@@ -759,6 +767,7 @@ impl DiagCtxt {
759
767
let mut inner = self . inner . borrow_mut ( ) ;
760
768
let DiagCtxtInner {
761
769
flags : _,
770
+ registry : _,
762
771
err_guars,
763
772
lint_err_guars,
764
773
delayed_bugs,
@@ -964,7 +973,7 @@ impl<'a> DiagCtxtHandle<'a> {
964
973
self . inner . borrow ( ) . has_errors_or_delayed_bugs ( )
965
974
}
966
975
967
- pub fn print_error_count ( & self , registry : & Registry ) {
976
+ pub fn print_error_count ( & self ) {
968
977
let mut inner = self . inner . borrow_mut ( ) ;
969
978
970
979
// Any stashed diagnostics should have been handled by
@@ -1014,7 +1023,7 @@ impl<'a> DiagCtxtHandle<'a> {
1014
1023
. emitted_diagnostic_codes
1015
1024
. iter ( )
1016
1025
. filter_map ( |& code| {
1017
- if registry. try_find_description ( code) . is_ok ( ) {
1026
+ if inner . registry . try_find_description ( code) . is_ok ( ) {
1018
1027
Some ( code. to_string ( ) )
1019
1028
} else {
1020
1029
None
@@ -1075,10 +1084,10 @@ impl<'a> DiagCtxtHandle<'a> {
1075
1084
}
1076
1085
1077
1086
pub fn emit_future_breakage_report ( & self ) {
1078
- let mut inner = self . inner . borrow_mut ( ) ;
1087
+ let inner = & mut * self . inner . borrow_mut ( ) ;
1079
1088
let diags = std:: mem:: take ( & mut inner. future_breakage_diagnostics ) ;
1080
1089
if !diags. is_empty ( ) {
1081
- inner. emitter . emit_future_breakage_report ( diags) ;
1090
+ inner. emitter . emit_future_breakage_report ( diags, & inner . registry ) ;
1082
1091
}
1083
1092
}
1084
1093
@@ -1409,6 +1418,7 @@ impl DiagCtxtInner {
1409
1418
fn new ( emitter : Box < DynEmitter > ) -> Self {
1410
1419
Self {
1411
1420
flags : DiagCtxtFlags { can_emit_warnings : true , ..Default :: default ( ) } ,
1421
+ registry : Registry :: new ( & [ ] ) ,
1412
1422
err_guars : Vec :: new ( ) ,
1413
1423
lint_err_guars : Vec :: new ( ) ,
1414
1424
delayed_bugs : Vec :: new ( ) ,
@@ -1582,7 +1592,7 @@ impl DiagCtxtInner {
1582
1592
}
1583
1593
self . has_printed = true ;
1584
1594
1585
- self . emitter . emit_diagnostic ( diagnostic) ;
1595
+ self . emitter . emit_diagnostic ( diagnostic, & self . registry ) ;
1586
1596
}
1587
1597
1588
1598
if is_error {
0 commit comments