From adca3f61a91185d3c70f58e95d95295fc5e4a819 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 3 Nov 2024 20:23:56 +0100 Subject: [PATCH] fix alloc/std ambiguity --- Cargo.lock | 44 ++++++++++++++++++++++---------------------- Cargo.toml | 4 ++-- src/data/byte_str.rs | 4 ++-- src/data/number.rs | 4 ++-- src/isa/bytecode.rs | 2 +- src/isa/exec.rs | 4 ++-- src/isa/flags.rs | 4 ++-- src/isa/instr.rs | 2 +- src/lib.rs | 5 +++-- src/library/lib.rs | 4 ++-- src/library/segs.rs | 6 +++--- src/reg/core_regs.rs | 6 +++--- src/vm.rs | 2 +- 13 files changed, 46 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1bf2f99..2e20520 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,9 +27,9 @@ dependencies = [ [[package]] name = "amplify" -version = "4.7.0" +version = "4.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7147b742325842988dd6c793d55f58df3ae36bccf7d9b6e07db10ab035be343d" +checksum = "448cf0c3afc71439b5f837aac5399a1ef2b223f5f38324dbfb4343deec3b80cc" dependencies = [ "amplify_apfloat", "amplify_derive", @@ -148,9 +148,9 @@ dependencies = [ [[package]] name = "bitcoin-io" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56" +checksum = "0b47c4ab7a93edb0c7198c5535ed9b52b63095f4e9b45279c6736cec4b856baf" [[package]] name = "bitcoin_hashes" @@ -204,9 +204,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.1.31" +version = "1.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" dependencies = [ "shlex", ] @@ -547,7 +547,7 @@ checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -579,9 +579,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "strict_encoding" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d69b4893cf054e129d5288a565102124520d7b94eb9589d1e78202abc7e2092d" +checksum = "4f84deeb6b9e839d4e4f67040aca49c13d0191e57f5383dc73c2626bca248d96" dependencies = [ "amplify", "half", @@ -592,9 +592,9 @@ dependencies = [ [[package]] name = "strict_encoding_derive" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4f9b678862372f8e439bcaafc27df7610ea93b06d2deb6244dec0af4259ce6" +checksum = "119f2044ee7438c2f25330cafd684be868de4f51621483de8ad8c442dc80bdb0" dependencies = [ "amplify_syn", "heck", @@ -649,9 +649,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -660,22 +660,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.65" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +checksum = "3b3c6efbfc763e64eb85c11c25320f0737cb7364c4b6336db90aa9ebe27a0bbd" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.65" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +checksum = "b607164372e89797d78b8e23a6d67d5d1038c1c65efd52e1389ef8b77caba2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -750,7 +750,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", "wasm-bindgen-shared", ] @@ -784,7 +784,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -818,7 +818,7 @@ checksum = "c97b2ef2c8d627381e51c071c2ab328eac606d3f69dd82bcbca20a9e389d95f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -931,7 +931,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5f80930..0160422 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.8.0", 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"] 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;