Skip to content

Commit

Permalink
Add test case from rust-lang#10488
Browse files Browse the repository at this point in the history
  • Loading branch information
schubart committed Apr 11, 2023
1 parent 008ba73 commit 3d71145
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
8 changes: 7 additions & 1 deletion tests/ui/collection_is_never_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,18 @@ fn shadowing_2() {
}

#[allow(clippy::let_unit_value)]
fn fake_read() {
fn fake_read_1() {
let mut x = vec![1, 2, 3]; // WARNING
x.reverse();
let _: () = x.clear();
}

fn fake_read_2() {
let mut x = vec![1, 2, 3]; // WARNING
x.reverse();
println!("{:?}", x.push(5));
}

fn assignment() {
let mut x = vec![1, 2, 3]; // WARNING
let y = vec![4, 5, 6]; // Ok
Expand Down
18 changes: 12 additions & 6 deletions tests/ui/collection_is_never_read.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,40 @@ LL | let mut x = vec![1, 2, 3]; // WARNING
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: collection is never read
--> $DIR/collection_is_never_read.rs:101:5
--> $DIR/collection_is_never_read.rs:100:5
|
LL | let mut x = vec![1, 2, 3]; // WARNING
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: collection is never read
--> $DIR/collection_is_never_read.rs:118:5
--> $DIR/collection_is_never_read.rs:107:5
|
LL | let mut x = vec![1, 2, 3]; // WARNING
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: collection is never read
--> $DIR/collection_is_never_read.rs:124:5
|
LL | let mut x = HashSet::new(); // WARNING
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: collection is never read
--> $DIR/collection_is_never_read.rs:132:5
--> $DIR/collection_is_never_read.rs:138:5
|
LL | let x = vec![1, 2, 3]; // WARNING
| ^^^^^^^^^^^^^^^^^^^^^^

error: collection is never read
--> $DIR/collection_is_never_read.rs:168:5
--> $DIR/collection_is_never_read.rs:174:5
|
LL | let mut s = String::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: collection is never read
--> $DIR/collection_is_never_read.rs:181:5
--> $DIR/collection_is_never_read.rs:187:5
|
LL | let mut s = String::from("Hello, World!");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 11 previous errors
error: aborting due to 12 previous errors

0 comments on commit 3d71145

Please sign in to comment.