mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-05-01 15:58:03 +00:00
feat(clippy): Use clippy for it's extra lints
This commit is contained in:
+6
-5
@@ -9,12 +9,13 @@ documentation = "https://serde-rs.github.io/serde/serde/serde/index.html"
|
|||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
keywords = ["serde", "serialization"]
|
keywords = ["serde", "serialization"]
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
num = "^0.1.27"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
nightly = []
|
nightly = ["clippy"]
|
||||||
num-impls = ["num-bigint", "num-complex", "num-rational"]
|
|
||||||
num-bigint = ["num/bigint"]
|
num-bigint = ["num/bigint"]
|
||||||
num-complex = ["num/complex"]
|
num-complex = ["num/complex"]
|
||||||
|
num-impls = ["num-bigint", "num-complex", "num-rational"]
|
||||||
num-rational = ["num/rational"]
|
num-rational = ["num/rational"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
clippy = { version = "^0.0.35", optional = true }
|
||||||
|
num = { version = "^0.1.27", default-features = false }
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ impl Visitor for StringVisitor {
|
|||||||
fn visit_str<E>(&mut self, v: &str) -> Result<String, E>
|
fn visit_str<E>(&mut self, v: &str) -> Result<String, E>
|
||||||
where E: Error,
|
where E: Error,
|
||||||
{
|
{
|
||||||
Ok(v.to_string())
|
Ok(v.to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_string<E>(&mut self, v: String) -> Result<String, E>
|
fn visit_string<E>(&mut self, v: String) -> Result<String, E>
|
||||||
@@ -247,12 +247,12 @@ impl Visitor for StringVisitor {
|
|||||||
where E: Error,
|
where E: Error,
|
||||||
{
|
{
|
||||||
match str::from_utf8(v) {
|
match str::from_utf8(v) {
|
||||||
Ok(s) => Ok(s.to_string()),
|
Ok(s) => Ok(s.to_owned()),
|
||||||
Err(_) => Err(Error::type_mismatch(Type::String)),
|
Err(_) => Err(Error::type_mismatch(Type::String)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_byte_buf<'a, E>(&mut self, v: Vec<u8>) -> Result<String, E>
|
fn visit_byte_buf<E>(&mut self, v: Vec<u8>) -> Result<String, E>
|
||||||
where E: Error,
|
where E: Error,
|
||||||
{
|
{
|
||||||
match String::from_utf8(v) {
|
match String::from_utf8(v) {
|
||||||
|
|||||||
+4
-1
@@ -10,7 +10,10 @@
|
|||||||
//! [github repository](https://github.com/serde-rs/serde)
|
//! [github repository](https://github.com/serde-rs/serde)
|
||||||
|
|
||||||
#![doc(html_root_url="https://serde-rs.github.io/serde/serde")]
|
#![doc(html_root_url="https://serde-rs.github.io/serde/serde")]
|
||||||
#![cfg_attr(feature = "nightly", feature(collections, enumset, nonzero, step_trait, zero_one))]
|
#![cfg_attr(feature = "nightly", feature(collections, enumset, nonzero, plugin, step_trait,
|
||||||
|
zero_one))]
|
||||||
|
#![cfg_attr(feature = "nightly", plugin(clippy))]
|
||||||
|
#![cfg_attr(feature = "nightly", allow(linkedlist))]
|
||||||
|
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
|
|||||||
@@ -566,8 +566,8 @@ impl<K, V, I> MapVisitor for MapIteratorVisitor<I>
|
|||||||
{
|
{
|
||||||
match self.iter.next() {
|
match self.iter.next() {
|
||||||
Some((key, value)) => {
|
Some((key, value)) => {
|
||||||
let value = try!(serializer.visit_map_elt(key, value));
|
try!(serializer.visit_map_elt(key, value));
|
||||||
Ok(Some(value))
|
Ok(Some(()))
|
||||||
}
|
}
|
||||||
None => Ok(None)
|
None => Ok(None)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -322,6 +322,7 @@ pub trait Serializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A trait that is used by a `Serialize` to iterate through a sequence.
|
/// A trait that is used by a `Serialize` to iterate through a sequence.
|
||||||
|
#[cfg_attr(feature = "nightly", allow(len_without_is_empty))]
|
||||||
pub trait SeqVisitor {
|
pub trait SeqVisitor {
|
||||||
/// Serializes a sequence item in the serializer.
|
/// Serializes a sequence item in the serializer.
|
||||||
///
|
///
|
||||||
@@ -338,6 +339,7 @@ pub trait SeqVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A trait that is used by a `Serialize` to iterate through a map.
|
/// A trait that is used by a `Serialize` to iterate through a map.
|
||||||
|
#[cfg_attr(feature = "nightly", allow(len_without_is_empty))]
|
||||||
pub trait MapVisitor {
|
pub trait MapVisitor {
|
||||||
/// Serializes a map item in the serializer.
|
/// Serializes a map item in the serializer.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ keywords = ["serde", "serialization"]
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["with-syntex"]
|
default = ["with-syntex"]
|
||||||
nightly = ["quasi_macros"]
|
nightly = ["clippy", "quasi_macros"]
|
||||||
with-syntex = ["quasi/with-syntex", "quasi_codegen", "quasi_codegen/with-syntex", "syntex", "syntex_syntax"]
|
with-syntex = ["quasi/with-syntex", "quasi_codegen", "quasi_codegen/with-syntex", "syntex", "syntex_syntax"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
@@ -20,6 +20,7 @@ syntex = { version = "^0.26.0", optional = true }
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
aster = { version = "^0.10.0", default-features = false }
|
aster = { version = "^0.10.0", default-features = false }
|
||||||
|
clippy = { version = "^0.0.35", optional = true }
|
||||||
quasi = { version = "^0.4.0", default-features = false }
|
quasi = { version = "^0.4.0", default-features = false }
|
||||||
quasi_macros = { version = "^0.4.0", optional = true }
|
quasi_macros = { version = "^0.4.0", optional = true }
|
||||||
syntex = { version = "^0.26.0", optional = true }
|
syntex = { version = "^0.26.0", optional = true }
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ impl FieldAttrs {
|
|||||||
/// Return a set of formats that the field has attributes for.
|
/// Return a set of formats that the field has attributes for.
|
||||||
pub fn formats(&self) -> HashSet<P<ast::Expr>> {
|
pub fn formats(&self) -> HashSet<P<ast::Expr>> {
|
||||||
match self.names {
|
match self.names {
|
||||||
FieldNames::Format{ref formats, default: _} => {
|
FieldNames::Format { ref formats, .. } => {
|
||||||
let mut set = HashSet::new();
|
let mut set = HashSet::new();
|
||||||
for (fmt, _) in formats.iter() {
|
for (fmt, _) in formats.iter() {
|
||||||
set.insert(fmt.clone());
|
set.insert(fmt.clone());
|
||||||
@@ -70,7 +70,7 @@ impl FieldAttrs {
|
|||||||
pub fn default_key_expr(&self) -> &P<ast::Expr> {
|
pub fn default_key_expr(&self) -> &P<ast::Expr> {
|
||||||
match self.names {
|
match self.names {
|
||||||
FieldNames::Global(ref expr) => expr,
|
FieldNames::Global(ref expr) => expr,
|
||||||
FieldNames::Format{formats: _, ref default} => default,
|
FieldNames::Format { ref default, .. } => default,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#![cfg_attr(feature = "nightly", plugin(clippy))]
|
||||||
|
#![cfg_attr(feature = "nightly", allow(used_underscore_binding))]
|
||||||
#![cfg_attr(not(feature = "with-syntex"), feature(rustc_private, plugin))]
|
#![cfg_attr(not(feature = "with-syntex"), feature(rustc_private, plugin))]
|
||||||
#![cfg_attr(not(feature = "with-syntex"), plugin(quasi_macros))]
|
#![cfg_attr(not(feature = "with-syntex"), plugin(quasi_macros))]
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ name = "serde_macros"
|
|||||||
plugin = true
|
plugin = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
clippy = "^0.0.35"
|
||||||
serde_codegen = { version = "*", path = "../serde_codegen", default-features = false, features = ["nightly"] }
|
serde_codegen = { version = "*", path = "../serde_codegen", default-features = false, features = ["nightly"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#![feature(custom_attribute, custom_derive, plugin, test)]
|
#![feature(custom_attribute, custom_derive, plugin, test)]
|
||||||
|
#![plugin(clippy)]
|
||||||
#![plugin(serde_macros)]
|
#![plugin(serde_macros)]
|
||||||
|
|
||||||
extern crate num;
|
extern crate num;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#![feature(plugin_registrar, rustc_private)]
|
#![feature(plugin, plugin_registrar, rustc_private)]
|
||||||
|
#![plugin(clippy)]
|
||||||
|
|
||||||
extern crate serde_codegen;
|
extern crate serde_codegen;
|
||||||
extern crate rustc_plugin;
|
extern crate rustc_plugin;
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ readme = "README.md"
|
|||||||
keywords = ["serialization"]
|
keywords = ["serialization"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
nightly = ["clippy", "serde/nightly"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
syntex = { version = "^0.26.0" }
|
syntex = { version = "^0.26.0" }
|
||||||
syntex_syntax = { 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"] }
|
serde = { version = "*", path = "../serde", features = ["num-impls"] }
|
||||||
syntex = "^0.26.0"
|
syntex = "^0.26.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
clippy = { version = "^0.0.35", optional = true }
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "test"
|
name = "test"
|
||||||
path = "tests/test.rs"
|
path = "tests/test.rs"
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
|
#![cfg_attr(feature = "nightly", feature(plugin))]
|
||||||
|
#![cfg_attr(feature = "nightly", plugin(clippy))]
|
||||||
|
|
||||||
extern crate num;
|
extern crate num;
|
||||||
extern crate rustc_serialize;
|
extern crate rustc_serialize;
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ fn bench_decoder_dog(b: &mut Bencher) {
|
|||||||
#[bench]
|
#[bench]
|
||||||
fn bench_decoder_frog(b: &mut Bencher) {
|
fn bench_decoder_frog(b: &mut Bencher) {
|
||||||
b.iter(|| {
|
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 mut d = decoder::AnimalDecoder::new(animal.clone());
|
||||||
let value: Animal = Decodable::decode(&mut d).unwrap();
|
let value: Animal = Decodable::decode(&mut d).unwrap();
|
||||||
@@ -439,7 +439,7 @@ fn bench_deserializer_dog(b: &mut Bencher) {
|
|||||||
#[bench]
|
#[bench]
|
||||||
fn bench_deserializer_frog(b: &mut Bencher) {
|
fn bench_deserializer_frog(b: &mut Bencher) {
|
||||||
b.iter(|| {
|
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 mut d = deserializer::AnimalDeserializer::new(animal.clone());
|
||||||
let value: Animal = Deserialize::deserialize(&mut d).unwrap();
|
let value: Animal = Deserialize::deserialize(&mut d).unwrap();
|
||||||
|
|||||||
@@ -614,7 +614,7 @@ mod deserializer {
|
|||||||
fn bench_decoder_0_0(b: &mut Bencher) {
|
fn bench_decoder_0_0(b: &mut Bencher) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut map = HashMap::new();
|
let mut map = HashMap::new();
|
||||||
map.insert("abc".to_string(), Some('c'));
|
map.insert("abc".to_owned(), Some('c'));
|
||||||
|
|
||||||
let outer = Outer {
|
let outer = Outer {
|
||||||
inner: vec!(),
|
inner: vec!(),
|
||||||
@@ -653,11 +653,11 @@ fn bench_decoder_1_0(b: &mut Bencher) {
|
|||||||
fn bench_decoder_1_5(b: &mut Bencher) {
|
fn bench_decoder_1_5(b: &mut Bencher) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut map = HashMap::new();
|
let mut map = HashMap::new();
|
||||||
map.insert("1".to_string(), Some('a'));
|
map.insert("1".to_owned(), Some('a'));
|
||||||
map.insert("2".to_string(), None);
|
map.insert("2".to_owned(), None);
|
||||||
map.insert("3".to_string(), Some('b'));
|
map.insert("3".to_owned(), Some('b'));
|
||||||
map.insert("4".to_string(), None);
|
map.insert("4".to_owned(), None);
|
||||||
map.insert("5".to_string(), Some('c'));
|
map.insert("5".to_owned(), Some('c'));
|
||||||
|
|
||||||
let outer = Outer {
|
let outer = Outer {
|
||||||
inner: vec!(
|
inner: vec!(
|
||||||
@@ -716,11 +716,11 @@ fn bench_deserializer_1_0(b: &mut Bencher) {
|
|||||||
fn bench_deserializer_1_5(b: &mut Bencher) {
|
fn bench_deserializer_1_5(b: &mut Bencher) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut map = HashMap::new();
|
let mut map = HashMap::new();
|
||||||
map.insert("1".to_string(), Some('a'));
|
map.insert("1".to_owned(), Some('a'));
|
||||||
map.insert("2".to_string(), None);
|
map.insert("2".to_owned(), None);
|
||||||
map.insert("3".to_string(), Some('b'));
|
map.insert("3".to_owned(), Some('b'));
|
||||||
map.insert("4".to_string(), None);
|
map.insert("4".to_owned(), None);
|
||||||
map.insert("5".to_string(), Some('c'));
|
map.insert("5".to_owned(), Some('c'));
|
||||||
|
|
||||||
let outer = Outer {
|
let outer = Outer {
|
||||||
inner: vec!(
|
inner: vec!(
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#![cfg_attr(feature = "nightly", feature(plugin))]
|
||||||
|
#![cfg_attr(feature = "nightly", plugin(clippy))]
|
||||||
|
|
||||||
extern crate num;
|
extern crate num;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
|
|
||||||
|
|||||||
@@ -95,12 +95,12 @@ declare_tests! {
|
|||||||
test_char {
|
test_char {
|
||||||
'a' => vec![Token::Char('a')],
|
'a' => vec![Token::Char('a')],
|
||||||
'a' => vec![Token::Str("a")],
|
'a' => vec![Token::Str("a")],
|
||||||
'a' => vec![Token::String("a".to_string())],
|
'a' => vec![Token::String("a".to_owned())],
|
||||||
}
|
}
|
||||||
test_string {
|
test_string {
|
||||||
"abc".to_string() => vec![Token::Str("abc")],
|
"abc".to_owned() => vec![Token::Str("abc")],
|
||||||
"abc".to_string() => vec![Token::String("abc".to_string())],
|
"abc".to_owned() => vec![Token::String("abc".to_owned())],
|
||||||
"a".to_string() => vec![Token::Char('a')],
|
"a".to_owned() => vec![Token::Char('a')],
|
||||||
}
|
}
|
||||||
test_option {
|
test_option {
|
||||||
None::<i32> => vec![Token::Unit],
|
None::<i32> => vec![Token::Unit],
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ declare_ser_tests! {
|
|||||||
}
|
}
|
||||||
test_str {
|
test_str {
|
||||||
"abc" => &[Token::Str("abc")],
|
"abc" => &[Token::Str("abc")],
|
||||||
"abc".to_string() => &[Token::Str("abc")],
|
"abc".to_owned() => &[Token::Str("abc")],
|
||||||
}
|
}
|
||||||
test_option {
|
test_option {
|
||||||
None::<i32> => &[Token::Option(false)],
|
None::<i32> => &[Token::Option(false)],
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ impl de::Error for Error {
|
|||||||
fn end_of_stream() -> Error { Error::EndOfStreamError }
|
fn end_of_stream() -> Error { Error::EndOfStreamError }
|
||||||
|
|
||||||
fn unknown_field(field: &str) -> Error {
|
fn unknown_field(field: &str) -> Error {
|
||||||
Error::UnknownFieldError(field.to_string())
|
Error::UnknownFieldError(field.to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn missing_field(field: &'static str) -> Error {
|
fn missing_field(field: &'static str) -> Error {
|
||||||
|
|||||||
Reference in New Issue
Block a user