Closed
Description
Both the error and the suggestion make it seem like Enum
is an enum variant; it's a type, not a variant.
pub enum Enum {
V1(i32),
}
pub fn foo(x: i32) -> Enum {
Enum::V1 { x }
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0559]: variant `Enum::V1` has no field named `x`
--> src/lib.rs:6:16
|
2 | V1(i32),
| -- `Enum` defined here
...
6 | Enum::V1 { x }
| -------- ^ field does not exist
| |
| `Enum` is a tuple variant, use the appropriate syntax: `Enum(/* fields */)`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0559`.
error: could not compile `playground`
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Diagnostics: Confusing error or lint that should be reworked.Diagnostics: A structured suggestion resulting in incorrect code.Diagnostics: Confusing error or lint; hard to understand for new users.Relevant to the compiler team, which will review and decide on the PR/issue.