Skip to content
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

[WIP] add format trailing comma linter skeleton #14196

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5617,6 +5617,7 @@ Released 2018-09-13
[`format_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_collect
[`format_in_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_in_format_args
[`format_push_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_push_string
[`format_trailing_macro_comma`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_trailing_macro_comma
[`four_forward_slashes`]: https://rust-lang.github.io/rust-clippy/master/index.html#four_forward_slashes
[`from_iter_instead_of_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect
[`from_over_into`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
crate::format_impl::PRINT_IN_FORMAT_IMPL_INFO,
crate::format_impl::RECURSIVE_FORMAT_IMPL_INFO,
crate::format_push_string::FORMAT_PUSH_STRING_INFO,
crate::format_trailing_macro_comma::FORMAT_TRAILING_MACRO_COMMA_INFO,
crate::formatting::POSSIBLE_MISSING_COMMA_INFO,
crate::formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING_INFO,
crate::formatting::SUSPICIOUS_ELSE_FORMATTING_INFO,
Expand Down
26 changes: 26 additions & 0 deletions clippy_lints/src/format_trailing_macro_comma.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use rustc_ast::ast::*;
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::declare_lint_pass;

declare_clippy_lint! {
/// ### What it does
///
/// ### Why is this bad?
///
/// ### Example
/// ```no_run
/// // example code where clippy issues a warning
/// ```
/// Use instead:
/// ```no_run
/// // example code which does not raise clippy warning
/// ```
#[clippy::version = "1.86.0"]
pub FORMAT_TRAILING_MACRO_COMMA,
style,
"default lint description"
}

declare_lint_pass!(FormatTrailingMacroComma => [FORMAT_TRAILING_MACRO_COMMA]);

impl EarlyLintPass for FormatTrailingMacroComma {}
2 changes: 2 additions & 0 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ mod format;
mod format_args;
mod format_impl;
mod format_push_string;
mod format_trailing_macro_comma;
mod formatting;
mod four_forward_slashes;
mod from_over_into;
Expand Down Expand Up @@ -980,5 +981,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
store.register_late_pass(move |_| Box::new(non_std_lazy_statics::NonStdLazyStatic::new(conf)));
store.register_late_pass(|_| Box::new(manual_option_as_slice::ManualOptionAsSlice::new(conf)));
store.register_late_pass(|_| Box::new(single_option_map::SingleOptionMap));
store.register_early_pass(|| Box::new(format_trailing_macro_comma::FormatTrailingMacroComma));
// add lints here, do not remove this comment, it's used in `new_lint`
}
5 changes: 5 additions & 0 deletions tests/ui/format_trailing_macro_comma.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![warn(clippy::format_trailing_macro_comma)]

fn main() {
// test code goes here
}
Loading