From 4bffe8f00d39ad754758fb0eb38f9f9be54c9928 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Tue, 21 Jul 2020 22:54:18 +0200 Subject: [PATCH] fetch -> lookup --- src/librustc_middle/ty/mod.rs | 2 +- src/librustc_mir/borrow_check/mod.rs | 2 +- src/librustc_mir/transform/check_unsafety.rs | 2 +- src/librustc_mir/transform/mod.rs | 6 +++--- src/librustc_mir_build/build/mod.rs | 5 ++++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 947f7444753..5316649d0e2 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -1627,7 +1627,7 @@ impl WithOptConstParam { /// Returns `Some((did, param_did))` if `def_id` is a const argument, /// `None` otherwise. #[inline(always)] - pub fn try_fetch(did: LocalDefId, tcx: TyCtxt<'_>) -> Option<(LocalDefId, DefId)> { + pub fn try_lookup(did: LocalDefId, tcx: TyCtxt<'_>) -> Option<(LocalDefId, DefId)> { tcx.opt_const_param_of(did).map(|param_did| (did, param_did)) } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 402dfc540c6..76cc03fa609 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -89,7 +89,7 @@ pub fn provide(providers: &mut Providers) { *providers = Providers { mir_borrowck: |tcx, did| { - if let Some(def) = ty::WithOptConstParam::try_fetch(did, tcx) { + if let Some(def) = ty::WithOptConstParam::try_lookup(did, tcx) { tcx.mir_borrowck_const_arg(def) } else { mir_borrowck(tcx, ty::WithOptConstParam::unknown(did)) diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index ca113bfaa4f..9c06e173bcd 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -439,7 +439,7 @@ fn check_target_features(&mut self, func_did: DefId) { pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { unsafety_check_result: |tcx, def_id| { - if let Some(def) = ty::WithOptConstParam::try_fetch(def_id, tcx) { + if let Some(def) = ty::WithOptConstParam::try_lookup(def_id, tcx) { tcx.unsafety_check_result_for_const_arg(def) } else { unsafety_check_result(tcx, ty::WithOptConstParam::unknown(def_id)) diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index c79da239a40..283e4b289f2 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -50,7 +50,7 @@ pub(crate) fn provide(providers: &mut Providers) { mir_const, mir_const_qualif: |tcx, def_id| { let def_id = def_id.expect_local(); - if let Some(def) = ty::WithOptConstParam::try_fetch(def_id, tcx) { + if let Some(def) = ty::WithOptConstParam::try_lookup(def_id, tcx) { tcx.mir_const_qualif_const_arg(def) } else { mir_const_qualif(tcx, ty::WithOptConstParam::unknown(def_id)) @@ -66,7 +66,7 @@ pub(crate) fn provide(providers: &mut Providers) { is_mir_available, promoted_mir: |tcx, def_id| { let def_id = def_id.expect_local(); - if let Some(def) = ty::WithOptConstParam::try_fetch(def_id, tcx) { + if let Some(def) = ty::WithOptConstParam::try_lookup(def_id, tcx) { tcx.promoted_mir_of_const_arg(def) } else { promoted_mir(tcx, ty::WithOptConstParam::unknown(def_id)) @@ -485,7 +485,7 @@ fn run_optimization_passes<'tcx>( fn optimized_mir<'tcx>(tcx: TyCtxt<'tcx>, did: DefId) -> &'tcx Body<'tcx> { let did = did.expect_local(); - if let Some(def) = ty::WithOptConstParam::try_fetch(did, tcx) { + if let Some(def) = ty::WithOptConstParam::try_lookup(did, tcx) { tcx.optimized_mir_of_const_arg(def) } else { tcx.arena.alloc(inner_optimized_mir(tcx, ty::WithOptConstParam::unknown(did))) diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index 120617160da..1e677f3d2ab 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -21,7 +21,10 @@ use super::lints; -crate fn mir_built<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam) -> &'tcx ty::steal::Steal> { +crate fn mir_built<'tcx>( + tcx: TyCtxt<'tcx>, + def: ty::WithOptConstParam, +) -> &'tcx ty::steal::Steal> { if let Some(def) = def.try_upgrade(tcx) { return tcx.mir_built(def); } -- 2.44.0