Skip to content

Commit c382c8b

Browse files
committed
Add false positive test for using different Vec's length
Currently failing, so currently commented out.
1 parent 97926f9 commit c382c8b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/ui/use_last.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,19 @@ fn index_into_last() -> i32 {
1818
last_element + 1 // To avoid warnings
1919
}
2020

21+
// False positive test (currently failing)
22+
// fn use_last_with_different_vec_length() -> Option<i32> {
23+
// let x = vec![2, 3, 5];
24+
// let y = vec!['a', 'b', 'c'];
25+
// let last_element = x.get(y.len() - 1);
26+
// last_element.map(|val| val + 1)
27+
// }
28+
2129
fn main() {
2230
let expected_value: i32 = 6;
2331
println!("Working...");
2432
assert_eq!(dont_use_last(), Some(expected_value));
2533
assert_eq!(indexing_two_from_end(), Some(expected_value));
2634
assert_eq!(index_into_last(), expected_value);
35+
// assert_eq!(use_last_with_different_vec_length(), Some(expected_value));
2736
}

0 commit comments

Comments
 (0)