9
9
//! The functions in this file should fall back to the default set in their
10
10
//! origin crate when the `TyCtxt` is not present in TLS.
11
11
12
- use rustc_errors:: { Diagnostic , TRACK_DIAGNOSTIC } ;
13
- use rustc_middle:: dep_graph:: { DepNodeExt , TaskDepsRef } ;
12
+ use rustc_middle:: dep_graph:: DepNodeExt ;
14
13
use rustc_middle:: ty:: tls;
15
14
use rustc_query_system:: dep_graph:: dep_node:: default_dep_kind_debug;
16
15
use rustc_query_system:: dep_graph:: { DepContext , DepKind , DepNode } ;
@@ -26,26 +25,6 @@ fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
26
25
} )
27
26
}
28
27
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
-
49
28
/// This is a callback from `rustc_hir` as it cannot access the implicit state
50
29
/// in `rustc_middle` otherwise.
51
30
fn def_id_debug ( def_id : rustc_hir:: def_id:: DefId , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -103,5 +82,5 @@ pub fn setup_callbacks() {
103
82
. swap ( & ( dep_kind_debug as fn ( _, & mut fmt:: Formatter < ' _ > ) -> _ ) ) ;
104
83
rustc_query_system:: dep_graph:: dep_node:: DEP_NODE_DEBUG
105
84
. 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 _ ) ) ;
107
86
}
0 commit comments