diff --git a/ast/src/ast.rs b/ast/src/ast.rs index ffde6e81..11d5479c 100644 --- a/ast/src/ast.rs +++ b/ast/src/ast.rs @@ -11,15 +11,12 @@ //! [interaction calculus]: https://en.wikipedia.org/wiki/Interaction_nets#Interaction_calculus #![cfg_attr(not(feature = "std"), no_std)] -include!("../../prelude.rs"); - #[cfg(feature = "parser")] mod parser; use alloc::collections::BTreeMap; -use crate::prelude::*; -use hvm64_util::{create_var, deref_to, maybe_grow, multi_iterator, ops::TypedOp as Op, var_to_num}; +use hvm64_util::{create_var, deref_to, maybe_grow, multi_iterator, ops::TypedOp as Op, prelude::*, var_to_num}; use ordered_float::OrderedFloat; diff --git a/ast/src/parser.rs b/ast/src/parser.rs index ac25ee35..a9ce0551 100644 --- a/ast/src/parser.rs +++ b/ast/src/parser.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use hvm64_util::prelude::*; use alloc::collections::BTreeMap; use core::str::FromStr; diff --git a/host/src/encode.rs b/host/src/encode.rs index 06878a0d..7047b041 100644 --- a/host/src/encode.rs +++ b/host/src/encode.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use hvm64_util::prelude::*; use crate::Host; use hvm64_ast::{Lab, Net as AstNet, Tree}; diff --git a/host/src/host.rs b/host/src/host.rs index 20eae7ff..07fc6de1 100644 --- a/host/src/host.rs +++ b/host/src/host.rs @@ -2,11 +2,9 @@ //! the runtime. #![cfg_attr(not(feature = "std"), no_std)] -include!("../../prelude.rs"); - -use crate::prelude::*; use hvm64_ast::{Book, Tree}; use hvm64_runtime::{Addr, Def, DynDef, InterpretedDef, LabSet, Port, Tag, Wire}; +use hvm64_util::prelude::*; mod calc_labels; mod encode; diff --git a/host/src/readback.rs b/host/src/readback.rs index 478da9cc..8198d610 100644 --- a/host/src/readback.rs +++ b/host/src/readback.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use hvm64_util::prelude::*; use super::{Addr, Host, Port, Tag, Wire}; diff --git a/prelude.rs b/prelude.rs deleted file mode 100644 index 0ae61b05..00000000 --- a/prelude.rs +++ /dev/null @@ -1,21 +0,0 @@ -extern crate alloc; - -#[allow(unused)] -mod prelude { - pub use alloc::{ - borrow::ToOwned, - boxed::Box, - format, - string::{String, ToString}, - vec, - vec::Vec, - }; - - pub use core::{fmt, hint, iter, mem, ptr}; - - #[cfg(feature = "std")] - pub use std::collections::{hash_map::Entry, HashMap as Map, HashSet as Set}; - - #[cfg(not(feature = "std"))] - pub use alloc::collections::{btree_map::Entry, BTreeMap as Map, BTreeSet as Set}; -} diff --git a/runtime/src/parallel.rs b/runtime/src/parallel.rs index b272f6dc..05d5b423 100644 --- a/runtime/src/parallel.rs +++ b/runtime/src/parallel.rs @@ -2,7 +2,7 @@ use std::{sync::Barrier, thread}; -use ::alloc::sync::Arc; +use alloc::sync::Arc; use atomic::AtomicUsize; use super::*; diff --git a/runtime/src/runtime.rs b/runtime/src/runtime.rs index 353eb7c8..2112f47d 100644 --- a/runtime/src/runtime.rs +++ b/runtime/src/runtime.rs @@ -20,9 +20,7 @@ #![cfg_attr(feature = "trace", feature(const_type_name))] #![cfg_attr(not(feature = "std"), no_std)] -include!("../../prelude.rs"); - -use crate::prelude::*; +use hvm64_util::prelude::*; pub use hvm64_util::ops; diff --git a/runtime/src/trace.rs b/runtime/src/trace.rs index 8728545e..d31b1557 100644 --- a/runtime/src/trace.rs +++ b/runtime/src/trace.rs @@ -73,7 +73,7 @@ use core::{ #[cfg(feature = "std")] use std::sync::{Mutex, Once}; -use crate::prelude::*; +use hvm64_util::prelude::*; use hvm64_util::ops::TypedOp as Op; use crate::{Addr, Port, Trg, Wire}; diff --git a/src/compile.rs b/src/compile.rs index b0a489f2..8cb80214 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -6,9 +6,9 @@ use alloc::collections::{BTreeMap, BTreeSet}; use core::{fmt::Write, hash::Hasher}; use std::hash::DefaultHasher; -use crate::prelude::*; use hvm64_host::Host; use hvm64_runtime::{Def, Instruction, InterpretedDef, LabSet, Port, Tag}; +use hvm64_util::prelude::*; struct DefInfo<'a> { rust_name: String, diff --git a/src/compile/include_files.rs b/src/compile/include_files.rs index 4867524f..4cf5931b 100644 --- a/src/compile/include_files.rs +++ b/src/compile/include_files.rs @@ -73,7 +73,6 @@ hvm64-runtime = { path = "../runtime", default-features = false } fs::write(".hvm/gen/src/lib.rs", lib)?; include_files! { - prelude crate util { lib bi_enum @@ -87,6 +86,7 @@ hvm64-runtime = { path = "../runtime", default-features = false } word } parse_abbrev_number + prelude pretty_num } crate runtime { diff --git a/src/main.rs b/src/main.rs index 14a6d53f..79dd1f85 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,9 @@ -include!("../prelude.rs"); - mod compile; mod args; mod full; -use crate::prelude::*; +use hvm64_util::prelude::*; use core::time::Duration; use std::{ diff --git a/transform/src/eta_reduce.rs b/transform/src/eta_reduce.rs index b12a0598..679bd2b9 100644 --- a/transform/src/eta_reduce.rs +++ b/transform/src/eta_reduce.rs @@ -55,7 +55,7 @@ use core::ops::RangeFrom; -use crate::prelude::*; +use hvm64_util::prelude::*; use hvm64_ast::{Net, Tree}; use ordered_float::OrderedFloat; diff --git a/transform/src/inline.rs b/transform/src/inline.rs index e197c651..4180f557 100644 --- a/transform/src/inline.rs +++ b/transform/src/inline.rs @@ -1,6 +1,6 @@ use core::ops::BitOr; -use crate::prelude::*; +use hvm64_util::prelude::*; use hvm64_ast::{Book, Net, Tree}; use hvm64_util::maybe_grow; diff --git a/transform/src/pre_reduce.rs b/transform/src/pre_reduce.rs index 1ee1f87d..a7a65ffd 100644 --- a/transform/src/pre_reduce.rs +++ b/transform/src/pre_reduce.rs @@ -14,7 +14,7 @@ //! At the end, each mutated [`ast::Net`] is placed into the [`Book`], //! overriding the previous one. -use crate::prelude::*; +use hvm64_util::prelude::*; use hvm64_ast::{Book, Tree}; use hvm64_host::Host; use hvm64_runtime::{AsDef, Def, Heap, InterpretedDef, LabSet, Port, Rewrites}; diff --git a/transform/src/prune.rs b/transform/src/prune.rs index 9c5b6a02..ab9ed53a 100644 --- a/transform/src/prune.rs +++ b/transform/src/prune.rs @@ -1,4 +1,4 @@ -use crate::prelude::*; +use hvm64_util::prelude::*; use hvm64_ast::{Book, Tree}; use hvm64_util::maybe_grow; diff --git a/transform/src/transform.rs b/transform/src/transform.rs index b6bfcc4f..de289ff0 100644 --- a/transform/src/transform.rs +++ b/transform/src/transform.rs @@ -1,8 +1,6 @@ #![cfg_attr(not(feature = "std"), no_std)] -include!("../../prelude.rs"); - -use crate::prelude::*; +use hvm64_util::prelude::*; use hvm64_ast::Book; diff --git a/util/src/bi_enum.rs b/util/src/bi_enum.rs index 88abcb9d..65ab1f1f 100644 --- a/util/src/bi_enum.rs +++ b/util/src/bi_enum.rs @@ -54,6 +54,7 @@ macro_rules! bi_enum { #[test] fn test_bi_enum() { + use crate::prelude::*; use alloc::string::ToString; use core::str::FromStr; diff --git a/util/src/lib.rs b/util/src/lib.rs index 15308183..db27903a 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -1,6 +1,6 @@ #![cfg_attr(not(feature = "std"), no_std)] -include!("../../prelude.rs"); +pub mod prelude; pub mod ops; diff --git a/util/src/prelude.rs b/util/src/prelude.rs new file mode 100644 index 00000000..88ca1815 --- /dev/null +++ b/util/src/prelude.rs @@ -0,0 +1,18 @@ +pub extern crate alloc; + +pub use alloc::{ + borrow::ToOwned, + boxed::Box, + format, + string::{String, ToString}, + vec, + vec::Vec, +}; + +pub use core::{fmt, hint, iter, mem, ptr}; + +#[cfg(feature = "std")] +pub use std::collections::{hash_map::Entry, HashMap as Map, HashSet as Set}; + +#[cfg(not(feature = "std"))] +pub use alloc::collections::{btree_map::Entry, BTreeMap as Map, BTreeSet as Set};