Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 2021 edition, bless tests #339

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "moka"
version = "0.12.1"
edition = "2018"
edition = "2021"
# Rust 1.65 was released on Nov 3, 2022.
rust-version = "1.65"
description = "A fast and concurrent cache library inspired by Java Caffeine"
Expand Down
3 changes: 0 additions & 3 deletions src/common/timer_wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,6 @@ impl<K> TimerWheel<K> {
// which is ~584 years in nanoseconds.
//
fn time_nanos(&self, time: Instant) -> u64 {
// `TryInto` will be in the prelude starting in Rust 2021 Edition.
use std::convert::TryInto;

let nanos_u128 = time
.checked_duration_since(self.origin)
// If `time` is earlier than `self.origin`, use zero. This would never
Expand Down
56 changes: 32 additions & 24 deletions tests/compile_tests/default/clone/sync_cache_clone.stderr
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
error[E0277]: the trait bound `MyValue: Clone` is not satisfied
--> tests/compile_tests/default/clone/sync_cache_clone.rs:18:41
|
18 | let _cache: Cache<MyKey, MyValue> = Cache::new(CAP);
| ^^^^^^^^^^ the trait `Clone` is not implemented for `MyValue`
|
--> tests/compile_tests/default/clone/sync_cache_clone.rs:18:41
|
18 | let _cache: Cache<MyKey, MyValue> = Cache::new(CAP);
| ^^^^^^^^^^ the trait `Clone` is not implemented for `MyValue`
|
note: required by a bound in `moka::sync::Cache::<K, V>::new`
--> src/sync/cache.rs
|
| V: Clone + Send + Sync + 'static,
| ^^^^^ required by this bound in `moka::sync::Cache::<K, V>::new`
--> src/sync/cache.rs
|
| V: Clone + Send + Sync + 'static,
| ^^^^^ required by this bound in `Cache::<K, V>::new`
...
| pub fn new(max_capacity: u64) -> Self {
| --- required by a bound in this associated function
help: consider annotating `MyValue` with `#[derive(Clone)]`
|
41 | #[derive(Clone)]
|
41 + #[derive(Clone)]
42 | pub struct MyValue(i32);
|

error[E0277]: the trait bound `MyBuildHasher1: Clone` is not satisfied
--> tests/compile_tests/default/clone/sync_cache_clone.rs:28:84
|
28 | let _cache: Cache<MyKey, Arc<MyValue>, _> = Cache::builder().build_with_hasher(MyBuildHasher1);
| ----------------- ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `MyBuildHasher1`
| |
| required by a bound introduced by this call
|
--> tests/compile_tests/default/clone/sync_cache_clone.rs:28:84
|
28 | let _cache: Cache<MyKey, Arc<MyValue>, _> = Cache::builder().build_with_hasher(MyBuildHasher1);
| ----------------- ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `MyBuildHasher1`
| |
| required by a bound introduced by this call
|
note: required by a bound in `moka::sync::CacheBuilder::<K, V, moka::sync::Cache<K, V>>::build_with_hasher`
--> src/sync/builder.rs
|
| S: BuildHasher + Clone + Send + Sync + 'static,
| ^^^^^ required by this bound in `moka::sync::CacheBuilder::<K, V, moka::sync::Cache<K, V>>::build_with_hasher`
--> src/sync/builder.rs
|
| pub fn build_with_hasher<S>(self, hasher: S) -> Cache<K, V, S>
| ----------------- required by a bound in this associated function
| where
| S: BuildHasher + Clone + Send + Sync + 'static,
| ^^^^^ required by this bound in `CacheBuilder::<K, V, Cache<K, V>>::build_with_hasher`
help: consider annotating `MyBuildHasher1` with `#[derive(Clone)]`
|
44 | #[derive(Clone)]
|
44 + #[derive(Clone)]
45 | pub struct MyBuildHasher1;
|
36 changes: 22 additions & 14 deletions tests/compile_tests/default/clone/sync_seg_cache_clone.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,33 @@ note: required by a bound in `SegmentedCache::<K, V>::new`
|
| V: Clone + Send + Sync + 'static,
| ^^^^^ required by this bound in `SegmentedCache::<K, V>::new`
...
| pub fn new(max_capacity: u64, num_segments: usize) -> Self {
| --- required by a bound in this associated function
help: consider annotating `MyValue` with `#[derive(Clone)]`
|
44 | #[derive(Clone)]
44 + #[derive(Clone)]
45 | pub struct MyValue(i32);
|

error[E0277]: the trait bound `MyBuildHasher1: Clone` is not satisfied
--> tests/compile_tests/default/clone/sync_seg_cache_clone.rs:30:56
|
30 | SegmentedCache::builder(SEG).build_with_hasher(MyBuildHasher1);
| ----------------- ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `MyBuildHasher1`
| |
| required by a bound introduced by this call
|
--> tests/compile_tests/default/clone/sync_seg_cache_clone.rs:30:56
|
30 | SegmentedCache::builder(SEG).build_with_hasher(MyBuildHasher1);
| ----------------- ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `MyBuildHasher1`
| |
| required by a bound introduced by this call
|
note: required by a bound in `moka::sync::CacheBuilder::<K, V, SegmentedCache<K, V>>::build_with_hasher`
--> src/sync/builder.rs
|
| S: BuildHasher + Clone + Send + Sync + 'static,
| ^^^^^ required by this bound in `moka::sync::CacheBuilder::<K, V, SegmentedCache<K, V>>::build_with_hasher`
--> src/sync/builder.rs
|
| pub fn build_with_hasher<S>(self, hasher: S) -> SegmentedCache<K, V, S>
| ----------------- required by a bound in this associated function
| where
| S: BuildHasher + Clone + Send + Sync + 'static,
| ^^^^^ required by this bound in `CacheBuilder::<K, V, SegmentedCache<K, V>>::build_with_hasher`
help: consider annotating `MyBuildHasher1` with `#[derive(Clone)]`
|
47 | #[derive(Clone)]
|
47 + #[derive(Clone)]
48 | pub struct MyBuildHasher1;
|
56 changes: 32 additions & 24 deletions tests/compile_tests/future/clone/future_cache_clone.stderr
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
error[E0277]: the trait bound `MyValue: Clone` is not satisfied
--> tests/compile_tests/future/clone/future_cache_clone.rs:19:41
|
19 | let _cache: Cache<MyKey, MyValue> = Cache::new(CAP);
| ^^^^^^^^^^ the trait `Clone` is not implemented for `MyValue`
|
--> tests/compile_tests/future/clone/future_cache_clone.rs:19:41
|
19 | let _cache: Cache<MyKey, MyValue> = Cache::new(CAP);
| ^^^^^^^^^^ the trait `Clone` is not implemented for `MyValue`
|
note: required by a bound in `moka::future::Cache::<K, V>::new`
--> src/future/cache.rs
|
| V: Clone + Send + Sync + 'static,
| ^^^^^ required by this bound in `moka::future::Cache::<K, V>::new`
--> src/future/cache.rs
|
| V: Clone + Send + Sync + 'static,
| ^^^^^ required by this bound in `Cache::<K, V>::new`
...
| pub fn new(max_capacity: u64) -> Self {
| --- required by a bound in this associated function
help: consider annotating `MyValue` with `#[derive(Clone)]`
|
42 | #[derive(Clone)]
|
42 + #[derive(Clone)]
43 | pub struct MyValue(i32);
|

error[E0277]: the trait bound `MyBuildHasher1: Clone` is not satisfied
--> tests/compile_tests/future/clone/future_cache_clone.rs:29:84
|
29 | let _cache: Cache<MyKey, Arc<MyValue>, _> = Cache::builder().build_with_hasher(MyBuildHasher1);
| ----------------- ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `MyBuildHasher1`
| |
| required by a bound introduced by this call
|
--> tests/compile_tests/future/clone/future_cache_clone.rs:29:84
|
29 | let _cache: Cache<MyKey, Arc<MyValue>, _> = Cache::builder().build_with_hasher(MyBuildHasher1);
| ----------------- ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `MyBuildHasher1`
| |
| required by a bound introduced by this call
|
note: required by a bound in `moka::future::CacheBuilder::<K, V, moka::future::Cache<K, V>>::build_with_hasher`
--> src/future/builder.rs
|
| S: BuildHasher + Clone + Send + Sync + 'static,
| ^^^^^ required by this bound in `moka::future::CacheBuilder::<K, V, moka::future::Cache<K, V>>::build_with_hasher`
--> src/future/builder.rs
|
| pub fn build_with_hasher<S>(self, hasher: S) -> Cache<K, V, S>
| ----------------- required by a bound in this associated function
| where
| S: BuildHasher + Clone + Send + Sync + 'static,
| ^^^^^ required by this bound in `CacheBuilder::<K, V, Cache<K, V>>::build_with_hasher`
help: consider annotating `MyBuildHasher1` with `#[derive(Clone)]`
|
45 | #[derive(Clone)]
|
45 + #[derive(Clone)]
46 | pub struct MyBuildHasher1;
|
Loading