Skip to content

Commit 6753366

Browse files
committed
add format trailing comma linter skeleton
Signed-off-by: sivchari <[email protected]>
1 parent ff87bea commit 6753366

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5617,6 +5617,7 @@ Released 2018-09-13
56175617
[`format_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_collect
56185618
[`format_in_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_in_format_args
56195619
[`format_push_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_push_string
5620+
[`format_trailing_macro_comma`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_trailing_macro_comma
56205621
[`four_forward_slashes`]: https://rust-lang.github.io/rust-clippy/master/index.html#four_forward_slashes
56215622
[`from_iter_instead_of_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect
56225623
[`from_over_into`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into

clippy_lints/src/declared_lints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
196196
crate::format_impl::PRINT_IN_FORMAT_IMPL_INFO,
197197
crate::format_impl::RECURSIVE_FORMAT_IMPL_INFO,
198198
crate::format_push_string::FORMAT_PUSH_STRING_INFO,
199+
crate::format_trailing_macro_comma::FORMAT_TRAILING_MACRO_COMMA_INFO,
199200
crate::formatting::POSSIBLE_MISSING_COMMA_INFO,
200201
crate::formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING_INFO,
201202
crate::formatting::SUSPICIOUS_ELSE_FORMATTING_INFO,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use rustc_ast::ast::*;
2+
use rustc_lint::{EarlyContext, EarlyLintPass};
3+
use rustc_session::declare_lint_pass;
4+
5+
declare_clippy_lint! {
6+
/// ### What it does
7+
///
8+
/// ### Why is this bad?
9+
///
10+
/// ### Example
11+
/// ```no_run
12+
/// // example code where clippy issues a warning
13+
/// ```
14+
/// Use instead:
15+
/// ```no_run
16+
/// // example code which does not raise clippy warning
17+
/// ```
18+
#[clippy::version = "1.86.0"]
19+
pub FORMAT_TRAILING_MACRO_COMMA,
20+
style,
21+
"default lint description"
22+
}
23+
24+
declare_lint_pass!(FormatTrailingMacroComma => [FORMAT_TRAILING_MACRO_COMMA]);
25+
26+
impl EarlyLintPass for FormatTrailingMacroComma {}

clippy_lints/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ mod format;
148148
mod format_args;
149149
mod format_impl;
150150
mod format_push_string;
151+
mod format_trailing_macro_comma;
151152
mod formatting;
152153
mod four_forward_slashes;
153154
mod from_over_into;
@@ -980,5 +981,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
980981
store.register_late_pass(move |_| Box::new(non_std_lazy_statics::NonStdLazyStatic::new(conf)));
981982
store.register_late_pass(|_| Box::new(manual_option_as_slice::ManualOptionAsSlice::new(conf)));
982983
store.register_late_pass(|_| Box::new(single_option_map::SingleOptionMap));
984+
store.register_early_pass(|| Box::new(format_trailing_macro_comma::FormatTrailingMacroComma));
983985
// add lints here, do not remove this comment, it's used in `new_lint`
984986
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![warn(clippy::format_trailing_macro_comma)]
2+
3+
fn main() {
4+
// test code goes here
5+
}

0 commit comments

Comments
 (0)