diff options
| author | bors <bors@rust-lang.org> | 2022-04-13 00:57:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-13 00:57:08 +0000 |
| commit | f70c73f5c4a43886af04941c6d4f0efd978c3fce (patch) | |
| tree | 2ca81b27f9c1950167c5c07aa3fa00086d169dd1 /src/test/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs | |
| parent | 06b1695814016a2d7b4b7902520deefbfed809b5 (diff) | |
| parent | dfdc5ad7d8f5d3787406a00bab2d1e049a57d1e2 (diff) | |
| download | rust-f70c73f5c4a43886af04941c6d4f0efd978c3fce.tar.gz rust-f70c73f5c4a43886af04941c6d4f0efd978c3fce.zip | |
Auto merge of #8692 - kyoto7250:fixing_unnecessary_to_owned, r=giraffate
fix unnecessary_to_owned about msrv
This PR fixes ``[`unnecessary_owned`]``.
## What
```rust
# sample code
fn _msrv_1_35() {
#![clippy::msrv = "1.35"]
let _ = &["x"][..].to_vec().into_iter();
}
fn _msrv_1_36() {
#![clippy::msrv = "1.36"]
let _ = &["x"][..].to_vec().into_iter();
}
```
If we will check this code using clippy, ``[`unnecessary_owned`]`` will modify the code as follows.
```rust
error: unnecessary use of `to_vec`
--> $DIR/unnecessary_to_owned.rs:219:14
|
LL | let _ = &["x"][..].to_vec().into_iter();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().copied()`
error: unnecessary use of `to_vec`
--> $DIR/unnecessary_to_owned.rs:224:14
|
LL | let _ = &["x"][..].to_vec().into_iter();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().copied()`
```
This is incorrect. Because `Iterator::copied` was estabilished in 1.36.
## Why
This bug was caused by not separating "copied" and "clone" by reference to msrv.
https://github.com/rust-lang/rust-clippy/blob/89ee6aa6e32df974ef9dbb3c825afbdce441e856/clippy_lints/src/methods/unnecessary_to_owned.rs#L195
So, I added a conditional branch and described the corresponding test.
Thank you in advance.
changelog: fix wrong suggestions about msrv in [`unnecessary_to_owned`]
r! `@giraffate`
Diffstat (limited to 'src/test/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs')
0 files changed, 0 insertions, 0 deletions
