From bac2448e3b15df7d40ff26aaf53cd533e24828d0 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Tue, 10 Jul 2018 11:35:33 +0100 Subject: [PATCH 1/2] Fix build errors on nightly (alloc crate changes) --- src/distributions/other.rs | 2 +- src/distributions/weighted.rs | 2 +- src/seq.rs | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/distributions/other.rs b/src/distributions/other.rs index 7570824fdb5..dc5be044303 100644 --- a/src/distributions/other.rs +++ b/src/distributions/other.rs @@ -180,7 +180,7 @@ impl Distribution> for Standard where Standard: Distribution { mod tests { use {Rng, RngCore, Standard}; use distributions::Alphanumeric; - #[cfg(all(not(feature="std"), feature="alloc"))] use alloc::String; + #[cfg(all(not(feature="std"), feature="alloc"))] use alloc::string::String; #[test] fn test_misc() { diff --git a/src/distributions/weighted.rs b/src/distributions/weighted.rs index 8f67578aef1..749dd0e9343 100644 --- a/src/distributions/weighted.rs +++ b/src/distributions/weighted.rs @@ -15,7 +15,7 @@ use ::core::cmp::PartialOrd; use ::{Error, ErrorKind}; // Note that this whole module is only imported if feature="alloc" is enabled. -#[cfg(not(feature="std"))] use alloc::Vec; +#[cfg(not(feature="std"))] use alloc::vec::Vec; /// A distribution using weighted sampling to pick a discretely selected item. /// diff --git a/src/seq.rs b/src/seq.rs index 4b99bc561d1..ac68d56a5ee 100644 --- a/src/seq.rs +++ b/src/seq.rs @@ -15,10 +15,11 @@ #[cfg(feature="alloc")] use core::ops::Index; #[cfg(feature="std")] use std::vec; -#[cfg(all(feature="alloc", not(feature="std")))] use alloc::{vec, Vec}; +#[cfg(all(feature="alloc", not(feature="std")))] use alloc::vec; +#[cfg(all(feature="alloc", not(feature="std")))] use alloc::vec::Vec; // BTreeMap is not as fast in tests, but better than nothing. #[cfg(feature="std")] use std::collections::HashMap; -#[cfg(all(feature="alloc", not(feature="std")))] use alloc::btree_map::BTreeMap; +#[cfg(all(feature="alloc", not(feature="std")))] use alloc::collections::BTreeMap; use super::Rng; @@ -599,7 +600,7 @@ mod test { #[cfg(feature = "alloc")] use {Rng, SeedableRng}; #[cfg(feature = "alloc")] use prng::XorShiftRng; #[cfg(all(feature="alloc", not(feature="std")))] - use alloc::Vec; + use alloc::vec::Vec; #[test] fn test_slice_choose() { From 90d306fec3f0f5f34359365d47ac77086aa04973 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Wed, 11 Jul 2018 10:20:51 +0100 Subject: [PATCH 2/2] Avoid use of from_bits until it is available in lib core Also don't use --tests flag with 1.22 compiler. --- .travis.yml | 3 ++- src/distributions/float.rs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d3633b9a6d..293796fd00f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,8 @@ matrix: - rust: 1.22.0 install: script: - - cargo test --tests --no-default-features + # TODO: use --tests instead of --lib on more recent compiler + - cargo test --lib --no-default-features - cargo test --package rand_core --no-default-features - cargo test --features serde1,log - rust: stable diff --git a/src/distributions/float.rs b/src/distributions/float.rs index 9bf4a69ab0b..a7e66ed0afc 100644 --- a/src/distributions/float.rs +++ b/src/distributions/float.rs @@ -95,7 +95,9 @@ macro_rules! float_impls { // The exponent is encoded using an offset-binary representation let exponent_bits: $u_scalar = (($exponent_bias + exponent) as $u_scalar) << $fraction_bits; - $ty::from_bits(self | exponent_bits) + // TODO: use from_bits when min compiler > 1.25 (see #545) + // $ty::from_bits(self | exponent_bits) + unsafe{ mem::transmute(self | exponent_bits) } } }