Skip to content

Commit 5bc5bfc

Browse files
committed
Add tests for FP in nonstandard_macro_braces
1 parent fb9b13a commit 5bc5bfc

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

tests/ui-toml/nonstandard_macro_braces/clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ standard-macro-braces = [
33
{ name = "quote::quote", brace = "{" },
44
{ name = "eprint", brace = "[" },
55
{ name = "type_pos", brace = "[" },
6+
{ name = "printlnfoo", brace = "[" },
67
]

tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ macro_rules! type_pos {
3232
};
3333
}
3434

35+
macro_rules! printlnfoo {
36+
($thing:expr) => {
37+
println!("hey {}", $thing)
38+
};
39+
}
40+
3541
#[rustfmt::skip]
3642
fn main() {
3743
let _ = vec! {1, 2, 3};
@@ -49,4 +55,8 @@ fn main() {
4955
let _: type_pos!(usize) = vec![];
5056

5157
eprint!("test if user config overrides defaults");
58+
59+
println!("test if println triggers for printlnfoo");
60+
61+
printlnfoo!("you");
5262
}

tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
error: use of irregular braces for `vec!` macro
2-
--> $DIR/conf_nonstandard_macro_braces.rs:37:13
2+
--> $DIR/conf_nonstandard_macro_braces.rs:43:13
33
|
44
LL | let _ = vec! {1, 2, 3};
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::nonstandard-macro-braces` implied by `-D warnings`
88
help: consider writing `vec![1, 2, 3]`
9-
--> $DIR/conf_nonstandard_macro_braces.rs:37:13
9+
--> $DIR/conf_nonstandard_macro_braces.rs:43:13
1010
|
1111
LL | let _ = vec! {1, 2, 3};
1212
| ^^^^^^^^^^^^^^
1313

1414
error: use of irregular braces for `format!` macro
15-
--> $DIR/conf_nonstandard_macro_braces.rs:38:13
15+
--> $DIR/conf_nonstandard_macro_braces.rs:44:13
1616
|
1717
LL | let _ = format!["ugh {} stop being such a good compiler", "hello"];
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1919
|
2020
help: consider writing `format!("ugh () stop being such a good compiler", "hello")`
21-
--> $DIR/conf_nonstandard_macro_braces.rs:38:13
21+
--> $DIR/conf_nonstandard_macro_braces.rs:44:13
2222
|
2323
LL | let _ = format!["ugh {} stop being such a good compiler", "hello"];
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2525

2626
error: use of irregular braces for `quote!` macro
27-
--> $DIR/conf_nonstandard_macro_braces.rs:39:13
27+
--> $DIR/conf_nonstandard_macro_braces.rs:45:13
2828
|
2929
LL | let _ = quote!(let x = 1;);
3030
| ^^^^^^^^^^^^^^^^^^
3131
|
3232
help: consider writing `quote! {let x = 1;}`
33-
--> $DIR/conf_nonstandard_macro_braces.rs:39:13
33+
--> $DIR/conf_nonstandard_macro_braces.rs:45:13
3434
|
3535
LL | let _ = quote!(let x = 1;);
3636
| ^^^^^^^^^^^^^^^^^^
3737

3838
error: use of irregular braces for `quote::quote!` macro
39-
--> $DIR/conf_nonstandard_macro_braces.rs:40:13
39+
--> $DIR/conf_nonstandard_macro_braces.rs:46:13
4040
|
4141
LL | let _ = quote::quote!(match match match);
4242
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4343
|
4444
help: consider writing `quote::quote! {match match match}`
45-
--> $DIR/conf_nonstandard_macro_braces.rs:40:13
45+
--> $DIR/conf_nonstandard_macro_braces.rs:46:13
4646
|
4747
LL | let _ = quote::quote!(match match match);
4848
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -67,28 +67,40 @@ LL | let _ = test!();
6767
= note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
6868

6969
error: use of irregular braces for `type_pos!` macro
70-
--> $DIR/conf_nonstandard_macro_braces.rs:49:12
70+
--> $DIR/conf_nonstandard_macro_braces.rs:55:12
7171
|
7272
LL | let _: type_pos!(usize) = vec![];
7373
| ^^^^^^^^^^^^^^^^
7474
|
7575
help: consider writing `type_pos![usize]`
76-
--> $DIR/conf_nonstandard_macro_braces.rs:49:12
76+
--> $DIR/conf_nonstandard_macro_braces.rs:55:12
7777
|
7878
LL | let _: type_pos!(usize) = vec![];
7979
| ^^^^^^^^^^^^^^^^
8080

8181
error: use of irregular braces for `eprint!` macro
82-
--> $DIR/conf_nonstandard_macro_braces.rs:51:5
82+
--> $DIR/conf_nonstandard_macro_braces.rs:57:5
8383
|
8484
LL | eprint!("test if user config overrides defaults");
8585
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8686
|
8787
help: consider writing `eprint!["test if user config overrides defaults"];`
88-
--> $DIR/conf_nonstandard_macro_braces.rs:51:5
88+
--> $DIR/conf_nonstandard_macro_braces.rs:57:5
8989
|
9090
LL | eprint!("test if user config overrides defaults");
9191
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9292

93-
error: aborting due to 7 previous errors
93+
error: use of irregular braces for `printlnfoo!` macro
94+
--> $DIR/conf_nonstandard_macro_braces.rs:61:5
95+
|
96+
LL | printlnfoo!("you");
97+
| ^^^^^^^^^^^^^^^^^^^
98+
|
99+
help: consider writing `printlnfoo!["you"];`
100+
--> $DIR/conf_nonstandard_macro_braces.rs:61:5
101+
|
102+
LL | printlnfoo!("you");
103+
| ^^^^^^^^^^^^^^^^^^^
104+
105+
error: aborting due to 8 previous errors
94106

0 commit comments

Comments
 (0)