Skip to content

Commit d0c6fc5

Browse files
committed
Back up to just addding track_caller to panic_nounwind
1 parent 4b9eeb5 commit d0c6fc5

File tree

62 files changed

+107
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+107
-105
lines changed

library/core/src/alloc/layout.rs

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ impl Layout {
123123
#[must_use]
124124
#[inline]
125125
#[rustc_allow_const_fn_unstable(ptr_alignment_type)]
126-
#[track_caller]
127126
pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
128127
assert_unsafe_precondition!(
129128
check_library_ub,

library/core/src/ascii/ascii_char.rs

-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,6 @@ impl AsciiChar {
503503
/// something useful. It might be tightened before stabilization.)
504504
#[unstable(feature = "ascii_char", issue = "110998")]
505505
#[inline]
506-
#[track_caller]
507506
pub const unsafe fn digit_unchecked(d: u8) -> Self {
508507
assert_unsafe_precondition!(
509508
check_language_ub,

library/core/src/char/convert.rs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub(super) const fn from_u32(i: u32) -> Option<char> {
2121
/// Converts a `u32` to a `char`, ignoring validity. See [`char::from_u32_unchecked`].
2222
#[inline]
2323
#[must_use]
24-
#[track_caller]
2524
pub(super) const unsafe fn from_u32_unchecked(i: u32) -> char {
2625
// SAFETY: the caller must guarantee that `i` is a valid char value.
2726
unsafe {

library/core/src/hint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ use crate::{intrinsics, ub_checks};
9797
#[inline]
9898
#[stable(feature = "unreachable", since = "1.27.0")]
9999
#[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")]
100-
#[track_caller]
100+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
101101
pub const unsafe fn unreachable_unchecked() -> ! {
102102
ub_checks::assert_unsafe_precondition!(
103103
check_language_ub,

library/core/src/intrinsics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3295,7 +3295,7 @@ pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(_ptr: *cons
32953295
#[rustc_allowed_through_unstable_modules]
32963296
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
32973297
#[inline(always)]
3298-
#[track_caller]
3298+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
32993299
#[rustc_diagnostic_item = "ptr_copy_nonoverlapping"]
33003300
pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
33013301
extern "rust-intrinsic" {
@@ -3397,7 +3397,7 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
33973397
#[rustc_allowed_through_unstable_modules]
33983398
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
33993399
#[inline(always)]
3400-
#[track_caller]
3400+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
34013401
#[rustc_diagnostic_item = "ptr_copy"]
34023402
pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
34033403
extern "rust-intrinsic" {
@@ -3477,7 +3477,7 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
34773477
#[rustc_allowed_through_unstable_modules]
34783478
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
34793479
#[inline(always)]
3480-
#[track_caller]
3480+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
34813481
#[rustc_diagnostic_item = "ptr_write_bytes"]
34823482
pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
34833483
extern "rust-intrinsic" {

library/core/src/num/int_macros.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ macro_rules! int_impl {
510510
#[must_use = "this returns the result of the operation, \
511511
without modifying the original"]
512512
#[inline(always)]
513-
#[track_caller]
513+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
514514
pub const unsafe fn unchecked_add(self, rhs: Self) -> Self {
515515
assert_unsafe_precondition!(
516516
check_language_ub,
@@ -662,7 +662,7 @@ macro_rules! int_impl {
662662
#[must_use = "this returns the result of the operation, \
663663
without modifying the original"]
664664
#[inline(always)]
665-
#[track_caller]
665+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
666666
pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self {
667667
assert_unsafe_precondition!(
668668
check_language_ub,
@@ -814,7 +814,7 @@ macro_rules! int_impl {
814814
#[must_use = "this returns the result of the operation, \
815815
without modifying the original"]
816816
#[inline(always)]
817-
#[track_caller]
817+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
818818
pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self {
819819
assert_unsafe_precondition!(
820820
check_language_ub,
@@ -1163,7 +1163,7 @@ macro_rules! int_impl {
11631163
without modifying the original"]
11641164
#[rustc_const_unstable(feature = "unchecked_neg", issue = "85122")]
11651165
#[inline(always)]
1166-
#[track_caller]
1166+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
11671167
pub const unsafe fn unchecked_neg(self) -> Self {
11681168
assert_unsafe_precondition!(
11691169
check_language_ub,
@@ -1296,7 +1296,7 @@ macro_rules! int_impl {
12961296
without modifying the original"]
12971297
#[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")]
12981298
#[inline(always)]
1299-
#[track_caller]
1299+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
13001300
pub const unsafe fn unchecked_shl(self, rhs: u32) -> Self {
13011301
assert_unsafe_precondition!(
13021302
check_language_ub,
@@ -1422,7 +1422,7 @@ macro_rules! int_impl {
14221422
without modifying the original"]
14231423
#[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")]
14241424
#[inline(always)]
1425-
#[track_caller]
1425+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
14261426
pub const unsafe fn unchecked_shr(self, rhs: u32) -> Self {
14271427
assert_unsafe_precondition!(
14281428
check_language_ub,

library/core/src/num/nonzero.rs

-2
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ where
364364
#[rustc_const_stable(feature = "nonzero", since = "1.28.0")]
365365
#[must_use]
366366
#[inline]
367-
#[track_caller]
368367
pub const unsafe fn new_unchecked(n: T) -> Self {
369368
match Self::new(n) {
370369
Some(n) => n,
@@ -405,7 +404,6 @@ where
405404
#[unstable(feature = "nonzero_from_mut", issue = "106290")]
406405
#[must_use]
407406
#[inline]
408-
#[track_caller]
409407
pub unsafe fn from_mut_unchecked(n: &mut T) -> &mut Self {
410408
match Self::from_mut(n) {
411409
Some(n) => n,

library/core/src/num/uint_macros.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ macro_rules! uint_impl {
557557
#[must_use = "this returns the result of the operation, \
558558
without modifying the original"]
559559
#[inline(always)]
560-
#[track_caller]
560+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
561561
pub const unsafe fn unchecked_add(self, rhs: Self) -> Self {
562562
assert_unsafe_precondition!(
563563
check_language_ub,
@@ -749,7 +749,7 @@ macro_rules! uint_impl {
749749
#[must_use = "this returns the result of the operation, \
750750
without modifying the original"]
751751
#[inline(always)]
752-
#[track_caller]
752+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
753753
pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self {
754754
assert_unsafe_precondition!(
755755
check_language_ub,
@@ -906,7 +906,7 @@ macro_rules! uint_impl {
906906
#[must_use = "this returns the result of the operation, \
907907
without modifying the original"]
908908
#[inline(always)]
909-
#[track_caller]
909+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
910910
pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self {
911911
assert_unsafe_precondition!(
912912
check_language_ub,
@@ -1485,7 +1485,7 @@ macro_rules! uint_impl {
14851485
without modifying the original"]
14861486
#[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")]
14871487
#[inline(always)]
1488-
#[track_caller]
1488+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
14891489
pub const unsafe fn unchecked_shl(self, rhs: u32) -> Self {
14901490
assert_unsafe_precondition!(
14911491
check_language_ub,
@@ -1611,7 +1611,7 @@ macro_rules! uint_impl {
16111611
without modifying the original"]
16121612
#[rustc_const_unstable(feature = "unchecked_shifts", issue = "85122")]
16131613
#[inline(always)]
1614-
#[track_caller]
1614+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
16151615
pub const unsafe fn unchecked_shr(self, rhs: u32) -> Self {
16161616
assert_unsafe_precondition!(
16171617
check_language_ub,

library/core/src/ops/index_range.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ impl IndexRange {
1818
/// # Safety
1919
/// - `start <= end`
2020
#[inline]
21-
#[track_caller]
2221
pub const unsafe fn new_unchecked(start: usize, end: usize) -> Self {
2322
ub_checks::assert_unsafe_precondition!(
2423
check_library_ub,

library/core/src/panicking.rs

-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ pub const fn panic_nounwind(expr: &'static str) -> ! {
223223
}
224224

225225
/// Like `panic_nounwind`, but also inhibits showing a backtrace.
226-
#[track_caller]
227226
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)]
228227
#[cfg_attr(feature = "panic_immediate_abort", inline)]
229228
#[rustc_nounwind]

library/core/src/ptr/alignment.rs

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ impl Alignment {
7575
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
7676
#[rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070")]
7777
#[inline]
78-
#[track_caller]
7978
pub const unsafe fn new_unchecked(align: usize) -> Self {
8079
assert_unsafe_precondition!(
8180
check_language_ub,

library/core/src/ptr/const_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ impl<T: ?Sized> *const T {
713713
#[unstable(feature = "ptr_sub_ptr", issue = "95892")]
714714
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
715715
#[inline]
716-
#[track_caller]
716+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
717717
pub const unsafe fn sub_ptr(self, origin: *const T) -> usize
718718
where
719719
T: Sized,

library/core/src/ptr/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,6 @@ pub const unsafe fn swap<T>(x: *mut T, y: *mut T) {
11381138
#[stable(feature = "swap_nonoverlapping", since = "1.27.0")]
11391139
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
11401140
#[rustc_diagnostic_item = "ptr_swap_nonoverlapping"]
1141-
#[track_caller]
11421141
pub const unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
11431142
#[allow(unused)]
11441143
macro_rules! attempt_swap_as_chunks {
@@ -1269,7 +1268,6 @@ const unsafe fn swap_nonoverlapping_simple_untyped<T>(x: *mut T, y: *mut T, coun
12691268
#[stable(feature = "rust1", since = "1.0.0")]
12701269
#[rustc_const_unstable(feature = "const_replace", issue = "83164")]
12711270
#[rustc_diagnostic_item = "ptr_replace"]
1272-
#[track_caller]
12731271
pub const unsafe fn replace<T>(dst: *mut T, src: T) -> T {
12741272
// SAFETY: the caller must guarantee that `dst` is valid to be
12751273
// cast to a mutable reference (valid for writes, aligned, initialized),
@@ -1396,7 +1394,7 @@ pub const unsafe fn replace<T>(dst: *mut T, src: T) -> T {
13961394
#[inline]
13971395
#[stable(feature = "rust1", since = "1.0.0")]
13981396
#[rustc_const_stable(feature = "const_ptr_read", since = "1.71.0")]
1399-
#[track_caller]
1397+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
14001398
#[rustc_diagnostic_item = "ptr_read"]
14011399
pub const unsafe fn read<T>(src: *const T) -> T {
14021400
// It would be semantically correct to implement this via `copy_nonoverlapping`
@@ -1622,7 +1620,7 @@ pub const unsafe fn read_unaligned<T>(src: *const T) -> T {
16221620
#[stable(feature = "rust1", since = "1.0.0")]
16231621
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
16241622
#[rustc_diagnostic_item = "ptr_write"]
1625-
#[track_caller]
1623+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
16261624
pub const unsafe fn write<T>(dst: *mut T, src: T) {
16271625
// Semantically, it would be fine for this to be implemented as a
16281626
// `copy_nonoverlapping` and appropriate drop suppression of `src`.
@@ -1804,7 +1802,7 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
18041802
/// ```
18051803
#[inline]
18061804
#[stable(feature = "volatile", since = "1.9.0")]
1807-
#[track_caller]
1805+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
18081806
#[rustc_diagnostic_item = "ptr_read_volatile"]
18091807
pub unsafe fn read_volatile<T>(src: *const T) -> T {
18101808
// SAFETY: the caller must uphold the safety contract for `volatile_load`.
@@ -1884,7 +1882,7 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
18841882
#[inline]
18851883
#[stable(feature = "volatile", since = "1.9.0")]
18861884
#[rustc_diagnostic_item = "ptr_write_volatile"]
1887-
#[track_caller]
1885+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
18881886
pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
18891887
// SAFETY: the caller must uphold the safety contract for `volatile_store`.
18901888
unsafe {

library/core/src/ptr/non_null.rs

-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ impl<T: ?Sized> NonNull<T> {
192192
#[stable(feature = "nonnull", since = "1.25.0")]
193193
#[rustc_const_stable(feature = "const_nonnull_new_unchecked", since = "1.25.0")]
194194
#[inline]
195-
#[track_caller]
196195
pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
197196
// SAFETY: the caller must guarantee that `ptr` is non-null.
198197
unsafe {

library/core/src/slice/index.rs

-6
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ unsafe impl<T> SliceIndex<[T]> for usize {
267267
}
268268

269269
#[inline]
270-
#[track_caller]
271270
unsafe fn get_unchecked(self, slice: *const [T]) -> *const T {
272271
assert_unsafe_precondition!(
273272
check_language_ub,
@@ -287,7 +286,6 @@ unsafe impl<T> SliceIndex<[T]> for usize {
287286
}
288287

289288
#[inline]
290-
#[track_caller]
291289
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut T {
292290
assert_unsafe_precondition!(
293291
check_library_ub,
@@ -338,7 +336,6 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
338336
}
339337

340338
#[inline]
341-
#[track_caller]
342339
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T] {
343340
assert_unsafe_precondition!(
344341
check_library_ub,
@@ -353,7 +350,6 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
353350
}
354351

355352
#[inline]
356-
#[track_caller]
357353
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T] {
358354
assert_unsafe_precondition!(
359355
check_library_ub,
@@ -420,7 +416,6 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
420416
}
421417

422418
#[inline]
423-
#[track_caller]
424419
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T] {
425420
assert_unsafe_precondition!(
426421
check_library_ub,
@@ -445,7 +440,6 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
445440
}
446441

447442
#[inline]
448-
#[track_caller]
449443
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T] {
450444
assert_unsafe_precondition!(
451445
check_library_ub,

library/core/src/slice/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,6 @@ impl<T> [T] {
923923
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
924924
#[unstable(feature = "slice_swap_unchecked", issue = "88539")]
925925
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
926-
#[track_caller]
927926
pub const unsafe fn swap_unchecked(&mut self, a: usize, b: usize) {
928927
assert_unsafe_precondition!(
929928
check_library_ub,
@@ -1269,7 +1268,6 @@ impl<T> [T] {
12691268
#[unstable(feature = "slice_as_chunks", issue = "74985")]
12701269
#[inline]
12711270
#[must_use]
1272-
#[track_caller]
12731271
pub const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]] {
12741272
assert_unsafe_precondition!(
12751273
check_language_ub,
@@ -1427,7 +1425,6 @@ impl<T> [T] {
14271425
#[unstable(feature = "slice_as_chunks", issue = "74985")]
14281426
#[inline]
14291427
#[must_use]
1430-
#[track_caller]
14311428
pub const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]] {
14321429
assert_unsafe_precondition!(
14331430
check_language_ub,
@@ -1954,7 +1951,6 @@ impl<T> [T] {
19541951
#[rustc_const_stable(feature = "const_slice_split_at_unchecked", since = "1.77.0")]
19551952
#[inline]
19561953
#[must_use]
1957-
#[track_caller]
19581954
pub const unsafe fn split_at_unchecked(&self, mid: usize) -> (&[T], &[T]) {
19591955
// HACK: the const function `from_raw_parts` is used to make this
19601956
// function const; previously the implementation used
@@ -2008,7 +2004,6 @@ impl<T> [T] {
20082004
#[rustc_const_unstable(feature = "const_slice_split_at_mut", issue = "101804")]
20092005
#[inline]
20102006
#[must_use]
2011-
#[track_caller]
20122007
pub const unsafe fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
20132008
let len = self.len();
20142009
let ptr = self.as_mut_ptr();

library/core/src/slice/raw.rs

-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ use crate::{array, ptr, ub_checks};
120120
#[rustc_const_stable(feature = "const_slice_from_raw_parts", since = "1.64.0")]
121121
#[must_use]
122122
#[rustc_diagnostic_item = "slice_from_raw_parts"]
123-
#[track_caller]
124123
pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
125124
// SAFETY: the caller must uphold the safety contract for `from_raw_parts`.
126125
unsafe {
@@ -175,7 +174,6 @@ pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T]
175174
#[rustc_const_unstable(feature = "const_slice_from_raw_parts_mut", issue = "67456")]
176175
#[must_use]
177176
#[rustc_diagnostic_item = "slice_from_raw_parts_mut"]
178-
#[track_caller]
179177
pub const unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] {
180178
// SAFETY: the caller must uphold the safety contract for `from_raw_parts_mut`.
181179
unsafe {

0 commit comments

Comments
 (0)