Skip to content

Commit

Permalink
Auto merge of rust-lang#86426 - hi-rustin:rustin-patch-lint-warn, r=A…
Browse files Browse the repository at this point in the history
…aron1011

Lint for unused borrows as part of UNUSED_MUST_USE

close rust-lang#76264

base on rust-lang#76894

r? `@RalfJung`
  • Loading branch information
bors committed Jun 19, 2021
2 parents ebf88c9 + e1cc628 commit 551931c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tests/ui/bytes_nth.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
fn main() {
let s = String::from("String");
s.as_bytes().get(3);
&s.as_bytes().get(3);
let _ = &s.as_bytes().get(3);
s[..].as_bytes().get(3);
}
2 changes: 1 addition & 1 deletion tests/ui/bytes_nth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
fn main() {
let s = String::from("String");
s.bytes().nth(3);
&s.bytes().nth(3);
let _ = &s.bytes().nth(3);
s[..].bytes().nth(3);
}
6 changes: 3 additions & 3 deletions tests/ui/bytes_nth.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ LL | s.bytes().nth(3);
= note: `-D clippy::bytes-nth` implied by `-D warnings`

error: called `.byte().nth()` on a `String`
--> $DIR/bytes_nth.rs:9:6
--> $DIR/bytes_nth.rs:9:14
|
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: called `.byte().nth()` on a `str`
--> $DIR/bytes_nth.rs:10:5
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/iter_count.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() {
linked_list.push_back(1);
binary_heap.push(1);

&vec[..].len();
let _ = &vec[..].len();
vec.len();
boxed_slice.len();
vec_deque.len();
Expand All @@ -62,13 +62,13 @@ fn main() {
binary_heap.len();

vec.len();
&vec[..].len();
let _ = &vec[..].len();
vec_deque.len();
hash_map.len();
b_tree_map.len();
linked_list.len();

&vec[..].len();
let _ = &vec[..].len();
vec.len();
vec_deque.len();
hash_set.len();
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/iter_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() {
linked_list.push_back(1);
binary_heap.push(1);

&vec[..].iter().count();
let _ = &vec[..].iter().count();
vec.iter().count();
boxed_slice.iter().count();
vec_deque.iter().count();
Expand All @@ -62,13 +62,13 @@ fn main() {
binary_heap.iter().count();

vec.iter_mut().count();
&vec[..].iter_mut().count();
let _ = &vec[..].iter_mut().count();
vec_deque.iter_mut().count();
hash_map.iter_mut().count();
b_tree_map.iter_mut().count();
linked_list.iter_mut().count();

&vec[..].into_iter().count();
let _ = &vec[..].into_iter().count();
vec.into_iter().count();
vec_deque.into_iter().count();
hash_set.into_iter().count();
Expand Down
18 changes: 9 additions & 9 deletions tests/ui/iter_count.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: called `.iter().count()` on a `slice`
--> $DIR/iter_count.rs:53:6
--> $DIR/iter_count.rs:53:14
|
LL | &vec[..].iter().count();
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
LL | let _ = &vec[..].iter().count();
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
|
= note: `-D clippy::iter-count` implied by `-D warnings`

Expand Down Expand Up @@ -67,10 +67,10 @@ LL | vec.iter_mut().count();
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.len()`

error: called `.iter_mut().count()` on a `slice`
--> $DIR/iter_count.rs:65:6
--> $DIR/iter_count.rs:65:14
|
LL | &vec[..].iter_mut().count();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
LL | let _ = &vec[..].iter_mut().count();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`

error: called `.iter_mut().count()` on a `VecDeque`
--> $DIR/iter_count.rs:66:5
Expand All @@ -97,10 +97,10 @@ LL | linked_list.iter_mut().count();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()`

error: called `.into_iter().count()` on a `slice`
--> $DIR/iter_count.rs:71:6
--> $DIR/iter_count.rs:71:14
|
LL | &vec[..].into_iter().count();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
LL | let _ = &vec[..].into_iter().count();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`

error: called `.into_iter().count()` on a `Vec`
--> $DIR/iter_count.rs:72:5
Expand Down

0 comments on commit 551931c

Please sign in to comment.