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#122471 - RalfJung:const-eval-span, r=oli-obk
preserve span when evaluating mir::ConstOperand
This lets us show to the user where they were using the faulty const (which can be quite relevant when generics are involved).
I wonder if we should change "erroneous constant encountered" to something like "the above error was encountered while evaluating this constant" or so, to make this more similar to what the collector emits when showing a "backtrace" of where things get monomorphized? It seems a bit strange to rely on the order of emitted diagnostics for that but it seems the collector already [does that](https://github.com/rust-lang/rust/blob/da8a8c9223722e17cc0173ce9490076b4a6d263d/compiler/rustc_monomorphize/src/collector.rs#L472-L475).
Copy file name to clipboardexpand all lines: tests/ui/consts/const-eval/unused-broken-const-late.stderr
+6
Original file line number
Diff line number
Diff line change
@@ -6,6 +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
+
note: erroneous constant encountered
10
+
--> $DIR/unused-broken-const-late.rs:15:17
11
+
|
12
+
LL | let _ = PrintName::<T>::VOID;
13
+
| ^^^^^^^^^^^^^^^^^^^^
14
+
9
15
error: aborting due to 1 previous error
10
16
11
17
For more information about this error, try `rustc --explain E0080`.
Copy file name to clipboardexpand all lines: tests/ui/inline-const/required-const.stderr
+6
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,12 @@ LL | const { 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
+
note: erroneous constant encountered
10
+
--> $DIR/required-const.rs:7:9
11
+
|
12
+
LL | const { panic!() }
13
+
| ^^^^^^^^^^^^^^^^^^
14
+
9
15
error: aborting due to 1 previous error
10
16
11
17
For more information about this error, try `rustc --explain E0080`.
0 commit comments