feat(clippy): Use clippy for it's extra lints

This commit is contained in:
Erick Tryzelaar
2016-01-18 12:24:03 -08:00
parent fbcf905c9f
commit bfa2b69193
19 changed files with 57 additions and 34 deletions
+6
View File
@@ -10,6 +10,9 @@ readme = "README.md"
keywords = ["serialization"]
build = "build.rs"
[features]
nightly = ["clippy", "serde/nightly"]
[build-dependencies]
syntex = { version = "^0.26.0" }
syntex_syntax = { version = "^0.26.0" }
@@ -21,6 +24,9 @@ rustc-serialize = "^0.3.16"
serde = { version = "*", path = "../serde", features = ["num-impls"] }
syntex = "^0.26.0"
[dependencies]
clippy = { version = "^0.0.35", optional = true }
[[test]]
name = "test"
path = "tests/test.rs"
+2
View File
@@ -1,4 +1,6 @@
#![feature(test)]
#![cfg_attr(feature = "nightly", feature(plugin))]
#![cfg_attr(feature = "nightly", plugin(clippy))]
extern crate num;
extern crate rustc_serialize;
+2 -2
View File
@@ -415,7 +415,7 @@ fn bench_decoder_dog(b: &mut Bencher) {
#[bench]
fn bench_decoder_frog(b: &mut Bencher) {
b.iter(|| {
let animal = Animal::Frog("Henry".to_string(), 349);
let animal = Animal::Frog("Henry".to_owned(), 349);
let mut d = decoder::AnimalDecoder::new(animal.clone());
let value: Animal = Decodable::decode(&mut d).unwrap();
@@ -439,7 +439,7 @@ fn bench_deserializer_dog(b: &mut Bencher) {
#[bench]
fn bench_deserializer_frog(b: &mut Bencher) {
b.iter(|| {
let animal = Animal::Frog("Henry".to_string(), 349);
let animal = Animal::Frog("Henry".to_owned(), 349);
let mut d = deserializer::AnimalDeserializer::new(animal.clone());
let value: Animal = Deserialize::deserialize(&mut d).unwrap();
+11 -11
View File
@@ -614,7 +614,7 @@ mod deserializer {
fn bench_decoder_0_0(b: &mut Bencher) {
b.iter(|| {
let mut map = HashMap::new();
map.insert("abc".to_string(), Some('c'));
map.insert("abc".to_owned(), Some('c'));
let outer = Outer {
inner: vec!(),
@@ -653,11 +653,11 @@ fn bench_decoder_1_0(b: &mut Bencher) {
fn bench_decoder_1_5(b: &mut Bencher) {
b.iter(|| {
let mut map = HashMap::new();
map.insert("1".to_string(), Some('a'));
map.insert("2".to_string(), None);
map.insert("3".to_string(), Some('b'));
map.insert("4".to_string(), None);
map.insert("5".to_string(), Some('c'));
map.insert("1".to_owned(), Some('a'));
map.insert("2".to_owned(), None);
map.insert("3".to_owned(), Some('b'));
map.insert("4".to_owned(), None);
map.insert("5".to_owned(), Some('c'));
let outer = Outer {
inner: vec!(
@@ -716,11 +716,11 @@ fn bench_deserializer_1_0(b: &mut Bencher) {
fn bench_deserializer_1_5(b: &mut Bencher) {
b.iter(|| {
let mut map = HashMap::new();
map.insert("1".to_string(), Some('a'));
map.insert("2".to_string(), None);
map.insert("3".to_string(), Some('b'));
map.insert("4".to_string(), None);
map.insert("5".to_string(), Some('c'));
map.insert("1".to_owned(), Some('a'));
map.insert("2".to_owned(), None);
map.insert("3".to_owned(), Some('b'));
map.insert("4".to_owned(), None);
map.insert("5".to_owned(), Some('c'));
let outer = Outer {
inner: vec!(
+3
View File
@@ -1,3 +1,6 @@
#![cfg_attr(feature = "nightly", feature(plugin))]
#![cfg_attr(feature = "nightly", plugin(clippy))]
extern crate num;
extern crate serde;
+4 -4
View File
@@ -95,12 +95,12 @@ declare_tests! {
test_char {
'a' => vec![Token::Char('a')],
'a' => vec![Token::Str("a")],
'a' => vec![Token::String("a".to_string())],
'a' => vec![Token::String("a".to_owned())],
}
test_string {
"abc".to_string() => vec![Token::Str("abc")],
"abc".to_string() => vec![Token::String("abc".to_string())],
"a".to_string() => vec![Token::Char('a')],
"abc".to_owned() => vec![Token::Str("abc")],
"abc".to_owned() => vec![Token::String("abc".to_owned())],
"a".to_owned() => vec![Token::Char('a')],
}
test_option {
None::<i32> => vec![Token::Unit],
+1 -1
View File
@@ -63,7 +63,7 @@ declare_ser_tests! {
}
test_str {
"abc" => &[Token::Str("abc")],
"abc".to_string() => &[Token::Str("abc")],
"abc".to_owned() => &[Token::Str("abc")],
}
test_option {
None::<i32> => &[Token::Option(false)],
+1 -1
View File
@@ -325,7 +325,7 @@ impl de::Error for Error {
fn end_of_stream() -> Error { Error::EndOfStreamError }
fn unknown_field(field: &str) -> Error {
Error::UnknownFieldError(field.to_string())
Error::UnknownFieldError(field.to_owned())
}
fn missing_field(field: &'static str) -> Error {