@@ -55,7 +55,6 @@ pub use diagnostic_impls::{
5555} ;
5656pub use emitter:: ColorConfig ;
5757use emitter:: { DynEmitter , Emitter , is_case_difference, is_different} ;
58- use registry:: Registry ;
5958use rustc_data_structures:: AtomicRef ;
6059use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
6160use rustc_data_structures:: stable_hasher:: { Hash128 , StableHasher } ;
@@ -77,6 +76,8 @@ pub use snippet::Style;
7776pub use termcolor:: { Color , ColorSpec , WriteColor } ;
7877use tracing:: debug;
7978
79+ use crate :: registry:: Registry ;
80+
8081pub mod annotate_snippet_emitter_writer;
8182pub mod codes;
8283mod diagnostic;
@@ -483,6 +484,8 @@ impl<'a> std::ops::Deref for DiagCtxtHandle<'a> {
483484struct DiagCtxtInner {
484485 flags : DiagCtxtFlags ,
485486
487+ registry : Registry ,
488+
486489 /// The error guarantees from all emitted errors. The length gives the error count.
487490 err_guars : Vec < ErrorGuaranteed > ,
488491 /// The error guarantee from all emitted lint errors. The length gives the
@@ -664,6 +667,11 @@ impl DiagCtxt {
664667 self
665668 }
666669
670+ pub fn with_registry ( mut self , registry : Registry ) -> Self {
671+ self . inner . get_mut ( ) . registry = registry;
672+ self
673+ }
674+
667675 pub fn new ( emitter : Box < DynEmitter > ) -> Self {
668676 Self { inner : Lock :: new ( DiagCtxtInner :: new ( emitter) ) }
669677 }
@@ -694,7 +702,7 @@ impl DiagCtxt {
694702 struct FalseEmitter ;
695703
696704 impl Emitter for FalseEmitter {
697- fn emit_diagnostic ( & mut self , _: DiagInner ) {
705+ fn emit_diagnostic ( & mut self , _: DiagInner , _ : & Registry ) {
698706 unimplemented ! ( "false emitter must only used during `wrap_emitter`" )
699707 }
700708
@@ -759,6 +767,7 @@ impl DiagCtxt {
759767 let mut inner = self . inner . borrow_mut ( ) ;
760768 let DiagCtxtInner {
761769 flags : _,
770+ registry : _,
762771 err_guars,
763772 lint_err_guars,
764773 delayed_bugs,
@@ -964,7 +973,7 @@ impl<'a> DiagCtxtHandle<'a> {
964973 self . inner . borrow ( ) . has_errors_or_delayed_bugs ( )
965974 }
966975
967- pub fn print_error_count ( & self , registry : & Registry ) {
976+ pub fn print_error_count ( & self ) {
968977 let mut inner = self . inner . borrow_mut ( ) ;
969978
970979 // Any stashed diagnostics should have been handled by
@@ -1014,7 +1023,7 @@ impl<'a> DiagCtxtHandle<'a> {
10141023 . emitted_diagnostic_codes
10151024 . iter ( )
10161025 . filter_map ( |& code| {
1017- if registry. try_find_description ( code) . is_ok ( ) {
1026+ if inner . registry . try_find_description ( code) . is_ok ( ) {
10181027 Some ( code. to_string ( ) )
10191028 } else {
10201029 None
@@ -1075,10 +1084,10 @@ impl<'a> DiagCtxtHandle<'a> {
10751084 }
10761085
10771086 pub fn emit_future_breakage_report ( & self ) {
1078- let mut inner = self . inner . borrow_mut ( ) ;
1087+ let inner = & mut * self . inner . borrow_mut ( ) ;
10791088 let diags = std:: mem:: take ( & mut inner. future_breakage_diagnostics ) ;
10801089 if !diags. is_empty ( ) {
1081- inner. emitter . emit_future_breakage_report ( diags) ;
1090+ inner. emitter . emit_future_breakage_report ( diags, & inner . registry ) ;
10821091 }
10831092 }
10841093
@@ -1409,6 +1418,7 @@ impl DiagCtxtInner {
14091418 fn new ( emitter : Box < DynEmitter > ) -> Self {
14101419 Self {
14111420 flags : DiagCtxtFlags { can_emit_warnings : true , ..Default :: default ( ) } ,
1421+ registry : Registry :: new ( & [ ] ) ,
14121422 err_guars : Vec :: new ( ) ,
14131423 lint_err_guars : Vec :: new ( ) ,
14141424 delayed_bugs : Vec :: new ( ) ,
@@ -1582,7 +1592,7 @@ impl DiagCtxtInner {
15821592 }
15831593 self . has_printed = true ;
15841594
1585- self . emitter . emit_diagnostic ( diagnostic) ;
1595+ self . emitter . emit_diagnostic ( diagnostic, & self . registry ) ;
15861596 }
15871597
15881598 if is_error {
0 commit comments