rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.38k stars 1.54k forks source link

Lint for trailing comma in macro parameters #12814

Open KershawChang opened 5 months ago

KershawChang commented 5 months ago

What it does

This proposed lint would detect and warn about unnecessary trailing commas in macro parameters. While a trailing comma in macro parameters is not an error in Rust, it can be superfluous and might not align with some coding style preferences.

Advantage

Drawbacks

No response

Example

println!("Hello, world!", );

Could be written as:

println!("Hello, world!");
Alexendoo commented 5 months ago

Related: https://github.com/rust-lang/rustfmt/issues/3065

pacak commented 5 months ago

Not every macro behaves the same way with respect to trailing commas FWIW. Macros bundled with rustc tend to accept them, but treats them as optional. Macros created by user might require it to function.