Give the correct track-caller location with MIR inlining.
This commit is contained in:
parent
d9ee0f468f
commit
edc73f9719
11 changed files with 24 additions and 24 deletions
|
@ -289,7 +289,7 @@ impl<'tcx> Inliner<'tcx> {
|
|||
) -> Option<CallSite<'tcx>> {
|
||||
// Only consider direct calls to functions
|
||||
let terminator = bb_data.terminator();
|
||||
if let TerminatorKind::Call { ref func, target, .. } = terminator.kind {
|
||||
if let TerminatorKind::Call { ref func, target, fn_span, .. } = terminator.kind {
|
||||
let func_ty = func.ty(caller_body, self.tcx);
|
||||
if let ty::FnDef(def_id, substs) = *func_ty.kind() {
|
||||
// To resolve an instance its substs have to be fully normalized.
|
||||
|
@ -302,14 +302,9 @@ impl<'tcx> Inliner<'tcx> {
|
|||
}
|
||||
|
||||
let fn_sig = self.tcx.bound_fn_sig(def_id).subst(self.tcx, substs);
|
||||
let source_info = SourceInfo { span: fn_span, ..terminator.source_info };
|
||||
|
||||
return Some(CallSite {
|
||||
callee,
|
||||
fn_sig,
|
||||
block: bb,
|
||||
target,
|
||||
source_info: terminator.source_info,
|
||||
});
|
||||
return Some(CallSite { callee, fn_sig, block: bb, target, source_info });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -316,6 +316,7 @@ impl ExpnId {
|
|||
// Stop going up the backtrace once include! is encountered
|
||||
if expn_data.is_root()
|
||||
|| expn_data.kind == ExpnKind::Macro(MacroKind::Bang, sym::include)
|
||||
|| expn_data.kind == ExpnKind::Inlined
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
let mut _2: std::pin::Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>; // in scope 0 at $DIR/inline_generator.rs:+1:14: +1:32
|
||||
let mut _3: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline_generator.rs:+1:23: +1:31
|
||||
let mut _4: [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline_generator.rs:+1:28: +1:31
|
||||
+ let mut _7: bool; // in scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
|
||||
+ let mut _7: bool; // in scope 0 at $DIR/inline_generator.rs:+1:33: +1:46
|
||||
scope 1 {
|
||||
debug _r => _1; // in scope 1 at $DIR/inline_generator.rs:+1:9: +1:11
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
|||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ scope 6 (inlined g::{closure#0}) { // at $DIR/inline_generator.rs:9:14: 9:46
|
||||
+ scope 6 (inlined g::{closure#0}) { // at $DIR/inline_generator.rs:9:33: 9:46
|
||||
+ debug a => _7; // in scope 6 at $DIR/inline_generator.rs:15:6: 15:7
|
||||
+ let mut _8: i32; // in scope 6 at $DIR/inline_generator.rs:15:17: 15:39
|
||||
+ let mut _9: u32; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41
|
||||
|
@ -68,8 +68,8 @@
|
|||
- // mir::Constant
|
||||
- // + span: $DIR/inline_generator.rs:9:33: 9:39
|
||||
- // + literal: Const { ty: for<'a> fn(Pin<&'a mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>, bool) -> GeneratorState<<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator<bool>>::Yield, <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator<bool>>::Return> {<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator<bool>>::resume}, val: Value(<ZST>) }
|
||||
+ StorageLive(_7); // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
|
||||
+ _7 = const false; // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
|
||||
+ StorageLive(_7); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46
|
||||
+ _7 = const false; // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46
|
||||
+ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41
|
||||
+ _9 = discriminant((*_10)); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41
|
||||
+ switchInt(move _9) -> [0: bb3, 1: bb8, 3: bb7, otherwise: bb9]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41
|
||||
|
@ -77,7 +77,7 @@
|
|||
|
||||
- bb3: {
|
||||
+ bb1: {
|
||||
+ StorageDead(_7); // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46
|
||||
+ StorageDead(_7); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46
|
||||
StorageDead(_2); // scope 0 at $DIR/inline_generator.rs:+1:45: +1:46
|
||||
StorageDead(_4); // scope 0 at $DIR/inline_generator.rs:+1:46: +1:47
|
||||
_0 = const (); // scope 0 at $DIR/inline_generator.rs:+0:11: +2:2
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
debug f => _1; // in scope 0 at $DIR/inline_shims.rs:+0:20: +0:21
|
||||
let mut _0: fn(A, B); // return place in scope 0 at $DIR/inline_shims.rs:+0:36: +0:44
|
||||
let mut _2: &fn(A, B); // in scope 0 at $DIR/inline_shims.rs:+1:5: +1:14
|
||||
+ scope 1 (inlined <fn(A, B) as Clone>::clone - shim(fn(A, B))) { // at $DIR/inline_shims.rs:6:5: 6:14
|
||||
+ scope 1 (inlined <fn(A, B) as Clone>::clone - shim(fn(A, B))) { // at $DIR/inline_shims.rs:6:7: 6:14
|
||||
+ }
|
||||
|
||||
bb0: {
|
||||
|
|
|
@ -6,7 +6,7 @@ fn a(_1: &mut [T]) -> &mut [T] {
|
|||
let mut _2: &mut [T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
|
||||
let mut _3: &mut [T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
|
||||
let mut _4: &mut [T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
|
||||
scope 1 (inlined <[T] as AsMut<[T]>>::as_mut) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:3:5: 3:15
|
||||
scope 1 (inlined <[T] as AsMut<[T]>>::as_mut) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:3:7: 3:15
|
||||
debug self => _4; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
|
||||
let mut _5: &mut [T]; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ fn b(_1: &mut Box<T>) -> &mut T {
|
|||
let mut _2: &mut T; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
|
||||
let mut _3: &mut T; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
|
||||
let mut _4: &mut std::boxed::Box<T>; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
|
||||
scope 1 (inlined <Box<T> as AsMut<T>>::as_mut) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:8:5: 8:15
|
||||
scope 1 (inlined <Box<T> as AsMut<T>>::as_mut) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:8:7: 8:15
|
||||
debug self => _4; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
||||
let mut _5: &mut T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
||||
let mut _6: &mut T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
||||
|
|
|
@ -5,7 +5,7 @@ fn c(_1: &[T]) -> &[T] {
|
|||
let mut _0: &[T]; // return place in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:25: +0:29
|
||||
let _2: &[T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
|
||||
let mut _3: &[T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
|
||||
scope 1 (inlined <[T] as AsRef<[T]>>::as_ref) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:13:5: 13:15
|
||||
scope 1 (inlined <[T] as AsRef<[T]>>::as_ref) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:13:7: 13:15
|
||||
debug self => _3; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ fn d(_1: &Box<T>) -> &T {
|
|||
let mut _0: &T; // return place in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:28: +0:30
|
||||
let _2: &T; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
|
||||
let mut _3: &std::boxed::Box<T>; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15
|
||||
scope 1 (inlined <Box<T> as AsRef<T>>::as_ref) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:18:5: 18:15
|
||||
scope 1 (inlined <Box<T> as AsRef<T>>::as_ref) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:18:7: 18:15
|
||||
debug self => _3; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
||||
let mut _4: std::boxed::Box<T>; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
||||
let mut _5: *const T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
debug out => _4; // in scope 2 at $DIR/issue_101973.rs:6:9: 6:16
|
||||
}
|
||||
}
|
||||
scope 3 (inlined core::num::<impl u32>::rotate_right) { // at $DIR/issue_101973.rs:14:5: 14:58
|
||||
scope 3 (inlined core::num::<impl u32>::rotate_right) { // at $DIR/issue_101973.rs:14:18: 14:58
|
||||
debug self => _4; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
|
||||
debug n => _6; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
|
||||
let mut _15: u32; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
|
||||
|
|
|
@ -4,9 +4,9 @@ fn num_to_digit(_1: char) -> u32 {
|
|||
debug num => _1; // in scope 0 at $DIR/issue_59352.rs:+0:21: +0:24
|
||||
let mut _0: u32; // return place in scope 0 at $DIR/issue_59352.rs:+0:35: +0:38
|
||||
let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/issue_59352.rs:+2:26: +2:41
|
||||
let mut _3: u32; // in scope 0 at $DIR/issue_59352.rs:+2:8: +2:23
|
||||
let mut _3: u32; // in scope 0 at $DIR/issue_59352.rs:+2:12: +2:23
|
||||
let mut _9: isize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
|
||||
scope 1 (inlined char::methods::<impl char>::is_digit) { // at $DIR/issue_59352.rs:14:8: 14:23
|
||||
scope 1 (inlined char::methods::<impl char>::is_digit) { // at $DIR/issue_59352.rs:14:12: 14:23
|
||||
debug self => _1; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
|
||||
debug radix => _3; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
|
||||
let mut _4: &std::option::Option<u32>; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
|
||||
|
@ -16,7 +16,7 @@ fn num_to_digit(_1: char) -> u32 {
|
|||
debug self => _4; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL
|
||||
}
|
||||
}
|
||||
scope 3 (inlined #[track_caller] Option::<u32>::unwrap) { // at $DIR/issue_59352.rs:14:26: 14:50
|
||||
scope 3 (inlined #[track_caller] Option::<u32>::unwrap) { // at $DIR/issue_59352.rs:14:42: 14:50
|
||||
debug self => _2; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL
|
||||
let mut _7: isize; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL
|
||||
let mut _8: !; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL
|
||||
|
@ -26,7 +26,7 @@ fn num_to_digit(_1: char) -> u32 {
|
|||
}
|
||||
|
||||
bb0: {
|
||||
StorageLive(_3); // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23
|
||||
StorageLive(_3); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23
|
||||
StorageLive(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
|
||||
StorageLive(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
|
||||
StorageLive(_6); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
|
||||
|
@ -65,7 +65,7 @@ fn num_to_digit(_1: char) -> u32 {
|
|||
_9 = discriminant((*_4)); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL
|
||||
StorageDead(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
|
||||
StorageDead(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL
|
||||
StorageDead(_3); // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23
|
||||
StorageDead(_3); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23
|
||||
switchInt(move _9) -> [1: bb1, otherwise: bb3]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
// run-pass
|
||||
// revisions: default mir-opt
|
||||
//[default] compile-flags: -Zinline-mir=no
|
||||
//[mir-opt] compile-flags: -Zmir-opt-level=4
|
||||
|
||||
use std::panic::Location;
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
#[inline(always)]
|
||||
#[track_caller]
|
||||
fn check_loc(&self, line: u32, col: u32) -> &Self {
|
||||
let loc = Location::caller();
|
||||
|
|
Loading…
Add table
Reference in a new issue