frozenlib / parse-display

Procedural macro to implement Display and FromStr using common settings.
Apache License 2.0
182 stars 14 forks source link

Clippy Warning in FromStr #3

Closed smessmer closed 4 years ago

smessmer commented 4 years ago

Using this enum:

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, FromStr, Display)]
pub enum MyFlag {
    #[display("o1")]
    OptionOne,
    #[display("o2")]
    OptionTwo,
}

causes a clippy warning:

warning: trivial regex
   --> lib.rs:
    |
841 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, FromStr, Display)]
    |                                                   ^^^^^^^
    |
    = help: consider using `==` on `str`s
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivial_regex
    = note: this warning originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

The generated FromStr macro could probably generate an #[allow(clippy::trivial_regex)] if this is intended, so that it can be used more easily in projects that enforce a clean clippy output.

frozenlib commented 4 years ago

Thanks for posting the issue.

This issue fix in 07c5b3772997a938749b46dac4155f5675f12827.

smessmer commented 4 years ago

Awesome, thanks for creating this library :)