Skip to content

Commit 927ce61

Browse files
committed
Remove span label when span isn't available
1 parent 1069039 commit 927ce61

21 files changed

+4
-81
lines changed

compiler/rustc_const_eval/src/const_eval/error.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ pub fn get_span_and_frames<'tcx>(
119119
if frames.len() > 0 {
120120
frames.remove(0);
121121
}
122-
if let Some(last) = frames.last_mut() {
122+
if let Some(last) = frames.last_mut()
123+
// If the span is not going to be printed, we don't want the span label for `is_last`.
124+
&& tcx.sess.source_map().span_to_snippet(last.span.source_callsite()).is_ok()
125+
{
123126
last.is_last = true;
124127
}
125128

tests/ui/const-ptr/forbidden_slices.stderr

-10
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ note: inside `from_ptr_range::<'_, ()>`
109109
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
110110
note: inside `std::ptr::const_ptr::<impl *const ()>::offset_from_unsigned`
111111
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
112-
|
113-
= note: the failure occurred here
114112
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
115113

116114
error[E0080]: could not evaluate static initializer
@@ -121,8 +119,6 @@ LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore
121119
|
122120
note: inside `std::ptr::const_ptr::<impl *const u32>::add`
123121
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
124-
|
125-
= note: the failure occurred here
126122

127123
error[E0080]: it is undefined behavior to use this value
128124
--> $DIR/forbidden_slices.rs:57:1
@@ -178,8 +174,6 @@ LL | from_ptr_range(ptr..ptr.add(1))
178174
|
179175
note: inside `std::ptr::const_ptr::<impl *const u64>::add`
180176
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
181-
|
182-
= note: the failure occurred here
183177

184178
error[E0080]: could not evaluate static initializer
185179
--> $DIR/forbidden_slices.rs:85:34
@@ -191,8 +185,6 @@ note: inside `from_ptr_range::<'_, u32>`
191185
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
192186
note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned`
193187
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
194-
|
195-
= note: the failure occurred here
196188

197189
error[E0080]: could not evaluate static initializer
198190
--> $DIR/forbidden_slices.rs:87:35
@@ -204,8 +196,6 @@ note: inside `from_ptr_range::<'_, u32>`
204196
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
205197
note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned`
206198
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
207-
|
208-
= note: the failure occurred here
209199

210200
error: aborting due to 18 previous errors
211201

tests/ui/const-ptr/out_of_bounds_read.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
66
|
77
note: inside `std::ptr::read::<u32>`
88
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
9-
|
10-
= note: the failure occurred here
119

1210
error[E0080]: evaluation of constant value failed
1311
--> $DIR/out_of_bounds_read.rs:11:39
@@ -19,8 +17,6 @@ note: inside `std::ptr::const_ptr::<impl *const u32>::read`
1917
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
2018
note: inside `std::ptr::read::<u32>`
2119
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
22-
|
23-
= note: the failure occurred here
2420

2521
error[E0080]: evaluation of constant value failed
2622
--> $DIR/out_of_bounds_read.rs:12:37
@@ -32,8 +28,6 @@ note: inside `std::ptr::mut_ptr::<impl *mut u32>::read`
3228
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
3329
note: inside `std::ptr::read::<u32>`
3430
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
35-
|
36-
= note: the failure occurred here
3731

3832
error: aborting due to 3 previous errors
3933

tests/ui/consts/const-eval/parse_ints.stderr

-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ note: inside `core::num::<impl u64>::from_str_radix`
88
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
99
note: inside `core::num::<impl u64>::from_ascii_radix`
1010
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
11-
|
12-
= note: the failure occurred here
1311
= note: this error originates in the macro `from_str_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
1412

1513
error[E0080]: evaluation of constant value failed
@@ -22,8 +20,6 @@ note: inside `core::num::<impl u64>::from_str_radix`
2220
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
2321
note: inside `core::num::<impl u64>::from_ascii_radix`
2422
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
25-
|
26-
= note: the failure occurred here
2723
= note: this error originates in the macro `from_str_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
2824

2925
error: aborting due to 2 previous errors

tests/ui/consts/const-eval/raw-pointer-ub.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ note: inside `std::ptr::const_ptr::<impl *const u32>::copy_to_nonoverlapping`
2020
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
2121
note: inside `copy_nonoverlapping::<u32>`
2222
--> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL
23-
|
24-
= note: the failure occurred here
2523

2624
error[E0080]: evaluation of constant value failed
2725
--> $DIR/raw-pointer-ub.rs:34:16

tests/ui/consts/const-eval/ub-enum.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ LL | unsafe { std::mem::discriminant(&*(&() as *const () as *const Never));
124124
|
125125
note: inside `discriminant::<Never>`
126126
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
127-
|
128-
= note: the failure occurred here
129127

130128
error: aborting due to 14 previous errors
131129

tests/ui/consts/const-eval/ub-ref-ptr.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ note: inside `std::ptr::const_ptr::<impl *const u32>::read`
158158
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
159159
note: inside `std::ptr::read::<u32>`
160160
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
161-
|
162-
= note: the failure occurred here
163161

164162
error: aborting due to 15 previous errors
165163

tests/ui/consts/const-ptr-is-null.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ note: inside `std::ptr::const_ptr::<impl *const i32>::is_null`
88
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
99
note: inside `std::ptr::const_ptr::<impl *const T>::is_null::compiletime`
1010
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
11-
|
12-
= note: the failure occurred here
1311
= note: this error originates in the macro `$crate::intrinsics::const_eval_select` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
1412

1513
error: aborting due to 1 previous error

tests/ui/consts/const_unsafe_unreachable_ub.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ LL | false => std::hint::unreachable_unchecked(),
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
note: inside `unreachable_unchecked`
1313
--> $SRC_DIR/core/src/hint.rs:LL:COL
14-
|
15-
= note: the failure occurred here
1614

1715
error: aborting due to 1 previous error
1816

tests/ui/consts/issue-miri-1910.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ note: inside `std::ptr::const_ptr::<impl *const u8>::read`
88
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
99
note: inside `std::ptr::read::<u8>`
1010
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
11-
|
12-
= note: the failure occurred here
1311
= help: this code performed an operation that depends on the underlying bytes representing a pointer
1412
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
1513

tests/ui/consts/miri_unleashed/assoc_const.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ note: inside `std::ptr::drop_in_place::<(Vec<u32>, u32)> - shim(Some((Vec<u32>,
88
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
99
note: inside `std::ptr::drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))`
1010
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
11-
|
12-
= note: the failure occurred here
1311

1412
note: erroneous constant encountered
1513
--> $DIR/assoc_const.rs:29:13

tests/ui/consts/miri_unleashed/drop.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ LL | };
66
|
77
note: inside `std::ptr::drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
88
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
9-
|
10-
= note: the failure occurred here
119

1210
warning: skipping const checks
1311
|

tests/ui/consts/missing_span_in_backtrace.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ note: inside `std::ptr::swap_nonoverlapping_simple_untyped::<MaybeUninit<u8>>`
1616
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
1717
note: inside `std::ptr::read::<MaybeUninit<MaybeUninit<u8>>>`
1818
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
19-
|
20-
= note: the failure occurred here
2119
= help: this code performed an operation that depends on the underlying bytes representing a pointer
2220
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
2321
= note: this error originates in the macro `$crate::intrinsics::const_eval_select` which comes from the expansion of the macro `const_eval_select` (in Nightly builds, run with -Z macro-backtrace for more info)

tests/ui/consts/offset_from_ub.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
1212
|
1313
note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from`
1414
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
15-
|
16-
= note: the failure occurred here
1715

1816
error[E0080]: evaluation of constant value failed
1917
--> $DIR/offset_from_ub.rs:31:14
@@ -83,8 +81,6 @@ LL | unsafe { ptr2.offset_from(ptr1) }
8381
|
8482
note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from`
8583
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
86-
|
87-
= note: the failure occurred here
8884

8985
error[E0080]: evaluation of constant value failed
9086
--> $DIR/offset_from_ub.rs:115:14
@@ -94,8 +90,6 @@ LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) }
9490
|
9591
note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from`
9692
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
97-
|
98-
= note: the failure occurred here
9993

10094
error: aborting due to 14 previous errors
10195

tests/ui/consts/offset_ub.stderr

-22
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1)
66
|
77
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
88
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
9-
|
10-
= note: the failure occurred here
119

1210
error[E0080]: evaluation of constant value failed
1311
--> $DIR/offset_ub.rs:9:43
@@ -17,8 +15,6 @@ LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
1715
|
1816
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
1917
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
20-
|
21-
= note: the failure occurred here
2218

2319
error[E0080]: evaluation of constant value failed
2420
--> $DIR/offset_ub.rs:10:45
@@ -28,8 +24,6 @@ LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101)
2824
|
2925
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
3026
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
31-
|
32-
= note: the failure occurred here
3327

3428
error[E0080]: evaluation of constant value failed
3529
--> $DIR/offset_ub.rs:12:43
@@ -39,8 +33,6 @@ LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::
3933
|
4034
note: inside `std::ptr::const_ptr::<impl *const u16>::offset`
4135
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
42-
|
43-
= note: the failure occurred here
4436

4537
error[E0080]: evaluation of constant value failed
4638
--> $DIR/offset_ub.rs:13:44
@@ -50,8 +42,6 @@ LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize:
5042
|
5143
note: inside `std::ptr::const_ptr::<impl *const u16>::offset`
5244
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
53-
|
54-
= note: the failure occurred here
5545

5646
error[E0080]: evaluation of constant value failed
5747
--> $DIR/offset_ub.rs:14:56
@@ -61,8 +51,6 @@ LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *cons
6151
|
6252
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
6353
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
64-
|
65-
= note: the failure occurred here
6654

6755
error[E0080]: evaluation of constant value failed
6856
--> $DIR/offset_ub.rs:15:57
@@ -72,8 +60,6 @@ LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).of
7260
|
7361
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
7462
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
75-
|
76-
= note: the failure occurred here
7763

7864
error[E0080]: evaluation of constant value failed
7965
--> $DIR/offset_ub.rs:16:49
@@ -83,8 +69,6 @@ LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_
8369
|
8470
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
8571
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
86-
|
87-
= note: the failure occurred here
8872

8973
error[E0080]: evaluation of constant value failed
9074
--> $DIR/offset_ub.rs:18:50
@@ -94,8 +78,6 @@ LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1
9478
|
9579
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
9680
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
97-
|
98-
= note: the failure occurred here
9981

10082
error[E0080]: evaluation of constant value failed
10183
--> $DIR/offset_ub.rs:19:42
@@ -105,8 +87,6 @@ LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_
10587
|
10688
note: inside `std::ptr::mut_ptr::<impl *mut u8>::offset`
10789
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
108-
|
109-
= note: the failure occurred here
11090

11191
error[E0080]: evaluation of constant value failed
11292
--> $DIR/offset_ub.rs:22:47
@@ -116,8 +96,6 @@ LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).off
11696
|
11797
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
11898
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
119-
|
120-
= note: the failure occurred here
12199

122100
error: aborting due to 11 previous errors
123101

tests/ui/consts/qualif-indirect-mutation-fail.stderr

-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ note: inside `std::ptr::drop_in_place::<String> - shim(Some(String))`
1919
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
2020
note: inside `std::ptr::drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))`
2121
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
22-
|
23-
= note: the failure occurred here
2422

2523
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
2624
--> $DIR/qualif-indirect-mutation-fail.rs:28:9
@@ -42,8 +40,6 @@ note: inside `std::ptr::drop_in_place::<String> - shim(Some(String))`
4240
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
4341
note: inside `std::ptr::drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))`
4442
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
45-
|
46-
= note: the failure occurred here
4743

4844
error[E0493]: destructor of `(u32, Option<String>)` cannot be evaluated at compile-time
4945
--> $DIR/qualif-indirect-mutation-fail.rs:6:9

tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ LL | std::hint::unreachable_unchecked();
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
note: inside `unreachable_unchecked`
1313
--> $SRC_DIR/core/src/hint.rs:LL:COL
14-
|
15-
= note: the failure occurred here
1614

1715
note: erroneous constant encountered
1816
--> $DIR/interpret-in-promoted.rs:13:27

tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ LL | std::hint::unreachable_unchecked();
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
note: inside `unreachable_unchecked`
1313
--> $SRC_DIR/core/src/hint.rs:LL:COL
14-
|
15-
= note: the failure occurred here
1614

1715
note: erroneous constant encountered
1816
--> $DIR/interpret-in-promoted.rs:13:27

tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ LL | static CHECK: () = assert!(align_of::<P2>() == 1);
2626
|
2727
note: inside `align_of::<P2>`
2828
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
29-
|
30-
= note: the failure occurred here
3129

3230
error: aborting due to 2 previous errors
3331

tests/ui/layout/unknown-when-no-type-parameter.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ LL | [(); size_of::<<() as Project>::Assoc>()];
66
|
77
note: inside `std::mem::size_of::<<() as Project>::Assoc>`
88
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
9-
|
10-
= note: the failure occurred here
119

1210
error: aborting due to 1 previous error
1311

tests/ui/limits/issue-55878.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
66
|
77
note: inside `std::mem::size_of::<[u8; usize::MAX]>`
88
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
9-
|
10-
= note: the failure occurred here
119

1210
error: aborting due to 1 previous error
1311

0 commit comments

Comments
 (0)