diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 28f3a281..aafa2420 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,15 +42,6 @@ default: #### stage: check -check-rust-stable-no_derive_no_std_full: - stage: check - <<: *docker-env - variables: - RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" - script: - - time cargo +stable check --verbose --no-default-features --features bit-vec,bytes,generic-array,full - - check-rust-stable-no_derive_no_std: stage: check <<: *docker-env @@ -69,13 +60,13 @@ check-rust-stable-no_std-chain-error: - time cargo +stable check --verbose --no-default-features --features chain-error -check-rust-stable-no_derive_full: +check-rust-stable-no_derive: stage: check <<: *docker-env variables: RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" script: - - time cargo +stable check --verbose --features bit-vec,bytes,generic-array,full + - time cargo +stable check --verbose --features bit-vec,bytes,generic-array #### stage: test @@ -124,6 +115,16 @@ build-no-std: - rustup target add thumbv6m-none-eabi - time cargo build --target thumbv6m-none-eabi --no-default-features +build-no-atomic-ptrs: + stage: test + <<: *docker-env + variables: + RUST_BACKTRACE: 1 + script: + # this target doesn't have atomic ptrs. Some parts of alloc are not available there + # we want to make sure that this crate still works on those targets + - cargo +nightly check --target bpfel-unknown-none -Zbuild-std="core,alloc" --no-default-features --features generic-array,derive,max-encoded-len,chain-error + #### stage: build build-linux-ubuntu-amd64: diff --git a/Cargo.toml b/Cargo.toml index 2fad6cd2..1148d086 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,11 +51,7 @@ max-encoded-len = ["parity-scale-codec-derive/max-encoded-len"] # Should not be used in a constrained environment. chain-error = [] -# WARNING: DO _NOT_ USE THIS FEATURE IF YOU ARE WORKING ON CONSENSUS CODE!* -# -# Provides implementations for more data structures than just Vec and Box. -# Concretely it will provide parity-scale-codec implementations for many types -# that can be found in std and/or alloc. +# This does not do anthing anymore. Remove with the next major release. full = [] [workspace] diff --git a/src/codec.rs b/src/codec.rs index d2d95d37..1008e4a0 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -43,19 +43,17 @@ use core::num::{ use byte_slice_cast::{AsByteSlice, AsMutByteSlice, ToMutByteSlice}; -#[cfg(any(feature = "std", feature = "full"))] +#[cfg(target_has_atomic = "ptr")] +use crate::alloc::sync::Arc; use crate::alloc::{ - string::String, - sync::Arc, - rc::Rc, -}; -use crate::alloc::{ - vec::Vec, boxed::Box, borrow::{Cow, ToOwned}, collections::{ BTreeMap, BTreeSet, VecDeque, LinkedList, BinaryHeap - } + }, + rc::Rc, + string::String, + vec::Vec, }; use crate::compact::Compact; use crate::encode_like::EncodeLike; @@ -212,10 +210,7 @@ pub enum TypeInfo { I64, U128, I128, - - #[cfg(feature = "full")] F32, - #[cfg(feature = "full")] F64, } @@ -365,24 +360,23 @@ impl<'a, T: ToOwned + Encode + ?Sized> EncodeLike for Cow<'a, T> {} impl<'a, T: ToOwned + Encode> EncodeLike for Cow<'a, T> {} impl<'a, T: ToOwned + Encode> EncodeLike> for T {} -#[cfg(any(feature = "std", feature = "full"))] -mod feature_full_wrapper_type_encode { - use super::*; +impl WrapperTypeEncode for Rc {} +impl EncodeLike for Rc {} +impl EncodeLike for Rc {} +impl EncodeLike> for T {} + +impl WrapperTypeEncode for String {} +impl EncodeLike for String {} +impl EncodeLike<&str> for String {} +impl EncodeLike for &str {} +#[cfg(target_has_atomic = "ptr")] +mod atomic_ptr_targets { + use super::*; impl WrapperTypeEncode for Arc {} impl EncodeLike for Arc {} impl EncodeLike for Arc {} impl EncodeLike> for T {} - - impl WrapperTypeEncode for Rc {} - impl EncodeLike for Rc {} - impl EncodeLike for Rc {} - impl EncodeLike> for T {} - - impl WrapperTypeEncode for String {} - impl EncodeLike for String {} - impl EncodeLike<&str> for String {} - impl EncodeLike for &str {} } #[cfg(feature = "bytes")] @@ -498,12 +492,11 @@ pub trait WrapperTypeDecode: Sized { impl WrapperTypeDecode for Box { type Wrapped = T; } -#[cfg(any(feature = "std", feature = "full"))] -impl WrapperTypeDecode for Arc { +impl WrapperTypeDecode for Rc { type Wrapped = T; } -#[cfg(any(feature = "std", feature = "full"))] -impl WrapperTypeDecode for Rc { +#[cfg(target_has_atomic = "ptr")] +impl WrapperTypeDecode for Arc { type Wrapped = T; } @@ -540,10 +533,7 @@ macro_rules! with_type_info { TypeInfo::U128 => { $macro!(u128 $( $( , $params )* )? ) }, TypeInfo::I128 => { $macro!(i128 $( $( , $params )* )? ) }, TypeInfo::Unknown => { $( $unknown_variant )* }, - - #[cfg(feature = "full")] TypeInfo::F32 => { $macro!(f32 $( $( , $params )* )? ) }, - #[cfg(feature = "full")] TypeInfo::F64 => { $macro!(f64 $( $( , $params )* )? ) }, } }; @@ -941,7 +931,6 @@ impl Decode for PhantomData { } } -#[cfg(any(feature = "std", feature = "full"))] impl Decode for String { fn decode(input: &mut I) -> Result { Self::from_utf8(Vec::decode(input)?).map_err(|_| "Invalid utf8 sequence".into()) @@ -1345,7 +1334,6 @@ macro_rules! impl_one_byte { impl_endians!(u16; U16, u32; U32, u64; U64, u128; U128, i16; I16, i32; I32, i64; I64, i128; I128); impl_one_byte!(u8; U8, i8; I8); -#[cfg(feature = "full")] impl_endians!(f32; F32, f64; F64); impl EncodeLike for bool {} @@ -1888,7 +1876,6 @@ mod tests { test_array_encode_and_decode!(u8, i8, u16, i16, u32, i32, u64, i64, u128, i128); - #[cfg(feature = "full")] test_array_encode_and_decode!(f32, f64); fn test_encoded_size(val: impl Encode) {