|
5 | 5 | pub mod tls; |
6 | 6 |
|
7 | 7 | use crate::arena::Arena; |
8 | | -use crate::dep_graph::{CurrentDepNode, DepGraph, DepKindStruct}; |
| 8 | +use crate::dep_graph::{CurrentDepNode, DepGraph, DepKindStruct, DepNode}; |
9 | 9 | use crate::infer::canonical::CanonicalVarInfo; |
10 | 10 | use crate::lint::struct_lint_level; |
11 | 11 | use crate::metadata::ModChild; |
@@ -548,7 +548,12 @@ impl<'tcx> GlobalCtxt<'tcx> { |
548 | 548 | where |
549 | 549 | F: FnOnce(TyCtxt<'tcx>) -> R, |
550 | 550 | { |
551 | | - let icx = tls::ImplicitCtxt::new(self); |
| 551 | + let current_node = if self.dep_graph.is_fully_enabled() { |
| 552 | + CurrentDepNode::Untracked |
| 553 | + } else { |
| 554 | + CurrentDepNode::regular(DepNode::NULL) |
| 555 | + }; |
| 556 | + let icx = tls::ImplicitCtxt::new(self, ¤t_node); |
552 | 557 | tls::enter_context(&icx, || f(icx.tcx)) |
553 | 558 | } |
554 | 559 | } |
@@ -905,25 +910,32 @@ impl<'tcx> TyCtxt<'tcx> { |
905 | 910 | impl<'tcx> TyCtxt<'tcx> { |
906 | 911 | #[instrument(level = "trace", skip(self), ret)] |
907 | 912 | pub fn create_expansion(self, expn_data: ExpnData) -> LocalExpnId { |
908 | | - let current_node = tls::with_related_context(self, |icx| icx.current_node.clone()); |
909 | | - let CurrentDepNode::Regular { dep_node, expn_disambiguators } = current_node else { |
910 | | - bug!("creating an expansion outside of a query") |
911 | | - }; |
912 | | - self.with_stable_hashing_context(|ctx| { |
913 | | - LocalExpnId::create_untracked_expansion(expn_data, dep_node, ctx, &expn_disambiguators) |
| 913 | + tls::with_related_context(self, |icx| { |
| 914 | + let CurrentDepNode::Regular { dep_node, expn_disambiguators } = icx.current_node else { |
| 915 | + bug!("creating an expansion outside of a query") |
| 916 | + }; |
| 917 | + self.with_stable_hashing_context(|ctx| { |
| 918 | + LocalExpnId::create_untracked_expansion( |
| 919 | + expn_data, |
| 920 | + dep_node, |
| 921 | + ctx, |
| 922 | + &expn_disambiguators, |
| 923 | + ) |
| 924 | + }) |
914 | 925 | }) |
915 | 926 | } |
916 | 927 |
|
917 | 928 | /// Fill an empty expansion. This method must not be used outside of the resolver. |
918 | 929 | #[inline] |
919 | 930 | #[instrument(level = "trace", skip(self))] |
920 | 931 | pub fn finalize_expansion(self, expn_id: LocalExpnId, expn_data: ExpnData) { |
921 | | - let current_node = tls::with_related_context(self, |icx| icx.current_node.clone()); |
922 | | - let CurrentDepNode::Regular { dep_node, expn_disambiguators } = current_node else { |
923 | | - bug!("creating an expansion outside of a query") |
924 | | - }; |
925 | | - self.with_stable_hashing_context(|ctx| { |
926 | | - expn_id.set_untracked_expn_data(expn_data, dep_node, ctx, &expn_disambiguators) |
| 932 | + tls::with_related_context(self, |icx| { |
| 933 | + let CurrentDepNode::Regular { dep_node, expn_disambiguators } = icx.current_node else { |
| 934 | + bug!("creating an expansion outside of a query") |
| 935 | + }; |
| 936 | + self.with_stable_hashing_context(|ctx| { |
| 937 | + expn_id.set_untracked_expn_data(expn_data, dep_node, ctx, &expn_disambiguators) |
| 938 | + }) |
927 | 939 | }); |
928 | 940 | } |
929 | 941 |
|
|
0 commit comments