diff --git a/Cargo.lock b/Cargo.lock index 1bf2f99..b8ad073 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,9 +27,8 @@ dependencies = [ [[package]] name = "amplify" -version = "4.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7147b742325842988dd6c793d55f58df3ae36bccf7d9b6e07db10ab035be343d" +version = "4.7.1" +source = "git+https://github.com/rust-amplify/rust-amplify?branch=v4.0#8108ed0ed906b699072b07eeb7e8a959ed0e62e5" dependencies = [ "amplify_apfloat", "amplify_derive", diff --git a/Cargo.toml b/Cargo.toml index 5f80930..7c3a61f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ name = "aluvm-stl" required-features = ["stl"] [dependencies] -amplify = { version = "4.7.0", default-features = false, features = ["apfloat", "derive", "hex"] } +amplify = { version = "4.7.1", default-features = false, features = ["apfloat", "derive", "hex"] } ascii-armor = { version = "0.7.2", optional = true } baid64 = "0.2.2" paste = "1" @@ -39,7 +39,7 @@ serde_crate = { package = "serde", version = "1", optional = true } default = ["std"] all = ["stl", "std", "log", "secp256k1", "curve25519", "serde", "ascii-armor"] stl = ["strict_types/armor", "std"] -std = ["amplify/std"] +std = ["amplify/std", "alloc"] log = ["std"] alloc = ["amplify/alloc"] curve25519 = ["curve25519-dalek"] @@ -55,3 +55,6 @@ wasm-bindgen-test = "0.3" [package.metadata.docs.rs] features = ["all"] + +[patch.crates-io] +amplify = { git = "https://github.com/rust-amplify/rust-amplify", branch = "v4.0" } diff --git a/src/data/byte_str.rs b/src/data/byte_str.rs index 585e2b3..0dcd9bc 100644 --- a/src/data/byte_str.rs +++ b/src/data/byte_str.rs @@ -23,9 +23,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::boxed::Box; -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::vec::Vec; use core::borrow::{Borrow, BorrowMut}; use core::convert::TryFrom; diff --git a/src/data/number.rs b/src/data/number.rs index 0aea924..6f4f565 100644 --- a/src/data/number.rs +++ b/src/data/number.rs @@ -26,9 +26,9 @@ //! Module defining number layout (integer, signed/unsigned, float etc) and universal in-memory //! number representation. -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::format; -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::string::{String, ToString}; use core::fmt::{ self, Debug, Display, Formatter, LowerExp, LowerHex, Octal, UpperExp, UpperHex, Write, diff --git a/src/isa/bytecode.rs b/src/isa/bytecode.rs index fd3d868..580cc2e 100644 --- a/src/isa/bytecode.rs +++ b/src/isa/bytecode.rs @@ -25,7 +25,7 @@ //! Instruction serialization and deserialization from bytecode. -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::boxed::Box; use core::ops::RangeInclusive; diff --git a/src/isa/exec.rs b/src/isa/exec.rs index 2dfb077..d25bf5f 100644 --- a/src/isa/exec.rs +++ b/src/isa/exec.rs @@ -23,10 +23,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::boxed::Box; use alloc::collections::BTreeSet; -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::string::{String, ToString}; use core::cmp::Ordering; use core::ops::{BitAnd, BitOr, BitXor, Neg, Rem, Shl, Shr}; diff --git a/src/isa/flags.rs b/src/isa/flags.rs index 121c2a8..7b334b3 100644 --- a/src/isa/flags.rs +++ b/src/isa/flags.rs @@ -25,9 +25,9 @@ //! Flags used by operation codes -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::borrow::ToOwned; -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::string::String; use core::fmt::{self, Display, Formatter, Write}; use core::str::FromStr; diff --git a/src/isa/instr.rs b/src/isa/instr.rs index a4f8083..19b91bd 100644 --- a/src/isa/instr.rs +++ b/src/isa/instr.rs @@ -23,7 +23,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::boxed::Box; use super::{ diff --git a/src/lib.rs b/src/lib.rs index 279b4eb..f8205e2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -142,10 +142,11 @@ // TODO(#7) Complete assembly compiler for string operations // TODO(#8) Implement operations on Edwards curves +#[cfg(not(any(feature = "alloc", feature = "std")))] +compile_error!("either `alloc` or `std` feature must be used"); + #[macro_use] extern crate alloc; -#[cfg(all(feature = "alloc", not(feature = "std")))] -extern crate alloc as std; #[macro_use] extern crate amplify; diff --git a/src/library/lib.rs b/src/library/lib.rs index 49b2ec8..9dafaf7 100644 --- a/src/library/lib.rs +++ b/src/library/lib.rs @@ -23,9 +23,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::string::{String, ToString}; -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::vec::Vec; use core::cmp::Ordering; use core::fmt::{self, Display, Formatter}; diff --git a/src/library/segs.rs b/src/library/segs.rs index 0d2a0d5..17c07fc 100644 --- a/src/library/segs.rs +++ b/src/library/segs.rs @@ -25,12 +25,12 @@ //! Data structures representing static library segments -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::borrow::ToOwned; use alloc::collections::{btree_set, BTreeSet}; -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::string::{String, ToString}; -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::vec::Vec; use core::fmt::{self, Debug, Display, Formatter}; use core::str::FromStr; diff --git a/src/reg/core_regs.rs b/src/reg/core_regs.rs index b9e5319..dd52e68 100644 --- a/src/reg/core_regs.rs +++ b/src/reg/core_regs.rs @@ -23,11 +23,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::boxed::Box; -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::string::ToString; -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::vec::Vec; use core::fmt::{self, Debug, Formatter}; diff --git a/src/vm.rs b/src/vm.rs index 46a24cb..75dd3cf 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -25,7 +25,7 @@ //! Alu virtual machine -#[cfg(all(feature = "alloc", not(feature = "std")))] +#[cfg(feature = "alloc")] use alloc::boxed::Box; use core::marker::PhantomData;