-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lints
Description
pub struct Foo(pub u32);
pub const CONSTANT: Foo = Foo(1);
#[derive(Clone)]
enum Enum {
Variant = CONSTANT,
}
fn main() {}
<anon>:2:27: 2:33 error: constant evaluation error: unsupported constant expr [E0080]
<anon>:2 pub const CONSTANT: Foo = Foo(1);
^~~~~~
<anon>:2:27: 2:33 help: see the detailed explanation for E0080
error: aborting due to previous error
Note specifically that the error points to the constant definition and not to its use in the enum, even though it is the enum which is in the wrong. This led to a rather difficult to diagnose error when working on another project.
If the struct is changed to just pub struct Foo;
, then another similarly confusing error occurs:
<anon>:2:27: 2:30 error: constant evaluation error: non-constant path in constant expr [E0080]
<anon>:2 pub const CONSTANT: Foo = Foo;
^~~
<anon>:2:27: 2:30 help: see the detailed explanation for E0080
error: aborting due to previous error
Again, the constant definition is totally fine, and it is the enum which is in the wrong.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lints