Skip to content

Removing redundant clone() #6998

@xdb64

Description

@xdb64

Lint name: clippy::redundant-clone

I tried this code:

    state
        .query
        .clone()
        .chars()
        .for_each(|_| user_interface.move_cursor(&mut state, Direction::Forward));

Removing clone() from this causes:

error[E0502]: cannot borrow `state` as mutable because it is also borrowed as immutable

Meta

$ cargo clippy -V
clippy 0.1.51 (2fd73fa 2021-03-23)
$ rustc -Vv
rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1

For context, see this

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 haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions