Compare commits

...

14 Commits

Author SHA1 Message Date
David Tolnay d960571439 Release 0.9.5 2017-02-01 01:01:06 -08:00
David Tolnay 1ccc58e2aa Merge pull request #735 from serde-rs/travis
Allow running travis build locally
2017-02-01 00:43:27 -08:00
David Tolnay 34b39083bc No error if clippy install fails 2017-02-01 00:38:02 -08:00
David Tolnay 48f4deac55 No more travis-cargo 2017-01-31 12:18:57 -08:00
David Tolnay 9a0f05d00d Speed up the travis clippy installation 2017-01-31 12:09:44 -08:00
David Tolnay b47e1a6dc3 Allow clippy failure in travis 2017-01-31 12:07:35 -08:00
David Tolnay 39c7797633 Allow running travis build locally 2017-01-31 12:07:31 -08:00
Oliver Schneider 368784949e move to cargo clippy instead of using the clippy plugin (#733)
* move to cargo clippy instead of using the clippy plugin

fixes #729

* non-exectable scripts must be run with `sh`

* don't build serde in the clippy travis job

* only run clippy tests if installing clippy succeeds

* why is travis so picky?

* no more serde_codegen

* serde_test_suite_deps has no features

* don't use empty loops, llvm optimizes them to undefined behaviour

* abort the clippy job when clippy lints are triggered

* use caches on travis to speed up builds

* why are we even using `travis-cargo`?

* need to reinstall clippy frequently due to nightly updates

* command line tools are hard
2017-01-31 09:09:37 -08:00
Oliver Schneider 74cf80989d Merge pull request #731 from serde-rs/pubtuple
No tuple structs with private fields in public API
2017-01-31 08:56:46 +01:00
David Tolnay f0b4735781 No tuple structs with private fields in public API 2017-01-30 18:10:50 -08:00
David Tolnay 297f373548 Release 0.9.4 2017-01-30 17:42:11 -08:00
David Tolnay 81f28da8e1 Clarify the role of Impossible serializer 2017-01-30 17:41:33 -08:00
David Tolnay d4bb687032 Merge pull request #728 from nox/impossibru
Introduce ser::Impossible (fixes #694)
2017-01-30 17:26:21 -08:00
Anthony Ramine f9bc5037f5 Introduce ser::Impossible (fixes #694) 2017-01-31 02:20:04 +01:00
19 changed files with 364 additions and 88 deletions
+6 -17
View File
@@ -1,5 +1,6 @@
sudo: false
language: rust
cache: cargo
# run builds for all the trains (and more)
rust:
@@ -8,21 +9,9 @@ rust:
- beta
- nightly
before_script:
- pip install 'travis-cargo<0.2' --user
- export PATH=$HOME/.local/bin:$PATH
matrix:
include:
- rust: nightly
env: CLIPPY=true
script:
- (cd serde && travis-cargo build)
- (cd serde && travis-cargo --only beta test)
- (cd serde && travis-cargo --only nightly test -- --features unstable-testing)
- (cd serde && travis-cargo build -- --no-default-features)
- (cd serde && travis-cargo --only nightly build -- --no-default-features --features alloc)
- (cd serde && travis-cargo --only nightly build -- --no-default-features --features collections)
- (cd test_suite && travis-cargo --only beta test)
- (cd test_suite/deps && travis-cargo --only nightly build && cd .. && travis-cargo --only nightly test -- --features unstable-testing)
- (cd test_suite/no_std && travis-cargo --only nightly build)
env:
global:
- TRAVIS_CARGO_NIGHTLY_FEATURE=""
script: ./travis.sh
+9
View File
@@ -0,0 +1,9 @@
[workspace]
members = [
"serde",
"serde_codegen_internals",
"serde_derive",
"serde_test",
"test_suite",
"test_suite/no_std",
]
+2 -5
View File
@@ -1,6 +1,6 @@
[package]
name = "serde"
version = "0.9.3"
version = "0.9.5"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "A generic serialization/deserialization framework"
@@ -22,10 +22,7 @@ std = []
unstable = []
alloc = ["unstable"]
collections = ["alloc"]
unstable-testing = ["clippy", "unstable", "std"]
[dependencies]
clippy = { version = "0.*", optional = true }
unstable-testing = ["unstable", "std"]
[dev-dependencies]
serde_derive = "0.9"
+75 -27
View File
@@ -51,7 +51,9 @@ use bytes;
/// This represents all the possible errors that can occur using the `ValueDeserializer`.
#[derive(Clone, Debug, PartialEq)]
pub struct Error(ErrorImpl);
pub struct Error {
err: ErrorImpl,
}
#[cfg(any(feature = "std", feature = "collections"))]
type ErrorImpl = Box<str>;
@@ -61,19 +63,23 @@ type ErrorImpl = ();
impl de::Error for Error {
#[cfg(any(feature = "std", feature = "collections"))]
fn custom<T: Display>(msg: T) -> Self {
Error(msg.to_string().into_boxed_str())
Error {
err: msg.to_string().into_boxed_str(),
}
}
#[cfg(not(any(feature = "std", feature = "collections")))]
fn custom<T: Display>(_msg: T) -> Self {
Error(())
Error {
err: (),
}
}
}
impl Display for Error {
#[cfg(any(feature = "std", feature = "collections"))]
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
formatter.write_str(&self.0)
formatter.write_str(&self.err)
}
#[cfg(not(any(feature = "std", feature = "collections")))]
@@ -85,7 +91,7 @@ impl Display for Error {
impl error::Error for Error {
#[cfg(any(feature = "std", feature = "collections"))]
fn description(&self) -> &str {
&self.0
&self.err
}
#[cfg(not(any(feature = "std", feature = "collections")))]
@@ -113,12 +119,16 @@ impl<E> ValueDeserializer<E> for ()
type Deserializer = UnitDeserializer<E>;
fn into_deserializer(self) -> UnitDeserializer<E> {
UnitDeserializer(PhantomData)
UnitDeserializer {
marker: PhantomData,
}
}
}
/// A helper deserializer that deserializes a `()`.
pub struct UnitDeserializer<E>(PhantomData<E>);
pub struct UnitDeserializer<E> {
marker: PhantomData<E>,
}
impl<E> de::Deserializer for UnitDeserializer<E>
where E: de::Error
@@ -149,7 +159,10 @@ impl<E> de::Deserializer for UnitDeserializer<E>
macro_rules! primitive_deserializer {
($ty:ty, $name:ident, $method:ident $($cast:tt)*) => {
/// A helper deserializer that deserializes a number.
pub struct $name<E>($ty, PhantomData<E>);
pub struct $name<E> {
value: $ty,
marker: PhantomData<E>
}
impl<E> ValueDeserializer<E> for $ty
where E: de::Error,
@@ -157,7 +170,10 @@ macro_rules! primitive_deserializer {
type Deserializer = $name<E>;
fn into_deserializer(self) -> $name<E> {
$name(self, PhantomData)
$name {
value: self,
marker: PhantomData,
}
}
}
@@ -175,7 +191,7 @@ macro_rules! primitive_deserializer {
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: de::Visitor,
{
visitor.$method(self.0 $($cast)*)
visitor.$method(self.value $($cast)*)
}
}
}
@@ -199,7 +215,10 @@ primitive_deserializer!(char, CharDeserializer, visit_char);
///////////////////////////////////////////////////////////////////////////////
/// A helper deserializer that deserializes a `&str`.
pub struct StrDeserializer<'a, E>(&'a str, PhantomData<E>);
pub struct StrDeserializer<'a, E> {
value: &'a str,
marker: PhantomData<E>,
}
impl<'a, E> ValueDeserializer<E> for &'a str
where E: de::Error,
@@ -207,7 +226,10 @@ impl<'a, E> ValueDeserializer<E> for &'a str
type Deserializer = StrDeserializer<'a, E>;
fn into_deserializer(self) -> StrDeserializer<'a, E> {
StrDeserializer(self, PhantomData)
StrDeserializer {
value: self,
marker: PhantomData,
}
}
}
@@ -219,7 +241,7 @@ impl<'a, E> de::Deserializer for StrDeserializer<'a, E>
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: de::Visitor,
{
visitor.visit_str(self.0)
visitor.visit_str(self.value)
}
fn deserialize_enum<V>(self,
@@ -255,7 +277,10 @@ impl<'a, E> de::EnumVisitor for StrDeserializer<'a, E>
/// A helper deserializer that deserializes a `String`.
#[cfg(any(feature = "std", feature = "collections"))]
pub struct StringDeserializer<E>(String, PhantomData<E>);
pub struct StringDeserializer<E> {
value: String,
marker: PhantomData<E>,
}
#[cfg(any(feature = "std", feature = "collections"))]
impl<E> ValueDeserializer<E> for String
@@ -264,7 +289,10 @@ impl<E> ValueDeserializer<E> for String
type Deserializer = StringDeserializer<E>;
fn into_deserializer(self) -> StringDeserializer<E> {
StringDeserializer(self, PhantomData)
StringDeserializer {
value: self,
marker: PhantomData,
}
}
}
@@ -277,7 +305,7 @@ impl<E> de::Deserializer for StringDeserializer<E>
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: de::Visitor,
{
visitor.visit_string(self.0)
visitor.visit_string(self.value)
}
fn deserialize_enum<V>(self,
@@ -314,7 +342,10 @@ impl<'a, E> de::EnumVisitor for StringDeserializer<E>
/// A helper deserializer that deserializes a `String`.
#[cfg(any(feature = "std", feature = "collections"))]
pub struct CowStrDeserializer<'a, E>(Cow<'a, str>, PhantomData<E>);
pub struct CowStrDeserializer<'a, E> {
value: Cow<'a, str>,
marker: PhantomData<E>,
}
#[cfg(any(feature = "std", feature = "collections"))]
impl<'a, E> ValueDeserializer<E> for Cow<'a, str>
@@ -323,7 +354,10 @@ impl<'a, E> ValueDeserializer<E> for Cow<'a, str>
type Deserializer = CowStrDeserializer<'a, E>;
fn into_deserializer(self) -> CowStrDeserializer<'a, E> {
CowStrDeserializer(self, PhantomData)
CowStrDeserializer {
value: self,
marker: PhantomData,
}
}
}
@@ -336,7 +370,7 @@ impl<'a, E> de::Deserializer for CowStrDeserializer<'a, E>
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: de::Visitor,
{
match self.0 {
match self.value {
Cow::Borrowed(string) => visitor.visit_str(string),
Cow::Owned(string) => visitor.visit_string(string),
}
@@ -885,12 +919,18 @@ impl<'a, E> ValueDeserializer<E> for bytes::Bytes<'a>
type Deserializer = BytesDeserializer<'a, E>;
fn into_deserializer(self) -> BytesDeserializer<'a, E> {
BytesDeserializer(self.into(), PhantomData)
BytesDeserializer {
value: self.into(),
marker: PhantomData,
}
}
}
/// A helper deserializer that deserializes a `&[u8]`.
pub struct BytesDeserializer<'a, E>(&'a [u8], PhantomData<E>);
pub struct BytesDeserializer<'a, E> {
value: &'a [u8],
marker: PhantomData<E>,
}
impl<'a, E> de::Deserializer for BytesDeserializer<'a, E>
where E: de::Error
@@ -900,7 +940,7 @@ impl<'a, E> de::Deserializer for BytesDeserializer<'a, E>
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: de::Visitor,
{
visitor.visit_bytes(self.0)
visitor.visit_bytes(self.value)
}
forward_to_deserialize! {
@@ -919,13 +959,19 @@ impl<E> ValueDeserializer<E> for bytes::ByteBuf
type Deserializer = ByteBufDeserializer<E>;
fn into_deserializer(self) -> Self::Deserializer {
ByteBufDeserializer(self.into(), PhantomData)
ByteBufDeserializer {
value: self.into(),
marker: PhantomData,
}
}
}
/// A helper deserializer that deserializes a `Vec<u8>`.
#[cfg(any(feature = "std", feature = "collections"))]
pub struct ByteBufDeserializer<E>(Vec<u8>, PhantomData<E>);
pub struct ByteBufDeserializer<E> {
value: Vec<u8>,
marker: PhantomData<E>,
}
#[cfg(any(feature = "std", feature = "collections"))]
impl<E> de::Deserializer for ByteBufDeserializer<E>
@@ -936,7 +982,7 @@ impl<E> de::Deserializer for ByteBufDeserializer<E>
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: de::Visitor,
{
visitor.visit_byte_buf(self.0)
visitor.visit_byte_buf(self.value)
}
forward_to_deserialize! {
@@ -952,10 +998,12 @@ mod private {
use de::{self, Unexpected};
use core::marker::PhantomData;
pub struct UnitOnly<E>(PhantomData<E>);
pub struct UnitOnly<E> {
marker: PhantomData<E>,
}
pub fn unit_only<T, E>(t: T) -> (T, UnitOnly<E>) {
(t, UnitOnly(PhantomData))
(t, UnitOnly { marker: PhantomData })
}
impl<E> de::VariantVisitor for UnitOnly<E>
+1 -3
View File
@@ -64,9 +64,7 @@
#![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, type_complexity, doc_markdown))]
#![cfg_attr(feature = "cargo-clippy", allow(linkedlist, type_complexity, doc_markdown))]
#![deny(missing_docs)]
#[cfg(feature = "collections")]
+1 -1
View File
@@ -231,7 +231,7 @@ impl<'a, I> Serialize for Iterator<I>
where S: Serializer,
{
// FIXME: use specialization to prevent invalidating the object in case of clonable iterators?
let iter = match self.0.borrow_mut().take() {
let iter = match self.data.borrow_mut().take() {
Some(iter) => iter.into_iter(),
None => return Err(Error::custom("Iterator used twice")),
};
+177
View File
@@ -0,0 +1,177 @@
//! This module contains `Impossible` serializer and its implementations.
use core::marker::PhantomData;
use ser::{
self,
Serialize,
SerializeSeq,
SerializeTuple,
SerializeTupleStruct,
SerializeTupleVariant,
SerializeMap,
SerializeStruct,
SerializeStructVariant,
};
/// Helper type for implementing a `Serializer` that does not support
/// serializing one of the compound types.
///
/// This type cannot be instantiated, but implements every one of the traits
/// corresponding to the `Serializer` compound types: `SerializeSeq`,
/// `SerializeTuple`, `SerializeTupleStruct`, `SerializeTupleVariant`,
/// `SerializeMap`, `SerializeStruct`, and `SerializeStructVariant`.
///
/// ```rust,ignore
/// impl Serializer for MySerializer {
/// type Ok = ();
/// type Error = Error;
///
/// type SerializeSeq = Impossible<(), Error>;
/// /* other associated types */
///
/// /// This data format does not support serializing sequences.
/// fn serialize_seq(self,
/// len: Option<usize>)
/// -> Result<Self::SerializeSeq, Error> {
/// // Given Impossible cannot be instantiated, the only
/// // thing we can do here is to return an error.
/// Err(...)
/// }
///
/// /* other Serializer methods */
/// }
/// ```
pub struct Impossible<Ok, E> {
void: Void,
_marker: PhantomData<(Ok, E)>,
}
enum Void {}
impl<Ok, E> SerializeSeq for Impossible<Ok, E>
where E: ser::Error,
{
type Ok = Ok;
type Error = E;
fn serialize_element<T: ?Sized + Serialize>(&mut self,
_value: &T)
-> Result<(), E> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
match self.void {}
}
}
impl<Ok, E> SerializeTuple for Impossible<Ok, E>
where E: ser::Error,
{
type Ok = Ok;
type Error = E;
fn serialize_element<T: ?Sized + Serialize>(&mut self,
_value: &T)
-> Result<(), E> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
match self.void {}
}
}
impl<Ok, E> SerializeTupleStruct for Impossible<Ok, E>
where E: ser::Error,
{
type Ok = Ok;
type Error = E;
fn serialize_field<T: ?Sized + Serialize>(&mut self,
_value: &T)
-> Result<(), E> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
match self.void {}
}
}
impl<Ok, E> SerializeTupleVariant for Impossible<Ok, E>
where E: ser::Error,
{
type Ok = Ok;
type Error = E;
fn serialize_field<T: ?Sized + Serialize>(&mut self,
_value: &T)
-> Result<(), E> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
match self.void {}
}
}
impl<Ok, E> SerializeMap for Impossible<Ok, E>
where E: ser::Error,
{
type Ok = Ok;
type Error = E;
fn serialize_key<T: ?Sized + Serialize>(&mut self,
_key: &T)
-> Result<(), E> {
match self.void {}
}
fn serialize_value<T: ?Sized + Serialize>(&mut self,
_value: &T)
-> Result<(), E> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
match self.void {}
}
}
impl<Ok, E> SerializeStruct for Impossible<Ok, E>
where E: ser::Error,
{
type Ok = Ok;
type Error = E;
fn serialize_field<T: ?Sized + Serialize>(&mut self,
_key: &'static str,
_value: &T)
-> Result<(), E> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
match self.void {}
}
}
impl<Ok, E> SerializeStructVariant for Impossible<Ok, E>
where E: ser::Error,
{
type Ok = Ok;
type Error = E;
fn serialize_field<T: ?Sized + Serialize>(&mut self,
_key: &'static str,
_value: &T)
-> Result<(), E> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
match self.void {}
}
}
+11 -3
View File
@@ -104,6 +104,9 @@ use core::cell::RefCell;
use core::fmt::Display;
mod impls;
mod impossible;
pub use self::impossible::Impossible;
///////////////////////////////////////////////////////////////////////////////
@@ -802,9 +805,12 @@ pub trait SerializeStructVariant {
/// of this with the `serde::ser::iterator` function every time you want to
/// serialize an iterator.
#[cfg(feature = "unstable")]
pub struct Iterator<I>(RefCell<Option<I>>)
pub struct Iterator<I>
where <I as IntoIterator>::Item: Serialize,
I: IntoIterator;
I: IntoIterator
{
data: RefCell<Option<I>>,
}
/// Create a wrapper type that can be passed to any function expecting a
/// `Serialize` and will serialize the given iterator as a sequence.
@@ -813,5 +819,7 @@ pub fn iterator<I>(iter: I) -> Iterator<I>
where <I as IntoIterator>::Item: Serialize,
I: IntoIterator
{
Iterator(RefCell::new(Some(iter)))
Iterator {
data: RefCell::new(Some(iter)),
}
}
+1 -5
View File
@@ -1,6 +1,6 @@
[package]
name = "serde_codegen_internals"
version = "0.12.0"
version = "0.12.1"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "AST representation used by Serde codegen. Unstable."
@@ -10,11 +10,7 @@ documentation = "https://docs.serde.rs/serde_codegen_internals/"
keywords = ["serde", "serialization"]
include = ["Cargo.toml", "src/**/*.rs"]
[features]
unstable-testing = ["clippy"]
[dependencies]
clippy = { version = "0.*", optional = true }
syn = "0.11"
[badges]
-3
View File
@@ -1,6 +1,3 @@
#![cfg_attr(feature = "clippy", plugin(clippy))]
#![cfg_attr(feature = "clippy", feature(plugin))]
extern crate syn;
pub mod ast;
+2 -4
View File
@@ -1,6 +1,6 @@
[package]
name = "serde_derive"
version = "0.9.3"
version = "0.9.5"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
@@ -12,7 +12,6 @@ include = ["Cargo.toml", "src/**/*.rs"]
[features]
unstable = []
unstable-testing = ["clippy", "serde_codegen_internals/unstable-testing"]
[badges]
travis-ci = { repository = "serde-rs/serde" }
@@ -22,7 +21,6 @@ name = "serde_derive"
proc-macro = true
[dependencies]
clippy = { version = "0.*", optional = true }
quote = "0.3.8"
serde_codegen_internals = { version = "=0.12.0", default-features = false, path = "../serde_codegen_internals" }
serde_codegen_internals = { version = "=0.12.1", default-features = false, path = "../serde_codegen_internals" }
syn = { version = "0.11", features = ["aster", "visit"] }
+2 -4
View File
@@ -1,7 +1,5 @@
#![cfg_attr(feature = "clippy", plugin(clippy))]
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", allow(too_many_arguments))]
#![cfg_attr(feature = "clippy", allow(used_underscore_binding))]
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#![cfg_attr(feature = "cargo-clippy", allow(used_underscore_binding))]
// The `quote!` macro requires deep recursion.
#![recursion_limit = "192"]
+1 -5
View File
@@ -1,6 +1,6 @@
[package]
name = "serde_test"
version = "0.9.3"
version = "0.9.5"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "Token De/Serializer for testing De/Serialize implementations"
@@ -11,11 +11,7 @@ readme = "../README.md"
keywords = ["serde", "serialization"]
include = ["Cargo.toml", "src/**/*.rs"]
[features]
unstable-testing = ["clippy"]
[dependencies]
clippy = { version = "0.*", optional = true }
serde = { version = "0.9", path = "../serde" }
[badges]
-3
View File
@@ -1,6 +1,3 @@
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
extern crate serde;
mod assert;
-4
View File
@@ -13,11 +13,8 @@ publish = false
[features]
unstable-testing = [
"clippy",
"compiletest_rs",
"serde/unstable-testing",
"serde_derive/unstable-testing",
"serde_test/unstable-testing",
]
[dev-dependencies]
@@ -28,7 +25,6 @@ serde_derive = { path = "../serde_derive" }
serde_test = { path = "../serde_test" }
[dependencies]
clippy = { version = "0.*", optional = true }
compiletest_rs = { version = "0.2", optional = true }
[[test]]
+2
View File
@@ -4,6 +4,8 @@ version = "0.0.0"
authors = ["David Tolnay <dtolnay@gmail.com>"]
publish = false
[workspace]
[dependencies]
serde = { path = "../../serde" }
serde_derive = { path = "../../serde_derive" }
+3 -1
View File
@@ -21,7 +21,9 @@ pub extern fn rust_eh_unwind_resume() {}
pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
_file: &'static str,
_line: u32) -> ! {
loop {}
unsafe {
libc::abort()
}
}
//////////////////////////////////////////////////////////////////////////////
-3
View File
@@ -1,6 +1,3 @@
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
#![cfg_attr(feature = "unstable-testing", feature(test, non_ascii_idents))]
#[cfg(feature = "unstable-testing")]
Executable
+71
View File
@@ -0,0 +1,71 @@
#!/bin/bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
channel() {
if [ -n "${TRAVIS}" ]; then
if [ "${TRAVIS_RUST_VERSION}" = "${CHANNEL}" ]; then
pwd
(set -x; cargo "$@")
fi
else
pwd
(set -x; cargo "+${CHANNEL}" "$@")
fi
}
if [ -n "${CLIPPY}" ]; then
# cached installation will not work on a later nightly
if [ -n "${TRAVIS}" ] && ! cargo install clippy --debug --force; then
echo "COULD NOT COMPILE CLIPPY, IGNORING CLIPPY TESTS"
exit
fi
cd "$DIR/serde"
cargo clippy --features unstable-testing -- -Dclippy
cd "$DIR/serde_derive"
cargo clippy --features unstable-testing -- -Dclippy
cd "$DIR/test_suite"
cargo clippy --features unstable-testing -- -Dclippy
cd "$DIR/test_suite/no_std"
cargo clippy -- -Dclippy
else
CHANNEL=nightly
cargo clean
cd "$DIR/serde"
channel build
channel build --no-default-features
channel build --no-default-features --features alloc
channel build --no-default-features --features collections
channel test --features unstable-testing
cd "$DIR/test_suite/deps"
channel build
cd "$DIR/test_suite"
channel test --features unstable-testing
cd "$DIR/test_suite/no_std"
channel build
CHANNEL=beta
cargo clean
cd "$DIR/serde"
channel build
cd "$DIR/test_suite"
channel test
CHANNEL=stable
cargo clean
cd "$DIR/serde"
channel build
channel build --no-default-features
CHANNEL=1.13.0
cargo clean
cd "$DIR/serde"
channel build
channel build --no-default-features
fi