Skip to content
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

cloned_instead_of_copied fails to respect msrv #7127

Closed
dtolnay opened this issue Apr 25, 2021 · 0 comments · Fixed by #7129
Closed

cloned_instead_of_copied fails to respect msrv #7127

dtolnay opened this issue Apr 25, 2021 · 0 comments · Fixed by #7129
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@dtolnay
Copy link
Member

dtolnay commented Apr 25, 2021

// src/main.rs

#![deny(clippy::pedantic)]

fn main() {
    let _ = Some(()).iter().cloned();
}
# .clippy.toml

msrv = "1.35.0"
$ cargo clippy

error: used `cloned` where `copied` could be used instead
 --> src/main.rs:4:29
  |
4 |     let _ = Some(()).iter().cloned();
  |                             ^^^^^^ help: try: `copied`
  |
note: the lint level is defined here
 --> src/main.rs:1:9
  |
1 | #![deny(clippy::pedantic)]
  |         ^^^^^^^^^^^^^^^^
  = note: `#[deny(clippy::cloned_instead_of_copied)]` implied by `#[deny(clippy::pedantic)]`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied

However, Clippy's suggested replacement involving .copied() does not compile on rustc 1.35.0.

error[E0658]: use of unstable library feature 'iter_copied' (see issue #57127)
 --> src/main.rs:4:29
  |
4 |     let _ = Some(()).iter().copied();
  |                             ^^^^^^

@camsteffen @Manishearth


Meta

  • cargo clippy -V: clippy 0.1.53 (42816d6 2021-04-24)
  • rustc -Vv:
    rustc 1.53.0-nightly (42816d61e 2021-04-24)
    binary: rustc
    commit-hash: 42816d61ead7e46d462df997958ccfd514f8c21c
    commit-date: 2021-04-24
    host: x86_64-unknown-linux-gnu
    release: 1.53.0-nightly
    LLVM version: 12.0.0
    
@dtolnay dtolnay 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 Apr 25, 2021
dtolnay added a commit to dtolnay/dissimilar that referenced this issue Apr 25, 2021
The .clippy.toml declares this crate's msrv as 1.31.0, so it is a Clippy
bug that this lint is triggering in the first place. Iterator::copied is
from Rust 1.36.

rust-lang/rust-clippy#7127

    error: used `cloned` where `copied` could be used instead
      --> src/range.rs:62:29
       |
    62 |         bytes(*self).iter().cloned()
       |                             ^^^^^^ help: try: `copied`
       |
       = note: `-D clippy::cloned-instead-of-copied` implied by `-D clippy::pedantic`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied
dtolnay added a commit to dtolnay/syn that referenced this issue Apr 25, 2021
The .clippy.toml declares this crate's msrv as 1.31.0, so it is a Clippy
bug that this lint is triggering in the first place. Option::copied is
from Rust 1.35.

rust-lang/rust-clippy#7127

    error: used `cloned` where `copied` could be used instead
       --> src/error.rs:248:14
        |
    248 |             .cloned()
        |              ^^^^^^ help: try: `copied`
        |
        = note: `-D clippy::cloned-instead-of-copied` implied by `-D clippy::pedantic`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied

    error: used `cloned` where `copied` could be used instead
       --> src/error.rs:250:39
        |
    250 |         let end = self.end_span.get().cloned().unwrap_or_else(Span::call_site);
        |                                       ^^^^^^ help: try: `copied`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied

    error: used `cloned` where `copied` could be used instead
       --> src/error.rs:337:14
        |
    337 |             .cloned()
        |              ^^^^^^ help: try: `copied`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied

    error: used `cloned` where `copied` could be used instead
       --> src/error.rs:339:39
        |
    339 |         let end = self.end_span.get().cloned().unwrap_or_else(Span::call_site);
        |                                       ^^^^^^ help: try: `copied`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied
@bors bors closed this as completed in c4e2d36 Apr 25, 2021
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 I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant