Skip to content

Commit b47a322

Browse files
committed
Add tests suggested by @llogiq
1 parent b66aa09 commit b47a322

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/ui/manual_slice_size_calculation.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ fn main() {
2222
// False negatives:
2323
let _ = 5 * size_of::<i32>() * s_i32.len(); // Ok (MISSED OPPORTUNITY)
2424
let _ = size_of::<i32>() * 5 * s_i32.len(); // Ok (MISSED OPPORTUNITY)
25+
26+
let len = s_i32.len();
27+
let size = size_of::<i32>();
28+
let _ = len * size_of::<i32>(); // Ok (MISSED OPPORTUNITY)
29+
let _ = s_i32.len() * size; // Ok (MISSED OPPORTUNITY)
30+
let _ = len * size; // Ok (MISSED OPPORTUNITY)
2531
}
2632

2733
const fn _const(s_i32: &[i32]) {

0 commit comments

Comments
 (0)