diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1bf6ae..aec0024 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,10 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v6 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + rustflags: "" - name: Build run: cargo build --verbose - name: Run tests diff --git a/Cargo.toml b/Cargo.toml index 739885b..e294ad3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ categories = [ keywords = ["hashconsing", "hash", "consing", "sharing", "caching"] license = "MIT/Apache-2.0" edition = "2021" +rust-version = "1.60" [package.metadata.docs.rs] features = ["unstable_docrs"] diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..8dbf642 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.90.0" +components = [ "rustfmt", "rustc", "rust-analyzer", "clippy" ] diff --git a/src/lib.rs b/src/lib.rs index c00789c..f3d7d69 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -213,8 +213,6 @@ //! [lazy static]: https://crates.io/crates/lazy_static //! (lazy_static library on crates.io) -#![deny(warnings)] - use std::{ cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd}, collections::{hash_map::RandomState, HashMap}, diff --git a/tests/try_build.rs b/tests/try_build.rs deleted file mode 100644 index 14689ac..0000000 --- a/tests/try_build.rs +++ /dev/null @@ -1,8 +0,0 @@ -//! Try-build tests. - -#[test] -fn issues() { - let t = trybuild::TestCases::new(); - - t.compile_fail("tests/try_build/issue_1.rs"); -} diff --git a/tests/try_build/issue_1.rs b/tests/try_build/issue_1.rs deleted file mode 100644 index 659c7b0..0000000 --- a/tests/try_build/issue_1.rs +++ /dev/null @@ -1,61 +0,0 @@ -//! From https://github.com/AdrienChampion/hashconsing/issues/1. - -#![forbid(unsafe_code)] - -use hashconsing::{HConsign, HashConsign}; - -use crossbeam_utils::thread; -use std::cell::Cell; -use std::hash::{Hash, Hasher}; - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -enum RefOrInt<'a> { - Ref(&'a u64), - Int(u64), -} - -#[derive(PartialEq, Eq)] -struct HashableCell { - cell: Cell, -} -// Fake hashing function just so we can get a HConsed going. -impl Hash for HashableCell { - fn hash(&self, state: &mut H) { - 1024.hash(state); - } -} - -static SOME_INT: u64 = 123; - -fn main() { - let cell = Cell::new(RefOrInt::Ref(&SOME_INT)); - let hashable_cell = HashableCell { cell: cell }; - - let mut factory: HConsign<_> = HConsign::empty(); - let hcons_cell_ref = factory.mk(&hashable_cell); - thread::scope(|s| { - s.spawn(move |_| { - let smuggled_cell = &hcons_cell_ref.get().cell; - - loop { - // Repeatedly write Ref(&addr) and Int(0xdeadbeef) into the cell. - smuggled_cell.set(RefOrInt::Ref(&SOME_INT)); - smuggled_cell.set(RefOrInt::Int(0xdeadbeef)); - } - }); - - loop { - if let RefOrInt::Ref(addr) = hashable_cell.cell.get() { - // Hope that between the time we pattern match the object as a - // `Ref`, it gets written to by the other thread. - if addr as *const u64 == &SOME_INT as *const u64 { - continue; - } - - // Due to the data race, obtaining Ref(0xdeadbeef) is possible - println!("Pointer is now: {:p}", addr); - println!("Dereferencing addr will now segfault: {}", *addr); - } - } - }); -} diff --git a/tests/try_build/issue_1.stderr b/tests/try_build/issue_1.stderr deleted file mode 100644 index 379a339..0000000 --- a/tests/try_build/issue_1.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0277]: `Cell>` cannot be shared between threads safely - --> tests/try_build/issue_1.rs:37:17 - | -37 | s.spawn(move |_| { - | ___________-----_^ - | | | - | | required by a bound introduced by this call -38 | | let smuggled_cell = &hcons_cell_ref.get().cell; -39 | | -40 | | loop { -... | -44 | | } -45 | | }); - | |_________^ `Cell>` cannot be shared between threads safely - | - = help: within `&HashableCell>`, the trait `Sync` is not implemented for `Cell>` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` -note: required because it appears within the type `HashableCell>` - --> tests/try_build/issue_1.rs:18:8 - | -18 | struct HashableCell { - | ^^^^^^^^^^^^ - = note: required because it appears within the type `&HashableCell>` - = note: required for `Arc<&HashableCell>>` to implement `Send` -note: required because it appears within the type `HConsed<&HashableCell>>` - --> src/lib.rs - | - | pub struct HConsed { - | ^^^^^^^ -note: required because it's used within this closure - --> tests/try_build/issue_1.rs:37:17 - | -37 | s.spawn(move |_| { - | ^^^^^^^^ -note: required by a bound in `crossbeam_utils::thread::Scope::<'env>::spawn` - --> $CARGO/crossbeam-utils-0.8.16/src/thread.rs - | - | pub fn spawn<'scope, F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T> - | ----- required by a bound in this associated function -... - | F: Send + 'env, - | ^^^^ required by this bound in `Scope::<'env>::spawn`