Skip to content

Commit e36dc78

Browse files
committed
Add some track_caller info to precondition panics
1 parent bbd3a5a commit e36dc78

77 files changed

Lines changed: 175 additions & 207 deletions

File tree

Some content is hidden

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

‎library/core/src/alloc/layout.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ impl Layout {
126126
#[rustc_const_stable(feature = "const_alloc_layout_unchecked", since = "1.36.0")]
127127
#[must_use]
128128
#[inline]
129+
#[track_caller]
129130
pubconstunsafefnfrom_size_align_unchecked(size:usize,align:usize) -> Self{
130131
assert_unsafe_precondition!(
131132
check_library_ub,

‎library/core/src/ascii/ascii_char.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ impl AsciiChar {
503503
/// something useful. It might be tightened before stabilization.)
504504
#[unstable(feature = "ascii_char", issue = "110998")]
505505
#[inline]
506+
#[track_caller]
506507
pubconstunsafefndigit_unchecked(d:u8) -> Self{
507508
assert_unsafe_precondition!(
508509
check_language_ub,

‎library/core/src/char/convert.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub(super) const fn from_u32(i: u32) -> Option<char> {
2222
#[inline]
2323
#[must_use]
2424
#[allow(unnecessary_transmutes)]
25+
#[track_caller]
2526
pub(super)constunsafefnfrom_u32_unchecked(i:u32) -> char{
2627
// SAFETY: the caller must guarantee that `i` is a valid char value.
2728
unsafe{

‎library/core/src/hint.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ use crate::{intrinsics, ub_checks};
9898
#[inline]
9999
#[stable(feature = "unreachable", since = "1.27.0")]
100100
#[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")]
101-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
101+
#[track_caller]
102102
pubconstunsafefnunreachable_unchecked() -> ! {
103103
ub_checks::assert_unsafe_precondition!(
104104
check_language_ub,

‎library/core/src/intrinsics/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2634,7 +2634,7 @@ pub const fn three_way_compare<T: Copy>(lhs: T, rhss: T) -> crate::cmp::Ordering
26342634
#[rustc_const_unstable(feature = "disjoint_bitor", issue = "135758")]
26352635
#[rustc_nounwind]
26362636
#[rustc_intrinsic]
2637-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
2637+
#[track_caller]
26382638
#[miri::intrinsic_fallback_is_spec]// the fallbacks all `assume` to tell Miri
26392639
pubconstunsafefndisjoint_bitor<T: ~const fallback::DisjointBitOr>(a:T,b:T) -> T{
26402640
// SAFETY: same preconditions as this function.

‎library/core/src/num/int_macros.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ macro_rules! int_impl {
555555
#[must_use = "this returns the result of the operation, \
556556
without modifying the original"]
557557
#[inline(always)]
558-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
558+
#[track_caller]
559559
pubconstunsafefn unchecked_add(self, rhs:Self) -> Self{
560560
assert_unsafe_precondition!(
561561
check_language_ub,
@@ -705,7 +705,7 @@ macro_rules! int_impl {
705705
#[must_use = "this returns the result of the operation, \
706706
without modifying the original"]
707707
#[inline(always)]
708-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
708+
#[track_caller]
709709
pubconstunsafefn unchecked_sub(self, rhs:Self) -> Self{
710710
assert_unsafe_precondition!(
711711
check_language_ub,
@@ -855,7 +855,7 @@ macro_rules! int_impl {
855855
#[must_use = "this returns the result of the operation, \
856856
without modifying the original"]
857857
#[inline(always)]
858-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
858+
#[track_caller]
859859
pubconstunsafefn unchecked_mul(self, rhs:Self) -> Self{
860860
assert_unsafe_precondition!(
861861
check_language_ub,
@@ -1199,7 +1199,7 @@ macro_rules! int_impl {
11991199
#[must_use = "this returns the result of the operation, \
12001200
without modifying the original"]
12011201
#[inline(always)]
1202-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
1202+
#[track_caller]
12031203
pubconstunsafefn unchecked_neg(self) -> Self{
12041204
assert_unsafe_precondition!(
12051205
check_language_ub,
@@ -1327,7 +1327,7 @@ macro_rules! int_impl {
13271327
#[must_use = "this returns the result of the operation, \
13281328
without modifying the original"]
13291329
#[inline(always)]
1330-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
1330+
#[track_caller]
13311331
pubconstunsafefn unchecked_shl(self, rhs:u32) -> Self{
13321332
assert_unsafe_precondition!(
13331333
check_language_ub,
@@ -1448,7 +1448,7 @@ macro_rules! int_impl {
14481448
#[must_use = "this returns the result of the operation, \
14491449
without modifying the original"]
14501450
#[inline(always)]
1451-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
1451+
#[track_caller]
14521452
pubconstunsafefn unchecked_shr(self, rhs:u32) -> Self{
14531453
assert_unsafe_precondition!(
14541454
check_language_ub,

‎library/core/src/num/nonzero.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ where
388388
#[rustc_const_stable(feature = "nonzero", since = "1.28.0")]
389389
#[must_use]
390390
#[inline]
391+
#[track_caller]
391392
pubconstunsafefnnew_unchecked(n:T) -> Self{
392393
matchSelf::new(n){
393394
Some(n) => n,
@@ -428,6 +429,7 @@ where
428429
#[unstable(feature = "nonzero_from_mut", issue = "106290")]
429430
#[must_use]
430431
#[inline]
432+
#[track_caller]
431433
pubunsafefnfrom_mut_unchecked(n:&mutT) -> &mutSelf{
432434
matchSelf::from_mut(n){
433435
Some(n) => n,

‎library/core/src/num/uint_macros.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ macro_rules! uint_impl {
601601
#[must_use = "this returns the result of the operation, \
602602
without modifying the original"]
603603
#[inline(always)]
604-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
604+
#[track_caller]
605605
pubconstunsafefn unchecked_add(self, rhs:Self) -> Self{
606606
assert_unsafe_precondition!(
607607
check_language_ub,
@@ -791,7 +791,7 @@ macro_rules! uint_impl {
791791
#[must_use = "this returns the result of the operation, \
792792
without modifying the original"]
793793
#[inline(always)]
794-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
794+
#[track_caller]
795795
pubconstunsafefn unchecked_sub(self, rhs:Self) -> Self{
796796
assert_unsafe_precondition!(
797797
check_language_ub,
@@ -974,7 +974,7 @@ macro_rules! uint_impl {
974974
#[must_use = "this returns the result of the operation, \
975975
without modifying the original"]
976976
#[inline(always)]
977-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
977+
#[track_caller]
978978
pubconstunsafefn unchecked_mul(self, rhs:Self) -> Self{
979979
assert_unsafe_precondition!(
980980
check_language_ub,
@@ -1588,7 +1588,7 @@ macro_rules! uint_impl {
15881588
#[must_use = "this returns the result of the operation, \
15891589
without modifying the original"]
15901590
#[inline(always)]
1591-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
1591+
#[track_caller]
15921592
pubconstunsafefn unchecked_shl(self, rhs:u32) -> Self{
15931593
assert_unsafe_precondition!(
15941594
check_language_ub,
@@ -1709,7 +1709,7 @@ macro_rules! uint_impl {
17091709
#[must_use = "this returns the result of the operation, \
17101710
without modifying the original"]
17111711
#[inline(always)]
1712-
#[cfg_attr(miri,track_caller)]// even without panics, this helps for Miri backtraces
1712+
#[track_caller]
17131713
pubconstunsafefn unchecked_shr(self, rhs:u32) -> Self{
17141714
assert_unsafe_precondition!(
17151715
check_language_ub,

‎library/core/src/ops/index_range.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ impl IndexRange {
1919
/// # Safety
2020
/// - `start <= end`
2121
#[inline]
22+
#[track_caller]
2223
pub(crate)constunsafefnnew_unchecked(start:usize,end:usize) -> Self{
2324
ub_checks::assert_unsafe_precondition!(
2425
check_library_ub,

‎library/core/src/ptr/alignment.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ impl Alignment {
7373
/// It must *not* be zero.
7474
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
7575
#[inline]
76+
#[track_caller]
7677
pubconstunsafefnnew_unchecked(align:usize) -> Self{
7778
assert_unsafe_precondition!(
7879
check_language_ub,

0 commit comments

Comments
 (0)