99//! The functions in this file should fall back to the default set in their
1010//! origin crate when the `TyCtxt` is not present in TLS.
1111
12- use rustc_errors:: { Diagnostic , TRACK_DIAGNOSTIC } ;
13- use rustc_middle:: dep_graph:: { DepNodeExt , TaskDepsRef } ;
12+ use rustc_middle:: dep_graph:: DepNodeExt ;
1413use rustc_middle:: ty:: tls;
1514use rustc_query_system:: dep_graph:: dep_node:: default_dep_kind_debug;
1615use rustc_query_system:: dep_graph:: { DepContext , DepKind , DepNode } ;
@@ -26,26 +25,6 @@ fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
2625 } )
2726}
2827
29- /// This is a callback from `rustc_errors` as it cannot access the implicit state
30- /// in `rustc_middle` otherwise. It is used when diagnostic messages are
31- /// emitted and stores them in the current query, if there is one.
32- fn track_diagnostic ( diagnostic : Diagnostic , f : & mut dyn FnMut ( Diagnostic ) ) {
33- tls:: with_context_opt ( |icx| {
34- if let Some ( icx) = icx {
35- if let Some ( diagnostics) = icx. diagnostics {
36- diagnostics. lock ( ) . extend ( Some ( diagnostic. clone ( ) ) ) ;
37- }
38-
39- // Diagnostics are tracked, we can ignore the dependency.
40- let icx = tls:: ImplicitCtxt { task_deps : TaskDepsRef :: Ignore , ..icx. clone ( ) } ;
41- return tls:: enter_context ( & icx, move || ( * f) ( diagnostic) ) ;
42- }
43-
44- // In any other case, invoke diagnostics anyway.
45- ( * f) ( diagnostic) ;
46- } )
47- }
48-
4928/// This is a callback from `rustc_hir` as it cannot access the implicit state
5029/// in `rustc_middle` otherwise.
5130fn def_id_debug ( def_id : rustc_hir:: def_id:: DefId , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -103,5 +82,5 @@ pub fn setup_callbacks() {
10382 . swap ( & ( dep_kind_debug as fn ( _, & mut fmt:: Formatter < ' _ > ) -> _ ) ) ;
10483 rustc_query_system:: dep_graph:: dep_node:: DEP_NODE_DEBUG
10584 . swap ( & ( dep_node_debug as fn ( _, & mut fmt:: Formatter < ' _ > ) -> _ ) ) ;
106- TRACK_DIAGNOSTIC . swap ( & ( track_diagnostic as _ ) ) ;
85+ rustc_errors :: TRACK_DIAGNOSTIC . swap ( & ( rustc_query_system :: tls :: track_diagnostic as _ ) ) ;
10786}
0 commit comments