Skip to content

Commit

Permalink
Add workaround for rust-lang/rust#52478.
Browse files Browse the repository at this point in the history
  • Loading branch information
AltSysrq committed Feb 11, 2019
1 parent 2325e7a commit 8fc5640
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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") &&
Expand Down
5 changes: 5 additions & 0 deletions proptest/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion proptest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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"

Expand Down
7 changes: 6 additions & 1 deletion proptest/src/arbitrary/_alloc/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<<Vec<u16> as IntoIterator>::IntoIter>,
SMapped<Vec<u16>, Self>;
static_map(vec(any::<u16>(), ..VEC_MAX), decode_utf16)
Expand Down Expand Up @@ -71,10 +72,14 @@ mod test {
escape_default => EscapeDefault,
escape_unicode => EscapeUnicode,
parse_char_error => ParseCharError,
decode_utf16 => DecodeUtf16<<Vec<u16> as IntoIterator>::IntoIter>,
decode_utf16_error => DecodeUtf16Error
);

#[cfg(feature = "break-dead-code")]
no_panic_test!(
decode_utf16 => DecodeUtf16<<Vec<u16> as IntoIterator>::IntoIter>
);

#[cfg(feature = "unstable")]
no_panic_test!(
to_lowercase => ToLowercase,
Expand Down

0 comments on commit 8fc5640

Please sign in to comment.