You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of rust-lang#104317 - RalfJung:ctfe-error-reporting, r=oli-obk
cleanup and dedupe CTFE and Miri error reporting
It looks like most of the time, this error raised from const_prop_lint is just redundant -- it duplicates the error reported when evaluating the const-eval query. This lets us make `ConstEvalErr` private to the const_eval module which I think is a good step.
The Miri change mostly replaces a `match` by `if let`, and dedupes the "this error is impossible in Miri" checks.
r? ``@oli-obk``
Fixesrust-lang#75461
(None, format!("pass the flag `-Zmiri-disable-isolation` to disable isolation;")),
176
-
(None, format!("or pass `-Zmiri-isolation-error=warn` to configure Miri to return an error code from isolated operations (if supported for that operation) and continue with a warning")),
177
-
],
178
-
StackedBorrowsUb{ help, history, .. } => {
179
-
let url = "https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md";
180
-
msg.extend(help.clone());
181
-
letmut helps = vec![
182
-
(None, format!("this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental")),
183
-
(None, format!("see {url} for further information")),
(None, format!("pass the flag `-Zmiri-disable-isolation` to disable isolation;")),
177
+
(None, format!("or pass `-Zmiri-isolation-error=warn` to configure Miri to return an error code from isolated operations (if supported for that operation) and continue with a warning")),
178
+
],
179
+
StackedBorrowsUb{ help, history, .. } => {
180
+
let url = "https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md";
181
+
msg.extend(help.clone());
182
+
letmut helps = vec![
183
+
(None, format!("this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental")),
184
+
(None, format!("see {url} for further information")),
bug!("This error should be impossible in Miri: {kind:?}"),
226
-
};
227
-
#[rustfmt::skip]
228
-
let helps = match e.kind(){
229
-
Unsupported(
230
-
UnsupportedOpInfo::ThreadLocalStatic(_) |
231
-
UnsupportedOpInfo::ReadExternStatic(_) |
232
-
UnsupportedOpInfo::PartialPointerOverwrite(_) |
233
-
UnsupportedOpInfo::PartialPointerCopy(_) |
234
-
UnsupportedOpInfo::ReadPointerAsBytes
235
-
) =>
236
-
panic!("Error should never be raised by Miri: {kind:?}", kind = e.kind()),
237
-
Unsupported(
238
-
UnsupportedOpInfo::Unsupported(_)
239
-
) =>
240
-
vec![(None, format!("this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support"))],
// We list only the ones that can actually happen.
218
+
UnsupportedOpInfo::Unsupported(_)
219
+
) =>
220
+
"unsupported operation",
221
+
InvalidProgram(
222
+
// We list only the ones that can actually happen.
223
+
InvalidProgramInfo::AlreadyReported(_) |
224
+
InvalidProgramInfo::Layout(..)
225
+
) =>
226
+
"post-monomorphization error",
227
+
kind =>
228
+
bug!("This error should be impossible in Miri: {kind:?}"),
229
+
};
230
+
#[rustfmt::skip]
231
+
let helps = match e.kind(){
232
+
Unsupported(_) =>
233
+
vec![(None, format!("this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support"))],
Copy file name to clipboardexpand all lines: tests/fail/erroneous_const.stderr
+3-12
Original file line number
Diff line number
Diff line change
@@ -6,21 +6,12 @@ LL | const VOID: ! = panic!();
6
6
|
7
7
= 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)
8
8
9
-
error: post-monomorphization error: referenced constant has errors
9
+
note: erroneous constant used
10
10
--> $DIR/erroneous_const.rs:LL:CC
11
11
|
12
12
LL | let _ = PrintName::<T>::VOID;
13
-
| ^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
14
-
|
15
-
= note: inside `no_codegen::<i32>` at $DIR/erroneous_const.rs:LL:CC
16
-
note: inside `main` at $DIR/erroneous_const.rs:LL:CC
17
-
--> $DIR/erroneous_const.rs:LL:CC
18
-
|
19
-
LL | no_codegen::<i32>();
20
-
| ^^^^^^^^^^^^^^^^^^^
21
-
22
-
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13
+
| ^^^^^^^^^^^^^^^^^^^^
23
14
24
-
error: aborting due to 2 previous errors
15
+
error: aborting due to previous error
25
16
26
17
For more information about this error, try `rustc --explain E0080`.
0 commit comments