mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-03 17:35:28 +03:00
f72e055625
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
46 lines
878 B
Rust
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
|
|
}
|
|
}
|