diff options
| author | bors <bors@rust-lang.org> | 2022-04-12 01:11:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-12 01:11:54 +0000 |
| commit | bc069efb1fffc180b13f03fbdc2ab483e5bab13b (patch) | |
| tree | fa5a1275f2ef868814a94d4289ed261e76dde2ca /src/test/codegen | |
| parent | dbcd82885f4730077fabd57340d7e297122bc596 (diff) | |
| parent | 40224f46c0158ff8bf6657f2272dba9ec2ee96d7 (diff) | |
| download | rust-bc069efb1fffc180b13f03fbdc2ab483e5bab13b.tar.gz rust-bc069efb1fffc180b13f03fbdc2ab483e5bab13b.zip | |
Auto merge of #8688 - kyoto7250:adding_condition_for_map_clone, r=giraffate
adding condition for map_clone message
This PR fixes the message about `map_clone`.
if msrv >= 1.36, the message is correct.
```bash
$ cat main.rs
fn main() {
let x: Vec<&i32> = vec![&1, &2];
let y: Vec<_> = x.iter().map(|i| *i).collect();
println!("{:?}", y);
}
$ cargo clippy
warning: you are using an explicit closure for copying elements
--> main.rs:3:20
|
3 | let y: Vec<_> = x.iter().map(|i| *i).collect();
| ^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.iter().copied()`
|
= note: `#[warn(clippy::map_clone)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_clone
warning: `test` (build script) generated 1 warning
warning: `test` (bin "test") generated 1 warning (1 duplicate)
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
```
but, if msrv < 1.36, the suggestion is `cloned`, but the message is `copying`.
```bash
$ cat clippy.toml
msrv = "1.35"
$ cargo clippy
warning: you are using an explicit closure for copying elements
--> main.rs:3:20
|
3 | let y: Vec<_> = x.iter().map(|i| *i).collect();
| ^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.iter().cloned()`
```
I think the separation of messages will make it more user-friendly.
thank you in advance.
changelog: Fixed a message in map_clone.
Diffstat (limited to 'src/test/codegen')
0 files changed, 0 insertions, 0 deletions
