Skip to content

Commit e0f7b89

Browse files
committed
Address review.
1 parent d08cc0b commit e0f7b89

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

src/librustc/dep_graph/mod.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,22 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
9191
TyCtxt::create_stable_hashing_context(*self)
9292
}
9393

94-
fn try_force_previous_green(&self, dep_dep_node: &DepNode) -> bool {
94+
fn try_force_from_dep_node(&self, dep_node: &DepNode) -> bool {
9595
// FIXME: This match is just a workaround for incremental bugs and should
9696
// be removed. https://github.com/rust-lang/rust/issues/62649 is one such
9797
// bug that must be fixed before removing this.
98-
match dep_dep_node.kind {
98+
match dep_node.kind {
9999
DepKind::hir_owner | DepKind::hir_owner_nodes | DepKind::CrateMetadata => {
100-
if let Some(def_id) = dep_dep_node.extract_def_id(*self) {
100+
if let Some(def_id) = dep_node.extract_def_id(*self) {
101101
if def_id_corresponds_to_hir_dep_node(*self, def_id) {
102-
if dep_dep_node.kind == DepKind::CrateMetadata {
102+
if dep_node.kind == DepKind::CrateMetadata {
103103
// The `DefPath` has corresponding node,
104104
// and that node should have been marked
105105
// either red or green in `data.colors`.
106106
bug!(
107107
"DepNode {:?} should have been \
108108
pre-marked as red or green but wasn't.",
109-
dep_dep_node
109+
dep_node
110110
);
111111
}
112112
} else {
@@ -134,8 +134,8 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
134134
}
135135
}
136136

137-
debug!("try_force_previous_green({:?}) --- trying to force", dep_dep_node);
138-
ty::query::force_from_dep_node(*self, dep_dep_node)
137+
debug!("try_force_from_dep_node({:?}) --- trying to force", dep_node);
138+
ty::query::force_from_dep_node(*self, dep_node)
139139
}
140140

141141
fn has_errors_or_delayed_span_bugs(&self) -> bool {
@@ -148,10 +148,8 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
148148

149149
// Interactions with on_disk_cache
150150
fn try_load_from_on_disk_cache(&self, dep_node: &DepNode) {
151-
use crate::mir::interpret::GlobalId;
152-
use crate::ty::query::queries;
153-
use crate::ty::query::QueryDescription;
154-
rustc_dep_node_try_load_from_on_disk_cache!(dep_node, *self)
151+
use crate::ty::query::try_load_from_on_disk_cache;
152+
try_load_from_on_disk_cache(*self, dep_node)
155153
}
156154

157155
fn load_diagnostics(&self, prev_dep_node_index: SerializedDepNodeIndex) -> Vec<Diagnostic> {

src/librustc/ty/query/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,9 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool
191191

192192
false
193193
}
194+
195+
pub(crate) fn try_load_from_on_disk_cache<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) {
196+
use crate::dep_graph::DepKind;
197+
198+
rustc_dep_node_try_load_from_on_disk_cache!(dep_node, tcx)
199+
}

src/librustc_query_system/dep_graph/graph.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use smallvec::{smallvec, SmallVec};
1313
use std::collections::hash_map::Entry;
1414
use std::env;
1515
use std::hash::Hash;
16+
use std::marker::PhantomData;
1617
use std::mem;
17-
use std::panic as bug;
1818
use std::sync::atomic::Ordering::Relaxed;
1919

2020
use super::debug::EdgeFilter;
@@ -215,7 +215,7 @@ impl<K: DepKind> DepGraph<K> {
215215
node: Some(_key),
216216
reads: SmallVec::new(),
217217
read_set: Default::default(),
218-
phantom_data: std::marker::PhantomData,
218+
phantom_data: PhantomData,
219219
})
220220
},
221221
|data, key, fingerprint, task| data.complete_task(key, task.unwrap(), fingerprint),
@@ -367,7 +367,7 @@ impl<K: DepKind> DepGraph<K> {
367367
std::mem::drop(map);
368368
data.read_index(dep_node_index);
369369
} else {
370-
bug!("DepKind {:?} should be pre-allocated but isn't.", v.kind)
370+
panic!("DepKind {:?} should be pre-allocated but isn't.", v.kind)
371371
}
372372
}
373373
}
@@ -645,7 +645,7 @@ impl<K: DepKind> DepGraph<K> {
645645
dependency {:?}",
646646
dep_node, dep_dep_node
647647
);
648-
if tcx.try_force_previous_green(dep_dep_node) {
648+
if tcx.try_force_from_dep_node(dep_dep_node) {
649649
let dep_dep_node_color = data.colors.get(dep_dep_node_index);
650650

651651
match dep_dep_node_color {
@@ -667,7 +667,7 @@ impl<K: DepKind> DepGraph<K> {
667667
}
668668
None => {
669669
if !tcx.has_errors_or_delayed_span_bugs() {
670-
bug!(
670+
panic!(
671671
"try_mark_previous_green() - Forcing the DepNode \
672672
should have set its color"
673673
)
@@ -948,7 +948,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
948948
match env::var("RUST_FORBID_DEP_GRAPH_EDGE") {
949949
Ok(s) => match EdgeFilter::new(&s) {
950950
Ok(f) => Some(f),
951-
Err(err) => bug!("RUST_FORBID_DEP_GRAPH_EDGE invalid: {}", err),
951+
Err(err) => panic!("RUST_FORBID_DEP_GRAPH_EDGE invalid: {}", err),
952952
},
953953
Err(_) => None,
954954
}
@@ -1074,7 +1074,7 @@ impl<K: DepKind> DepGraphData<K> {
10741074
if let Some(ref forbidden_edge) = self.current.forbidden_edge {
10751075
let source = data[source].node;
10761076
if forbidden_edge.test(&source, &target) {
1077-
bug!("forbidden edge {:?} -> {:?} created", source, target)
1077+
panic!("forbidden edge {:?} -> {:?} created", source, target)
10781078
}
10791079
}
10801080
}
@@ -1096,7 +1096,7 @@ pub struct TaskDeps<K> {
10961096
node: Option<DepNode<K>>,
10971097
reads: EdgesVec,
10981098
read_set: FxHashSet<DepNodeIndex>,
1099-
phantom_data: std::marker::PhantomData<DepNode<K>>,
1099+
phantom_data: PhantomData<DepNode<K>>,
11001100
}
11011101

11021102
impl<K> Default for TaskDeps<K> {
@@ -1106,7 +1106,7 @@ impl<K> Default for TaskDeps<K> {
11061106
node: None,
11071107
reads: EdgesVec::new(),
11081108
read_set: FxHashSet::default(),
1109-
phantom_data: std::marker::PhantomData,
1109+
phantom_data: PhantomData,
11101110
}
11111111
}
11121112
}

src/librustc_query_system/dep_graph/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub trait DepContext: Copy {
3131
fn create_stable_hashing_context(&self) -> Self::StableHashingContext;
3232

3333
/// Try to force a dep node to execute and see if it's green.
34-
fn try_force_previous_green(&self, node: &DepNode<Self::DepKind>) -> bool;
34+
fn try_force_from_dep_node(&self, dep_node: &DepNode<Self::DepKind>) -> bool;
3535

3636
/// Return whether the current session is tainted by errors.
3737
fn has_errors_or_delayed_span_bugs(&self) -> bool;

0 commit comments

Comments
 (0)