]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/transform/instrument_coverage.rs
Address remaining feedback items
[rust.git] / src / librustc_mir / transform / instrument_coverage.rs
index a24d0acf4212cff3062b72f03f2b8697fe0e4f9a..94aa26b3081e52b44571a012c56296cd3a644651 100644 (file)
@@ -3,7 +3,7 @@
 use rustc_data_structures::fingerprint::Fingerprint;
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 use rustc_hir::lang_items;
-use rustc_hir::*;
+use rustc_middle::hir;
 use rustc_middle::ich::StableHashingContext;
 use rustc_middle::mir::interpret::Scalar;
 use rustc_middle::mir::{
@@ -140,7 +140,7 @@ fn placeholder_block(span: Span) -> BasicBlockData<'tcx> {
 
 fn hash_mir_source<'tcx>(tcx: TyCtxt<'tcx>, src: &MirSource<'tcx>) -> u64 {
     let fn_body_id = match tcx.hir().get_if_local(src.def_id()) {
-        Some(node) => match associated_body(node) {
+        Some(node) => match hir::map::associated_body(node) {
             Some(body_id) => body_id,
             _ => bug!("instrumented MirSource does not include a function body: {:?}", node),
         },
@@ -159,26 +159,3 @@ fn hash(
     node.hash_stable(hcx, &mut stable_hasher);
     stable_hasher.finish()
 }
-
-fn associated_body<'hir>(node: Node<'hir>) -> Option<BodyId> {
-    match node {
-        Node::Item(Item {
-            kind: ItemKind::Const(_, body) | ItemKind::Static(.., body) | ItemKind::Fn(.., body),
-            ..
-        })
-        | Node::TraitItem(TraitItem {
-            kind:
-                TraitItemKind::Const(_, Some(body)) | TraitItemKind::Fn(_, TraitFn::Provided(body)),
-            ..
-        })
-        | Node::ImplItem(ImplItem {
-            kind: ImplItemKind::Const(_, body) | ImplItemKind::Fn(_, body),
-            ..
-        })
-        | Node::Expr(Expr { kind: ExprKind::Closure(.., body, _, _), .. }) => Some(*body),
-
-        Node::AnonConst(constant) => Some(constant.body),
-
-        _ => None,
-    }
-}