]> git.lizzy.rs Git - rust.git/commit
size_of_in_element_count: Disable lint on division by byte-size
authorMarijn Suijten <marijn@traverseresearch.nl>
Tue, 12 Jan 2021 10:35:44 +0000 (11:35 +0100)
committerMarijn Suijten <marijn@traverseresearch.nl>
Tue, 19 Jan 2021 19:05:40 +0000 (20:05 +0100)
commitd4bf59b6ef24042653951b69105a3a68542f3bbd
tree2fad486ca92efe97679f76e2022f2584929325e7
parent391bb218b5a79f32ddfacc668838fdfb06835f77
size_of_in_element_count: Disable lint on division by byte-size

It is fairly common to divide some length in bytes by the byte-size of a
single element before creating a `from_raw_parts` slice or similar
operation. This lint would erroneously disallow such expressions.

Just in case, instead of simply disabling this lint in the RHS of a
division, keep track of the inversion and enable it again on recursive
division.
clippy_lints/src/size_of_in_element_count.rs
tests/ui/size_of_in_element_count/expressions.rs
tests/ui/size_of_in_element_count/expressions.stderr