diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-10-30 09:58:54 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-10-31 16:15:18 +0000 |
| commit | 77174d3f29a44d2473a924a350862bd2824d06d6 (patch) | |
| tree | 3685ce93cb2ef8923bbb05a482d12ddc4b57994f /compiler/rustc_const_eval/src | |
| parent | 045f158d7b3b53f7c4cb01b8c3a0c42151b0d314 (diff) | |
| download | rust-77174d3f29a44d2473a924a350862bd2824d06d6.tar.gz rust-77174d3f29a44d2473a924a350862bd2824d06d6.zip | |
Turn const_caller_location from a query to a hook
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/util/caller_location.rs | 13 |
2 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_const_eval/src/lib.rs b/compiler/rustc_const_eval/src/lib.rs index 7fc87ed8881..7d36e2eaefe 100644 --- a/compiler/rustc_const_eval/src/lib.rs +++ b/compiler/rustc_const_eval/src/lib.rs @@ -49,7 +49,7 @@ pub fn provide(providers: &mut Providers) { const_eval::provide(providers); providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider; providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider; - providers.const_caller_location = util::caller_location::const_caller_location_provider; + providers.hooks.const_caller_location = util::caller_location::const_caller_location_provider; providers.eval_to_valtree = |tcx, param_env_and_value| { let (param_env, raw) = param_env_and_value.into_parts(); const_eval::eval_to_valtree(tcx, param_env, raw) diff --git a/compiler/rustc_const_eval/src/util/caller_location.rs b/compiler/rustc_const_eval/src/util/caller_location.rs index d67863d75d6..4a3cfd50b44 100644 --- a/compiler/rustc_const_eval/src/util/caller_location.rs +++ b/compiler/rustc_const_eval/src/util/caller_location.rs @@ -1,8 +1,9 @@ use rustc_hir::LangItem; use rustc_middle::mir; +use rustc_middle::query::TyCtxtAt; +use rustc_middle::ty; use rustc_middle::ty::layout::LayoutOf; -use rustc_middle::ty::{self, TyCtxt}; -use rustc_span::{source_map::DUMMY_SP, symbol::Symbol}; +use rustc_span::symbol::Symbol; use rustc_type_ir::Mutability; use crate::const_eval::{mk_eval_cx, CanAccessStatics, CompileTimeEvalContext}; @@ -49,11 +50,13 @@ fn alloc_caller_location<'mir, 'tcx>( } pub(crate) fn const_caller_location_provider( - tcx: TyCtxt<'_>, - (file, line, col): (Symbol, u32, u32), + tcx: TyCtxtAt<'_>, + file: Symbol, + line: u32, + col: u32, ) -> mir::ConstValue<'_> { trace!("const_caller_location: {}:{}:{}", file, line, col); - let mut ecx = mk_eval_cx(tcx, DUMMY_SP, ty::ParamEnv::reveal_all(), CanAccessStatics::No); + let mut ecx = mk_eval_cx(tcx.tcx, tcx.span, ty::ParamEnv::reveal_all(), CanAccessStatics::No); let loc_place = alloc_caller_location(&mut ecx, file, line, col); if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, &loc_place).is_err() { |
