Skip to content

Commit 14895b3

Browse files
committed
Remove duplicated span from const eval frame list
When the primary span for a const error is the same as the first frame in the const error report, skip it. ``` error[E0080]: evaluation of constant value failed --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | LL | panic!() | ^^^^^^^^ explicit panic | note: inside `_CONST` --> $DIR/issue-88434-removal-index-should-be-less.rs:3:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); | ^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) ``` instead of ``` error[E0080]: evaluation of constant value failed --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | LL | panic!() | ^^^^^^^^ explicit panic | note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>` --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | LL | panic!() | ^^^^^^^^ note: inside `_CONST` --> $DIR/issue-88434-removal-index-should-be-less.rs:3:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); | ^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered --> $DIR/issue-88434-removal-index-should-be-less.rs:3:23 | LL | const _CONST: &[u8] = &f(&[], |_| {}); | ^^^^^^^^^^^^^^^ ```
1 parent 3a8df87 commit 14895b3

Some content is hidden

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

42 files changed

+7
-193
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
@@ -147,8 +147,11 @@ where
147147
}
148148
// Report remaining errors.
149149
_ => {
150-
let (our_span, frames) = get_span_and_frames();
150+
let (our_span, mut frames) = get_span_and_frames();
151151
let span = span.substitute_dummy(our_span);
152+
if Some(span) == frames.get(0).map(|frame| frame.span) {
153+
frames.remove(0);
154+
}
152155
let err = mk(span, frames);
153156
let mut err = tcx.dcx().create_err(err);
154157
// We allow invalid programs in infallible promoteds since invalid layouts can occur

tests/ui/borrowck/issue-81899.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ error[E0080]: evaluation of constant value failed
44
LL | panic!()
55
| ^^^^^^^^ explicit panic
66
|
7-
note: inside `f::<{closure@$DIR/issue-81899.rs:4:31: 4:34}>`
8-
--> $DIR/issue-81899.rs:11:5
9-
|
10-
LL | panic!()
11-
| ^^^^^^^^
127
note: inside `_CONST`
138
--> $DIR/issue-81899.rs:4:24
149
|

tests/ui/borrowck/issue-88434-minimal-example.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ error[E0080]: evaluation of constant value failed
44
LL | panic!()
55
| ^^^^^^^^ explicit panic
66
|
7-
note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28}>`
8-
--> $DIR/issue-88434-minimal-example.rs:10:5
9-
|
10-
LL | panic!()
11-
| ^^^^^^^^
127
note: inside `_CONST`
138
--> $DIR/issue-88434-minimal-example.rs:3:22
149
|

tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ error[E0080]: evaluation of constant value failed
44
LL | panic!()
55
| ^^^^^^^^ explicit panic
66
|
7-
note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>`
8-
--> $DIR/issue-88434-removal-index-should-be-less.rs:10:5
9-
|
10-
LL | panic!()
11-
| ^^^^^^^^
127
note: inside `_CONST`
138
--> $DIR/issue-88434-removal-index-should-be-less.rs:3:24
149
|

tests/ui/coherence/const-errs-dont-conflict-103369.stderr

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ error[E0080]: evaluation of constant value failed
44
LL | panic!("Some error occurred");
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Some error occurred
66
|
7-
note: inside `my_fn`
8-
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
9-
|
10-
LL | panic!("Some error occurred");
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127
note: inside `<() as ConstGenericTrait<{my_fn(1)}>>::{constant#0}`
138
--> $DIR/const-errs-dont-conflict-103369.rs:5:25
149
|
@@ -22,11 +17,6 @@ error[E0080]: evaluation of constant value failed
2217
LL | panic!("Some error occurred");
2318
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Some error occurred
2419
|
25-
note: inside `my_fn`
26-
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
27-
|
28-
LL | panic!("Some error occurred");
29-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3020
note: inside `<() as ConstGenericTrait<{my_fn(2)}>>::{constant#0}`
3121
--> $DIR/const-errs-dont-conflict-103369.rs:7:25
3222
|

tests/ui/const-generics/issues/issue-100313.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ error[E0080]: evaluation of constant value failed
44
LL | *(B as *const bool as *mut bool) = false;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ writing to ALLOC0 which is read-only
66
|
7-
note: inside `T::<&true>::set_false`
8-
--> $DIR/issue-100313.rs:9:13
9-
|
10-
LL | *(B as *const bool as *mut bool) = false;
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127
note: inside `_`
138
--> $DIR/issue-100313.rs:17:5
149
|

tests/ui/const-ptr/forbidden_slices.stderr

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ error[E0080]: could not evaluate static initializer
104104
|
105105
= note: assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize
106106
|
107-
note: inside `std::ptr::const_ptr::<impl *const ()>::sub_ptr`
108-
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
109107
note: inside `from_ptr_range::<'_, ()>`
110108
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
111109
note: inside `R1`
@@ -120,8 +118,6 @@ error[E0080]: could not evaluate static initializer
120118
|
121119
= note: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC10 which is only 4 bytes from the end of the allocation
122120
|
123-
note: inside `std::ptr::const_ptr::<impl *const u32>::add`
124-
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
125121
note: inside `R2`
126122
--> $DIR/forbidden_slices.rs:53:25
127123
|
@@ -179,8 +175,6 @@ error[E0080]: could not evaluate static initializer
179175
|
180176
= note: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation
181177
|
182-
note: inside `std::ptr::const_ptr::<impl *const u64>::add`
183-
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
184178
note: inside `R8`
185179
--> $DIR/forbidden_slices.rs:77:25
186180
|
@@ -192,8 +186,6 @@ error[E0080]: could not evaluate static initializer
192186
|
193187
= note: `ptr_offset_from_unsigned` called on pointers into different allocations
194188
|
195-
note: inside `std::ptr::const_ptr::<impl *const u32>::sub_ptr`
196-
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
197189
note: inside `from_ptr_range::<'_, u32>`
198190
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
199191
note: inside `R9`
@@ -207,8 +199,6 @@ error[E0080]: could not evaluate static initializer
207199
|
208200
= note: `ptr_offset_from_unsigned` called on pointers into different allocations
209201
|
210-
note: inside `std::ptr::const_ptr::<impl *const u32>::sub_ptr`
211-
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
212202
note: inside `from_ptr_range::<'_, u32>`
213203
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
214204
note: inside `R10`

tests/ui/const-ptr/out_of_bounds_read.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ error[E0080]: evaluation of constant value failed
33
|
44
= 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
55
|
6-
note: inside `std::ptr::read::<u32>`
7-
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
86
note: inside `_READ`
97
--> $DIR/out_of_bounds_read.rs:10:33
108
|
@@ -16,8 +14,6 @@ error[E0080]: evaluation of constant value failed
1614
|
1715
= 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
1816
|
19-
note: inside `std::ptr::read::<u32>`
20-
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
2117
note: inside `std::ptr::const_ptr::<impl *const u32>::read`
2218
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
2319
note: inside `_CONST_READ`
@@ -31,8 +27,6 @@ error[E0080]: evaluation of constant value failed
3127
|
3228
= 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
3329
|
34-
note: inside `std::ptr::read::<u32>`
35-
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
3630
note: inside `std::ptr::mut_ptr::<impl *mut u32>::read`
3731
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
3832
note: inside `_MUT_READ`

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ error[E0080]: evaluation of constant value failed
44
LL | x(y)
55
| ^^^^ calling non-const function `double`
66
|
7-
note: inside `bar`
8-
--> $DIR/const_fn_ptr_fail2.rs:9:5
9-
|
10-
LL | x(y)
11-
| ^^^^
127
note: inside `Y`
138
--> $DIR/const_fn_ptr_fail2.rs:14:18
149
|
@@ -21,11 +16,6 @@ error[E0080]: evaluation of constant value failed
2116
LL | x(y)
2217
| ^^^^ calling non-const function `double`
2318
|
24-
note: inside `bar`
25-
--> $DIR/const_fn_ptr_fail2.rs:9:5
26-
|
27-
LL | x(y)
28-
| ^^^^
2919
note: inside `Z`
3020
--> $DIR/const_fn_ptr_fail2.rs:15:18
3121
|

tests/ui/consts/const-eval/const_panic_track_caller.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const fn c() -> u32 {
1515
b()
1616
//~^ ERROR evaluation of constant value failed
1717
//~| NOTE hey
18-
//~| NOTE inside
1918
}
2019

2120
const X: u32 = c();

0 commit comments

Comments
 (0)