From 1beb3104c185fb37fd5ad089bb2b7cac917d5e37 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 30 Sep 2021 01:01:59 -0400 Subject: [PATCH] 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::().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::().unwrap().to_string(); | ^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone --- tests/test.rs | 4 ++-- tests/test_fmt.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test.rs b/tests/test.rs index b133489..5ddd824 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -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::().unwrap().to_string(); println!("first: {}", s); - let s2 = s.to_string().parse::().unwrap().to_string(); + let s2 = s.parse::().unwrap().to_string(); assert_eq!(s, s2); } roundtrip("a"); diff --git a/tests/test_fmt.rs b/tests/test_fmt.rs index 6ebd368..93dd19e 100644 --- a/tests/test_fmt.rs +++ b/tests/test_fmt.rs @@ -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());