From 8c3a45eda8a2b7178512ddd1f71d247bccf43b33 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Fri, 1 Dec 2023 11:21:21 -0500 Subject: [PATCH] fixes --- Cargo.toml | 2 +- Makefile | 1 + core-traits/Cargo.toml | 2 +- core/Cargo.toml | 2 +- edn/Cargo.toml | 2 +- edn/src/query.rs | 4 ++-- rust-toolchain | 1 + shell.nix | 38 ++++++++++++++++++++++++++++++++++++++ tests/query.rs | 2 +- tolstoy-traits/Cargo.toml | 2 +- tolstoy/Cargo.toml | 4 ++-- 11 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 rust-toolchain create mode 100644 shell.nix diff --git a/Cargo.toml b/Cargo.toml index d85558d3..5afc043d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ failure = "~0.1" lazy_static = "~1.4" time = "0.3.1" log = "~0.4" -uuid = { version = "~1.0", features = ["v4", "serde"] } +uuid = { version = "~1", features = ["v4", "serde"] } [dependencies.rusqlite] version = "~0.26" diff --git a/Makefile b/Makefile index d718bf76..7c3ef9d9 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +.PHONY: outdated fix outdated: for p in $(dirname $(ls Cargo.toml */Cargo.toml */*/Cargo.toml)); do echo $p; (cd $p; cargo outdated -R); done diff --git a/core-traits/Cargo.toml b/core-traits/Cargo.toml index c43d6231..e47d0155 100644 --- a/core-traits/Cargo.toml +++ b/core-traits/Cargo.toml @@ -13,7 +13,7 @@ enum-set = "~0.0.8" lazy_static = "~1.4" indexmap = "~1.7" ordered-float = { version = "~2.8", features = ["serde"] } -uuid = { version = "~1.0", features = ["v4", "serde"] } +uuid = { version = "~1", features = ["v4", "serde"] } serde = { version = "~1.0", features = ["rc"] } serde_derive = "~1.0" bytes = { version = "1.0.1", features = ["serde"] } diff --git a/core/Cargo.toml b/core/Cargo.toml index 0bc4142b..e65d8d09 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -9,7 +9,7 @@ enum-set = "~0.0" failure = "~0.1" indexmap = "~1.7" ordered-float = { version = "~2.8", features = ["serde"] } -uuid = { version = "~1.0", features = ["v4", "serde"] } +uuid = { version = "~1", features = ["v4", "serde"] } [dependencies.core_traits] path = "../core-traits" diff --git a/edn/Cargo.toml b/edn/Cargo.toml index 9ac64a04..b02002af 100644 --- a/edn/Cargo.toml +++ b/edn/Cargo.toml @@ -15,7 +15,7 @@ itertools = "~0.10" num = "~0.4" ordered-float = "~2.8" pretty = "~0.10" -uuid = { version = "~1.0", features = ["v4", "serde"] } +uuid = { version = "~1", features = ["v4", "serde"] } serde = { version = "~1.0", optional = true } serde_derive = { version = "~1.0", optional = true } peg = "~0.7" diff --git a/edn/src/query.rs b/edn/src/query.rs index dde4e91b..c0cdf487 100644 --- a/edn/src/query.rs +++ b/edn/src/query.rs @@ -1123,14 +1123,14 @@ impl OrJoin { (self.clauses, self.unify_vars, vars) } - pub fn mentioned_variables(mut self) -> BTreeSet { + pub fn mentioned_variables<'a>(&'a mut self) -> &'a BTreeSet { if self.mentioned_vars.is_none() { let m = self.collect_mentioned_variables(); self.mentioned_vars = Some(m); } if let Some(ref mentioned) = self.mentioned_vars { - mentioned.clone() + mentioned } else { unreachable!() } diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 00000000..d57d7a14 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly-2023-11-27 diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..832dcf30 --- /dev/null +++ b/shell.nix @@ -0,0 +1,38 @@ +{ pkgs ? import {} }: + pkgs.mkShell rec { + buildInputs = with pkgs; [ + # Necessary for the openssl-sys crate: + pkgs.openssl + pkgs.pkg-config + # Compiler + clang + # Replace llvmPackages with llvmPackages_X, where X is the latest LLVM version (at the time of writing, 16) + llvmPackages.bintools + rustup + ]; + RUSTC_VERSION = pkgs.lib.readFile ./rust-toolchain; + # https://github.com/rust-lang/rust-bindgen#environment-variables + LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ]; + shellHook = '' + export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin + export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/ + ''; + # Add precompiled library to rustc search path + RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [ + # add libraries here (e.g. pkgs.libvmi) + ]); + # Add glibc, clang, glib and other headers to bindgen search path + BINDGEN_EXTRA_CLANG_ARGS = + # Includes with normal include path + (builtins.map (a: ''-I"${a}/include"'') [ + # add dev libraries here (e.g. pkgs.libvmi.dev) + pkgs.glibc.dev + ]) + # Includes with special directory paths + ++ [ + ''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"'' + ''-I"${pkgs.glib.dev}/include/glib-2.0"'' + ''-I${pkgs.glib.out}/lib/glib-2.0/include/'' + ]; + + } diff --git a/tests/query.rs b/tests/query.rs index 6a5cf616..7eef8b45 100644 --- a/tests/query.rs +++ b/tests/query.rs @@ -254,7 +254,7 @@ fn test_unbound_inputs() { fn test_instants_and_uuids() { // We assume, perhaps foolishly, that the clocks on test machines won't lose more than an // hour while this test is running. - let start = Utc::now() + FixedOffset::west(60 * 60); + let start = Utc::now() + FixedOffset::west_opt(60 * 60).unwrap(); let mut c = new_connection("").expect("Couldn't open conn."); let mut conn = Conn::connect(&mut c).expect("Couldn't open DB."); diff --git a/tolstoy-traits/Cargo.toml b/tolstoy-traits/Cargo.toml index 0ea6b071..062268fb 100644 --- a/tolstoy-traits/Cargo.toml +++ b/tolstoy-traits/Cargo.toml @@ -16,7 +16,7 @@ failure_derive = "~0.1" http = "~0.2" hyper = "~0.14" serde_json = "~1.0" -uuid = { version = "~1.0" } +uuid = { version = "~1" } [dependencies.rusqlite] version = "~0.26" diff --git a/tolstoy/Cargo.toml b/tolstoy/Cargo.toml index f12388d7..8c747fde 100644 --- a/tolstoy/Cargo.toml +++ b/tolstoy/Cargo.toml @@ -1,5 +1,5 @@ [package] -edition = "2018" +edition = "2021" name = "mentat_tolstoy" version = "0.0.2" workspace = ".." @@ -22,7 +22,7 @@ serde_json = "~1.0" serde_cbor = "~0.11" serde_derive = "~1.0" lazy_static = "~1.4" -uuid = { version = "~1.0", features = ["v4", "serde"] } +uuid = { version = "~1", features = ["v4", "serde"] } [dependencies.rusqlite] version = "~0.26"