You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
slice.len(), usize multiplication, and size_of::<T> are all const, but size_of_val is only unstably const. Code may be using this pattern out of necessity.
Then maybe only linting for nightly builds? It can be quickly checked from cx.sess().is_nightly_build(). As far as I'm aware, there are no unstable Clippy lints.
What it does
When
a
is&[T]
, detecta.len() * size_of::<T>()
and suggestsize_of_val(a)
instead.Lint Name
manual_slice_size_calculation
Category
complexity, perf
Advantage
Drawbacks
No response
Example
https://github.com/rust-lang/rust/blob/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/core/src/hash/mod.rs#L837
Could be written as:
The text was updated successfully, but these errors were encountered: