Skip to content

Wrong single_char_pattern suggestion for hex escaped char #2996

@dtolnay

Description

@dtolnay
fn main() {
    let msg = "";
    println!("{}", msg.starts_with("\x03"));
}
warning: single-character string constant used as pattern
 --> src/main.rs:3:36
  |
3 |     println!("{}", msg.starts_with("\x03"));
  |                    ----------------^^^^^^- help: try using a char instead: `msg.starts_with("\x03")`
  |

I would expect the lint to recommend msg.starts_with('\x03') and not msg.starts_with("\x03") which is the original code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions