|
15 | 15 | use rustc_ast::{self as ast, Attribute, NestedMetaItem};
|
16 | 16 | use rustc_data_structures::fx::FxHashSet;
|
17 | 17 | use rustc_hir as hir;
|
18 |
| -use rustc_hir::def_id::{DefId, LocalDefId}; |
| 18 | +use rustc_hir::def_id::LocalDefId; |
19 | 19 | use rustc_hir::intravisit;
|
20 | 20 | use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
21 | 21 | use rustc_hir::Node as HirNode;
|
@@ -302,18 +302,6 @@ impl DirtyCleanVisitor<'tcx> {
|
302 | 302 | out
|
303 | 303 | }
|
304 | 304 |
|
305 |
| - fn dep_nodes<'l>( |
306 |
| - &self, |
307 |
| - labels: &'l Labels, |
308 |
| - def_id: DefId, |
309 |
| - ) -> impl Iterator<Item = DepNode> + 'l { |
310 |
| - let def_path_hash = self.tcx.def_path_hash(def_id); |
311 |
| - labels.iter().map(move |label| match DepNode::from_label_string(label, def_path_hash) { |
312 |
| - Ok(dep_node) => dep_node, |
313 |
| - Err(()) => unreachable!("label: {}", label), |
314 |
| - }) |
315 |
| - } |
316 |
| - |
317 | 305 | fn dep_node_str(&self, dep_node: &DepNode) -> String {
|
318 | 306 | if let Some(def_id) = dep_node.extract_def_id(self.tcx) {
|
319 | 307 | format!("{:?}({})", dep_node.kind, self.tcx.def_path_str(def_id))
|
@@ -345,16 +333,19 @@ impl DirtyCleanVisitor<'tcx> {
|
345 | 333 | }
|
346 | 334 |
|
347 | 335 | fn check_item(&mut self, item_id: LocalDefId, item_span: Span) {
|
| 336 | + let def_path_hash = self.tcx.def_path_hash(item_id.to_def_id()); |
348 | 337 | for attr in self.tcx.get_attrs(item_id.to_def_id()).iter() {
|
349 | 338 | let assertion = match self.assertion_maybe(item_id, attr) {
|
350 | 339 | Some(a) => a,
|
351 | 340 | None => continue,
|
352 | 341 | };
|
353 | 342 | self.checked_attrs.insert(attr.id);
|
354 |
| - for dep_node in self.dep_nodes(&assertion.clean, item_id.to_def_id()) { |
| 343 | + for label in assertion.clean { |
| 344 | + let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap(); |
355 | 345 | self.assert_clean(item_span, dep_node);
|
356 | 346 | }
|
357 |
| - for dep_node in self.dep_nodes(&assertion.dirty, item_id.to_def_id()) { |
| 347 | + for label in assertion.dirty { |
| 348 | + let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap(); |
358 | 349 | self.assert_dirty(item_span, dep_node);
|
359 | 350 | }
|
360 | 351 | }
|
|
0 commit comments