Merge two query callbacks arrays.
This commit is contained in:
parent
dc7143367c
commit
b09de95fab
12 changed files with 179 additions and 246 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue