Files
rust/tests/ui/println_empty_string.rs
T
Yuri Astrakhan f72e055625 Add unnecessary_trailing_comma lint
Suggest removing an unnecessary trailing comma before the closing
parenthesis in single-line format-like macro invocations (e.g.
println!, format!, write!). The lint currently only runs on
format-like macros because it relies on format-argument parsing;
arbitrary user macros are not supported to avoid incorrect
suggestions.

- Lint is in the `style` group (allow-by-default)
- Single-line only: multi-line macro invocations are not linted
- Machine-applicable fix: removes the trailing comma
2026-02-17 14:30:43 -05:00

46 lines
878 B
Rust

#![allow(clippy::match_single_binding, clippy::unnecessary_trailing_comma)]
fn main() {
println!();
println!("");
//~^ println_empty_string
match "a" {
_ => println!(""),
//~^ println_empty_string
}
eprintln!();
eprintln!("");
//~^ println_empty_string
match "a" {
_ => eprintln!(""),
//~^ println_empty_string
}
}
#[rustfmt::skip]
fn issue_16167() {
//~v println_empty_string
println!(
"\
\
"
,
);
match "a" {
_ => println!("" ,), // there is a space between "" and comma
//~^ println_empty_string
}
eprintln!("" ,); // there is a tab between "" and comma
//~^ println_empty_string
match "a" {
_ => eprintln!("" ,), // tab and space between "" and comma
//~^ println_empty_string
}
}