diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 817e2ca72ec12..83b221213ac7f 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -790,13 +790,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let (fn_abi, llfn, instance) = common::build_langcall(bx, Some(source_info.span), LangItem::PanicNounwind); + let location = self.get_caller_location(bx, source_info).immediate(); + // Codegen the actual panic invoke/call. helper.do_call( self, bx, fn_abi, llfn, - &[msg.0, msg.1], + &[msg.0, msg.1, location], target.as_ref().map(|bb| (ReturnDest::Nothing, *bb)), unwind, &[], diff --git a/compiler/rustc_codegen_ssa/src/size_of_val.rs b/compiler/rustc_codegen_ssa/src/size_of_val.rs index 933904f984505..eb48c2181b397 100644 --- a/compiler/rustc_codegen_ssa/src/size_of_val.rs +++ b/compiler/rustc_codegen_ssa/src/size_of_val.rs @@ -72,12 +72,20 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( // (But we are in good company, this code is duplicated plenty of times.) let fn_ty = bx.fn_decl_backend_type(fn_abi); + let const_loc = bx.tcx().span_as_caller_location(rustc_span::DUMMY_SP); + let location = crate::mir::operand::OperandRef::from_const( + bx, + const_loc, + bx.tcx().caller_location_ty(), + ) + .immediate(); + bx.call( fn_ty, /* fn_attrs */ None, Some(fn_abi), llfn, - &[msg.0, msg.1], + &[msg.0, msg.1, location], None, None, ); diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 7affe63825719..78995cd0cae40 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -212,6 +212,7 @@ panic_const! { /// Like `panic`, but without unwinding and track_caller to reduce the impact on codesize on the caller. /// If you want `#[track_caller]` for nicer errors, call `panic_nounwind_fmt` directly. +#[track_caller] #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[lang = "panic_nounwind"] // needed by codegen for non-unwinding panics @@ -222,6 +223,7 @@ pub const fn panic_nounwind(expr: &'static str) -> ! { } /// Like `panic_nounwind`, but also inhibits showing a backtrace. +#[track_caller] #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[rustc_nounwind] diff --git a/tests/ui/extern/extern-types-field-offset.run.stderr b/tests/ui/extern/extern-types-field-offset.run.stderr index f14073989800b..5121ea7b07e3f 100644 --- a/tests/ui/extern/extern-types-field-offset.run.stderr +++ b/tests/ui/extern/extern-types-field-offset.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at core/src/panicking.rs:$LINE:$COL: +thread 'main' panicked at $DIR/extern-types-field-offset.rs:1:1: attempted to compute the size or alignment of extern type `Opaque` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread caused non-unwinding panic. aborting. diff --git a/tests/ui/extern/extern-types-size_of_val.align.run.stderr b/tests/ui/extern/extern-types-size_of_val.align.run.stderr index faad1aa13faf6..a5740d351205c 100644 --- a/tests/ui/extern/extern-types-size_of_val.align.run.stderr +++ b/tests/ui/extern/extern-types-size_of_val.align.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at core/src/panicking.rs:$LINE:$COL: +thread 'main' panicked at $DIR/extern-types-size_of_val.rs:1:1: attempted to compute the size or alignment of extern type `A` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread caused non-unwinding panic. aborting. diff --git a/tests/ui/extern/extern-types-size_of_val.size.run.stderr b/tests/ui/extern/extern-types-size_of_val.size.run.stderr index faad1aa13faf6..a5740d351205c 100644 --- a/tests/ui/extern/extern-types-size_of_val.size.run.stderr +++ b/tests/ui/extern/extern-types-size_of_val.size.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at core/src/panicking.rs:$LINE:$COL: +thread 'main' panicked at $DIR/extern-types-size_of_val.rs:1:1: attempted to compute the size or alignment of extern type `A` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread caused non-unwinding panic. aborting.