Skip to content

cloned_instead_of_copied fails to respect msrv #7127

Closed
@dtolnay

Description

@dtolnay
// 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
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions