From d8047f83a95c42cfab19e3b89d24992b1722eb5c Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Mon, 2 Mar 2020 10:43:03 -0800 Subject: [PATCH] Use `is_const_fn_raw` query for HIR const-checking --- src/librustc_passes/check_const.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/librustc_passes/check_const.rs b/src/librustc_passes/check_const.rs index f68213cc9c230..f409b040c69d4 100644 --- a/src/librustc_passes/check_const.rs +++ b/src/librustc_passes/check_const.rs @@ -74,16 +74,16 @@ enum ConstKind { } impl ConstKind { - fn for_body(body: &hir::Body<'_>, hir_map: Map<'_>) -> Option { - let is_const_fn = |id| hir_map.fn_sig_by_hir_id(id).unwrap().header.is_const(); - - let owner = hir_map.body_owner(body.id()); - let const_kind = match hir_map.body_owner_kind(owner) { + fn for_body(body: &hir::Body<'_>, tcx: TyCtxt<'_>) -> Option { + let owner = tcx.hir().body_owner(body.id()); + let const_kind = match tcx.hir().body_owner_kind(owner) { hir::BodyOwnerKind::Const => Self::Const, hir::BodyOwnerKind::Static(Mutability::Mut) => Self::StaticMut, hir::BodyOwnerKind::Static(Mutability::Not) => Self::Static, - hir::BodyOwnerKind::Fn if is_const_fn(owner) => Self::ConstFn, + hir::BodyOwnerKind::Fn if tcx.is_const_fn_raw(tcx.hir().local_def_id(owner)) => { + Self::ConstFn + } hir::BodyOwnerKind::Fn | hir::BodyOwnerKind::Closure => return None, }; @@ -211,7 +211,7 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> { } fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) { - let kind = ConstKind::for_body(body, self.tcx.hir()); + let kind = ConstKind::for_body(body, self.tcx); self.recurse_into(kind, |this| intravisit::walk_body(this, body)); }