From 8fc56406ea95c0d26c240d8bee62e2d1d2aa5f55 Mon Sep 17 00:00:00 2001 From: Jason Lingle Date: Mon, 11 Feb 2019 00:22:37 +0000 Subject: [PATCH] Add workaround for rust-lang/rust#52478. --- .travis.yml | 1 + proptest/CHANGELOG.md | 5 +++++ proptest/Cargo.toml | 8 +++++++- proptest/src/arbitrary/_alloc/char.rs | 7 ++++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7c75c33d..4ed38054 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ script: - | (cd proptest && travis-cargo build) && (cd proptest && travis-cargo test) && + (cd proptest && env RUST_FLAGS='-C link-dead-code' travis-cargo --only stable build -- --no-default-features --features default-code-coverage) && (cd proptest && travis-cargo --only stable build -- --no-default-features --features fork) && (cd proptest && travis-cargo --only stable build -- --lib --no-default-features --features std) && (cd proptest && travis-cargo --only nightly build -- --no-default-features --features "alloc unstable") && diff --git a/proptest/CHANGELOG.md b/proptest/CHANGELOG.md index 10181767..6e7fdf19 100644 --- a/proptest/CHANGELOG.md +++ b/proptest/CHANGELOG.md @@ -30,6 +30,11 @@ makes it possible to use an external source of entropy with Proptest. - `TestRunner` now has a `deterministic()` constructor which uses the same RNG every time, to facilitate doing statistical tests on strategy outputs. +- There is now a work-around for a [compiler + bug](https://github.com/rust-lang/rust/issues/52478) which prevents building + with `-C link-dead-code`. Please see this issue for details: + https://github.com/AltSysrq/proptest/issues/124 + ### Deprecations - The `load_persisted_failures` and `save_persisted_failure` methods on the diff --git a/proptest/Cargo.toml b/proptest/Cargo.toml index ea0eb588..72e4bcff 100644 --- a/proptest/Cargo.toml +++ b/proptest/Cargo.toml @@ -25,7 +25,9 @@ service = "github" [features] -default = ["std", "fork", "timeout", "bit-set"] +default = ["std", "fork", "timeout", "bit-set", "break-dead-code"] +# Everything in `default` that doesn't break code coverage builds +default-code-coverage = ["std", "fork", "timeout", "bit-set"] # Enables unstable features of Rust. unstable = [] @@ -53,6 +55,10 @@ timeout = ["fork", "rusty-fork/timeout"] # need it excluded, however. atomic64bit = [] +# Include features which break the Rust compiler when `-C link-dead-code` is +# passed (see https://github.com/AltSysrq/proptest/issues/124). +break-dead-code = [] + [dependencies] bitflags = "1.0.1" diff --git a/proptest/src/arbitrary/_alloc/char.rs b/proptest/src/arbitrary/_alloc/char.rs index 02fd213e..4bf6315d 100644 --- a/proptest/src/arbitrary/_alloc/char.rs +++ b/proptest/src/arbitrary/_alloc/char.rs @@ -43,6 +43,7 @@ impl_wrap_char!(ToLowercase, char::to_lowercase); #[cfg(feature = "unstable")] impl_wrap_char!(ToUppercase, char::to_uppercase); +#[cfg(feature = "break-dead-code")] arbitrary!(DecodeUtf16< as IntoIterator>::IntoIter>, SMapped, Self>; static_map(vec(any::(), ..VEC_MAX), decode_utf16) @@ -71,10 +72,14 @@ mod test { escape_default => EscapeDefault, escape_unicode => EscapeUnicode, parse_char_error => ParseCharError, - decode_utf16 => DecodeUtf16< as IntoIterator>::IntoIter>, decode_utf16_error => DecodeUtf16Error ); + #[cfg(feature = "break-dead-code")] + no_panic_test!( + decode_utf16 => DecodeUtf16< as IntoIterator>::IntoIter> + ); + #[cfg(feature = "unstable")] no_panic_test!( to_lowercase => ToLowercase,