diff options
| author | Michael Schubart <michael@schubart.net> | 2023-04-06 13:45:50 +0100 |
|---|---|---|
| committer | Michael Schubart <michael@schubart.net> | 2023-04-06 13:45:50 +0100 |
| commit | b47a322ef11e541231b18c67dfe133dac8764b11 (patch) | |
| tree | da37b47700c403a8e5abcc14497e601d7d4d4352 /tests | |
| parent | b66aa09b951dace249fad3376c2d97c95d11b6a9 (diff) | |
| download | rust-b47a322ef11e541231b18c67dfe133dac8764b11.tar.gz rust-b47a322ef11e541231b18c67dfe133dac8764b11.zip | |
Add tests suggested by @llogiq
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/manual_slice_size_calculation.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/ui/manual_slice_size_calculation.rs b/tests/ui/manual_slice_size_calculation.rs index 8ec4ae0aed7..2cb8c4c2ad3 100644 --- a/tests/ui/manual_slice_size_calculation.rs +++ b/tests/ui/manual_slice_size_calculation.rs @@ -22,6 +22,12 @@ fn main() { // False negatives: let _ = 5 * size_of::<i32>() * s_i32.len(); // Ok (MISSED OPPORTUNITY) let _ = size_of::<i32>() * 5 * s_i32.len(); // Ok (MISSED OPPORTUNITY) + + let len = s_i32.len(); + let size = size_of::<i32>(); + let _ = len * size_of::<i32>(); // Ok (MISSED OPPORTUNITY) + let _ = s_i32.len() * size; // Ok (MISSED OPPORTUNITY) + let _ = len * size; // Ok (MISSED OPPORTUNITY) } const fn _const(s_i32: &[i32]) { |
