From 531080e8e565f4e32bda1290d835f9c746a01142 Mon Sep 17 00:00:00 2001 From: Jendrik Date: Sat, 26 Mar 2022 16:19:47 +0100 Subject: [PATCH] add #[must_use] to functions of slice and its iterators. --- src/tools/clippy/tests/ui/bytes_nth.stderr | 12 +++++----- .../clippy/tests/ui/iter_next_slice.stderr | 24 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/tools/clippy/tests/ui/bytes_nth.stderr b/src/tools/clippy/tests/ui/bytes_nth.stderr index 536decf5e7fc4..8a7afa934502d 100644 --- a/src/tools/clippy/tests/ui/bytes_nth.stderr +++ b/src/tools/clippy/tests/ui/bytes_nth.stderr @@ -1,8 +1,8 @@ error: called `.byte().nth()` on a `String` - --> $DIR/bytes_nth.rs:8:5 + --> $DIR/bytes_nth.rs:8:13 | -LL | s.bytes().nth(3); - | ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)` +LL | let _ = s.bytes().nth(3); + | ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)` | = note: `-D clippy::bytes-nth` implied by `-D warnings` @@ -13,10 +13,10 @@ LL | let _ = &s.bytes().nth(3); | ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)` error: called `.byte().nth()` on a `str` - --> $DIR/bytes_nth.rs:10:5 + --> $DIR/bytes_nth.rs:10:13 | -LL | s[..].bytes().nth(3); - | ^^^^^^^^^^^^^^^^^^^^ help: try: `s[..].as_bytes().get(3)` +LL | let _ = s[..].bytes().nth(3); + | ^^^^^^^^^^^^^^^^^^^^ help: try: `s[..].as_bytes().get(3)` error: aborting due to 3 previous errors diff --git a/src/tools/clippy/tests/ui/iter_next_slice.stderr b/src/tools/clippy/tests/ui/iter_next_slice.stderr index 8c10a252ee01b..a78d2c2d5e838 100644 --- a/src/tools/clippy/tests/ui/iter_next_slice.stderr +++ b/src/tools/clippy/tests/ui/iter_next_slice.stderr @@ -1,28 +1,28 @@ error: using `.iter().next()` on an array - --> $DIR/iter_next_slice.rs:9:5 + --> $DIR/iter_next_slice.rs:9:13 | -LL | s.iter().next(); - | ^^^^^^^^^^^^^^^ help: try calling: `s.get(0)` +LL | let _ = s.iter().next(); + | ^^^^^^^^^^^^^^^ help: try calling: `s.get(0)` | = note: `-D clippy::iter-next-slice` implied by `-D warnings` error: using `.iter().next()` on a Slice without end index - --> $DIR/iter_next_slice.rs:12:5 + --> $DIR/iter_next_slice.rs:12:13 | -LL | s[2..].iter().next(); - | ^^^^^^^^^^^^^^^^^^^^ help: try calling: `s.get(2)` +LL | let _ = s[2..].iter().next(); + | ^^^^^^^^^^^^^^^^^^^^ help: try calling: `s.get(2)` error: using `.iter().next()` on a Slice without end index - --> $DIR/iter_next_slice.rs:15:5 + --> $DIR/iter_next_slice.rs:15:13 | -LL | v[5..].iter().next(); - | ^^^^^^^^^^^^^^^^^^^^ help: try calling: `v.get(5)` +LL | let _ = v[5..].iter().next(); + | ^^^^^^^^^^^^^^^^^^^^ help: try calling: `v.get(5)` error: using `.iter().next()` on an array - --> $DIR/iter_next_slice.rs:18:5 + --> $DIR/iter_next_slice.rs:18:13 | -LL | v.iter().next(); - | ^^^^^^^^^^^^^^^ help: try calling: `v.get(0)` +LL | let _ = v.iter().next(); + | ^^^^^^^^^^^^^^^ help: try calling: `v.get(0)` error: aborting due to 4 previous errors