Skip to content

Lint for unused borrows as part of UNUSED_MUST_USE #86426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/clippy/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 src/tools/clippy/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 src/tools/clippy/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
16 changes: 8 additions & 8 deletions src/tools/clippy/tests/ui/iter_count.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

#![warn(clippy::iter_count)]
#![allow(
unused_variables,
array_into_iter,
unused_mut,
clippy::into_iter_on_ref,
clippy::unnecessary_operation
unused_variables,
array_into_iter,
unused_mut,
clippy::into_iter_on_ref,
clippy::unnecessary_operation
)]

extern crate option_helpers;
Expand Down 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
16 changes: 8 additions & 8 deletions src/tools/clippy/tests/ui/iter_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

#![warn(clippy::iter_count)]
#![allow(
unused_variables,
array_into_iter,
unused_mut,
clippy::into_iter_on_ref,
clippy::unnecessary_operation
unused_variables,
array_into_iter,
unused_mut,
clippy::into_iter_on_ref,
clippy::unnecessary_operation
)]

extern crate option_helpers;
Expand Down 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 src/tools/clippy/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