diff --git a/Cargo.toml b/Cargo.toml index d219ac41..5130e35f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,24 +1,13 @@ -[workspace] -resolver = "2" - -members = ["ast", "host", "runtime", "transform", "util"] - -[workspace.lints.clippy] -alloc_instead_of_core = "warn" -std_instead_of_core = "warn" -std_instead_of_alloc = "warn" -absolute_paths = "warn" -field_reassign_with_default = "allow" -missing_safety_doc = "allow" -new_ret_no_self = "allow" - [package] name = "hvm64" -version = "0.3.0" +version.workspace = true edition = "2021" description = "HVM-Core is a massively parallel Interaction Combinator evaluator." license = "MIT" +[workspace.package] +version = "0.3.0" + [[bin]] name = "hvm64" path = "src/main.rs" @@ -57,3 +46,18 @@ highlight_error = { git = "https://github.com/tjjfvi/rust_highlight_error/", bra [[test]] name = "tests" harness = false + +[lints] +workspace = true + +[workspace] +resolver = "2" + +[workspace.lints.clippy] +alloc_instead_of_core = "warn" +std_instead_of_core = "warn" +std_instead_of_alloc = "warn" +absolute_paths = "warn" +field_reassign_with_default = "allow" +missing_safety_doc = "allow" +new_ret_no_self = "allow" diff --git a/ast/Cargo.toml b/ast/Cargo.toml index 4a6d9a3f..0ccca293 100644 --- a/ast/Cargo.toml +++ b/ast/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hvm64-ast" -version = "0.3.0" +version.workspace = true edition = "2021" [lib] diff --git a/host/Cargo.toml b/host/Cargo.toml index e337a6d5..e3e28ba2 100644 --- a/host/Cargo.toml +++ b/host/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hvm64-host" -version = "0.3.0" +version.workspace = true edition = "2021" [lib] diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index c8cc6661..a9f8648c 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hvm64-runtime" -version = "0.3.0" +version.workspace = true edition = "2021" [lib] diff --git a/src/compile.rs b/src/compile.rs index 8d8bff27..b0a489f2 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -2,11 +2,9 @@ mod include_files; pub use include_files::*; -use std::{ - collections::{BTreeMap, BTreeSet}, - fmt::Write, - hash::{DefaultHasher, Hasher}, -}; +use alloc::collections::{BTreeMap, BTreeSet}; +use core::{fmt::Write, hash::Hasher}; +use std::hash::DefaultHasher; use crate::prelude::*; use hvm64_host::Host; diff --git a/src/compile/include_files.rs b/src/compile/include_files.rs index b4174578..4867524f 100644 --- a/src/compile/include_files.rs +++ b/src/compile/include_files.rs @@ -49,6 +49,7 @@ pub fn create_temp_hvm(host: &Host) -> Result<(), io::Error> { r#" [workspace] resolver = "2" +package.version = "0.0.0" members = ["util", "runtime", "gen"] @@ -60,7 +61,6 @@ members = ["util", "runtime", "gen"] r#" [package] name = "hvm64-gen" -version = "0.3.0" edition = "2021" [lib] diff --git a/src/main.rs b/src/main.rs index cd7c30e4..14a6d53f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,13 +5,19 @@ mod compile; mod args; mod full; +use crate::prelude::*; + +use core::time::Duration; use std::{ - env::consts::{DLL_PREFIX, DLL_SUFFIX}, + env::{ + self, + consts::{DLL_PREFIX, DLL_SUFFIX}, + }, ffi::OsStr, fs, io, path::PathBuf, process::{self, Stdio}, - time::{Duration, Instant}, + time::Instant, }; use self::full::{CliMode, FullCli}; @@ -21,12 +27,13 @@ use clap::Parser; use hvm64_ast::{Book, Net, Tree}; use hvm64_host::Host; -use hvm64_runtime::{DynDef, Heap, Port, Trg}; +use hvm64_runtime::{trace, DynDef, Heap, Port, Trg}; use hvm64_transform::Transform; +use hvm64_util::pretty_num; fn main() { if cfg!(feature = "trace") { - hvm64_runtime::trace::set_hook(); + trace::set_hook(); } let cli = FullCli::parse(); @@ -70,7 +77,7 @@ fn main() { }; if cfg!(feature = "trace") { - hvm64_runtime::trace::_read_traces(usize::MAX); + trace::_read_traces(usize::MAX); } } @@ -124,7 +131,7 @@ fn load_book(files: &[PathBuf], transform_args: TransformArgs) -> Book { } fn load_dylibs(host: &mut Host, include: &[PathBuf]) { - let current_dir = std::env::current_dir().unwrap(); + let current_dir = env::current_dir().unwrap(); for file in include { unsafe { @@ -163,7 +170,7 @@ fn load_dylibs(host: &mut Host, include: &[PathBuf]) { }); // Leak the lib to avoid unloading it, as code from it is still referenced. - std::mem::forget(lib); + mem::forget(lib); } } } @@ -198,17 +205,6 @@ fn print_stats(net: &hvm64_runtime::Net, elapsed: Duration) { eprintln!("RPS : {:.3} M", (net.rwts.total() as f64) / (elapsed.as_millis() as f64) / 1000.0); } -fn pretty_num(n: u64) -> String { - n.to_string() - .as_bytes() - .rchunks(3) - .rev() - .map(|x| std::str::from_utf8(x).unwrap()) - .flat_map(|x| ["_", x]) - .skip(1) - .collect() -} - /// Compiles the `.hvm` directory, appending the provided `args` to `cargo`. fn compile_temp_hvm() -> Result<(), io::Error> { let output = process::Command::new("cargo") diff --git a/tests/cli.rs b/tests/cli.rs index 58cdacb3..e166ef1f 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -2,6 +2,7 @@ use std::{ error::Error, + fs, io::Read, process::{Command, ExitStatus, Stdio}, }; @@ -253,5 +254,5 @@ fn test_cli_compile() { [#13 #1] "###); - std::fs::remove_file("examples/arithmetic").unwrap(); + fs::remove_file("examples/arithmetic").unwrap(); } diff --git a/tests/tests.rs b/tests/tests.rs index 5f024f3f..2141f71a 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,6 +1,7 @@ +use core::str::FromStr; use dyntest::{dyntest, DynTester}; use hvm64_transform::pre_reduce::PreReduce; -use std::{fs, path::Path, str::FromStr}; +use std::{fs, path::Path}; use hvm64_ast::{self as ast, Book, Net}; use hvm64_host::Host; diff --git a/tests/transform.rs b/tests/transform.rs index 30794c90..654715ca 100644 --- a/tests/transform.rs +++ b/tests/transform.rs @@ -5,8 +5,8 @@ use hvm64_ast::{Book, Net}; use hvm64_transform::{eta_reduce::EtaReduce, inline::Inline, pre_reduce::PreReduce, prune::Prune, TransformError}; +use core::str::FromStr; use insta::assert_snapshot; -use std::str::FromStr; mod loaders; use loaders::*; diff --git a/transform/Cargo.toml b/transform/Cargo.toml index 1024942e..54692452 100644 --- a/transform/Cargo.toml +++ b/transform/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hvm64-transform" -version = "0.3.0" +version.workspace = true edition = "2021" [lib] diff --git a/util/Cargo.toml b/util/Cargo.toml index b2cfbf56..3c7210d8 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hvm64-util" -version = "0.3.0" +version.workspace = true edition = "2021" [dependencies]