Skip to content

Commit 6a9919e

Browse files
committed
const-eval error: always say in which item the error occurred
1 parent 792fc2b commit 6a9919e

File tree

174 files changed

+928
-947
lines changed

Some content is hidden

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

174 files changed

+928
-947
lines changed

compiler/rustc_const_eval/messages.ftl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,7 @@ const_eval_division_overflow =
8888
const_eval_dyn_call_not_a_method =
8989
`dyn` call trying to call something that is not a method
9090
91-
const_eval_error = {$error_kind ->
92-
[static] evaluation of static initializer failed here
93-
[const] evaluation of constant value failed here
94-
[const_with_path] evaluation of `{$instance}` failed here
95-
*[other] {""}
96-
}
91+
const_eval_error = evaluation of `{$instance}` failed here
9792
9893
const_eval_exact_div_has_remainder =
9994
exact_div: {$a} cannot be divided by {$b} without remainder

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -430,20 +430,7 @@ fn report_eval_error<'tcx>(
430430
let (error, backtrace) = error.into_parts();
431431
backtrace.print_backtrace();
432432

433-
let (kind, instance) = if ecx.tcx.is_static(cid.instance.def_id()) {
434-
("static", String::new())
435-
} else {
436-
// If the current item has generics, we'd like to enrich the message with the
437-
// instance and its args: to show the actual compile-time values, in addition to
438-
// the expression, leading to the const eval error.
439-
let instance = &cid.instance;
440-
if !instance.args.is_empty() {
441-
let instance = with_no_trimmed_paths!(instance.to_string());
442-
("const_with_path", instance)
443-
} else {
444-
("const", String::new())
445-
}
446-
};
433+
let instance = with_no_trimmed_paths!(cid.instance.to_string());
447434

448435
super::report(
449436
*ecx.tcx,
@@ -455,7 +442,6 @@ fn report_eval_error<'tcx>(
455442
diag.code(E0080);
456443
diag.span_label(span, crate::fluent_generated::const_eval_error);
457444
diag.arg("instance", instance);
458-
diag.arg("error_kind", kind);
459445
for frame in frames {
460446
diag.subdiagnostic(frame);
461447
}

tests/ui/array-slice-vec/array_const_index-0.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: index out of bounds: the length is 0 but the index is 1
22
--> $DIR/array_const_index-0.rs:2:16
33
|
44
LL | const B: i32 = (&A)[1];
5-
| ^^^^^^^ evaluation of constant value failed here
5+
| ^^^^^^^ evaluation of `B` failed here
66

77
error: aborting due to 1 previous error
88

tests/ui/array-slice-vec/array_const_index-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: index out of bounds: the length is 0 but the index is 1
22
--> $DIR/array_const_index-1.rs:2:16
33
|
44
LL | const B: i32 = A[1];
5-
| ^^^^ evaluation of constant value failed here
5+
| ^^^^ evaluation of `B` failed here
66

77
error: aborting due to 1 previous error
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 panicked: explicit panic
22
--> $DIR/issue-81899.rs:6:24
33
|
44
LL | const _CONST: &[u8] = &f(&[], |_| {});
5-
| ^^^^^^^^^^^^^^ evaluation of constant value failed here
5+
| ^^^^^^^^^^^^^^ evaluation of `f::<{closure@$DIR/issue-81899.rs:6:31: 6:34}>` failed here
66
|
77
note: inside `f::<{closure@$DIR/issue-81899.rs:6:31: 6:34}>`
88
--> $DIR/issue-81899.rs:13: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 panicked: explicit panic
22
--> $DIR/issue-88434-minimal-example.rs:5:22
33
|
44
LL | const _CONST: &() = &f(&|_| {});
5-
| ^^^^^^^^^^ evaluation of constant value failed here
5+
| ^^^^^^^^^^ evaluation of `f::<{closure@$DIR/issue-88434-minimal-example.rs:5:25: 5:28}>` failed here
66
|
77
note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:5:25: 5:28}>`
88
--> $DIR/issue-88434-minimal-example.rs:12: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 panicked: explicit panic
22
--> $DIR/issue-88434-removal-index-should-be-less.rs:5:24
33
|
44
LL | const _CONST: &[u8] = &f(&[], |_| {});
5-
| ^^^^^^^^^^^^^^ evaluation of constant value failed here
5+
| ^^^^^^^^^^^^^^ evaluation of `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:5:31: 5:34}>` failed here
66
|
77
note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:5:31: 5:34}>`
88
--> $DIR/issue-88434-removal-index-should-be-less.rs:12: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 panicked: Some error occurred
22
--> $DIR/const-errs-dont-conflict-103369.rs:5:25
33
|
44
LL | impl ConstGenericTrait<{my_fn(1)}> for () {}
5-
| ^^^^^^^^ evaluation of constant value failed here
5+
| ^^^^^^^^ evaluation of `my_fn` failed here
66
|
77
note: inside `my_fn`
88
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
@@ -14,7 +14,7 @@ error[E0080]: evaluation panicked: Some error occurred
1414
--> $DIR/const-errs-dont-conflict-103369.rs:7:25
1515
|
1616
LL | impl ConstGenericTrait<{my_fn(2)}> for () {}
17-
| ^^^^^^^^ evaluation of constant value failed here
17+
| ^^^^^^^^ evaluation of `my_fn` failed here
1818
|
1919
note: inside `my_fn`
2020
--> $DIR/const-errs-dont-conflict-103369.rs:10:5

tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
22
--> $DIR/default-param-wf-concrete.rs:4:28
33
|
44
LL | struct Foo<const N: u8 = { 255 + 1 }>;
5-
| ^^^^^^^ evaluation of constant value failed here
5+
| ^^^^^^^ evaluation of `Foo::{constant#0}` failed here
66

77
error: aborting due to 1 previous error
88

tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
22
--> $DIR/default-param-wf-concrete.rs:4:28
33
|
44
LL | struct Foo<const N: u8 = { 255 + 1 }>;
5-
| ^^^^^^^ evaluation of constant value failed here
5+
| ^^^^^^^ evaluation of `Foo::{constant#0}` failed here
66

77
error: aborting due to 1 previous error
88

0 commit comments

Comments
 (0)