Skip to content

Commit a6e43ad

Browse files
committed
Remove special casing of const panic label
1 parent ef8f4d8 commit a6e43ad

File tree

62 files changed

+97
-107
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

+97
-107
lines changed

compiler/rustc_const_eval/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ const_eval_overflow_arith =
302302
const_eval_overflow_shift =
303303
overflowing shift by {$shift_amount} in `{$intrinsic}`
304304
305-
const_eval_panic = panic: {$msg}
305+
const_eval_panic = evaluation panicked: {$msg}
306306
307307
const_eval_panic_non_str = argument to `panic!()` in a const context must have type `&str`
308308

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,7 @@ impl MachineStopType for ConstEvalErrKind {
3434
match self {
3535
ConstAccessesMutGlobal => const_eval_const_accesses_mut_global,
3636
ModifiedGlobal => const_eval_modified_global,
37-
Panic { msg, .. } => {
38-
let msg = msg.as_str();
39-
match msg {
40-
"explicit panic"
41-
| "not implemented"
42-
| "not yet implemented"
43-
| "internal error: entered unreachable code" => msg.to_string().into(),
44-
_ if msg.starts_with("assertion failed: ") => msg.to_string().into(),
45-
_ => const_eval_panic,
46-
}
47-
}
37+
Panic { .. } => const_eval_panic,
4838
RecursiveStatic => const_eval_recursive_static,
4939
AssertFailure(x) => x.diagnostic_message(),
5040
WriteThroughImmutablePointer => const_eval_write_through_immutable_pointer,

src/tools/miri/tests/fail/erroneous_const.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: evaluation of `PrintName::<i32>::VOID` failed
22
--> tests/fail/erroneous_const.rs:LL:CC
33
|
44
LL | const VOID: ! = panic!();
5-
| ^^^^^^^^ explicit panic
5+
| ^^^^^^^^ evaluation panicked: explicit panic
66
|
77
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
88

tests/ui/borrowck/issue-81899.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
22
--> $DIR/issue-81899.rs:4:24
33
|
44
LL | const _CONST: &[u8] = &f(&[], |_| {});
5-
| ^^^^^^^^^^^^^^ explicit panic
5+
| ^^^^^^^^^^^^^^ evaluation panicked: explicit panic
66
|
77
note: inside `f::<{closure@$DIR/issue-81899.rs:4:31: 4:34}>`
88
--> $DIR/issue-81899.rs:11:5

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
22
--> $DIR/issue-88434-minimal-example.rs:3:22
33
|
44
LL | const _CONST: &() = &f(&|_| {});
5-
| ^^^^^^^^^^ explicit panic
5+
| ^^^^^^^^^^ evaluation panicked: explicit panic
66
|
77
note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28}>`
88
--> $DIR/issue-88434-minimal-example.rs:10:5

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
22
--> $DIR/issue-88434-removal-index-should-be-less.rs:3:24
33
|
44
LL | const _CONST: &[u8] = &f(&[], |_| {});
5-
| ^^^^^^^^^^^^^^ explicit panic
5+
| ^^^^^^^^^^^^^^ evaluation panicked: explicit panic
66
|
77
note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>`
88
--> $DIR/issue-88434-removal-index-should-be-less.rs:10:5

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
22
--> $DIR/const-errs-dont-conflict-103369.rs:5:25
33
|
44
LL | impl ConstGenericTrait<{my_fn(1)}> for () {}
5-
| ^^^^^^^^ panic: Some error occurred
5+
| ^^^^^^^^ evaluation panicked: Some error occurred
66
|
77
note: inside `my_fn`
88
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
@@ -15,7 +15,7 @@ error[E0080]: evaluation of constant value failed
1515
--> $DIR/const-errs-dont-conflict-103369.rs:7:25
1616
|
1717
LL | impl ConstGenericTrait<{my_fn(2)}> for () {}
18-
| ^^^^^^^^ panic: Some error occurred
18+
| ^^^^^^^^ evaluation panicked: Some error occurred
1919
|
2020
note: inside `my_fn`
2121
--> $DIR/const-errs-dont-conflict-103369.rs:10:5

tests/ui/const-ptr/forbidden_slices.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ error[E0080]: could not evaluate static initializer
103103
--> $DIR/forbidden_slices.rs:50:33
104104
|
105105
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore
106-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize
106+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize
107107
|
108108
note: inside `from_ptr_range::<'_, ()>`
109109
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
110-
note: inside `std::ptr::const_ptr::<impl *const ()>::sub_ptr`
110+
note: inside `std::ptr::const_ptr::<impl *const ()>::offset_from_unsigned`
111111
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
112112
|
113113
= note: the failure occurred here
@@ -189,7 +189,7 @@ LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).ad
189189
|
190190
note: inside `from_ptr_range::<'_, u32>`
191191
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
192-
note: inside `std::ptr::const_ptr::<impl *const u32>::sub_ptr`
192+
note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned`
193193
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
194194
|
195195
= note: the failure occurred here
@@ -202,7 +202,7 @@ LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
202202
|
203203
note: inside `from_ptr_range::<'_, u32>`
204204
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
205-
note: inside `std::ptr::const_ptr::<impl *const u32>::sub_ptr`
205+
note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned`
206206
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
207207
|
208208
= note: the failure occurred here

tests/ui/consts/assert-type-intrinsics.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ error[E0080]: evaluation of constant value failed
22
--> $DIR/assert-type-intrinsics.rs:11:9
33
|
44
LL | MaybeUninit::<!>::uninit().assume_init();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ panic: aborted execution: attempted to instantiate uninhabited type `!`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!`
66

77
error[E0080]: evaluation of constant value failed
88
--> $DIR/assert-type-intrinsics.rs:15:9
99
|
1010
LL | intrinsics::assert_mem_uninitialized_valid::<&'static i32>();
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ panic: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid
1212

1313
error[E0080]: evaluation of constant value failed
1414
--> $DIR/assert-type-intrinsics.rs:19:9
1515
|
1616
LL | intrinsics::assert_zero_valid::<&'static i32>();
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ panic: aborted execution: attempted to zero-initialize type `&i32`, which is invalid
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid
1818

1919
error: aborting due to 3 previous errors
2020

tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
22
--> $DIR/const_panic-normalize-tabs-115498.rs:3:17
33
|
44
LL | struct Bug([u8; panic!{"\t"}]);
5-
| ^^^^^^^^^^^^ panic:
5+
| ^^^^^^^^^^^^ evaluation panicked:
66
|
77
= 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)
88

0 commit comments

Comments
 (0)