diff --git a/tests/ui/clear_with_drain.fixed b/tests/ui/clear_with_drain.fixed index 6ab05d9ba..0a15463dd 100644 --- a/tests/ui/clear_with_drain.fixed +++ b/tests/ui/clear_with_drain.fixed @@ -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 } diff --git a/tests/ui/clear_with_drain.rs b/tests/ui/clear_with_drain.rs index 6926a4b60..40201d9cc 100644 --- a/tests/ui/clear_with_drain.rs +++ b/tests/ui/clear_with_drain.rs @@ -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() { diff --git a/tests/ui/clear_with_drain.stderr b/tests/ui/clear_with_drain.stderr index b7206cd90..e7152a1cb 100644 --- a/tests/ui/clear_with_drain.stderr +++ b/tests/ui/clear_with_drain.stderr @@ -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