Skip to content

False positive for write! with format string that ends with an escaped backslash followed by 'n' #3514

@james-bostock

Description

@james-bostock

The Clippy lint for calls to write! ,whose format string ends with a newline (\n), erroneously flags the case where the backslash itself is escaped (\\n). For example, the following Rust code triggers the warning:

use std::io;
use std::io::Write;

fn main() -> std::io::Result<()> {
    write!(io::stdout(), "\\n")?;
    Ok(())
}

I am using the following version of Clippy:

$ cargo clippy -V
clippy 0.0.212 (2e26fdc 2018-11-22)

Thanks for creating such a great utility!

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