Skip to content

Commit

Permalink
Bump bitvec dependency to 0.22.3
Browse files Browse the repository at this point in the history
There was a conflict between bitvec and a dependency of it (funty) that
caused a build failure. See:
- ferrilab/bitvec#105
- ferrilab/funty#3

Due to semver, when importing parity-scale-codec as a library and
resolving bitvec 0.20.1 dependencies, funty 0.12 is pulled, which causes
the aforementioned build failure.  I believe this is not happening when
testing parity-scale-codec itself because Cargo.lock pins funty to
1.1.0, but when importing parity-scale-codec from another crate, this
pinning is sometimes not possible.  Bumping bitvec to 0.22.3 solves this
issue, as it is compatible with funty 0.12.
  • Loading branch information
ed255 committed Oct 29, 2021
1 parent ca03f7f commit 9bb2644
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
15 changes: 9 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2018"
arrayvec = { version = "0.7", default-features = false }
serde = { version = "1.0.102", optional = true }
parity-scale-codec-derive = { path = "derive", version = "2.3.1", default-features = false, optional = true }
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"], optional = true }
bitvec = { version = "0.22.3", default-features = false, features = ["alloc"], optional = true }
byte-slice-cast = { version = "1.0.0", default-features = false }
generic-array = { version = "0.14.4", optional = true }
arbitrary = { version = "1.0.1", features = ["derive"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion fuzzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ publish = false
parity-scale-codec = { path = "..", features = ["derive", "bit-vec", "fuzz"] }
honggfuzz = "0.5.54"
arbitrary = { version = "1.0.1", features = ["derive"] }
bitvec = { version = "0.20.1", features = ["alloc"] }
bitvec = { version = "0.22.3", features = ["alloc"] }
14 changes: 9 additions & 5 deletions src/bit_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
//! `BitVec` specific serialization.
use bitvec::{
vec::BitVec, store::BitStore, order::BitOrder, slice::BitSlice, boxed::BitBox, mem::BitMemory
boxed::BitBox, order::BitOrder, slice::BitSlice, store::BitStore, vec::BitVec,
view::BitViewSized,
};
use crate::{
EncodeLike, Encode, Decode, Input, Output, Error, Compact,
Expand All @@ -31,11 +32,11 @@ impl<O: BitOrder, T: BitStore + Encode> Encode for BitSlice<O, T> {
);
Compact(len as u32).encode_to(dest);

// NOTE: doc of `BitSlice::as_slice`:
// NOTE: doc of `BitSlice::as_raw_slice`:
// > The returned slice handle views all elements touched by self
//
// Thus we are sure the slice doesn't contain unused elements at the end.
let slice = self.as_slice();
let slice = self.as_raw_slice();

encode_slice_no_len(slice, dest)
}
Expand Down Expand Up @@ -97,7 +98,7 @@ impl<O: BitOrder, T: BitStore + Decode> Decode for BitBox<O, T> {
/// NOTE: this should never happen if `bits` is already checked to be less than
/// `BitStore::MAX_BITS`.
fn required_elements<T: BitStore>(bits: u32) -> Result<u32, Error> {
let element_bits = T::Mem::BITS as u32;
let element_bits = T::BITS as u32;
let error = Error::from("Attempt to decode bitvec with too many bits");
Ok((bits.checked_add(element_bits).ok_or_else(|| error)? - 1) / element_bits)
}
Expand Down Expand Up @@ -170,6 +171,10 @@ mod tests {
}

#[test]
// Flaky test due to:
// * https://github.com/bitvecto-rs/bitvec/issues/135
// * https://github.com/rust-lang/miri/issues/1866
#[cfg(not(miri))]
fn bitvec_u8() {
for v in &test_data!(u8) {
let encoded = v.encode();
Expand All @@ -182,7 +187,6 @@ mod tests {
// * https://github.com/bitvecto-rs/bitvec/issues/135
// * https://github.com/rust-lang/miri/issues/1866
#[cfg(not(miri))]

fn bitvec_u16() {
for v in &test_data!(u16) {
let encoded = v.encode();
Expand Down

0 comments on commit 9bb2644

Please sign in to comment.