Skip to content

Commit c1c313d

Browse files
committed
Auto merge of rust-lang#117388 - oli-obk:dequerification, r=<try>
Turn const_caller_location from a query to a hook blocked on rust-lang#117317 cc `@RalfJung`
2 parents 91bbdd9 + b5cb0f3 commit c1c313d

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

compiler/rustc_codegen_cranelift/src/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,13 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
436436
use rustc_session::RemapFileNameExt;
437437
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
438438
let caller = fx.tcx.sess.source_map().lookup_char_pos(topmost.lo());
439-
let const_loc = fx.tcx.const_caller_location((
439+
let const_loc = fx.tcx.const_caller_location(
440440
rustc_span::symbol::Symbol::intern(
441441
&caller.file.name.for_codegen(&fx.tcx.sess).to_string_lossy(),
442442
),
443443
caller.line as u32,
444444
caller.col_display as u32 + 1,
445-
));
445+
);
446446
crate::constant::codegen_const_value(fx, const_loc, fx.tcx.caller_location_ty())
447447
};
448448

compiler/rustc_codegen_ssa/src/mir/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1457,11 +1457,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14571457
use rustc_session::RemapFileNameExt;
14581458
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
14591459
let caller = tcx.sess.source_map().lookup_char_pos(topmost.lo());
1460-
let const_loc = tcx.const_caller_location((
1460+
let const_loc = tcx.const_caller_location(
14611461
Symbol::intern(&caller.file.name.for_codegen(self.cx.sess()).to_string_lossy()),
14621462
caller.line as u32,
14631463
caller.col_display as u32 + 1,
1464-
));
1464+
);
14651465
OperandRef::from_const(bx, const_loc, bx.tcx().caller_location_ty())
14661466
};
14671467

compiler/rustc_const_eval/src/const_eval/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ pub use machine::*;
2121
pub(crate) use valtrees::{const_to_valtree_inner, valtree_to_const_value};
2222

2323
pub(crate) fn const_caller_location(
24-
tcx: TyCtxt<'_>,
25-
(file, line, col): (Symbol, u32, u32),
24+
tcx: TyCtxtAt<'_>,
25+
file: Symbol,
26+
line: u32,
27+
col: u32,
2628
) -> mir::ConstValue<'_> {
27-
trace!("const_caller_location: {}:{}:{}", file, line, col);
28-
let mut ecx = mk_eval_cx(tcx, DUMMY_SP, ty::ParamEnv::reveal_all(), CanAccessStatics::No);
29+
let mut ecx = mk_eval_cx(tcx.tcx, tcx.span, ty::ParamEnv::reveal_all(), CanAccessStatics::No);
2930

3031
let loc_place = ecx.alloc_caller_location(file, line, col);
3132
if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, &loc_place).is_err() {

compiler/rustc_const_eval/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn provide(providers: &mut Providers) {
4949
const_eval::provide(providers);
5050
providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider;
5151
providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider;
52-
providers.const_caller_location = const_eval::const_caller_location;
52+
providers.hooks.const_caller_location = const_eval::const_caller_location;
5353
providers.eval_to_valtree = |tcx, param_env_and_value| {
5454
let (param_env, raw) = param_env_and_value.into_parts();
5555
const_eval::eval_to_valtree(tcx, param_env, raw)

compiler/rustc_middle/src/hooks/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,7 @@ declare_hooks! {
6767
/// Tries to destructure an `mir::Const` ADT or array into its variant index
6868
/// and its field values. This should only be used for pretty printing.
6969
hook try_destructure_mir_constant_for_diagnostics(val: mir::ConstValue<'tcx>, ty: Ty<'tcx>) -> Option<mir::DestructuredConstant<'tcx>>;
70+
71+
/// Getting a &core::panic::Location referring to a span.
72+
hook const_caller_location(file: rustc_span::Symbol, line: u32, col: u32) -> mir::ConstValue<'tcx>;
7073
}

compiler/rustc_middle/src/query/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1101,10 +1101,6 @@ rustc_queries! {
11011101
desc { "destructuring type level constant"}
11021102
}
11031103

1104-
query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> mir::ConstValue<'tcx> {
1105-
desc { "getting a &core::panic::Location referring to a span" }
1106-
}
1107-
11081104
// FIXME get rid of this with valtrees
11091105
query lit_to_const(
11101106
key: LitToConstInput<'tcx>

0 commit comments

Comments
 (0)