profile
viewpoint

Ask questionsredundant-clone false-positive for structopt attrs

<!-- Hi there! Whether you've come to make a suggestion for a new lint, an improvement to an existing lint or to report a bug or a false positive in Clippy, you've come to the right place.

For bug reports and false positives, please include the output of cargo clippy -V in the report.

Thank you for using Clippy!

Write your comment below this line: --> For following code:


#[derive(StructOpt, Debug)]
struct ExecOpt {
//...
 #[structopt(
        short = "x",
        long = "expose",
        parse(try_from_str = parse_path_exposition_item)
    )]
    exposed_paths: Vec<minion::PathExpositionOptions>,
//...
}

Clippy gives error:

error: redundant clone
  --> src/minion-cli/src/main.rs:93:30
   |
93 |         parse(try_from_str = parse_path_exposition_item)
   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `-D clippy::redundant-clone` implied by `-D clippy::all`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone

Upd: clippy 0.0.212 (5cb9833 2019-10-08) rustc 1.40.0-nightly (c27f7568b 2019-10-13)

rust-lang/rust-clippy

Answer questions sinkuu

There would be actually a redundant .to_string() if your try_from_str function returns Result<_, String>. Anyway, try upgrading structopt to 0.3.3, as they have added #[allow(clippy)] to the generated code.

useful!
source:https://uonfu.com/
Github User Rank List