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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 0 additions & 10 deletions
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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 0 additions & 4 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

0 commit comments

Comments
 (0)