mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Add tests with usize::MIN
This commit is contained in:
parent
2493be2196
commit
3966580c9d
3 changed files with 41 additions and 5 deletions
|
@ -9,6 +9,12 @@ fn range() {
|
|||
let mut v = vec![1, 2, 3];
|
||||
let n = v.drain(0..v.len()).count(); // Yay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
let n = v.drain(usize::MIN..v.len()).count(); // Yay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
v.clear(); // Nay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
v.clear(); // Nay
|
||||
}
|
||||
|
@ -20,6 +26,12 @@ fn range_from() {
|
|||
let mut v = vec![1, 2, 3];
|
||||
let next = v.drain(0..).next(); // Yay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
let next = v.drain(usize::MIN..).next(); // Yay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
v.clear(); // Nay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
v.clear(); // Nay
|
||||
}
|
||||
|
|
|
@ -9,8 +9,14 @@ fn range() {
|
|||
let mut v = vec![1, 2, 3];
|
||||
let n = v.drain(0..v.len()).count(); // Yay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
let n = v.drain(usize::MIN..v.len()).count(); // Yay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
v.drain(0..v.len()); // Nay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
v.drain(usize::MIN..v.len()); // Nay
|
||||
}
|
||||
|
||||
fn range_from() {
|
||||
|
@ -20,8 +26,14 @@ fn range_from() {
|
|||
let mut v = vec![1, 2, 3];
|
||||
let next = v.drain(0..).next(); // Yay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
let next = v.drain(usize::MIN..).next(); // Yay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
v.drain(0..); // Nay
|
||||
|
||||
let mut v = vec![1, 2, 3];
|
||||
v.drain(usize::MIN..); // Nay
|
||||
}
|
||||
|
||||
fn range_full() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: `drain` used to clear a `Vec`
|
||||
--> $DIR/clear_with_drain.rs:13:7
|
||||
--> $DIR/clear_with_drain.rs:16:7
|
||||
|
|
||||
LL | v.drain(0..v.len()); // Nay
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `clear()`
|
||||
|
@ -7,22 +7,34 @@ LL | v.drain(0..v.len()); // Nay
|
|||
= note: `-D clippy::clear-with-drain` implied by `-D warnings`
|
||||
|
||||
error: `drain` used to clear a `Vec`
|
||||
--> $DIR/clear_with_drain.rs:24:7
|
||||
--> $DIR/clear_with_drain.rs:19:7
|
||||
|
|
||||
LL | v.drain(usize::MIN..v.len()); // Nay
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `clear()`
|
||||
|
||||
error: `drain` used to clear a `Vec`
|
||||
--> $DIR/clear_with_drain.rs:33:7
|
||||
|
|
||||
LL | v.drain(0..); // Nay
|
||||
| ^^^^^^^^^^ help: try: `clear()`
|
||||
|
||||
error: `drain` used to clear a `Vec`
|
||||
--> $DIR/clear_with_drain.rs:38:7
|
||||
--> $DIR/clear_with_drain.rs:36:7
|
||||
|
|
||||
LL | v.drain(usize::MIN..); // Nay
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try: `clear()`
|
||||
|
||||
error: `drain` used to clear a `Vec`
|
||||
--> $DIR/clear_with_drain.rs:50:7
|
||||
|
|
||||
LL | v.drain(..); // Nay
|
||||
| ^^^^^^^^^ help: try: `clear()`
|
||||
|
||||
error: `drain` used to clear a `Vec`
|
||||
--> $DIR/clear_with_drain.rs:52:7
|
||||
--> $DIR/clear_with_drain.rs:64:7
|
||||
|
|
||||
LL | v.drain(..v.len()); // Nay
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `clear()`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue