Skip to content

Lint for trailing comma in macro parameters #12814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
KershawChang opened this issue May 17, 2024 · 2 comments
Open

Lint for trailing comma in macro parameters #12814

KershawChang opened this issue May 17, 2024 · 2 comments
Labels
A-lint Area: New lints

Comments

@KershawChang
Copy link

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

  • Improved Readability: Removing unnecessary trailing commas can make the code clearer and easier to read.
  • Consistency: Enforcing this style can help maintain a consistent coding standard across the codebase.

Drawbacks

No response

Example

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

Could be written as:

println!("Hello, world!");
@Alexendoo
Copy link
Member

Related: rust-lang/rustfmt#3065

@pacak
Copy link
Contributor

pacak commented May 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

3 participants