Resolve redundant_clone clippy lint

error: redundant clone
      --> tests/test_fmt.rs:17:58
       |
    17 |     let none_nonempty = Group::new(Delimiter::None, inner.clone());
       |                                                          ^^^^^^^^ help: remove this
       |
       = note: `-D clippy::redundant-clone` implied by `-D clippy::all`
    note: this value is dropped without further use
      --> tests/test_fmt.rs:17:53
       |
    17 |     let none_nonempty = Group::new(Delimiter::None, inner.clone());
       |                                                     ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone

    error: could not compile `proc-macro2` due to previous error
    warning: build failed, waiting for other jobs to finish...
    error: redundant clone
       --> tests/test.rs:188:19
        |
    188 |         let s2 = s.to_string().parse::<TokenStream>().unwrap().to_string();
        |                   ^^^^^^^^^^^^ help: remove this
        |
        = note: `-D clippy::redundant-clone` implied by `-D clippy::all`
    note: cloned value is neither consumed nor mutated
       --> tests/test.rs:188:18
        |
    188 |         let s2 = s.to_string().parse::<TokenStream>().unwrap().to_string();
        |                  ^^^^^^^^^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
This commit is contained in:
David Tolnay 2021-09-30 01:01:59 -04:00
parent 4565d979c3
commit 1beb3104c1
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
#![allow(clippy::redundant_clone, clippy::default_trait_access)]
#![allow(clippy::default_trait_access)]
use proc_macro2::{Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
use std::panic;
@ -185,7 +185,7 @@ fn roundtrip() {
println!("parse: {}", p);
let s = p.parse::<TokenStream>().unwrap().to_string();
println!("first: {}", s);
let s2 = s.to_string().parse::<TokenStream>().unwrap().to_string();
let s2 = s.parse::<TokenStream>().unwrap().to_string();
assert_eq!(s, s2);
}
roundtrip("a");

View File

@ -1,4 +1,4 @@
#![allow(clippy::redundant_clone, clippy::from_iter_instead_of_collect)]
#![allow(clippy::from_iter_instead_of_collect)]
use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
use std::iter::{self, FromIterator};
@ -14,7 +14,7 @@ fn test_fmt_group() {
let braces_empty = Group::new(Delimiter::Brace, TokenStream::new());
let braces_nonempty = Group::new(Delimiter::Brace, inner.clone());
let none_empty = Group::new(Delimiter::None, TokenStream::new());
let none_nonempty = Group::new(Delimiter::None, inner.clone());
let none_nonempty = Group::new(Delimiter::None, inner);
// Matches libproc_macro.
assert_eq!("()", parens_empty.to_string());