pest-parser / ast

Apache License 2.0
81 stars 15 forks source link

Remove unnecessary `clone` on `Span` #27

Closed veeenu closed 1 year ago

veeenu commented 1 year ago

Hi!

I started using pest-ast and I was running into the following lint:

warning: using `clone` on type `Span<'_>` which implements the `Copy` trait
   --> src/ast.rs:102:38
    |
102 | ...t_ast(outer(with(span_into_string)))] String);
    |          ^^^^^ help: try removing the `clone` call: `outer`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Personally I think it is desirable to have it on, so I checked out pest-ast's code and noticed that the first element in the ConversionStrategy::Outer tuple is always a Span, which is Copy and thus shouldn't ever need clone.

I have not delved super deep in the code, though, so I'm not 100% confident on this statement: have I overlooked something?

I also changed the example slightly, removing the need for allowing lints altogether. Hth!