diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/.ci_extras/pin-crate-vers-msrv.sh b/.ci_extras/pin-crate-vers-msrv.sh index a10eb759..d05ec46d 100755 --- a/.ci_extras/pin-crate-vers-msrv.sh +++ b/.ci_extras/pin-crate-vers-msrv.sh @@ -3,4 +3,4 @@ set -eux # Pin some dependencies to specific versions for the MSRV. -cargo update -p cargo-platform --precise 0.1.5 +# cargo update -p --precise diff --git a/.ci_extras/pin-crate-vers-nightly.sh b/.ci_extras/pin-crate-vers-nightly.sh index b20a029b..87d75437 100755 --- a/.ci_extras/pin-crate-vers-nightly.sh +++ b/.ci_extras/pin-crate-vers-nightly.sh @@ -4,3 +4,5 @@ set -eux # Pin some dependencies to specific versions for the nightly toolchain. cargo update -p proc-macro2 --precise 1.0.63 +# https://github.com/tkaitchuck/aHash/issues/200 +cargo update -p ahash --precise 0.8.7 diff --git a/.github/workflows/Lints.yml b/.github/workflows/Lints.yml index 6ab94554..e259d057 100644 --- a/.github/workflows/Lints.yml +++ b/.github/workflows/Lints.yml @@ -28,6 +28,8 @@ jobs: if: needs.pre_job.outputs.should_skip != 'true' runs-on: ubuntu-latest strategy: + # Continue running other jobs in the matrix even if one fails. + fail-fast: false matrix: rust: - toolchain: stable @@ -45,10 +47,7 @@ jobs: components: rustfmt, clippy - name: Run Clippy - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --lib --tests --all-features --all-targets -- -D warnings + run: cargo clippy --lib --tests --all-features --all-targets -- -D warnings env: RUSTFLAGS: ${{ matrix.rust.rustflags }} diff --git a/.github/workflows/LinuxCrossCompileTest.yml b/.github/workflows/LinuxCrossCompileTest.yml index 99599f4d..22bd0eec 100644 --- a/.github/workflows/LinuxCrossCompileTest.yml +++ b/.github/workflows/LinuxCrossCompileTest.yml @@ -76,7 +76,7 @@ jobs: - name: Remove integration tests and force enable rustc_version crate run: | rm -rf tests - sed -i '/actix-rt\|async-std\|reqwest\|skeptic/d' Cargo.toml + sed -i '/actix-rt\|async-std\|reqwest/d' Cargo.toml sed -i 's/target.*rustver.*\.//' Cargo.toml sed -i 's/build = "build.rs"/build = ".ci_extras\/build_linux_cross.rs"/' Cargo.toml cat Cargo.toml diff --git a/.github/workflows/Skeptic.yml b/.github/workflows/Trybuild.yml similarity index 70% rename from .github/workflows/Skeptic.yml rename to .github/workflows/Trybuild.yml index 11aa2c6e..784891cb 100644 --- a/.github/workflows/Skeptic.yml +++ b/.github/workflows/Trybuild.yml @@ -1,4 +1,4 @@ -name: Skeptic and Trybuild +name: Trybuild on: push: @@ -42,21 +42,6 @@ jobs: with: toolchain: ${{ matrix.rust }} - - name: Run tests (no features) - run: cargo test --release - env: - RUSTFLAGS: '--cfg skeptic' - - - name: Run tests (release, sync and future) - run: cargo test --release --features 'sync, future' - env: - RUSTFLAGS: '--cfg skeptic' - - - name: Run tests (sync and future, without atomic64 and quanta) - run: cargo test --release --no-default-features --features 'sync, future' - env: - RUSTFLAGS: '--cfg skeptic' - - name: Run compile error tests (sync and future features, trybuild) if: ${{ matrix.rust == 'stable' }} run: cargo test ui_trybuild --release --features 'sync, future' diff --git a/.vscode/settings.json b/.vscode/settings.json index 0a88a2ee..1992c84d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -24,6 +24,8 @@ "Descheduled", "devcontainer", "docsrs", + "doctest", + "doctests", "Einziger", "else's", "ENHANCEME", diff --git a/Cargo.toml b/Cargo.toml index 28998444..dd0c6430 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,15 +99,11 @@ env_logger = "0.10.0" getrandom = "0.2" paste = "1.0.9" reqwest = { version = "0.11.11", default-features = false, features = ["rustls-tls"] } -skeptic = "0.13" tokio = { version = "1.19", features = ["fs", "macros", "rt-multi-thread", "sync", "time" ] } [target.'cfg(trybuild)'.dev-dependencies] trybuild = "1.0" -[target.'cfg(skeptic)'.build-dependencies] -skeptic = "0.13.5" - [target.'cfg(rustver)'.build-dependencies] rustc_version = "0.4.0" diff --git a/README.md b/README.md index bd4bd143..9f902e08 100644 --- a/README.md +++ b/README.md @@ -498,14 +498,13 @@ To run all tests including `future` feature and doc tests on the README, use the following command: ```console -$ RUSTFLAGS='--cfg skeptic --cfg trybuild' cargo test --all-features +$ RUSTFLAGS='--cfg trybuild' cargo test --all-features ``` **Running All Tests without Default Features** ```console -$ RUSTFLAGS='--cfg skeptic --cfg trybuild' cargo test \ - --no-default-features --features future +$ RUSTFLAGS='--cfg trybuild' cargo test --no-default-features --features future ``` **Generating the Doc** diff --git a/build.rs b/build.rs index 88e341e8..72a59c0e 100644 --- a/build.rs +++ b/build.rs @@ -1,9 +1,3 @@ -#[cfg(skeptic)] -fn main() { - // generates doc tests for `README.md`. - skeptic::generate_doc_tests(&["README.md"]); -} - #[cfg(rustver)] fn main() { use rustc_version::version; @@ -14,5 +8,5 @@ fn main() { ); } -#[cfg(not(any(skeptic, rustver)))] +#[cfg(not(rustver))] fn main() {} diff --git a/src/common/timer_wheel.rs b/src/common/timer_wheel.rs index 6badd648..ed6985dc 100644 --- a/src/common/timer_wheel.rs +++ b/src/common/timer_wheel.rs @@ -401,10 +401,13 @@ pub(crate) enum TimerEvent { // This cache entry has been rescheduled. Rescheduling includes moving a timer // from one wheel to another in a lower level of the hierarchy. (This variant // is mainly used for testing) + #[cfg(test)] Rescheduled(TrioArc>), + #[cfg(not(test))] + Rescheduled(()), /// This timer node (containing a cache entry) has been removed from the timer. /// (This variant is mainly used for testing) - Descheduled(Box>>), + Descheduled, } /// An iterator over expired cache entries. @@ -515,6 +518,7 @@ impl<'iter, K> Iterator for TimerEventsIter<'iter, K> { // The cache entry has not expired. Reschedule it. let node_p = NonNull::new(Box::into_raw(node)).expect("Got a null ptr"); match self.timer_wheel.schedule_existing_node(node_p) { + #[cfg(test)] ReschedulingResult::Rescheduled => { let entry_info = unsafe { node_p.as_ref() }.element.entry_info(); @@ -522,11 +526,15 @@ impl<'iter, K> Iterator for TimerEventsIter<'iter, K> { entry_info, ))); } + #[cfg(not(test))] + ReschedulingResult::Rescheduled => { + return Some(TimerEvent::Rescheduled(())); + } ReschedulingResult::Removed(node) => { // The timer event has been removed from the timer // wheel. Unset the timer node from the ValueEntry. node.as_ref().element.unset_timer_node_in_deq_nodes(); - return Some(TimerEvent::Descheduled(node)); + return Some(TimerEvent::Descheduled); } } } diff --git a/src/future/cache.rs b/src/future/cache.rs index 4d783abb..90044b92 100644 --- a/src/future/cache.rs +++ b/src/future/cache.rs @@ -3578,7 +3578,7 @@ mod tests { // Note that MyError does not implement std::error::Error trait // like anyhow::Error. #[derive(Debug)] - pub struct MyError(String); + pub struct MyError(#[allow(dead_code)] String); type MyResult = Result>; @@ -3713,7 +3713,7 @@ mod tests { // Note that MyError does not implement std::error::Error trait // like anyhow::Error. #[derive(Debug)] - pub struct MyError(String); + pub struct MyError(#[allow(dead_code)] String); type MyResult = Result>; diff --git a/src/lib.rs b/src/lib.rs index 160ec20f..e9637719 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -220,3 +220,10 @@ mod tests { t.compile_fail("tests/compile_tests/future/clone/*.rs"); } } + +#[cfg(all(doctest, feature = "sync"))] +mod doctests { + // https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#include-items-only-when-collecting-doctests + #[doc = include_str!("../README.md")] + struct ReadMeDoctests; +} diff --git a/src/policy.rs b/src/policy.rs index 155ec3da..ce91b76c 100644 --- a/src/policy.rs +++ b/src/policy.rs @@ -206,7 +206,7 @@ impl Clone for ExpirationPolicy { Self { time_to_live: self.time_to_live, time_to_idle: self.time_to_idle, - expiry: self.expiry.as_ref().map(Arc::clone), + expiry: self.expiry.clone(), } } } @@ -244,7 +244,7 @@ impl ExpirationPolicy { } pub(crate) fn expiry(&self) -> Option + Send + Sync + 'static>> { - self.expiry.as_ref().map(Arc::clone) + self.expiry.clone() } pub(crate) fn set_expiry(&mut self, expiry: Arc + Send + Sync + 'static>) { diff --git a/src/sync/cache.rs b/src/sync/cache.rs index 2e3dd2c2..c47245dc 100644 --- a/src/sync/cache.rs +++ b/src/sync/cache.rs @@ -3588,7 +3588,7 @@ mod tests { // Note that MyError does not implement std::error::Error trait like // anyhow::Error. #[derive(Debug)] - pub struct MyError(String); + pub struct MyError(#[allow(dead_code)] String); type MyResult = Result>; @@ -3727,7 +3727,7 @@ mod tests { // Note that MyError does not implement std::error::Error trait like // anyhow::Error. #[derive(Debug)] - pub struct MyError(String); + pub struct MyError(#[allow(dead_code)] String); type MyResult = Result>; diff --git a/src/sync/segment.rs b/src/sync/segment.rs index c1728ad3..166ff5a3 100644 --- a/src/sync/segment.rs +++ b/src/sync/segment.rs @@ -759,8 +759,8 @@ where seg_max_capacity, seg_init_capacity, build_hasher.clone(), - weigher.as_ref().map(Arc::clone), - eviction_listener.as_ref().map(Arc::clone), + weigher.clone(), + eviction_listener.clone(), eviction_listener_conf.clone(), expiration_policy.clone(), invalidator_enabled, diff --git a/src/sync_base/base_cache.rs b/src/sync_base/base_cache.rs index 7dd68220..08638ce8 100644 --- a/src/sync_base/base_cache.rs +++ b/src/sync_base/base_cache.rs @@ -74,7 +74,7 @@ impl Clone for BaseCache { inner: Arc::clone(&self.inner), read_op_ch: self.read_op_ch.clone(), write_op_ch: self.write_op_ch.clone(), - housekeeper: self.housekeeper.as_ref().map(Arc::clone), + housekeeper: self.housekeeper.clone(), } } } diff --git a/tests/skeptic.rs b/tests/skeptic.rs deleted file mode 100644 index 6b54ee21..00000000 --- a/tests/skeptic.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[cfg(skeptic)] -include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs"));