Skip to content

Move collection_is_never_read from nursery to suspicious #11591

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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 clippy_lints/src/collection_is_never_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ declare_clippy_lint! {
/// ```
#[clippy::version = "1.70.0"]
pub COLLECTION_IS_NEVER_READ,
nursery,
suspicious,
"a collection is never queried"
}
declare_lint_pass!(CollectionIsNeverRead => [COLLECTION_IS_NEVER_READ]);
Expand Down
1 change: 1 addition & 0 deletions tests/ui-toml/too_large_for_stack/useless_vec.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(clippy::useless_vec)]
#![allow(clippy::collection_is_never_read)]

fn main() {
let x = [0u8; 500];
Expand Down
1 change: 1 addition & 0 deletions tests/ui-toml/too_large_for_stack/useless_vec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(clippy::useless_vec)]
#![allow(clippy::collection_is_never_read)]

fn main() {
let x = vec![0u8; 500];
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-toml/too_large_for_stack/useless_vec.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: useless use of `vec!`
--> $DIR/useless_vec.rs:4:13
--> $DIR/useless_vec.rs:5:13
|
LL | let x = vec![0u8; 500];
| ^^^^^^^^^^^^^^ help: you can use an array directly: `[0u8; 500]`
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/boxed_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
clippy::needless_pass_by_value,
clippy::unused_unit,
clippy::redundant_clone,
clippy::match_single_binding
clippy::match_single_binding,
clippy::collection_is_never_read
)]
#![warn(clippy::boxed_local)]

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/boxed_local.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: local variable doesn't need to be boxed here
--> $DIR/boxed_local.rs:40:13
--> $DIR/boxed_local.rs:41:13
|
LL | fn warn_arg(x: Box<A>) {
| ^
Expand All @@ -8,19 +8,19 @@ LL | fn warn_arg(x: Box<A>) {
= help: to override `-D warnings` add `#[allow(clippy::boxed_local)]`

error: local variable doesn't need to be boxed here
--> $DIR/boxed_local.rs:123:12
--> $DIR/boxed_local.rs:124:12
|
LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
| ^^^^^^^^^^^

error: local variable doesn't need to be boxed here
--> $DIR/boxed_local.rs:188:44
--> $DIR/boxed_local.rs:189:44
|
LL | fn default_impl_x(self: Box<Self>, x: Box<u32>) -> u32 {
| ^

error: local variable doesn't need to be boxed here
--> $DIR/boxed_local.rs:196:16
--> $DIR/boxed_local.rs:197:16
|
LL | fn foo(x: Box<u32>) {}
| ^
Expand Down
6 changes: 5 additions & 1 deletion tests/ui/branches_sharing_code/shared_at_top.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#![deny(clippy::branches_sharing_code, clippy::if_same_then_else)]
#![allow(dead_code)]
#![allow(clippy::mixed_read_write_in_expression, clippy::uninlined_format_args)]
#![allow(
clippy::mixed_read_write_in_expression,
clippy::uninlined_format_args,
clippy::collection_is_never_read
)]
//@no-rustfix
// This tests the branches_sharing_code lint at the start of blocks

Expand Down
16 changes: 8 additions & 8 deletions tests/ui/branches_sharing_code/shared_at_top.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: all if blocks contain the same code at the start
--> $DIR/shared_at_top.rs:11:5
--> $DIR/shared_at_top.rs:15:5
|
LL | / if true {
LL | |
Expand All @@ -18,7 +18,7 @@ LL + if true {
|

error: all if blocks contain the same code at the start
--> $DIR/shared_at_top.rs:21:5
--> $DIR/shared_at_top.rs:25:5
|
LL | / if x == 0 {
LL | |
Expand All @@ -37,7 +37,7 @@ LL + if x == 0 {
|

error: all if blocks contain the same code at the start
--> $DIR/shared_at_top.rs:43:5
--> $DIR/shared_at_top.rs:47:5
|
LL | / let _ = if x == 7 {
LL | |
Expand All @@ -51,7 +51,7 @@ LL + let _ = if x == 7 {
|

error: all if blocks contain the same code at the start
--> $DIR/shared_at_top.rs:62:5
--> $DIR/shared_at_top.rs:66:5
|
LL | / if x == 10 {
LL | |
Expand All @@ -68,7 +68,7 @@ LL + if x == 10 {
|

error: all if blocks contain the same code at the start
--> $DIR/shared_at_top.rs:77:5
--> $DIR/shared_at_top.rs:81:5
|
LL | / if x == 11 {
LL | |
Expand All @@ -85,7 +85,7 @@ LL + if x == 11 {
|

error: all if blocks contain the same code at the start
--> $DIR/shared_at_top.rs:94:5
--> $DIR/shared_at_top.rs:98:5
|
LL | / if x == 2020 {
LL | |
Expand All @@ -101,7 +101,7 @@ LL + if x == 2020 {
|

error: this `if` has identical blocks
--> $DIR/shared_at_top.rs:103:18
--> $DIR/shared_at_top.rs:107:18
|
LL | if x == 2019 {
| __________________^
Expand All @@ -111,7 +111,7 @@ LL | | } else {
| |_____^
|
note: same as this
--> $DIR/shared_at_top.rs:106:12
--> $DIR/shared_at_top.rs:110:12
|
LL | } else {
| ____________^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/clear_with_drain.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unused)]
#![allow(unused, clippy::collection_is_never_read)]
#![warn(clippy::clear_with_drain)]

use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/clear_with_drain.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unused)]
#![allow(unused, clippy::collection_is_never_read)]
#![warn(clippy::clear_with_drain)]

use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/clone_on_copy.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
clippy::unnecessary_operation,
clippy::vec_init_then_push,
clippy::toplevel_ref_arg,
clippy::needless_borrow
clippy::needless_borrow,
clippy::collection_is_never_read
)]

use std::cell::RefCell;
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/clone_on_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
clippy::unnecessary_operation,
clippy::vec_init_then_push,
clippy::toplevel_ref_arg,
clippy::needless_borrow
clippy::needless_borrow,
clippy::collection_is_never_read
)]

use std::cell::RefCell;
Expand Down
18 changes: 9 additions & 9 deletions tests/ui/clone_on_copy.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: using `clone` on type `i32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:23:5
--> $DIR/clone_on_copy.rs:24:5
|
LL | 42.clone();
| ^^^^^^^^^^ help: try removing the `clone` call: `42`
Expand All @@ -8,49 +8,49 @@ LL | 42.clone();
= help: to override `-D warnings` add `#[allow(clippy::clone_on_copy)]`

error: using `clone` on type `i32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:27:5
--> $DIR/clone_on_copy.rs:28:5
|
LL | (&42).clone();
| ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)`

error: using `clone` on type `i32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:30:5
--> $DIR/clone_on_copy.rs:31:5
|
LL | rc.borrow().clone();
| ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()`

error: using `clone` on type `u32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:33:5
--> $DIR/clone_on_copy.rs:34:5
|
LL | x.clone().rotate_left(1);
| ^^^^^^^^^ help: try removing the `clone` call: `x`

error: using `clone` on type `i32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:47:5
--> $DIR/clone_on_copy.rs:48:5
|
LL | m!(42).clone();
| ^^^^^^^^^^^^^^ help: try removing the `clone` call: `m!(42)`

error: using `clone` on type `[u32; 2]` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:57:5
--> $DIR/clone_on_copy.rs:58:5
|
LL | x.clone()[0];
| ^^^^^^^^^ help: try dereferencing it: `(*x)`

error: using `clone` on type `char` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:67:14
--> $DIR/clone_on_copy.rs:68:14
|
LL | is_ascii('z'.clone());
| ^^^^^^^^^^^ help: try removing the `clone` call: `'z'`

error: using `clone` on type `i32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:71:14
--> $DIR/clone_on_copy.rs:72:14
|
LL | vec.push(42.clone());
| ^^^^^^^^^^ help: try removing the `clone` call: `42`

error: using `clone` on type `Option<i32>` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:75:17
--> $DIR/clone_on_copy.rs:76:17
|
LL | let value = opt.clone()?; // operator precedence needed (*opt)?
| ^^^^^^^^^^^ help: try dereferencing it: `(*opt)`
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/crashes/ice-2774.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Bar {
#[derive(Eq, PartialEq, Debug, Hash)]
pub struct Foo;

#[allow(clippy::implicit_hasher)]
#[allow(clippy::implicit_hasher, clippy::collection_is_never_read)]
// This should not cause a "cannot relate bound region" ICE.
pub fn add_barfoos_to_foos(bars: &HashSet<&Bar>) {
//~^ ERROR: the following explicit lifetimes could be elided: 'a
Expand All @@ -19,7 +19,7 @@ pub fn add_barfoos_to_foos(bars: &HashSet<&Bar>) {
foos.extend(bars.iter().map(|b| &b.foo));
}

#[allow(clippy::implicit_hasher)]
#[allow(clippy::implicit_hasher, clippy::collection_is_never_read)]
// Also, this should not cause a "cannot relate bound region" ICE.
pub fn add_barfoos_to_foos2(bars: &HashSet<&Bar>) {
let mut foos = HashSet::new();
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/crashes/ice-2774.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Bar {
#[derive(Eq, PartialEq, Debug, Hash)]
pub struct Foo;

#[allow(clippy::implicit_hasher)]
#[allow(clippy::implicit_hasher, clippy::collection_is_never_read)]
// This should not cause a "cannot relate bound region" ICE.
pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) {
//~^ ERROR: the following explicit lifetimes could be elided: 'a
Expand All @@ -19,7 +19,7 @@ pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) {
foos.extend(bars.iter().map(|b| &b.foo));
}

#[allow(clippy::implicit_hasher)]
#[allow(clippy::implicit_hasher, clippy::collection_is_never_read)]
// Also, this should not cause a "cannot relate bound region" ICE.
pub fn add_barfoos_to_foos2(bars: &HashSet<&Bar>) {
let mut foos = HashSet::new();
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/eta.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
clippy::redundant_closure_call,
clippy::uninlined_format_args,
clippy::useless_vec,
clippy::unnecessary_map_on_constructor
clippy::unnecessary_map_on_constructor,
clippy::collection_is_never_read
)]

use std::path::{Path, PathBuf};
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/eta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
clippy::redundant_closure_call,
clippy::uninlined_format_args,
clippy::useless_vec,
clippy::unnecessary_map_on_constructor
clippy::unnecessary_map_on_constructor,
clippy::collection_is_never_read
)]

use std::path::{Path, PathBuf};
Expand Down
Loading