Skip to content

manual_ignore_case_cmp: Please detect forms using .chars() and Iterator::cmp as well #16961

@joshtriplett

Description

@joshtriplett

Summary

manual_ignore_case_cmp doesn't detect code that walks an iterator of .chars(). See the reproducer.

Lint Name

manual_ignore_case_cmp

Reproducer

Example 1:

let file_name = OsString::from("XYz");
let ret = file_name.to_str().is_some_and(|dir| {
    dir.chars()
        .map(|c| c.to_ascii_lowercase())
        .cmp(".xyz".chars().map(|c| c.to_ascii_lowercase()))
        .is_eq()
});

Example 2:

let file_name = String::from("XYz");
let ret = file_name
        .chars()
        .map(|c| c.to_ascii_lowercase())
        .cmp(".xyz".chars().map(|c| c.to_ascii_lowercase()))
        .is_eq();

I would like to see this caught by manual_ignore_case_cmp, and turned into the following:

let file_name = OsString::from("XYz");
let ret = file_name.eq_ignore_ascii_case(".xyz");

Version

rustc 1.95.0 (59807616e 2026-04-14)
binary: rustc
commit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860
commit-date: 2026-04-14
host: x86_64-unknown-linux-gnu
release: 1.95.0
LLVM version: 22.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions