- Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Closed
Copy link
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Consider this code:
struct S<T>(T); const fn oopsie() -> ! { panic!(); } impl<T> S<T> { const C1: i32 = panic!(); const C2: i32 = oopsie(); } fn main() { S::<i32>::C1; // or C2 }
If we use C1
, we get the following:
error[E0080]: evaluation of `S::<i32>::C1` failed --> src/main.rs:8:21 | 8 | const C1: i32 = panic!(); | ^^^^^^^^ evaluation panicked: explicit panic
But if we use C2
, we get:
error[E0080]: evaluation of `oopsie` failed --> src/main.rs:9:21 | 9 | const C2: i32 = oopsie(); | ^^^^^^^^ evaluation panicked: explicit panic | note: inside `oopsie` --> src/main.rs:4:5 | 4 | panic!(); | ^^^^^^^^ the failure occurred here
Note that it says "evaluation of oopsie
failed"; I would have expected "evaluation of S::<i32>::C2
failed". That's where the span points at, too.
Cc @oli-obk
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.