Skip to content

Commit

Permalink
fix alloc/std ambiguity
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Nov 3, 2024
1 parent b671b88 commit adca3f6
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 45 deletions.
44 changes: 22 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions src/data/byte_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/data/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/isa/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/isa/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 2 additions & 2 deletions src/isa/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/isa/instr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/library/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
6 changes: 3 additions & 3 deletions src/library/segs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/reg/core_regs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit adca3f6

Please sign in to comment.