Unverified Commit 641fd380 authored by Austin Abell's avatar Austin Abell Committed by GitHub
Browse files

Replace array impls with const generics (#754)

* Replace array impls with const generics

* remove dead code comment

* bump scale codec version
parent 53e9a66b
Pipeline #134058 passed with stages
in 42 minutes and 17 seconds
......@@ -20,7 +20,7 @@ ink_allocator = { version = "3.0.0-rc3", path = "../allocator/", default-feature
ink_primitives = { version = "3.0.0-rc3", path = "../primitives/", default-features = false }
ink_prelude = { version = "3.0.0-rc3", path = "../prelude/", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive", "full"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
derive_more = { version = "0.99", default-features = false, features = ["from", "display"] }
num-traits = { version = "0.2", default-features = false, features = ["i128"] }
cfg-if = "1.0"
......
......@@ -22,7 +22,7 @@ ink_metadata = { version = "3.0.0-rc3", path = "../metadata", default-features =
ink_prelude = { version = "3.0.0-rc3", path = "../prelude/", default-features = false }
ink_lang_macro = { version = "3.0.0-rc3", path = "macro", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive", "full"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
derive_more = { version = "0.99", default-features = false, features = ["from"] }
static_assertions = "1.1"
......
......@@ -28,7 +28,7 @@ either = { version = "1.5", default-features = false }
regex = "1.3"
blake2 = "0.9"
heck = "0.3.1"
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive", "full"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
impl-serde = "0.3.1"
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -19,7 +19,7 @@ ink_lang_ir = { version = "3.0.0-rc3", path = "../ir", default-features = false
ink_lang_codegen = { version = "3.0.0-rc3", path = "../codegen", default-features = false }
ink_primitives = { version = "3.0.0-rc3", path = "../../primitives/", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
syn = "1"
proc-macro2 = "1"
......
......@@ -16,7 +16,7 @@ include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
[dependencies]
ink_prelude = { version = "3.0.0-rc3", path = "../prelude/", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive", "full"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -21,7 +21,7 @@ ink_primitives = { version = "3.0.0-rc3", path = "../primitives/", default-featu
ink_storage_derive = { version = "3.0.0-rc3", path = "derive", default-features = false }
ink_prelude = { version = "3.0.0-rc3", path = "../prelude/", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive", "full"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
derive_more = { version = "0.99", default-features = false, features = ["from", "display"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
cfg-if = "1.0"
......
......@@ -24,7 +24,7 @@ proc-macro2 = "1.0"
synstructure = "0.12.4"
[dev-dependencies]
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive", "full"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
ink_env = { version = "3.0.0-rc3", path = "../../env" }
ink_primitives = { version = "3.0.0-rc3", path = "../../primitives" }
ink_metadata = { version = "3.0.0-rc3", path = "../../metadata" }
......
......@@ -20,74 +20,55 @@ use crate::traits::{
use array_init::array_init;
use ink_primitives::Key;
#[rustfmt::skip]
macro_rules! forward_supported_array_lens {
( $mac:ident ) => {
$mac! {
1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32,
}
};
}
impl<T, const N: usize> SpreadLayout for [T; N]
where
T: SpreadLayout,
{
const FOOTPRINT: u64 = N as u64 * <T as SpreadLayout>::FOOTPRINT;
const REQUIRES_DEEP_CLEAN_UP: bool = <T as SpreadLayout>::REQUIRES_DEEP_CLEAN_UP;
macro_rules! impl_layout_for_array {
( $($len:literal),* $(,)? ) => {
$(
impl<T> SpreadLayout for [T; $len]
where
T: SpreadLayout,
{
const FOOTPRINT: u64 = $len * <T as SpreadLayout>::FOOTPRINT;
const REQUIRES_DEEP_CLEAN_UP: bool = <T as SpreadLayout>::REQUIRES_DEEP_CLEAN_UP;
fn push_spread(&self, ptr: &mut KeyPtr) {
for elem in self {
<T as SpreadLayout>::push_spread(elem, ptr)
}
}
fn push_spread(&self, ptr: &mut KeyPtr) {
for elem in self {
<T as SpreadLayout>::push_spread(elem, ptr)
}
}
fn clear_spread(&self, ptr: &mut KeyPtr) {
for elem in self {
<T as SpreadLayout>::clear_spread(elem, ptr)
}
}
fn clear_spread(&self, ptr: &mut KeyPtr) {
for elem in self {
<T as SpreadLayout>::clear_spread(elem, ptr)
}
}
fn pull_spread(ptr: &mut KeyPtr) -> Self {
array_init::<_, T, $len>(|_| <T as SpreadLayout>::pull_spread(ptr))
}
}
fn pull_spread(ptr: &mut KeyPtr) -> Self {
array_init::<_, T, N>(|_| <T as SpreadLayout>::pull_spread(ptr))
}
}
impl<T> PackedLayout for [T; $len]
where
T: PackedLayout,
{
#[inline]
fn push_packed(&self, at: &Key) {
for elem in self {
<T as PackedLayout>::push_packed(elem, at)
}
}
impl<T, const N: usize> PackedLayout for [T; N]
where
T: PackedLayout,
{
#[inline]
fn push_packed(&self, at: &Key) {
for elem in self {
<T as PackedLayout>::push_packed(elem, at)
}
}
#[inline]
fn clear_packed(&self, at: &Key) {
for elem in self {
<T as PackedLayout>::clear_packed(elem, at)
}
}
#[inline]
fn clear_packed(&self, at: &Key) {
for elem in self {
<T as PackedLayout>::clear_packed(elem, at)
}
}
#[inline]
fn pull_packed(&mut self, at: &Key) {
for elem in self {
<T as PackedLayout>::pull_packed(elem, at)
}
}
}
)*
#[inline]
fn pull_packed(&mut self, at: &Key) {
for elem in self {
<T as PackedLayout>::pull_packed(elem, at)
}
}
}
forward_supported_array_lens!(impl_layout_for_array);
#[cfg(test)]
mod tests {
......
......@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc3", path = "../../crates/env", default-features =
ink_storage = { version = "3.0.0-rc3", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc3", path = "../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc3", path = "../../crates/env", default-features =
ink_storage = { version = "3.0.0-rc3", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc3", path = "../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc3", path = "../../crates/env", default-features =
ink_storage = { version = "3.0.0-rc3", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc3", path = "../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
adder = { version = "3.0.0-rc3", path = "adder", default-features = false, features = ["ink-as-dependency"] }
subber = { version = "3.0.0-rc3", path = "subber", default-features = false, features = ["ink-as-dependency"] }
......
......@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc3", path = "../../../crates/env", default-feature
ink_storage = { version = "3.0.0-rc3", path = "../../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc3", path = "../../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -13,7 +13,7 @@ ink_lang = { version = "3.0.0-rc3", path = "../../../crates/lang", default-featu
accumulator = { version = "3.0.0-rc3", path = "../accumulator", default-features = false, features = ["ink-as-dependency"] }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -13,7 +13,7 @@ ink_lang = { version = "3.0.0-rc3", path = "../../../crates/lang", default-featu
accumulator = { version = "3.0.0-rc3", path = "../accumulator", default-features = false, features = ["ink-as-dependency"] }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc3", path = "../../crates/env", default-features =
ink_storage = { version = "3.0.0-rc3", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc3", path = "../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc3", path = "../../crates/env", default-features =
ink_storage = { version = "3.0.0-rc3", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc3", path = "../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc3", path = "../../crates/env", default-features =
ink_storage = { version = "3.0.0-rc3", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc3", path = "../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc3", path = "../../crates/env", default-features =
ink_storage = { version = "3.0.0-rc3", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc3", path = "../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc3", path = "../../crates/env", default-features =
ink_storage = { version = "3.0.0-rc3", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc3", path = "../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
......@@ -12,7 +12,7 @@ ink_storage = { version = "3.0.0-rc3", path = "../../crates/storage", default-fe
ink_lang = { version = "3.0.0-rc3", path = "../../crates/lang", default-features = false }
ink_prelude = { version = "3.0.0-rc3", path = "../../crates/prelude", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
# Should be removed once bitvecto-rs/bitvec#105 is resolved
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment