1
Fork 0

Turn const_caller_location from a query to a hook

This commit is contained in:
Oli Scherer 2023-10-30 09:58:54 +00:00
parent 045f158d7b
commit 77174d3f29
5 changed files with 14 additions and 12 deletions

View file

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

View file

@ -590,12 +590,12 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn span_as_caller_location(self, span: Span) -> ConstValue<'tcx> {
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
let caller = self.sess.source_map().lookup_char_pos(topmost.lo());
self.const_caller_location((
self.const_caller_location(
rustc_span::symbol::Symbol::intern(
&caller.file.name.for_codegen(&self.sess).to_string_lossy(),
),
caller.line as u32,
caller.col_display as u32 + 1,
))
)
}
}

View file

@ -1101,10 +1101,6 @@ rustc_queries! {
desc { "destructuring type level constant"}
}
query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> mir::ConstValue<'tcx> {
desc { "getting a &core::panic::Location referring to a span" }
}
// FIXME get rid of this with valtrees
query lit_to_const(
key: LitToConstInput<'tcx>