about summary refs log tree commit diff
path: root/compiler/rustc_incremental/src
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2021-10-16 20:10:23 +0200
committerCamille GILLOT <gillot.camille@gmail.com>2021-10-20 18:29:27 +0200
commitb09de95fab42d3afbcb74185ea1f8a2d200a6353 (patch)
treebf19aa90ec14f99125d260b98505f1bc4e737b1c /compiler/rustc_incremental/src
parentdc7143367c85f3f498d072ef4a2b8befdf1f75c0 (diff)
downloadrust-b09de95fab42d3afbcb74185ea1f8a2d200a6353.tar.gz
rust-b09de95fab42d3afbcb74185ea1f8a2d200a6353.zip
Merge two query callbacks arrays.
Diffstat (limited to 'compiler/rustc_incremental/src')
-rw-r--r--compiler/rustc_incremental/src/assert_dep_graph.rs40
-rw-r--r--compiler/rustc_incremental/src/persist/dirty_clean.rs21
2 files changed, 29 insertions, 32 deletions
diff --git a/compiler/rustc_incremental/src/assert_dep_graph.rs b/compiler/rustc_incremental/src/assert_dep_graph.rs
index d42e2f7a99c..571337a8dcb 100644
--- a/compiler/rustc_incremental/src/assert_dep_graph.rs
+++ b/compiler/rustc_incremental/src/assert_dep_graph.rs
@@ -126,30 +126,36 @@ impl IfThisChanged<'tcx> {
             if attr.has_name(sym::rustc_if_this_changed) {
                 let dep_node_interned = self.argument(attr);
                 let dep_node = match dep_node_interned {
-                    None => DepNode::from_def_path_hash(def_path_hash, DepKind::hir_owner),
-                    Some(n) => match DepNode::from_label_string(&n.as_str(), def_path_hash) {
-                        Ok(n) => n,
-                        Err(()) => {
-                            self.tcx.sess.span_fatal(
-                                attr.span,
-                                &format!("unrecognized DepNode variant {:?}", n),
-                            );
+                    None => {
+                        DepNode::from_def_path_hash(self.tcx, def_path_hash, DepKind::hir_owner)
+                    }
+                    Some(n) => {
+                        match DepNode::from_label_string(self.tcx, &n.as_str(), def_path_hash) {
+                            Ok(n) => n,
+                            Err(()) => {
+                                self.tcx.sess.span_fatal(
+                                    attr.span,
+                                    &format!("unrecognized DepNode variant {:?}", n),
+                                );
+                            }
                         }
-                    },
+                    }
                 };
                 self.if_this_changed.push((attr.span, def_id.to_def_id(), dep_node));
             } else if attr.has_name(sym::rustc_then_this_would_need) {
                 let dep_node_interned = self.argument(attr);
                 let dep_node = match dep_node_interned {
-                    Some(n) => match DepNode::from_label_string(&n.as_str(), def_path_hash) {
-                        Ok(n) => n,
-                        Err(()) => {
-                            self.tcx.sess.span_fatal(
-                                attr.span,
-                                &format!("unrecognized DepNode variant {:?}", n),
-                            );
+                    Some(n) => {
+                        match DepNode::from_label_string(self.tcx, &n.as_str(), def_path_hash) {
+                            Ok(n) => n,
+                            Err(()) => {
+                                self.tcx.sess.span_fatal(
+                                    attr.span,
+                                    &format!("unrecognized DepNode variant {:?}", n),
+                                );
+                            }
                         }
-                    },
+                    }
                     None => {
                         self.tcx.sess.span_fatal(attr.span, "missing DepNode variant");
                     }
diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs
index 55286384de3..b2eaf61b7d1 100644
--- a/compiler/rustc_incremental/src/persist/dirty_clean.rs
+++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs
@@ -15,7 +15,7 @@
 use rustc_ast::{self as ast, Attribute, NestedMetaItem};
 use rustc_data_structures::fx::FxHashSet;
 use rustc_hir as hir;
-use rustc_hir::def_id::{DefId, LocalDefId};
+use rustc_hir::def_id::LocalDefId;
 use rustc_hir::intravisit;
 use rustc_hir::itemlikevisit::ItemLikeVisitor;
 use rustc_hir::Node as HirNode;
@@ -302,18 +302,6 @@ impl DirtyCleanVisitor<'tcx> {
         out
     }
 
-    fn dep_nodes<'l>(
-        &self,
-        labels: &'l Labels,
-        def_id: DefId,
-    ) -> impl Iterator<Item = DepNode> + 'l {
-        let def_path_hash = self.tcx.def_path_hash(def_id);
-        labels.iter().map(move |label| match DepNode::from_label_string(label, def_path_hash) {
-            Ok(dep_node) => dep_node,
-            Err(()) => unreachable!("label: {}", label),
-        })
-    }
-
     fn dep_node_str(&self, dep_node: &DepNode) -> String {
         if let Some(def_id) = dep_node.extract_def_id(self.tcx) {
             format!("{:?}({})", dep_node.kind, self.tcx.def_path_str(def_id))
@@ -345,16 +333,19 @@ impl DirtyCleanVisitor<'tcx> {
     }
 
     fn check_item(&mut self, item_id: LocalDefId, item_span: Span) {
+        let def_path_hash = self.tcx.def_path_hash(item_id.to_def_id());
         for attr in self.tcx.get_attrs(item_id.to_def_id()).iter() {
             let assertion = match self.assertion_maybe(item_id, attr) {
                 Some(a) => a,
                 None => continue,
             };
             self.checked_attrs.insert(attr.id);
-            for dep_node in self.dep_nodes(&assertion.clean, item_id.to_def_id()) {
+            for label in assertion.clean {
+                let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap();
                 self.assert_clean(item_span, dep_node);
             }
-            for dep_node in self.dep_nodes(&assertion.dirty, item_id.to_def_id()) {
+            for label in assertion.dirty {
+                let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap();
                 self.assert_dirty(item_span, dep_node);
             }
         }