Reduce use of local_def_id_to_hir_id.
This commit is contained in:
parent
ebcc847369
commit
67727aa7c3
39 changed files with 182 additions and 237 deletions
|
@ -76,10 +76,8 @@ impl<'tcx> MirPass<'tcx> for ConstProp {
|
|||
}
|
||||
|
||||
let def_id = body.source.def_id().expect_local();
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
|
||||
let is_fn_like = tcx.hir().get(hir_id).fn_kind().is_some();
|
||||
let is_assoc_const = tcx.def_kind(def_id.to_def_id()) == DefKind::AssocConst;
|
||||
let is_fn_like = tcx.hir().get_by_def_id(def_id).fn_kind().is_some();
|
||||
let is_assoc_const = tcx.def_kind(def_id) == DefKind::AssocConst;
|
||||
|
||||
// Only run const prop on functions, methods, closures and associated constants
|
||||
if !is_fn_like && !is_assoc_const {
|
||||
|
|
|
@ -66,8 +66,8 @@ impl<'tcx> MirPass<'tcx> for InstrumentCoverage {
|
|||
return;
|
||||
}
|
||||
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(mir_source.def_id().expect_local());
|
||||
let is_fn_like = tcx.hir().get(hir_id).fn_kind().is_some();
|
||||
let is_fn_like =
|
||||
tcx.hir().get_by_def_id(mir_source.def_id().expect_local()).fn_kind().is_some();
|
||||
|
||||
// Only instrument functions, methods, and closures (not constants since they are evaluated
|
||||
// at compile time by Miri).
|
||||
|
|
|
@ -366,8 +366,7 @@ fn mir_drops_elaborated_and_const_checked<'tcx>(
|
|||
tcx.ensure().mir_borrowck(def.did);
|
||||
}
|
||||
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def.did);
|
||||
let is_fn_like = tcx.hir().get(hir_id).fn_kind().is_some();
|
||||
let is_fn_like = tcx.hir().get_by_def_id(def.did).fn_kind().is_some();
|
||||
if is_fn_like {
|
||||
let did = def.did.to_def_id();
|
||||
let def = ty::WithOptConstParam::unknown(did);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue