Skip to content

double_ended_iterator_last should not trigger on immutable non-ref receiver #14139

@samueltardieu

Description

@samueltardieu

Summary

See title

Lint Name

double_ended_iterator_last

Reproducer

fn main() {
    let mut index = [true,true,false,false,false,true].iter();
    let subindex = index.by_ref().take(3);
    subindex.last();
}

suggests using subindex.next_back() which won't work because subindex cannot be auto-derefed into a ref mut.

Version

rustc 1.86.0-nightly (2f348cb7c 2025-01-27)
binary: rustc
commit-hash: 2f348cb7ce4063fa4eb40038e6ada3c5214717bd
commit-date: 2025-01-27
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Additional Labels

No response

Metadata

Metadata

Assignees

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