Skip to content

println-empty-string chokes on , after arg #16167

@matthiaskrgr

Description

@matthiaskrgr

Using the following flags

--force-warn clippy::println-empty-string

this code:

fn main() {
    println!(
        "\
            \
            ",
    );
}

caused the following diagnostics:

    Checking _69a3a7cbaebf801147532861f00082a327b21dd9 v0.1.0 (/tmp/icemaker_global_tempdir.fzTw1TOrsbiL/icemaker_clippyfix_tempdir.SQdN0PQ0vdq3/_69a3a7cbaebf801147532861f00082a327b21dd9)
warning: empty string literal in `println!`
 --> src/main.rs:2:5
  |
2 | /      println!(
3 | |/         "\
4 | ||             \
5 | ||             ",
  | ||_____________- help: remove the empty string
6 | |      );
  | |______^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#println_empty_string
  = note: requested on the command line with `--force-warn clippy::println-empty-string`

warning: `_69a3a7cbaebf801147532861f00082a327b21dd9` (bin "_69a3a7cbaebf801147532861f00082a327b21dd9") generated 1 warning (run `cargo clippy --fix --bin "_69a3a7cbaebf801147532861f00082a327b21dd9" -p _69a3a7cbaebf801147532861f00082a327b21dd9` to apply 1 suggestion)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.19s

However after applying these diagnostics, the resulting code:

fn main() {
    println!(
        ,
    );
}

no longer compiled:

    Checking _69a3a7cbaebf801147532861f00082a327b21dd9 v0.1.0 (/tmp/icemaker_global_tempdir.fzTw1TOrsbiL/icemaker_clippyfix_tempdir.SQdN0PQ0vdq3/_69a3a7cbaebf801147532861f00082a327b21dd9)
error: expected expression, found `,`
 --> src/main.rs:3:9
  |
3 |         ,
  |         ^ expected expression

error: could not compile `_69a3a7cbaebf801147532861f00082a327b21dd9` (bin "_69a3a7cbaebf801147532861f00082a327b21dd9") due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `_69a3a7cbaebf801147532861f00082a327b21dd9` (bin "_69a3a7cbaebf801147532861f00082a327b21dd9" test) due to 1 previous error

Version:

rustc 1.93.0-nightly (f40a70d2b 2025-11-30)
binary: rustc
commit-hash: f40a70d2bcd830a4f1f8c7ca1a7f93f1d9d703d6
commit-date: 2025-11-30
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-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