Make clippy tests happy

This commit is contained in:
hi-rustin 2021-06-18 16:11:32 +08:00
parent 611b74e1fe
commit 6e8549e05e
6 changed files with 30 additions and 30 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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

View File

@ -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;
@ -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();
@ -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();

View File

@ -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;
@ -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();
@ -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();

View File

@ -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`
@ -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
@ -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