Skip to content

Commit 7248d06

Browse files
committed
Auto merge of rust-lang#9471 - jplatte:patch-1, r=xFrednet
Add matches! checking to nonstandard_macro_braces changelog: Enhancement: [`nonstandard_macro_braces`]: Now includes `matches!()` in the default lint config [rust-lang#9471](rust-lang/rust-clippy#9471)
2 parents 3956c9d + 25584c0 commit 7248d06

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

clippy_lints/src/nonstandard_macro_braces.rs

+4
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ fn macro_braces(conf: FxHashSet<MacroMatcher>) -> FxHashMap<String, (String, Str
184184
name: "vec",
185185
braces: ("[", "]"),
186186
),
187+
macro_matcher!(
188+
name: "matches",
189+
braces: ("(", ")"),
190+
),
187191
]
188192
.into_iter()
189193
.collect::<FxHashMap<_, _>>();

tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ macro_rules! printlnfoo {
4242
fn main() {
4343
let _ = vec! {1, 2, 3};
4444
let _ = format!["ugh {} stop being such a good compiler", "hello"];
45+
let _ = matches!{{}, ()};
4546
let _ = quote!(let x = 1;);
4647
let _ = quote::quote!(match match match);
4748
let _ = test!(); // trigger when macro def is inside our own crate

tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr

+21-9
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,38 @@ help: consider writing `format!("ugh () stop being such a good compiler", "hello
2323
LL | let _ = format!["ugh {} stop being such a good compiler", "hello"];
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2525

26-
error: use of irregular braces for `quote!` macro
26+
error: use of irregular braces for `matches!` macro
27+
--> $DIR/conf_nonstandard_macro_braces.rs:45:13
28+
|
29+
LL | let _ = matches!{{}, ()};
30+
| ^^^^^^^^^^^^^^^^
31+
|
32+
help: consider writing `matches!((), ())`
2733
--> $DIR/conf_nonstandard_macro_braces.rs:45:13
2834
|
35+
LL | let _ = matches!{{}, ()};
36+
| ^^^^^^^^^^^^^^^^
37+
38+
error: use of irregular braces for `quote!` macro
39+
--> $DIR/conf_nonstandard_macro_braces.rs:46:13
40+
|
2941
LL | let _ = quote!(let x = 1;);
3042
| ^^^^^^^^^^^^^^^^^^
3143
|
3244
help: consider writing `quote! {let x = 1;}`
33-
--> $DIR/conf_nonstandard_macro_braces.rs:45:13
45+
--> $DIR/conf_nonstandard_macro_braces.rs:46:13
3446
|
3547
LL | let _ = quote!(let x = 1;);
3648
| ^^^^^^^^^^^^^^^^^^
3749

3850
error: use of irregular braces for `quote::quote!` macro
39-
--> $DIR/conf_nonstandard_macro_braces.rs:46:13
51+
--> $DIR/conf_nonstandard_macro_braces.rs:47:13
4052
|
4153
LL | let _ = quote::quote!(match match match);
4254
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4355
|
4456
help: consider writing `quote::quote! {match match match}`
45-
--> $DIR/conf_nonstandard_macro_braces.rs:46:13
57+
--> $DIR/conf_nonstandard_macro_braces.rs:47:13
4658
|
4759
LL | let _ = quote::quote!(match match match);
4860
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -67,28 +79,28 @@ LL | let _ = test!(); // trigger when macro def is inside our own crate
6779
= note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
6880

6981
error: use of irregular braces for `type_pos!` macro
70-
--> $DIR/conf_nonstandard_macro_braces.rs:55:12
82+
--> $DIR/conf_nonstandard_macro_braces.rs:56:12
7183
|
7284
LL | let _: type_pos!(usize) = vec![];
7385
| ^^^^^^^^^^^^^^^^
7486
|
7587
help: consider writing `type_pos![usize]`
76-
--> $DIR/conf_nonstandard_macro_braces.rs:55:12
88+
--> $DIR/conf_nonstandard_macro_braces.rs:56:12
7789
|
7890
LL | let _: type_pos!(usize) = vec![];
7991
| ^^^^^^^^^^^^^^^^
8092

8193
error: use of irregular braces for `eprint!` macro
82-
--> $DIR/conf_nonstandard_macro_braces.rs:57:5
94+
--> $DIR/conf_nonstandard_macro_braces.rs:58:5
8395
|
8496
LL | eprint!("test if user config overrides defaults");
8597
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8698
|
8799
help: consider writing `eprint!["test if user config overrides defaults"]`
88-
--> $DIR/conf_nonstandard_macro_braces.rs:57:5
100+
--> $DIR/conf_nonstandard_macro_braces.rs:58:5
89101
|
90102
LL | eprint!("test if user config overrides defaults");
91103
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
92104

93-
error: aborting due to 7 previous errors
105+
error: aborting due to 8 previous errors
94106

0 commit comments

Comments
 (0)