From ee718c0b90520c9204fcfb368cb42aff75d0b167 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Mon, 12 Sep 2022 12:53:35 +0100 Subject: [PATCH 1/7] Don't force bitvec to be included when "std" is enabled. --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0aff87b8..fafa02d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,9 +23,9 @@ derive_more = { version = "0.99.1", default-features = false, features = ["from" scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } [features] -default = ["std"] +default = ["std", "bit-vec"] std = [ - "bitvec/std", + "bitvec?/std", "scale/std", ] derive = [ From 30f093fd88c8a281ccdda9b65925743eaf88bc1d Mon Sep 17 00:00:00 2001 From: James Wilson Date: Mon, 12 Sep 2022 13:10:30 +0100 Subject: [PATCH 2/7] update UI test output --- test_suite/tests/ui/fail_duplicate_bounds_params.stderr | 2 +- test_suite/tests/ui/fail_missing_derive.stderr | 2 +- test_suite/tests/ui/fail_unions.stderr | 2 +- test_suite/tests/ui/fail_with_invalid_codec_attrs.stderr | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test_suite/tests/ui/fail_duplicate_bounds_params.stderr b/test_suite/tests/ui/fail_duplicate_bounds_params.stderr index cd76cddf..7c3d8be9 100644 --- a/test_suite/tests/ui/fail_duplicate_bounds_params.stderr +++ b/test_suite/tests/ui/fail_duplicate_bounds_params.stderr @@ -2,4 +2,4 @@ error: Duplicate `bounds` attributes --> tests/ui/fail_duplicate_bounds_params.rs:6:1 | 6 | #[scale_info(bounds(), bounds())] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ diff --git a/test_suite/tests/ui/fail_missing_derive.stderr b/test_suite/tests/ui/fail_missing_derive.stderr index 801764b4..bce17102 100644 --- a/test_suite/tests/ui/fail_missing_derive.stderr +++ b/test_suite/tests/ui/fail_missing_derive.stderr @@ -13,7 +13,7 @@ error[E0277]: the trait bound `PawType: TypeInfo` is not satisfied (A, B, C, D) (A, B, C, D, E) (A, B, C, D, E, F) - and 54 others + and 57 others note: required because of the requirements on the impl of `TypeInfo` for `Cat` --> tests/ui/fail_missing_derive.rs:8:10 | diff --git a/test_suite/tests/ui/fail_unions.stderr b/test_suite/tests/ui/fail_unions.stderr index 3b0248d1..ec4ae02c 100644 --- a/test_suite/tests/ui/fail_unions.stderr +++ b/test_suite/tests/ui/fail_unions.stderr @@ -23,7 +23,7 @@ error[E0277]: the trait bound `Commonwealth: TypeInfo` is not satisfied (A, B, C, D) (A, B, C, D, E) (A, B, C, D, E, F) - and 53 others + and 56 others note: required by a bound in `assert_type_info` --> tests/ui/fail_unions.rs:11:24 | diff --git a/test_suite/tests/ui/fail_with_invalid_codec_attrs.stderr b/test_suite/tests/ui/fail_with_invalid_codec_attrs.stderr index 90d52022..6246d1c9 100644 --- a/test_suite/tests/ui/fail_with_invalid_codec_attrs.stderr +++ b/test_suite/tests/ui/fail_with_invalid_codec_attrs.stderr @@ -2,13 +2,13 @@ error: Invalid attribute on field, only `#[codec(skip)]`, `#[codec(compact)]` an --> tests/ui/fail_with_invalid_codec_attrs.rs:8:7 | 8 | #[codec(skip, compact)] - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ error: Invalid attribute on field, only `#[codec(skip)]`, `#[codec(compact)]` and `#[codec(encoded_as = "$EncodeAs")]` are accepted. --> tests/ui/fail_with_invalid_codec_attrs.rs:14:19 | 14 | Thing(#[codec(index = 3)] u32), - | ^^^^^^^^^ + | ^^^^^ error: expected literal --> tests/ui/fail_with_invalid_codec_attrs.rs:19:21 From 31748e424fbf0b3bd99830d7e2e80f1e5d5827b2 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Mon, 12 Sep 2022 13:27:38 +0100 Subject: [PATCH 3/7] Ah, we test on nightly --- test_suite/tests/ui/fail_duplicate_bounds_params.stderr | 2 +- test_suite/tests/ui/fail_missing_derive.stderr | 6 +++--- test_suite/tests/ui/fail_with_invalid_codec_attrs.stderr | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test_suite/tests/ui/fail_duplicate_bounds_params.stderr b/test_suite/tests/ui/fail_duplicate_bounds_params.stderr index 7c3d8be9..cd76cddf 100644 --- a/test_suite/tests/ui/fail_duplicate_bounds_params.stderr +++ b/test_suite/tests/ui/fail_duplicate_bounds_params.stderr @@ -2,4 +2,4 @@ error: Duplicate `bounds` attributes --> tests/ui/fail_duplicate_bounds_params.rs:6:1 | 6 | #[scale_info(bounds(), bounds())] - | ^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/test_suite/tests/ui/fail_missing_derive.stderr b/test_suite/tests/ui/fail_missing_derive.stderr index bce17102..7e3d26d7 100644 --- a/test_suite/tests/ui/fail_missing_derive.stderr +++ b/test_suite/tests/ui/fail_missing_derive.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `PawType: TypeInfo` is not satisfied - --> tests/ui/fail_missing_derive.rs:19:5 + --> tests/ui/fail_missing_derive.rs:19:24 | 19 | assert_type_info::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TypeInfo` is not implemented for `PawType` + | ^^^^^^^^^^^^^^^^^^ the trait `TypeInfo` is not implemented for `PawType` | = help: the following other types implement trait `TypeInfo`: &T @@ -14,7 +14,7 @@ error[E0277]: the trait bound `PawType: TypeInfo` is not satisfied (A, B, C, D, E) (A, B, C, D, E, F) and 57 others -note: required because of the requirements on the impl of `TypeInfo` for `Cat` +note: required for `Cat` to implement `TypeInfo` --> tests/ui/fail_missing_derive.rs:8:10 | 8 | #[derive(TypeInfo)] diff --git a/test_suite/tests/ui/fail_with_invalid_codec_attrs.stderr b/test_suite/tests/ui/fail_with_invalid_codec_attrs.stderr index 6246d1c9..90d52022 100644 --- a/test_suite/tests/ui/fail_with_invalid_codec_attrs.stderr +++ b/test_suite/tests/ui/fail_with_invalid_codec_attrs.stderr @@ -2,13 +2,13 @@ error: Invalid attribute on field, only `#[codec(skip)]`, `#[codec(compact)]` an --> tests/ui/fail_with_invalid_codec_attrs.rs:8:7 | 8 | #[codec(skip, compact)] - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ error: Invalid attribute on field, only `#[codec(skip)]`, `#[codec(compact)]` and `#[codec(encoded_as = "$EncodeAs")]` are accepted. --> tests/ui/fail_with_invalid_codec_attrs.rs:14:19 | 14 | Thing(#[codec(index = 3)] u32), - | ^^^^^ + | ^^^^^^^^^ error: expected literal --> tests/ui/fail_with_invalid_codec_attrs.rs:19:21 From 6aedf4fc1466771e6c8d7aa4c7b2a94d790dac9b Mon Sep 17 00:00:00 2001 From: James Wilson Date: Mon, 12 Sep 2022 14:03:36 +0100 Subject: [PATCH 4/7] don't require bit-vec to construct a TypeDefBitSequence --- src/ty/mod.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ty/mod.rs b/src/ty/mod.rs index b1defa7e..02c25137 100644 --- a/src/ty/mod.rs +++ b/src/ty/mod.rs @@ -576,17 +576,21 @@ where } } -#[cfg(feature = "bit-vec")] impl TypeDefBitSequence { /// Creates a new [`TypeDefBitSequence`] for the supplied bit order and bit store types. - pub fn new() -> Self + /// + /// With the `bit-vec` feature enabled, the expected usage is to provide either + /// `bitvec::order::Lsb0` or `bitvec::order::Msb0` as the order type, and then something + /// like u8, u8, or u32 as the store type. Without the `bit-vec` feature enabled, it's + /// recommended that your types have identical `TypeInfo` to those. + pub fn new() -> Self where - T: bitvec::store::BitStore + TypeInfo + 'static, - O: bitvec::order::BitOrder + TypeInfo + 'static, + Store: TypeInfo + 'static, + Order: TypeInfo + 'static, { Self { - bit_store_type: MetaType::new::(), - bit_order_type: MetaType::new::(), + bit_store_type: MetaType::new::(), + bit_order_type: MetaType::new::(), } } } From 033578cfb0afd9d71f3097b57e721a57d0dfb481 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Mon, 12 Sep 2022 14:11:33 +0100 Subject: [PATCH 5/7] no bit-vec feature on std actually --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fafa02d6..7fa8088a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ derive_more = { version = "0.99.1", default-features = false, features = ["from" scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } [features] -default = ["std", "bit-vec"] +default = ["std"] std = [ "bitvec?/std", "scale/std", From c96abd49ddf44f014ef6afc8295b7e5330299120 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Mon, 12 Sep 2022 14:47:33 +0100 Subject: [PATCH 6/7] update test output again --- test_suite/tests/ui/fail_missing_derive.stderr | 2 +- test_suite/tests/ui/fail_unions.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test_suite/tests/ui/fail_missing_derive.stderr b/test_suite/tests/ui/fail_missing_derive.stderr index 7e3d26d7..9207cb25 100644 --- a/test_suite/tests/ui/fail_missing_derive.stderr +++ b/test_suite/tests/ui/fail_missing_derive.stderr @@ -13,7 +13,7 @@ error[E0277]: the trait bound `PawType: TypeInfo` is not satisfied (A, B, C, D) (A, B, C, D, E) (A, B, C, D, E, F) - and 57 others + and 54 others note: required for `Cat` to implement `TypeInfo` --> tests/ui/fail_missing_derive.rs:8:10 | diff --git a/test_suite/tests/ui/fail_unions.stderr b/test_suite/tests/ui/fail_unions.stderr index ec4ae02c..3b0248d1 100644 --- a/test_suite/tests/ui/fail_unions.stderr +++ b/test_suite/tests/ui/fail_unions.stderr @@ -23,7 +23,7 @@ error[E0277]: the trait bound `Commonwealth: TypeInfo` is not satisfied (A, B, C, D) (A, B, C, D, E) (A, B, C, D, E, F) - and 56 others + and 53 others note: required by a bound in `assert_type_info` --> tests/ui/fail_unions.rs:11:24 | From 3804c2672ab4be99f8b2692577c29c15a0e4364e Mon Sep 17 00:00:00 2001 From: James Wilson Date: Tue, 13 Sep 2022 10:44:36 +0100 Subject: [PATCH 7/7] bump rust-version to 1.60.0 and add section in unreleased --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77543a57..d4de931c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- Minimum Rust version is 1.60.0 owing to using weak dependency crate features. +- Loosen restriction on `TypeDefBitSequence::new()` so that `bitvec` isn't required, and try to avoid pulling in `bitvec` when the `std` feature is enabled [(#168)](https://github.com/paritytech/scale-info/pull/168) + ## [2.1.2] - 2022-05-18 ### Fixed diff --git a/Cargo.toml b/Cargo.toml index 7fa8088a..5dde65d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "scale-info" version = "2.1.2" authors = ["Parity Technologies "] edition = "2021" -rust-version = "1.56.1" +rust-version = "1.60.0" license = "Apache-2.0" readme = "README.md"