Skip to content

map_clone doesn't respect MSRV for copied #8276

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
Kixunil opened this issue Jan 14, 2022 · 2 comments · Fixed by #8280
Closed

map_clone doesn't respect MSRV for copied #8276

Kixunil opened this issue Jan 14, 2022 · 2 comments · Fixed by #8280
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-positive Issue: The lint was triggered on code it shouldn't have I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@Kixunil
Copy link

Kixunil commented Jan 14, 2022

Summary

.copied() method was added in 1.36 but if msrv is set to less (e.g. 1.29) in clippy.toml the map_clone lint fires anyway

Lint Name

map_clone

Reproducer

I tried this code:

[1, 2, 3].iter().map(|x| *x).collect::<Vec<_>>();

clippy.toml:

msrv = "1.29"

I saw this happen:

warning: you are using an explicit closure for copying elements
 --> src/main.rs:2:5
  |
2 |     [1, 2, 3].iter().map(|x| *x).collect::<Vec<_>>();
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `[1, 2, 3].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

I expected to see this happen:

No lint fires

Version

rustc 1.58.0 (02072b482 2022-01-11)
binary: rustc
commit-hash: 02072b482a8b5357f7fb5e5637444ae30e423c40
commit-date: 2022-01-11
host: x86_64-unknown-linux-gnu
release: 1.58.0
LLVM version: 13.0.0

Additional Labels

@rustbot label +I-suggestion-causes-error

@Kixunil Kixunil added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Jan 14, 2022
@rustbot rustbot added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Jan 14, 2022
@xFrednet
Copy link
Member

FYI for someone looking into this: the msrv for the copied call is 1.36.0

@xFrednet xFrednet added the good-first-issue These issues are a good way to get started with Clippy label Jan 14, 2022
@xFrednet
Copy link
Member

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-positive Issue: The lint was triggered on code it shouldn't have I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants