Skip to content

Provide better error message when field attribute is incorrectΒ #44

@Kriskras99

Description

@Kriskras99

I got this error message:

error: custom attribute panicked
  --> ubiart_toolkit/src/cooked/isg/mod.rs:18:1
   |
18 | #[superstruct(variants(V22, V21, V20, V20C, V19, V18, V17, V16))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: message: called `Result::unwrap()` on an `Err` value: Error { kind: UnknownField(ErrorUnknownField { name: "V19", did_you_mean: None }), locations: [], span: Some(#0 bytes(619472..619475)) }

which was because I had a field attribute [superstruct(V19)] instead of [superstruct(only(V19))]. It would be nice of the error message detected that the field name is also an attribute and suggests only and any other relevant attributes.
If it could also give the line number that would be even better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions