All combinations of features compile without warnings

This commit is contained in:
David Tolnay 2017-01-10 01:02:45 -08:00
parent e27553d3df
commit a09a8a039a
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
6 changed files with 36 additions and 43 deletions

View File

@ -2,7 +2,7 @@
#[cfg(feature = "std")]
use std::borrow::Cow;
#[cfg(all(feature = "unstable", feature = "collections", not(feature = "std")))]
#[cfg(all(feature = "collections", not(feature = "std")))]
use collections::borrow::Cow;
#[cfg(all(feature = "collections", not(feature = "std")))]
@ -27,12 +27,13 @@ use std::collections::{
VecDeque,
};
#[cfg(all(feature = "unstable", feature = "collections"))]
#[cfg(feature = "collections")]
use collections::enum_set::{CLike, EnumSet};
#[cfg(all(feature = "unstable", feature = "collections"))]
#[cfg(feature = "collections")]
use collections::borrow::ToOwned;
use core::fmt;
#[cfg(feature = "std")]
use core::hash::{Hash, BuildHasher};
use core::marker::PhantomData;
#[cfg(feature = "std")]
@ -43,15 +44,15 @@ use core::str;
#[cfg(feature = "std")]
use std::rc::Rc;
#[cfg(all(feature = "unstable", feature = "alloc", not(feature = "std")))]
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::rc::Rc;
#[cfg(feature = "std")]
use std::sync::Arc;
#[cfg(all(feature = "unstable", feature = "alloc", not(feature = "std")))]
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::arc::Arc;
#[cfg(all(feature = "unstable", feature = "alloc", not(feature = "std")))]
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::boxed::Box;
#[cfg(feature = "std")]
@ -482,7 +483,7 @@ seq_impl!(
BTreeSet::new(),
BTreeSet::insert);
#[cfg(all(feature = "unstable", feature = "collections"))]
#[cfg(feature = "collections")]
seq_impl!(
EnumSet<T>,
EnumSetVisitor<T: Deserialize + CLike>,

View File

@ -415,7 +415,7 @@ pub trait Deserialize: Sized {
/// to deserialize it into a flat representation like `vec![1, 2, 3, 4, 5, 6]`.
/// Allocating a brand new `Vec<T>` for each subarray would be slow. Instead we
/// would like to allocate a single `Vec<T>` and then deserialize each subarray
/// into it. This requires stateful deserialization using the DeserializeSeed
/// into it. This requires stateful deserialization using the `DeserializeSeed`
/// trait.
///
/// ```rust

View File

@ -33,9 +33,7 @@ use collections::boxed::Box;
#[cfg(all(feature = "collections", not(feature = "std")))]
use collections::string::ToString;
#[cfg(all(feature = "unstable", feature = "collections"))]
use collections::borrow::ToOwned;
#[cfg(feature = "std")]
use core::hash::Hash;
#[cfg(feature = "std")]
use std::error;
@ -67,7 +65,7 @@ impl de::Error for Error {
}
#[cfg(not(any(feature = "std", feature = "collections")))]
fn custom<T: Display>(msg: T) -> Self {
fn custom<T: Display>(_msg: T) -> Self {
Error(())
}
}
@ -579,7 +577,7 @@ impl<I, E> MapDeserializer<I, E>
}
}
fn next(&mut self) -> Option<(<I::Item as private::Pair>::First, <I::Item as private::Pair>::Second)> {
fn next_pair(&mut self) -> Option<(<I::Item as private::Pair>::First, <I::Item as private::Pair>::Second)> {
match self.iter.next() {
Some(kv) => {
self.count += 1;
@ -654,7 +652,7 @@ impl<I, E> de::MapVisitor for MapDeserializer<I, E>
fn visit_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
where T: de::DeserializeSeed,
{
match self.next() {
match self.next_pair() {
Some((key, value)) => {
self.value = Some(value);
seed.deserialize(key.into_deserializer()).map(Some)
@ -677,7 +675,7 @@ impl<I, E> de::MapVisitor for MapDeserializer<I, E>
where TK: de::DeserializeSeed,
TV: de::DeserializeSeed
{
match self.next() {
match self.next_pair() {
Some((key, value)) => {
let key = try!(kseed.deserialize(key.into_deserializer()));
let value = try!(vseed.deserialize(value.into_deserializer()));
@ -704,7 +702,7 @@ impl<I, E> de::SeqVisitor for MapDeserializer<I, E>
fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
where T: de::DeserializeSeed,
{
match self.next() {
match self.next_pair() {
Some((k, v)) => {
let de = PairDeserializer(k, v, PhantomData);
seed.deserialize(de).map(Some)
@ -993,8 +991,8 @@ mod private {
}
}
/// Avoid having to restate the generic types on MapDeserializer. The
/// Iterator::Item contains enough information to figure out K and V.
/// Avoid having to restate the generic types on `MapDeserializer`. The
/// `Iterator::Item` contains enough information to figure out K and V.
pub trait Pair {
type First;
type Second;

View File

@ -11,30 +11,29 @@
#![doc(html_root_url="https://docs.serde.rs")]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "unstable", feature(reflect_marker, unicode, nonzero, plugin, step_trait, zero_one, inclusive_range))]
#![cfg_attr(feature = "unstable", feature(nonzero, inclusive_range, zero_one))]
#![cfg_attr(feature = "alloc", feature(alloc))]
#![cfg_attr(feature = "collections", feature(collections, enumset))]
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
#![cfg_attr(feature = "clippy", allow(linkedlist))]
#![cfg_attr(any(not(feature = "std"), feature = "unstable"), allow(unused_variables, unused_imports, unused_features, dead_code))]
#![cfg_attr(feature = "clippy", allow(linkedlist, type_complexity))]
#![deny(missing_docs)]
#[cfg(all(feature = "unstable", feature = "collections"))]
#[cfg(feature = "collections")]
extern crate collections;
#[cfg(all(feature = "unstable", feature = "alloc"))]
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "unstable")]
extern crate core as actual_core;
#[cfg(feature = "std")]
mod core {
pub use std::{ops, hash, fmt, cmp, marker, mem, i8, i16, i32, i64, u8, u16, u32, u64, isize,
usize, f32, f64, char, str, num, slice, iter, cell};
#[cfg(feature = "unstable")]
extern crate core;
#[cfg(feature = "unstable")]
pub use self::core::nonzero;
pub use actual_core::nonzero;
}
pub use ser::{Serialize, Serializer};
@ -48,6 +47,6 @@ pub mod de;
#[cfg(feature = "std")]
pub mod iter;
pub mod ser;
#[cfg(not(feature = "std"))]
#[cfg_attr(feature = "std", doc(hidden))]
pub mod error;
mod utils;

View File

@ -30,19 +30,18 @@ use collections::{
Vec,
};
#[cfg(all(feature = "unstable", feature = "collections"))]
#[cfg(feature = "collections")]
use collections::enum_set::{CLike, EnumSet};
#[cfg(all(feature = "unstable", feature = "collections"))]
#[cfg(feature = "collections")]
use collections::borrow::ToOwned;
#[cfg(feature = "std")]
use core::hash::{Hash, BuildHasher};
#[cfg(feature = "unstable")]
use core::iter;
#[cfg(feature = "std")]
use std::net;
#[cfg(feature = "unstable")]
use core::num;
#[cfg(feature = "unstable")]
use core::ops;
#[cfg(feature = "std")]
use std::path;
@ -67,14 +66,13 @@ use core::marker::PhantomData;
use core::nonzero::{NonZero, Zeroable};
use super::{
Error,
Serialize,
SerializeMap,
SerializeSeq,
SerializeStruct,
SerializeTuple,
Serializer,
};
#[cfg(any(feature = "std", feature = "unstable"))]
use super::Error;
#[cfg(feature = "unstable")]
use super::Iterator;
@ -241,7 +239,7 @@ impl<'a, I> Serialize for Iterator<I>
// FIXME: use specialization to prevent invalidating the object in case of clonable iterators?
let iter = match self.0.borrow_mut().take() {
Some(iter) => iter.into_iter(),
None => return Err(S::Error::custom("Iterator used twice")),
None => return Err(Error::custom("Iterator used twice")),
};
let size = match iter.size_hint() {
(lo, Some(hi)) if lo == hi => Some(lo),
@ -286,7 +284,7 @@ impl<T> Serialize for BTreeSet<T>
serialize_seq!();
}
#[cfg(all(feature = "unstable", feature = "collections"))]
#[cfg(feature = "collections")]
impl<T> Serialize for EnumSet<T>
where T: Serialize + CLike
{
@ -573,6 +571,7 @@ macro_rules! serialize_map {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,
{
use super::SerializeMap;
let mut map = try!(serializer.serialize_map(Some(self.len())));
for (k, v) in self {
try!(map.serialize_key(k));
@ -695,6 +694,7 @@ impl Serialize for Duration {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,
{
use super::SerializeStruct;
let mut state = try!(serializer.serialize_struct("Duration", 2));
try!(state.serialize_field("secs", self.as_secs()));
try!(state.serialize_field("nanos", self.subsec_nanos()));

View File

@ -15,11 +15,6 @@ use std::error;
#[cfg(not(feature = "std"))]
use error;
#[cfg(all(feature = "collections", not(feature = "std")))]
use collections::String;
#[cfg(feature = "unstable")]
use core::marker::PhantomData;
#[cfg(feature = "unstable")]
use core::cell::RefCell;