Skip to content

write!() -> writeln!() invalid when just printing a newline #6612

@ChrisJefferson

Description

@ChrisJefferson

This is visible on both stable and nightly. When advising changing write! to writeln!, the clippy outputs no string but still prints the comma. There has to either be no comma after out_file.

warning: using `write!()` with a format string that ends in a single newline
  --> src/gap_chat.rs:80:9
   |
80 |         write!(gap_channel.out_file, "\n").unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(clippy::write_with_newline)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#write_with_newline
help: use `writeln!()` instead
   |
80 |         writeln!(gap_channel.out_file, ).unwrap();
   |         ^^^^^^^                       --

warning: 1 warning emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesL-suggestionLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions