Skip to content

Commit

Permalink
clippy: uibless new test output
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtriplett committed Jan 15, 2025
1 parent 113e13a commit d972108
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/tools/clippy/tests/ui/iter_overeager_cloned.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ fn main() {

let _: Option<String> = vec.iter().chain(vec.iter()).next().cloned();

let _: usize = vec.iter().filter(|x| x == &"2").count();
let _: usize = vec.iter().filter(|x| x == "2").count();

let _: Vec<_> = vec.iter().take(2).cloned().collect();

let _: Vec<_> = vec.iter().skip(2).cloned().collect();

let _ = vec.iter().filter(|x| x == &"2").nth(2).cloned();
let _ = vec.iter().filter(|x| x == "2").nth(2).cloned();

let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))]
.iter()
Expand Down
21 changes: 20 additions & 1 deletion src/tools/clippy/tests/ui/iter_overeager_cloned.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count();
= note: `-D clippy::redundant-clone` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]`

error: taken reference of right operand
--> tests/ui/iter_overeager_cloned.rs:16:42
|
LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count();
| ^^^^^----
| |
| help: use the right value directly: `"2"`
|
= note: `-D clippy::op-ref` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::op_ref)]`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:18:21
|
Expand All @@ -52,6 +63,14 @@ LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2);
| |
| help: try: `.nth(2).cloned()`

error: taken reference of right operand
--> tests/ui/iter_overeager_cloned.rs:22:35
|
LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2);
| ^^^^^----
| |
| help: use the right value directly: `"2"`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:24:13
|
Expand Down Expand Up @@ -164,5 +183,5 @@ LL | let _ = vec.iter().cloned().any(|x| x.len() == 1);
| |
| help: try: `.any(|x| x.len() == 1)`

error: aborting due to 19 previous errors
error: aborting due to 21 previous errors

2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/op_ref.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
let a = "a".to_string();
let b = "a";

if b < &a {
if b < a {
println!("OK");
}

Expand Down
10 changes: 9 additions & 1 deletion src/tools/clippy/tests/ui/op_ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ help: use the values directly
LL | let foo = 5 - 6;
| ~ ~

error: taken reference of right operand
--> tests/ui/op_ref.rs:21:8
|
LL | if b < &a {
| ^^^^--
| |
| help: use the right value directly: `a`

error: taken reference of right operand
--> tests/ui/op_ref.rs:58:13
|
Expand All @@ -35,5 +43,5 @@ LL | let _ = two + &three;
| |
| help: use the right value directly: `three`

error: aborting due to 4 previous errors
error: aborting due to 5 previous errors

0 comments on commit d972108

Please sign in to comment.