From 47937f26eefe0636b6b2c63723762804a71e1283 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Tue, 27 Aug 2024 11:05:45 -0400 Subject: [PATCH 1/2] Add some track_caller info to precondition panics --- compiler/rustc_codegen_ssa/src/mir/block.rs | 4 +++- compiler/rustc_codegen_ssa/src/size_of_val.rs | 10 +++++++++- library/core/src/panicking.rs | 2 ++ library/core/src/slice/index.rs | 6 ++++++ library/core/src/slice/raw.rs | 2 ++ library/core/src/ub_checks.rs | 1 + ...checked_mut_range.PreCodegen.after.panic-unwind.mir | 2 +- ...t_unchecked_range.PreCodegen.after.panic-unwind.mir | 2 +- ...ec_deref_to_slice.PreCodegen.after.panic-unwind.mir | 2 +- tests/ui/extern/extern-types-field-offset.run.stderr | 2 +- .../extern/extern-types-size_of_val.align.run.stderr | 2 +- .../ui/extern/extern-types-size_of_val.size.run.stderr | 2 +- 12 files changed, 29 insertions(+), 8 deletions(-) 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/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index de1492e82ce7d..13d9f55b81fe3 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -267,6 +267,7 @@ unsafe impl SliceIndex<[T]> for usize { } #[inline] + #[track_caller] unsafe fn get_unchecked(self, slice: *const [T]) -> *const T { assert_unsafe_precondition!( check_language_ub, @@ -286,6 +287,7 @@ unsafe impl SliceIndex<[T]> for usize { } #[inline] + #[track_caller] unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut T { assert_unsafe_precondition!( check_library_ub, @@ -336,6 +338,7 @@ unsafe impl SliceIndex<[T]> for ops::IndexRange { } #[inline] + #[track_caller] unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T] { assert_unsafe_precondition!( check_library_ub, @@ -350,6 +353,7 @@ unsafe impl SliceIndex<[T]> for ops::IndexRange { } #[inline] + #[track_caller] unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T] { assert_unsafe_precondition!( check_library_ub, @@ -416,6 +420,7 @@ unsafe impl SliceIndex<[T]> for ops::Range { } #[inline] + #[track_caller] unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T] { assert_unsafe_precondition!( check_library_ub, @@ -440,6 +445,7 @@ unsafe impl SliceIndex<[T]> for ops::Range { } #[inline] + #[track_caller] unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T] { assert_unsafe_precondition!( check_library_ub, diff --git a/library/core/src/slice/raw.rs b/library/core/src/slice/raw.rs index 85507eb8a7381..1a6e6590d80e9 100644 --- a/library/core/src/slice/raw.rs +++ b/library/core/src/slice/raw.rs @@ -120,6 +120,7 @@ use crate::{array, ptr, ub_checks}; #[rustc_const_stable(feature = "const_slice_from_raw_parts", since = "1.64.0")] #[must_use] #[rustc_diagnostic_item = "slice_from_raw_parts"] +#[track_caller] pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { // SAFETY: the caller must uphold the safety contract for `from_raw_parts`. unsafe { @@ -174,6 +175,7 @@ pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] #[rustc_const_unstable(feature = "const_slice_from_raw_parts_mut", issue = "67456")] #[must_use] #[rustc_diagnostic_item = "slice_from_raw_parts_mut"] +#[track_caller] pub const unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] { // SAFETY: the caller must uphold the safety contract for `from_raw_parts_mut`. unsafe { diff --git a/library/core/src/ub_checks.rs b/library/core/src/ub_checks.rs index c1a8c34539e6c..c07069725f6e6 100644 --- a/library/core/src/ub_checks.rs +++ b/library/core/src/ub_checks.rs @@ -65,6 +65,7 @@ macro_rules! assert_unsafe_precondition { #[inline] #[rustc_nounwind] #[rustc_const_unstable(feature = "const_ub_checks", issue = "none")] + #[track_caller] const fn precondition_check($($name:$ty),*) { if !$e { ::core::panicking::panic_nounwind( diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir index 220e881f86645..afd9999cd3fcc 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir @@ -9,7 +9,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> scope 1 (inlined core::slice::::get_unchecked_mut::>) { let mut _5: *mut [u32]; let mut _11: *mut [u32]; - scope 2 (inlined as SliceIndex<[u32]>>::get_unchecked_mut) { + scope 2 (inlined #[track_caller] as SliceIndex<[u32]>>::get_unchecked_mut) { let mut _6: usize; let _7: (); let _8: usize; diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir index 1e0df94b67fb1..e34723898e4ac 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir @@ -7,7 +7,7 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - let mut _3: usize; let mut _4: usize; scope 1 (inlined std::ptr::const_ptr::::get_unchecked::>) { - scope 2 (inlined as SliceIndex<[u32]>>::get_unchecked) { + scope 2 (inlined #[track_caller] as SliceIndex<[u32]>>::get_unchecked) { let mut _5: usize; let _6: (); let _7: usize; diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir index ce1e4a0abd61f..ffd83b8db44a1 100644 --- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir @@ -48,7 +48,7 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { } } } - scope 13 (inlined std::slice::from_raw_parts::<'_, u8>) { + scope 13 (inlined #[track_caller] std::slice::from_raw_parts::<'_, u8>) { debug data => _5; debug len => _7; let _8: *const [u8]; 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. From 6ba38e6db0b6237e12375d96d956769c14da25ac Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 1 Sep 2024 17:25:08 -0400 Subject: [PATCH 2/2] Add #[track_caller] to all ub-checked functions --- library/core/src/alloc/layout.rs | 1 + library/core/src/ascii/ascii_char.rs | 1 + library/core/src/char/convert.rs | 1 + library/core/src/hint.rs | 2 +- library/core/src/intrinsics.rs | 6 +++--- library/core/src/num/int_macros.rs | 12 ++++++------ library/core/src/num/nonzero.rs | 2 ++ library/core/src/num/uint_macros.rs | 10 +++++----- library/core/src/ops/index_range.rs | 1 + library/core/src/ptr/alignment.rs | 1 + library/core/src/ptr/const_ptr.rs | 2 +- library/core/src/ptr/mod.rs | 10 ++++++---- library/core/src/ptr/non_null.rs | 1 + library/core/src/slice/mod.rs | 5 +++++ library/core/src/str/traits.rs | 4 ++++ ...ain.DataflowConstProp.32bit.panic-abort.diff | 2 +- ...in.DataflowConstProp.32bit.panic-unwind.diff | 2 +- ...ain.DataflowConstProp.64bit.panic-abort.diff | 2 +- ...in.DataflowConstProp.64bit.panic-unwind.diff | 2 +- ..._boxed_slice.main.GVN.32bit.panic-abort.diff | 2 +- ...boxed_slice.main.GVN.32bit.panic-unwind.diff | 2 +- ..._boxed_slice.main.GVN.64bit.panic-abort.diff | 2 +- ...boxed_slice.main.GVN.64bit.panic-unwind.diff | 2 +- tests/mir-opt/inline/unchecked_shifts.rs | 4 ++-- ...shl_unsigned_smaller.Inline.panic-abort.diff | 2 +- ...hl_unsigned_smaller.Inline.panic-unwind.diff | 2 +- ...ned_smaller.PreCodegen.after.panic-abort.mir | 2 +- ...ed_smaller.PreCodegen.after.panic-unwind.mir | 2 +- ...ed_shr_signed_bigger.Inline.panic-abort.diff | 2 +- ...d_shr_signed_bigger.Inline.panic-unwind.diff | 2 +- ...gned_bigger.PreCodegen.after.panic-abort.mir | 2 +- ...ned_bigger.PreCodegen.after.panic-unwind.mir | 2 +- ...ked.unwrap_unchecked.Inline.panic-abort.diff | 2 +- ...ed.unwrap_unchecked.Inline.panic-unwind.diff | 2 +- ...p_unchecked.PreCodegen.after.panic-abort.mir | 2 +- ..._unchecked.PreCodegen.after.panic-unwind.mir | 2 +- ...nchecked.InstSimplify-after-simplifycfg.diff | 2 +- ...checked_shl.PreCodegen.after.panic-abort.mir | 2 +- ...hecked_shl.PreCodegen.after.panic-unwind.mir | 2 +- ..._switch_targets.ub_if_b.PreCodegen.after.mir | 2 +- ...mem_replace.PreCodegen.after.panic-abort.mir | 4 ++-- ...em_replace.PreCodegen.after.panic-unwind.mir | 4 ++-- ...d_mut_range.PreCodegen.after.panic-abort.mir | 2 +- ...ecked_range.PreCodegen.after.panic-abort.mir | 2 +- ...ef_to_slice.PreCodegen.after.panic-abort.mir | 2 +- tests/ui/const-ptr/forbidden_slices.stderr | 15 ++++----------- tests/ui/const-ptr/out_of_bounds_read.stderr | 17 +++-------------- .../ui/consts/const-eval/raw-pointer-ub.stderr | 4 +--- tests/ui/consts/const-eval/ub-ref-ptr.stderr | 4 +--- .../consts/const_unsafe_unreachable_ub.stderr | 7 +++---- tests/ui/consts/issue-miri-1910.stderr | 4 +--- .../ui/consts/missing_span_in_backtrace.stderr | 4 ---- .../interpret-in-promoted.noopt.stderr | 7 +++---- .../interpret-in-promoted.opt.stderr | 7 +++---- .../required-consts/interpret-in-promoted.rs | 2 +- tests/ui/print_type_sizes/niche-filling.stdout | 4 ++++ 56 files changed, 96 insertions(+), 104 deletions(-) diff --git a/library/core/src/alloc/layout.rs b/library/core/src/alloc/layout.rs index ad3f9d8087897..fbf9d7b172076 100644 --- a/library/core/src/alloc/layout.rs +++ b/library/core/src/alloc/layout.rs @@ -123,6 +123,7 @@ impl Layout { #[must_use] #[inline] #[rustc_allow_const_fn_unstable(ptr_alignment_type)] + #[track_caller] pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self { assert_unsafe_precondition!( check_library_ub, diff --git a/library/core/src/ascii/ascii_char.rs b/library/core/src/ascii/ascii_char.rs index ce09a0b444da3..7e695b9280df1 100644 --- a/library/core/src/ascii/ascii_char.rs +++ b/library/core/src/ascii/ascii_char.rs @@ -503,6 +503,7 @@ impl AsciiChar { /// something useful. It might be tightened before stabilization.) #[unstable(feature = "ascii_char", issue = "110998")] #[inline] + #[track_caller] pub const unsafe fn digit_unchecked(d: u8) -> Self { assert_unsafe_precondition!( check_language_ub, diff --git a/library/core/src/char/convert.rs b/library/core/src/char/convert.rs index f0c2636307fcf..fc7e1fa4d67e1 100644 --- a/library/core/src/char/convert.rs +++ b/library/core/src/char/convert.rs @@ -21,6 +21,7 @@ pub(super) const fn from_u32(i: u32) -> Option { /// Converts a `u32` to a `char`, ignoring validity. See [`char::from_u32_unchecked`]. #[inline] #[must_use] +#[track_caller] pub(super) const unsafe fn from_u32_unchecked(i: u32) -> char { // SAFETY: the caller must guarantee that `i` is a valid char value. unsafe { diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs index 6ca5e53df3b01..84b03542bc338 100644 --- a/library/core/src/hint.rs +++ b/library/core/src/hint.rs @@ -96,7 +96,7 @@ use crate::{intrinsics, ub_checks}; #[inline] #[stable(feature = "unreachable", since = "1.27.0")] #[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")] -#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces +#[track_caller] pub const unsafe fn unreachable_unchecked() -> ! { ub_checks::assert_unsafe_precondition!( check_language_ub, diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 8cb9accd59db4..e34524334eea3 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -3295,7 +3295,7 @@ pub const fn ptr_metadata + ?Sized, M>(_ptr: *cons #[rustc_allowed_through_unstable_modules] #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] #[inline(always)] -#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces +#[track_caller] #[rustc_diagnostic_item = "ptr_copy_nonoverlapping"] pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { extern "rust-intrinsic" { @@ -3397,7 +3397,7 @@ pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: us #[rustc_allowed_through_unstable_modules] #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] #[inline(always)] -#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces +#[track_caller] #[rustc_diagnostic_item = "ptr_copy"] pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { extern "rust-intrinsic" { @@ -3477,7 +3477,7 @@ pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { #[rustc_allowed_through_unstable_modules] #[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")] #[inline(always)] -#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces +#[track_caller] #[rustc_diagnostic_item = "ptr_write_bytes"] pub const unsafe fn write_bytes(dst: *mut T, val: u8, count: usize) { extern "rust-intrinsic" { diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 878a911dde50d..b870db8d5a35f 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -510,7 +510,7 @@ macro_rules! int_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn unchecked_add(self, rhs: Self) -> Self { assert_unsafe_precondition!( check_language_ub, @@ -662,7 +662,7 @@ macro_rules! int_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self { assert_unsafe_precondition!( check_language_ub, @@ -814,7 +814,7 @@ macro_rules! int_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self { assert_unsafe_precondition!( check_language_ub, @@ -1163,7 +1163,7 @@ macro_rules! int_impl { without modifying the original"] #[rustc_const_unstable(feature = "unchecked_neg", issue = "85122")] #[inline(always)] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn unchecked_neg(self) -> Self { assert_unsafe_precondition!( check_language_ub, @@ -1296,7 +1296,7 @@ macro_rules! int_impl { without modifying the original"] #[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")] #[inline(always)] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn unchecked_shl(self, rhs: u32) -> Self { assert_unsafe_precondition!( check_language_ub, @@ -1422,7 +1422,7 @@ macro_rules! int_impl { without modifying the original"] #[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")] #[inline(always)] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn unchecked_shr(self, rhs: u32) -> Self { assert_unsafe_precondition!( check_language_ub, diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 8b888f12da0b1..d8d2ed9613d0b 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -364,6 +364,7 @@ where #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] #[must_use] #[inline] + #[track_caller] pub const unsafe fn new_unchecked(n: T) -> Self { match Self::new(n) { Some(n) => n, @@ -404,6 +405,7 @@ where #[unstable(feature = "nonzero_from_mut", issue = "106290")] #[must_use] #[inline] + #[track_caller] pub unsafe fn from_mut_unchecked(n: &mut T) -> &mut Self { match Self::from_mut(n) { Some(n) => n, diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index d9036abecc592..5c14bbd74840e 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -557,7 +557,7 @@ macro_rules! uint_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn unchecked_add(self, rhs: Self) -> Self { assert_unsafe_precondition!( check_language_ub, @@ -749,7 +749,7 @@ macro_rules! uint_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self { assert_unsafe_precondition!( check_language_ub, @@ -906,7 +906,7 @@ macro_rules! uint_impl { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self { assert_unsafe_precondition!( check_language_ub, @@ -1485,7 +1485,7 @@ macro_rules! uint_impl { without modifying the original"] #[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")] #[inline(always)] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn unchecked_shl(self, rhs: u32) -> Self { assert_unsafe_precondition!( check_language_ub, @@ -1611,7 +1611,7 @@ macro_rules! uint_impl { without modifying the original"] #[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")] #[inline(always)] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn unchecked_shr(self, rhs: u32) -> Self { assert_unsafe_precondition!( check_language_ub, diff --git a/library/core/src/ops/index_range.rs b/library/core/src/ops/index_range.rs index 64214eae377dd..f1656078cd066 100644 --- a/library/core/src/ops/index_range.rs +++ b/library/core/src/ops/index_range.rs @@ -18,6 +18,7 @@ impl IndexRange { /// # Safety /// - `start <= end` #[inline] + #[track_caller] pub const unsafe fn new_unchecked(start: usize, end: usize) -> Self { ub_checks::assert_unsafe_precondition!( check_library_ub, diff --git a/library/core/src/ptr/alignment.rs b/library/core/src/ptr/alignment.rs index 19fe03d57cc0a..459a4147bad4f 100644 --- a/library/core/src/ptr/alignment.rs +++ b/library/core/src/ptr/alignment.rs @@ -75,6 +75,7 @@ impl Alignment { #[unstable(feature = "ptr_alignment_type", issue = "102070")] #[rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070")] #[inline] + #[track_caller] pub const unsafe fn new_unchecked(align: usize) -> Self { assert_unsafe_precondition!( check_language_ub, diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 3b635e2a4aa9e..2c24620fc3dc4 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -713,7 +713,7 @@ impl *const T { #[unstable(feature = "ptr_sub_ptr", issue = "95892")] #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] #[inline] - #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[track_caller] pub const unsafe fn sub_ptr(self, origin: *const T) -> usize where T: Sized, diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index d7ed4edcc0041..4a749afe93810 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -1138,6 +1138,7 @@ pub const unsafe fn swap(x: *mut T, y: *mut T) { #[stable(feature = "swap_nonoverlapping", since = "1.27.0")] #[rustc_const_unstable(feature = "const_swap", issue = "83163")] #[rustc_diagnostic_item = "ptr_swap_nonoverlapping"] +#[track_caller] pub const unsafe fn swap_nonoverlapping(x: *mut T, y: *mut T, count: usize) { #[allow(unused)] macro_rules! attempt_swap_as_chunks { @@ -1268,6 +1269,7 @@ const unsafe fn swap_nonoverlapping_simple_untyped(x: *mut T, y: *mut T, coun #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_replace", issue = "83164")] #[rustc_diagnostic_item = "ptr_replace"] +#[track_caller] pub const unsafe fn replace(dst: *mut T, src: T) -> T { // SAFETY: the caller must guarantee that `dst` is valid to be // cast to a mutable reference (valid for writes, aligned, initialized), @@ -1394,7 +1396,7 @@ pub const unsafe fn replace(dst: *mut T, src: T) -> T { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_ptr_read", since = "1.71.0")] -#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces +#[track_caller] #[rustc_diagnostic_item = "ptr_read"] pub const unsafe fn read(src: *const T) -> T { // It would be semantically correct to implement this via `copy_nonoverlapping` @@ -1620,7 +1622,7 @@ pub const unsafe fn read_unaligned(src: *const T) -> T { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")] #[rustc_diagnostic_item = "ptr_write"] -#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces +#[track_caller] pub const unsafe fn write(dst: *mut T, src: T) { // Semantically, it would be fine for this to be implemented as a // `copy_nonoverlapping` and appropriate drop suppression of `src`. @@ -1802,7 +1804,7 @@ pub const unsafe fn write_unaligned(dst: *mut T, src: T) { /// ``` #[inline] #[stable(feature = "volatile", since = "1.9.0")] -#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces +#[track_caller] #[rustc_diagnostic_item = "ptr_read_volatile"] pub unsafe fn read_volatile(src: *const T) -> T { // SAFETY: the caller must uphold the safety contract for `volatile_load`. @@ -1882,7 +1884,7 @@ pub unsafe fn read_volatile(src: *const T) -> T { #[inline] #[stable(feature = "volatile", since = "1.9.0")] #[rustc_diagnostic_item = "ptr_write_volatile"] -#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces +#[track_caller] pub unsafe fn write_volatile(dst: *mut T, src: T) { // SAFETY: the caller must uphold the safety contract for `volatile_store`. unsafe { diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index b1429fff74434..08b24c1a05c06 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -192,6 +192,7 @@ impl NonNull { #[stable(feature = "nonnull", since = "1.25.0")] #[rustc_const_stable(feature = "const_nonnull_new_unchecked", since = "1.25.0")] #[inline] + #[track_caller] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { // SAFETY: the caller must guarantee that `ptr` is non-null. unsafe { diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index c7918499d4ab9..f16d94203da3d 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -923,6 +923,7 @@ impl [T] { /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html #[unstable(feature = "slice_swap_unchecked", issue = "88539")] #[rustc_const_unstable(feature = "const_swap", issue = "83163")] + #[track_caller] pub const unsafe fn swap_unchecked(&mut self, a: usize, b: usize) { assert_unsafe_precondition!( check_library_ub, @@ -1268,6 +1269,7 @@ impl [T] { #[unstable(feature = "slice_as_chunks", issue = "74985")] #[inline] #[must_use] + #[track_caller] pub const unsafe fn as_chunks_unchecked(&self) -> &[[T; N]] { assert_unsafe_precondition!( check_language_ub, @@ -1425,6 +1427,7 @@ impl [T] { #[unstable(feature = "slice_as_chunks", issue = "74985")] #[inline] #[must_use] + #[track_caller] pub const unsafe fn as_chunks_unchecked_mut(&mut self) -> &mut [[T; N]] { assert_unsafe_precondition!( check_language_ub, @@ -1951,6 +1954,7 @@ impl [T] { #[rustc_const_stable(feature = "const_slice_split_at_unchecked", since = "1.77.0")] #[inline] #[must_use] + #[track_caller] pub const unsafe fn split_at_unchecked(&self, mid: usize) -> (&[T], &[T]) { // HACK: the const function `from_raw_parts` is used to make this // function const; previously the implementation used @@ -2004,6 +2008,7 @@ impl [T] { #[rustc_const_unstable(feature = "const_slice_split_at_mut", issue = "101804")] #[inline] #[must_use] + #[track_caller] pub const unsafe fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut [T], &mut [T]) { let len = self.len(); let ptr = self.as_mut_ptr(); diff --git a/library/core/src/str/traits.rs b/library/core/src/str/traits.rs index b69c476ae5e53..bede1b3cb12aa 100644 --- a/library/core/src/str/traits.rs +++ b/library/core/src/str/traits.rs @@ -188,6 +188,7 @@ unsafe impl SliceIndex for ops::Range { } } #[inline] + #[track_caller] unsafe fn get_unchecked(self, slice: *const str) -> *const Self::Output { let slice = slice as *const [u8]; @@ -215,6 +216,7 @@ unsafe impl SliceIndex for ops::Range { } } #[inline] + #[track_caller] unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut Self::Output { let slice = slice as *mut [u8]; @@ -290,6 +292,7 @@ unsafe impl SliceIndex for range::Range { } } #[inline] + #[track_caller] unsafe fn get_unchecked(self, slice: *const str) -> *const Self::Output { let slice = slice as *const [u8]; @@ -317,6 +320,7 @@ unsafe impl SliceIndex for range::Range { } } #[inline] + #[track_caller] unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut Self::Output { let slice = slice as *mut [u8]; diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff index 4097e060f4d47..80a9eefe087e7 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff @@ -18,7 +18,7 @@ scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { + scope 10 (inlined #[track_caller] NonNull::<[bool; 0]>::new_unchecked) { let mut _8: bool; let _9: (); let mut _10: *mut (); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index ff44d0df5e3e9..b6d91cfb9ea7a 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff @@ -18,7 +18,7 @@ scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { + scope 10 (inlined #[track_caller] NonNull::<[bool; 0]>::new_unchecked) { let mut _8: bool; let _9: (); let mut _10: *mut (); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index 3662c3b59d271..aa5d26b9ad113 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff @@ -18,7 +18,7 @@ scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { + scope 10 (inlined #[track_caller] NonNull::<[bool; 0]>::new_unchecked) { let mut _8: bool; let _9: (); let mut _10: *mut (); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index 68dee57dee9e0..1b58c4c9e09b0 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff @@ -18,7 +18,7 @@ scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { + scope 10 (inlined #[track_caller] NonNull::<[bool; 0]>::new_unchecked) { let mut _8: bool; let _9: (); let mut _10: *mut (); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff index c7870a7902b98..6662bd69b9ec1 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff @@ -18,7 +18,7 @@ scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { + scope 10 (inlined #[track_caller] NonNull::<[bool; 0]>::new_unchecked) { let mut _8: bool; let _9: (); let mut _10: *mut (); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff index f5de7a361bc10..ddb8324a73e11 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff @@ -18,7 +18,7 @@ scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { + scope 10 (inlined #[track_caller] NonNull::<[bool; 0]>::new_unchecked) { let mut _8: bool; let _9: (); let mut _10: *mut (); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff index 3b0bc6377da62..2b2b5f258dcb6 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff @@ -18,7 +18,7 @@ scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { + scope 10 (inlined #[track_caller] NonNull::<[bool; 0]>::new_unchecked) { let mut _8: bool; let _9: (); let mut _10: *mut (); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff index 5dd7ad9a11773..a7dee9a1dc800 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff @@ -18,7 +18,7 @@ scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { + scope 10 (inlined #[track_caller] NonNull::<[bool; 0]>::new_unchecked) { let mut _8: bool; let _9: (); let mut _10: *mut (); diff --git a/tests/mir-opt/inline/unchecked_shifts.rs b/tests/mir-opt/inline/unchecked_shifts.rs index 3c4e73bf7ea6c..122f099da4b7d 100644 --- a/tests/mir-opt/inline/unchecked_shifts.rs +++ b/tests/mir-opt/inline/unchecked_shifts.rs @@ -11,7 +11,7 @@ // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 { // CHECK-LABEL: fn unchecked_shl_unsigned_smaller( - // CHECK: (inlined core::num::::unchecked_shl) + // CHECK: (inlined #[track_caller] core::num::::unchecked_shl) a.unchecked_shl(b) } @@ -19,6 +19,6 @@ pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 { // EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.mir pub unsafe fn unchecked_shr_signed_bigger(a: i64, b: u32) -> i64 { // CHECK-LABEL: fn unchecked_shr_signed_bigger( - // CHECK: (inlined core::num::::unchecked_shr) + // CHECK: (inlined #[track_caller] core::num::::unchecked_shr) a.unchecked_shr(b) } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff index f36157a762c27..110bc99271fbc 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff @@ -7,7 +7,7 @@ let mut _0: u16; let mut _3: u16; let mut _4: u32; -+ scope 1 (inlined core::num::::unchecked_shl) { ++ scope 1 (inlined #[track_caller] core::num::::unchecked_shl) { + let mut _5: bool; + let _6: (); + scope 2 (inlined core::ub_checks::check_language_ub) { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff index be1b066c6c1b4..3d34da779d9e5 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff @@ -7,7 +7,7 @@ let mut _0: u16; let mut _3: u16; let mut _4: u32; -+ scope 1 (inlined core::num::::unchecked_shl) { ++ scope 1 (inlined #[track_caller] core::num::::unchecked_shl) { + let mut _5: bool; + let _6: (); + scope 2 (inlined core::ub_checks::check_language_ub) { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir index 611273ab08d74..0fc7c4b7947e2 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir @@ -4,7 +4,7 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { debug a => _1; debug b => _2; let mut _0: u16; - scope 1 (inlined core::num::::unchecked_shl) { + scope 1 (inlined #[track_caller] core::num::::unchecked_shl) { scope 2 (inlined core::ub_checks::check_language_ub) { scope 3 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir index 611273ab08d74..0fc7c4b7947e2 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir @@ -4,7 +4,7 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { debug a => _1; debug b => _2; let mut _0: u16; - scope 1 (inlined core::num::::unchecked_shl) { + scope 1 (inlined #[track_caller] core::num::::unchecked_shl) { scope 2 (inlined core::ub_checks::check_language_ub) { scope 3 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff index 360687f3c4e7f..fe3a252bbf09c 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff @@ -7,7 +7,7 @@ let mut _0: i64; let mut _3: i64; let mut _4: u32; -+ scope 1 (inlined core::num::::unchecked_shr) { ++ scope 1 (inlined #[track_caller] core::num::::unchecked_shr) { + let mut _5: bool; + let _6: (); + scope 2 (inlined core::ub_checks::check_language_ub) { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff index 986df55df0372..bb8d6630c916a 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff @@ -7,7 +7,7 @@ let mut _0: i64; let mut _3: i64; let mut _4: u32; -+ scope 1 (inlined core::num::::unchecked_shr) { ++ scope 1 (inlined #[track_caller] core::num::::unchecked_shr) { + let mut _5: bool; + let _6: (); + scope 2 (inlined core::ub_checks::check_language_ub) { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir index f4ddd0bca04d9..bef7fa7b1df75 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir @@ -4,7 +4,7 @@ fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 { debug a => _1; debug b => _2; let mut _0: i64; - scope 1 (inlined core::num::::unchecked_shr) { + scope 1 (inlined #[track_caller] core::num::::unchecked_shr) { scope 2 (inlined core::ub_checks::check_language_ub) { scope 3 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir index f4ddd0bca04d9..bef7fa7b1df75 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir @@ -4,7 +4,7 @@ fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 { debug a => _1; debug b => _2; let mut _0: i64; - scope 1 (inlined core::num::::unchecked_shr) { + scope 1 (inlined #[track_caller] core::num::::unchecked_shr) { scope 2 (inlined core::ub_checks::check_language_ub) { scope 3 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff index 28878736ed7cd..8428acc1838cc 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff @@ -9,7 +9,7 @@ + let mut _3: isize; + scope 2 { + } -+ scope 3 (inlined unreachable_unchecked) { ++ scope 3 (inlined #[track_caller] unreachable_unchecked) { + let mut _4: bool; + let _5: (); + scope 4 (inlined core::ub_checks::check_language_ub) { diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff index 27b6bb6a5bb23..30c12c06e119e 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff @@ -9,7 +9,7 @@ + let mut _3: isize; + scope 2 { + } -+ scope 3 (inlined unreachable_unchecked) { ++ scope 3 (inlined #[track_caller] unreachable_unchecked) { + let mut _4: bool; + let _5: (); + scope 4 (inlined core::ub_checks::check_language_ub) { diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir index 66ab5e1b96228..b7b892c177c3e 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir @@ -7,7 +7,7 @@ fn unwrap_unchecked(_1: Option) -> T { let mut _2: isize; scope 2 { } - scope 3 (inlined unreachable_unchecked) { + scope 3 (inlined #[track_caller] unreachable_unchecked) { scope 4 (inlined core::ub_checks::check_language_ub) { scope 5 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir index 66ab5e1b96228..b7b892c177c3e 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir @@ -7,7 +7,7 @@ fn unwrap_unchecked(_1: Option) -> T { let mut _2: isize; scope 2 { } - scope 3 (inlined unreachable_unchecked) { + scope 3 (inlined #[track_caller] unreachable_unchecked) { scope 4 (inlined core::ub_checks::check_language_ub) { scope 5 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff index 5fee9a6733dd0..35ad3bbef0074 100644 --- a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff +++ b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff @@ -9,7 +9,7 @@ let mut _3: isize; scope 2 { } - scope 3 (inlined unreachable_unchecked) { + scope 3 (inlined #[track_caller] unreachable_unchecked) { let mut _4: bool; let _5: (); scope 4 (inlined core::ub_checks::check_language_ub) { diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir index a9dd8886577dd..18eeb8e4d3b61 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir @@ -7,7 +7,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option { scope 1 (inlined core::num::::checked_shl) { let mut _3: bool; let mut _4: u32; - scope 2 (inlined core::num::::unchecked_shl) { + scope 2 (inlined #[track_caller] core::num::::unchecked_shl) { scope 3 (inlined core::ub_checks::check_language_ub) { scope 4 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir index a9dd8886577dd..18eeb8e4d3b61 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir @@ -7,7 +7,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option { scope 1 (inlined core::num::::checked_shl) { let mut _3: bool; let mut _4: u32; - scope 2 (inlined core::num::::unchecked_shl) { + scope 2 (inlined #[track_caller] core::num::::unchecked_shl) { scope 3 (inlined core::ub_checks::check_language_ub) { scope 4 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir index 518fedffc1698..8a6732d5f745a 100644 --- a/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir @@ -4,7 +4,7 @@ fn ub_if_b(_1: Thing) -> Thing { debug t => _1; let mut _0: Thing; let mut _2: isize; - scope 1 (inlined unreachable_unchecked) { + scope 1 (inlined #[track_caller] unreachable_unchecked) { scope 2 (inlined core::ub_checks::check_language_ub) { scope 3 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir index ed494f6e74cf3..a5e3da2a30c30 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir @@ -6,10 +6,10 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { let mut _0: u32; scope 1 (inlined std::mem::replace::) { scope 2 { - scope 4 (inlined std::ptr::write::) { + scope 4 (inlined #[track_caller] std::ptr::write::) { } } - scope 3 (inlined std::ptr::read::) { + scope 3 (inlined #[track_caller] std::ptr::read::) { } } diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir index ed494f6e74cf3..a5e3da2a30c30 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir @@ -6,10 +6,10 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { let mut _0: u32; scope 1 (inlined std::mem::replace::) { scope 2 { - scope 4 (inlined std::ptr::write::) { + scope 4 (inlined #[track_caller] std::ptr::write::) { } } - scope 3 (inlined std::ptr::read::) { + scope 3 (inlined #[track_caller] std::ptr::read::) { } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir index 220e881f86645..afd9999cd3fcc 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir @@ -9,7 +9,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range) -> scope 1 (inlined core::slice::::get_unchecked_mut::>) { let mut _5: *mut [u32]; let mut _11: *mut [u32]; - scope 2 (inlined as SliceIndex<[u32]>>::get_unchecked_mut) { + scope 2 (inlined #[track_caller] as SliceIndex<[u32]>>::get_unchecked_mut) { let mut _6: usize; let _7: (); let _8: usize; diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir index 1e0df94b67fb1..e34723898e4ac 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir @@ -7,7 +7,7 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range) - let mut _3: usize; let mut _4: usize; scope 1 (inlined std::ptr::const_ptr::::get_unchecked::>) { - scope 2 (inlined as SliceIndex<[u32]>>::get_unchecked) { + scope 2 (inlined #[track_caller] as SliceIndex<[u32]>>::get_unchecked) { let mut _5: usize; let _6: (); let _7: usize; diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir index ce1e4a0abd61f..ffd83b8db44a1 100644 --- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir @@ -48,7 +48,7 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { } } } - scope 13 (inlined std::slice::from_raw_parts::<'_, u8>) { + scope 13 (inlined #[track_caller] std::slice::from_raw_parts::<'_, u8>) { debug data => _5; debug len => _7; let _8: *const [u8]; diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index fad078ad2b2bd..b98e100aedaae 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -100,12 +100,10 @@ LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) } } error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | - = note: the evaluated program panicked at 'assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize', $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + = note: the evaluated program panicked at 'assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize', $SRC_DIR/core/src/slice/raw.rs:LL:COL | -note: inside `std::ptr::const_ptr::::sub_ptr` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `from_ptr_range::<'_, ()>` --> $SRC_DIR/core/src/slice/raw.rs:LL:COL note: inside `R1` @@ -113,7 +111,6 @@ note: inside `R1` | LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -188,12 +185,10 @@ LL | from_ptr_range(ptr..ptr.add(1)) | ^^^^^^^^^^ error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | = note: `ptr_offset_from_unsigned` called on pointers into different allocations | -note: inside `std::ptr::const_ptr::::sub_ptr` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `from_ptr_range::<'_, u32>` --> $SRC_DIR/core/src/slice/raw.rs:LL:COL note: inside `R9` @@ -203,12 +198,10 @@ LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).ad | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $SRC_DIR/core/src/slice/raw.rs:LL:COL | = note: `ptr_offset_from_unsigned` called on pointers into different allocations | -note: inside `std::ptr::const_ptr::::sub_ptr` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `from_ptr_range::<'_, u32>` --> $SRC_DIR/core/src/slice/raw.rs:LL:COL note: inside `R10` diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index 7f354963eb1fd..1918807888771 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -1,23 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL - | - = note: memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes - | -note: inside `std::ptr::read::` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `_READ` --> $DIR/out_of_bounds_read.rs:10:33 | LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | = note: memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | -note: inside `std::ptr::read::` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::const_ptr::::read` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `_CONST_READ` @@ -27,12 +18,10 @@ LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; | ^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL | = note: memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | -note: inside `std::ptr::read::` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::mut_ptr::::read` --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL note: inside `_MUT_READ` diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr index aeb46725c0642..9234e4b45d1a2 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -11,12 +11,10 @@ LL | *ptr = 0; | ^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/intrinsics.rs:LL:COL + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | = note: accessing memory with alignment 1, but alignment 4 is required | -note: inside `copy_nonoverlapping::` - --> $SRC_DIR/core/src/intrinsics.rs:LL:COL note: inside `std::ptr::const_ptr::::copy_to_nonoverlapping` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `MISALIGNED_COPY` diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index 3bbf2977392c0..db79c2dbd8717 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -149,12 +149,10 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; } error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | = note: accessing memory based on pointer with alignment 1, but alignment 4 is required | -note: inside `std::ptr::read::` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::const_ptr::::read` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `UNALIGNED_READ` diff --git a/tests/ui/consts/const_unsafe_unreachable_ub.stderr b/tests/ui/consts/const_unsafe_unreachable_ub.stderr index 6394563e2bb87..c1be7f72ba979 100644 --- a/tests/ui/consts/const_unsafe_unreachable_ub.stderr +++ b/tests/ui/consts/const_unsafe_unreachable_ub.stderr @@ -1,10 +1,9 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/hint.rs:LL:COL + --> $DIR/const_unsafe_unreachable_ub.rs:6:18 | - = note: entering unreachable code +LL | false => std::hint::unreachable_unchecked(), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entering unreachable code | -note: inside `unreachable_unchecked` - --> $SRC_DIR/core/src/hint.rs:LL:COL note: inside `foo` --> $DIR/const_unsafe_unreachable_ub.rs:6:18 | diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index 32beed5dba095..5a9482d7d0e38 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -1,10 +1,8 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | = note: unable to turn pointer into integer | -note: inside `std::ptr::read::` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::const_ptr::::read` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `C` diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index 9e0506e7e386c..f3cebe7a3e08a 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -3,12 +3,8 @@ error[E0080]: evaluation of constant value failed | = note: unable to copy parts of a pointer from memory at ALLOC0 | -note: inside `std::ptr::read::>>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::swap_nonoverlapping_simple_untyped::>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `swap_nonoverlapping::>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `X` --> $DIR/missing_span_in_backtrace.rs:17:9 | diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr index 6ab991b647196..3536847415e39 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr @@ -1,10 +1,9 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/hint.rs:LL:COL + --> $DIR/interpret-in-promoted.rs:7:5 | - = note: entering unreachable code +LL | std::hint::unreachable_unchecked(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entering unreachable code | -note: inside `unreachable_unchecked` - --> $SRC_DIR/core/src/hint.rs:LL:COL note: inside `ub` --> $DIR/interpret-in-promoted.rs:7:5 | diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr index 6ab991b647196..3536847415e39 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr @@ -1,10 +1,9 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/hint.rs:LL:COL + --> $DIR/interpret-in-promoted.rs:7:5 | - = note: entering unreachable code +LL | std::hint::unreachable_unchecked(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entering unreachable code | -note: inside `unreachable_unchecked` - --> $SRC_DIR/core/src/hint.rs:LL:COL note: inside `ub` --> $DIR/interpret-in-promoted.rs:7:5 | diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.rs b/tests/ui/consts/required-consts/interpret-in-promoted.rs index 48caece6ff56f..abe26cfe9a9e0 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.rs +++ b/tests/ui/consts/required-consts/interpret-in-promoted.rs @@ -4,7 +4,7 @@ //! Make sure we evaluate const fn calls even if they get promoted and their result ignored. const unsafe fn ub() { - std::hint::unreachable_unchecked(); + std::hint::unreachable_unchecked(); //~ evaluation of constant value failed } pub const FOO: () = unsafe { diff --git a/tests/ui/print_type_sizes/niche-filling.stdout b/tests/ui/print_type_sizes/niche-filling.stdout index eeb5de5324121..22de9ffd74af0 100644 --- a/tests/ui/print_type_sizes/niche-filling.stdout +++ b/tests/ui/print_type_sizes/niche-filling.stdout @@ -1,3 +1,7 @@ +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.file`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes print-type-size type: `IndirectNonZero`: 12 bytes, alignment: 4 bytes print-type-size field `.nested`: 8 bytes print-type-size field `.post`: 2 bytes