Skip to content

manual_is_ascii_check suggests incorrect type #13913

@Otto-AA

Description

@Otto-AA

Summary

The manual_is_ascii_check lint suggests an incompatible type, leading to a compilation error. The lambda requires |c: &char|, but clippy inserts |c: char| instead.

I think this is related to #11988.

Reproducer

I tried this code:

fn main() {
    let digits: String = "1234ABCD"
        .chars()
        .take_while(|c| ('0'..='9').contains(c)) // <-- line that is changed
        .collect();

    println!("{digits}");
}

I expected to see this happen:

  • either .take_while(|c| c.is_ascii_digit())
  • or .take_while(|c: &char| c.is_ascii_digit())

Instead, this happened:

  • .take_while(|c: char| c.is_ascii_digit())

Version

rustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: x86_64-unknown-linux-gnu
release: 1.83.0
LLVM version: 19.1.1

Additional Labels

@rustbot label I-suggestion-causes-error

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-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