Skip to content

Commit 0046bab

Browse files
committed
review comment: reword message and add detail to tests
1 parent 0c1d5b4 commit 0046bab

File tree

50 files changed

+154
-141
lines changed

Some content is hidden

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

50 files changed

+154
-141
lines changed

compiler/rustc_const_eval/messages.ftl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ const_eval_frame_note = {$times ->
104104
}
105105
106106
const_eval_frame_note_inner = {$is_last ->
107-
[true] {"the evaluated program failed "}
107+
[true] {"the failure occurred "}
108108
*[false] {""}
109109
}inside {$where_ ->
110110
[closure] closure
111111
[instance] `{$instance}`
112112
*[other] {""}
113113
}
114114
115-
const_eval_frame_note_last = the evaluated program failed here
115+
const_eval_frame_note_last = the failure occurred here
116116
117117
const_eval_in_bounds_test = out-of-bounds pointer use
118118
const_eval_incompatible_calling_conventions =

tests/ui/borrowck/issue-81899.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const fn f<F>(_: &[u8], _: F) -> &[u8]
88
where
99
F: FnMut(&u8),
1010
{
11-
panic!() //~ panic
11+
panic!() //~ inside `f
1212
}
1313

1414
fn main() {}

tests/ui/borrowck/issue-81899.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error[E0080]: evaluation of constant value failed
44
LL | const _CONST: &[u8] = &f(&[], |_| {});
55
| ^^^^^^^^^^^^^^ panic: explicit panic
66
|
7-
note: the evaluated program failed inside `f::<{closure@$DIR/issue-81899.rs:4:31: 4:34}>`
7+
note: the failure occurred inside `f::<{closure@$DIR/issue-81899.rs:4:31: 4:34}>`
88
--> $DIR/issue-81899.rs:11:5
99
|
1010
LL | panic!()
11-
| ^^^^^^^^ the evaluated program failed here
11+
| ^^^^^^^^ the failure occurred here
1212
= 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)
1313

1414
note: erroneous constant encountered

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const fn f<F>(_: &F)
77
where
88
F: FnMut(&u8),
99
{
10-
panic!() //~ panic
10+
panic!() //~ inside `f
1111
}
1212

1313
fn main() { }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error[E0080]: evaluation of constant value failed
44
LL | const _CONST: &() = &f(&|_| {});
55
| ^^^^^^^^^^ panic: explicit panic
66
|
7-
note: the evaluated program failed inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28}>`
7+
note: the failure occurred inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28}>`
88
--> $DIR/issue-88434-minimal-example.rs:10:5
99
|
1010
LL | panic!()
11-
| ^^^^^^^^ the evaluated program failed here
11+
| ^^^^^^^^ the failure occurred here
1212
= 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)
1313

1414
note: erroneous constant encountered

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const fn f<F>(_: &[u8], _: F) -> &[u8]
77
where
88
F: FnMut(&u8),
99
{
10-
panic!() //~ panic
10+
panic!() //~ inside `f
1111
}
1212

1313
fn main() { }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error[E0080]: evaluation of constant value failed
44
LL | const _CONST: &[u8] = &f(&[], |_| {});
55
| ^^^^^^^^^^^^^^ panic: explicit panic
66
|
7-
note: the evaluated program failed inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>`
7+
note: the failure occurred 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
99
|
1010
LL | panic!()
11-
| ^^^^^^^^ the evaluated program failed here
11+
| ^^^^^^^^ the failure occurred here
1212
= 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)
1313

1414
note: erroneous constant encountered

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error[E0080]: evaluation of constant value failed
44
LL | impl ConstGenericTrait<{my_fn(1)}> for () {}
55
| ^^^^^^^^ panic: Some error occurred
66
|
7-
note: the evaluated program failed inside `my_fn`
7+
note: the failure occurred inside `my_fn`
88
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
99
|
1010
LL | panic!("Some error occurred");
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program failed here
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
1212
= 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)
1313

1414
error[E0080]: evaluation of constant value failed
@@ -17,11 +17,11 @@ error[E0080]: evaluation of constant value failed
1717
LL | impl ConstGenericTrait<{my_fn(2)}> for () {}
1818
| ^^^^^^^^ panic: Some error occurred
1919
|
20-
note: the evaluated program failed inside `my_fn`
20+
note: the failure occurred inside `my_fn`
2121
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
2222
|
2323
LL | panic!("Some error occurred");
24-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program failed here
24+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
2525
= 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)
2626

2727
error: aborting due to 2 previous errors

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ struct T<const B: &'static bool>;
66
impl<const B: &'static bool> T<B> {
77
const fn set_false(&self) {
88
unsafe {
9-
*(B as *const bool as *mut bool) = false;
9+
*(B as *const bool as *mut bool) = false; //~ inside `T
1010
}
1111
}
1212
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error[E0080]: evaluation of constant value failed
44
LL | x.set_false();
55
| ^^^^^^^^^^^^^ writing to ALLOC0 which is read-only
66
|
7-
note: the evaluated program failed inside `T::<&true>::set_false`
7+
note: the failure occurred inside `T::<&true>::set_false`
88
--> $DIR/issue-100313.rs:9:13
99
|
1010
LL | *(B as *const bool as *mut bool) = false;
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program failed here
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
1212

1313
error: aborting due to 1 previous error
1414

tests/ui/const-ptr/forbidden_slices.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
107107
|
108108
note: inside `from_ptr_range::<'_, ()>`
109109
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
110-
note: the evaluated program failed inside `std::ptr::const_ptr::<impl *const ()>::sub_ptr`
110+
note: the failure occurred inside `std::ptr::const_ptr::<impl *const ()>::sub_ptr`
111111
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
112112
|
113-
= note: the evaluated program failed here
113+
= note: the failure occurred here
114114
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
115115

116116
error[E0080]: could not evaluate static initializer
@@ -119,10 +119,10 @@ error[E0080]: could not evaluate static initializer
119119
LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore
120120
| ^^^^^^^^^^ 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
121121
|
122-
note: the evaluated program failed inside `std::ptr::const_ptr::<impl *const u32>::add`
122+
note: the failure occurred inside `std::ptr::const_ptr::<impl *const u32>::add`
123123
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
124124
|
125-
= note: the evaluated program failed here
125+
= note: the failure occurred here
126126

127127
error[E0080]: it is undefined behavior to use this value
128128
--> $DIR/forbidden_slices.rs:57:1
@@ -176,10 +176,10 @@ error[E0080]: could not evaluate static initializer
176176
LL | from_ptr_range(ptr..ptr.add(1))
177177
| ^^^^^^^^^^ 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
178178
|
179-
note: the evaluated program failed inside `std::ptr::const_ptr::<impl *const u64>::add`
179+
note: the failure occurred inside `std::ptr::const_ptr::<impl *const u64>::add`
180180
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
181181
|
182-
= note: the evaluated program failed here
182+
= note: the failure occurred here
183183

184184
error[E0080]: could not evaluate static initializer
185185
--> $DIR/forbidden_slices.rs:85:34
@@ -189,10 +189,10 @@ 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: the evaluated program failed inside `std::ptr::const_ptr::<impl *const u32>::sub_ptr`
192+
note: the failure occurred inside `std::ptr::const_ptr::<impl *const u32>::sub_ptr`
193193
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
194194
|
195-
= note: the evaluated program failed here
195+
= note: the failure occurred here
196196

197197
error[E0080]: could not evaluate static initializer
198198
--> $DIR/forbidden_slices.rs:87:35
@@ -202,10 +202,10 @@ 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: the evaluated program failed inside `std::ptr::const_ptr::<impl *const u32>::sub_ptr`
205+
note: the failure occurred inside `std::ptr::const_ptr::<impl *const u32>::sub_ptr`
206206
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
207207
|
208-
= note: the evaluated program failed here
208+
= note: the failure occurred here
209209

210210
error: aborting due to 18 previous errors
211211

tests/ui/const-ptr/out_of_bounds_read.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ error[E0080]: evaluation of constant value failed
44
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
55
| ^^^^^^^^^^^^^^^^^^^^^^^ 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
66
|
7-
note: the evaluated program failed inside `std::ptr::read::<u32>`
7+
note: the failure occurred inside `std::ptr::read::<u32>`
88
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
99
|
10-
= note: the evaluated program failed here
10+
= note: the failure occurred here
1111

1212
error[E0080]: evaluation of constant value failed
1313
--> $DIR/out_of_bounds_read.rs:11:39
@@ -17,10 +17,10 @@ LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
1717
|
1818
note: inside `std::ptr::const_ptr::<impl *const u32>::read`
1919
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
20-
note: the evaluated program failed inside `std::ptr::read::<u32>`
20+
note: the failure occurred inside `std::ptr::read::<u32>`
2121
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
2222
|
23-
= note: the evaluated program failed here
23+
= note: the failure occurred here
2424

2525
error[E0080]: evaluation of constant value failed
2626
--> $DIR/out_of_bounds_read.rs:12:37
@@ -30,10 +30,10 @@ LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
3030
|
3131
note: inside `std::ptr::mut_ptr::<impl *mut u32>::read`
3232
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
33-
note: the evaluated program failed inside `std::ptr::read::<u32>`
33+
note: the failure occurred inside `std::ptr::read::<u32>`
3434
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
3535
|
36-
= note: the evaluated program failed here
36+
= note: the failure occurred here
3737

3838
error: aborting due to 3 previous errors
3939

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ const X: fn(usize) -> usize = double;
77

88
const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
99
x(y)
10+
//~^ NOTE the failure occurred inside `bar`
11+
//~| NOTE the failure occurred here
12+
//~| NOTE the failure occurred inside `bar`
13+
//~| NOTE the failure occurred here
1014
}
1115

1216
const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
1317
//~^ ERROR evaluation of constant value failed
18+
//~| NOTE calling non-const function `double`
1419
const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
1520
//~^ ERROR evaluation of constant value failed
21+
//~| NOTE calling non-const function `double`
1622

1723
fn main() {
1824
assert_eq!(Y, 4);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
error[E0080]: evaluation of constant value failed
2-
--> $DIR/const_fn_ptr_fail2.rs:12:18
2+
--> $DIR/const_fn_ptr_fail2.rs:16:18
33
|
44
LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
55
| ^^^^^^^^^ calling non-const function `double`
66
|
7-
note: the evaluated program failed inside `bar`
7+
note: the failure occurred inside `bar`
88
--> $DIR/const_fn_ptr_fail2.rs:9:5
99
|
1010
LL | x(y)
11-
| ^^^^ the evaluated program failed here
11+
| ^^^^ the failure occurred here
1212

1313
error[E0080]: evaluation of constant value failed
14-
--> $DIR/const_fn_ptr_fail2.rs:14:18
14+
--> $DIR/const_fn_ptr_fail2.rs:19:18
1515
|
1616
LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
1717
| ^^^^^^^^^^^^^^ calling non-const function `double`
1818
|
19-
note: the evaluated program failed inside `bar`
19+
note: the failure occurred inside `bar`
2020
--> $DIR/const_fn_ptr_fail2.rs:9:5
2121
|
2222
LL | x(y)
23-
| ^^^^ the evaluated program failed here
23+
| ^^^^ the failure occurred here
2424

2525
warning: skipping const checks
2626
|

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const fn b() -> u32 {
1313

1414
const fn c() -> u32 {
1515
b() //~ NOTE inside `c`
16-
//~^ NOTE the evaluated
16+
//~^ NOTE the failure occurred here
1717
}
1818

1919
const X: u32 = c();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error[E0080]: evaluation of constant value failed
44
LL | const X: u32 = c();
55
| ^^^ panic: hey
66
|
7-
note: the evaluated program failed inside `c`
7+
note: the failure occurred inside `c`
88
--> $DIR/const_panic_track_caller.rs:15:5
99
|
1010
LL | b()
11-
| ^^^ the evaluated program failed here
11+
| ^^^ the failure occurred here
1212

1313
error: aborting due to 1 previous error
1414

tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error[E0080]: evaluation of constant value failed
44
LL | const FOO: i32 = foo();
55
| ^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2
66
|
7-
note: the evaluated program failed inside `foo`
7+
note: the failure occurred inside `foo`
88
--> $DIR/alloc_intrinsic_errors.rs:8:17
99
|
1010
LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32;
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program failed here
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
1212

1313
error: aborting due to 1 previous error
1414

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ LL | const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); };
66
|
77
note: inside `core::num::<impl u64>::from_str_radix`
88
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
9-
note: the evaluated program failed inside `core::num::<impl u64>::from_ascii_radix`
9+
note: the failure occurred inside `core::num::<impl u64>::from_ascii_radix`
1010
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
1111
|
12-
= note: the evaluated program failed here
12+
= note: the failure occurred here
1313
= note: this error originates in the macro `from_str_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
1414

1515
error[E0080]: evaluation of constant value failed
@@ -20,10 +20,10 @@ LL | const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); };
2020
|
2121
note: inside `core::num::<impl u64>::from_str_radix`
2222
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
23-
note: the evaluated program failed inside `core::num::<impl u64>::from_ascii_radix`
23+
note: the failure occurred inside `core::num::<impl u64>::from_ascii_radix`
2424
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
2525
|
26-
= note: the evaluated program failed here
26+
= note: the failure occurred here
2727
= note: this error originates in the macro `from_str_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
2828

2929
error: aborting due to 2 previous errors

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ LL | y.copy_to_nonoverlapping(&mut z, 1);
1818
|
1919
note: inside `std::ptr::const_ptr::<impl *const u32>::copy_to_nonoverlapping`
2020
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
21-
note: the evaluated program failed inside `copy_nonoverlapping::<u32>`
21+
note: the failure occurred inside `copy_nonoverlapping::<u32>`
2222
--> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL
2323
|
24-
= note: the evaluated program failed here
24+
= note: the failure occurred here
2525

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

tests/ui/consts/const-eval/transmute-size-mismatch.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ const unsafe fn mir_transmute<T, U>(x: T) -> U {
1010
mir!{
1111
{
1212
RET = CastTransmute(x);
13+
//~^ NOTE inside `mir_transmute
14+
//~| NOTE inside `mir_transmute
15+
//~| NOTE the failure occurred here
16+
//~| NOTE the failure occurred here
1317
Return()
1418
}
1519
}
1620
}
1721

1822
const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; //~ ERROR evaluation of constant value failed
23+
//~^ NOTE transmuting from 4-byte type to 2-byte type: `i32` -> `u16`
1924

2025
const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; //~ ERROR evaluation of constant value failed
26+
//~^ NOTE transmuting from 2-byte type to 4-byte type: `i16` -> `u32`
2127

2228
fn main() {}

0 commit comments

Comments
 (0)