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

Clippy warnings #12

Closed
tatsuya6502 opened this issue Aug 10, 2023 · 1 comment · Fixed by #13
Closed

Clippy warnings #12

tatsuya6502 opened this issue Aug 10, 2023 · 1 comment · Fixed by #13

Comments

@tatsuya6502
Copy link
Member

I will fix or disable these Clippy warnings tomorrow. (It is already midnight in my timezone)

$ cargo +stable clippy --lib --tests --all-features --all-targets

warning: very complex type used. Consider factoring parts into `type` definitions
   --> src/sync/base_cache.rs:565:10
    |
565 |     ) -> Option<(Arc<K>, TrioArc<ValueEntry<K, V>>)> {
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
note: the lint level is defined here
   --> src/lib.rs:1:9
    |
1   | #![warn(clippy::all)]
    |         ^^^^^^^^^^^
    = note: `#[warn(clippy::type_complexity)]` implied by `#[warn(clippy::all)]`

warning: very complex type used. Consider factoring parts into `type` definitions
   --> src/sync/base_cache.rs:578:10
    |
578 |     ) -> Option<(Arc<K>, TrioArc<ValueEntry<K, V>>)> {
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity

warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
   --> src/sync/base_cache.rs:894:17
    |
894 | //                 self.remove(&Arc::clone(&kh.key), RemovalCause::Size)
895 | ||                     .map(|(k, v)| (self.eviction_handler)(k, &v.value, RemovalCause::Size));
    | ||___________________________________________________________________________________________^- help: try this: `if let Some((k, v)) = self.remove(&Arc::clone(&kh.key), RemovalCause::Size) { (self.eviction_handler)(k, &v.value, RemovalCause::Size) }`
    |  |___________________________________________________________________________________________|
    | 
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn
    = note: `#[warn(clippy::option_map_unit_fn)]` implied by `#[warn(clippy::all)]`

The current beta Clippy emits the following clippy::arc_with_non_send_sync warning. For our case, Clippy is wrong. I will disable it only when the beta Clippy is used (otherwise stable Clippy will fail as it does not have clippy::arc_with_non_send_sync). I will do the same to moka-rs/moka#291.

$ cargo +beta clippy --lib --tests --all-features --all-targets

warning: usage of `Arc<T>` where `T` is not `Send` or `Sync`
   --> src/sync/base_cache.rs:117:20
    |
117 |             inner: Arc::new(inner),
    |                    ^^^^^^^^^^^^^^^
    |
    = help: consider using `Rc<T>` instead or wrapping `T` in a std::sync type like `Mutex<T>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync

... (snip. same as the stable) ...
@tatsuya6502
Copy link
Member Author

The current beta Clippy emits the following clippy::arc_with_non_send_sync warning. For our case, Clippy is wrong.

I updated my local beta toolchain installation, and found that beta Clippy no longer emits the warning.

$ rustup update
...
      beta-aarch64-apple-darwin updated - rustc 1.72.0-beta.6 (d8fd588af 2023-08-03) (from rustc 1.72.0-beta.5 (1537df02f 2023-08-01))

The issue was reported by rust-lang/rust-clippy#11076 and fixed already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant