File tree Expand file tree Collapse file tree 3 files changed +118
-0
lines changed
tests/ui-toml/disallowed_macros Expand file tree Collapse file tree 3 files changed +118
-0
lines changed Original file line number Diff line number Diff line change 11disallowed-macros = [
2+ " std::panic" ,
23 " std::println" ,
34 " std::vec" ,
45 { path = " std::cfg" },
Original file line number Diff line number Diff line change 1+ fn test_allow_on_function ( ) {
2+ #![ allow( clippy:: disallowed_macros) ]
3+
4+ panic ! ( ) ;
5+ panic ! ( "message" ) ;
6+ panic ! ( "{}" , 123 ) ;
7+ panic ! ( "{} {}" , 123 , 456 ) ;
8+ println ! ( "test" ) ;
9+ println ! ( "{}" , 123 ) ;
10+ vec ! [ 1 , 2 , 3 ] ;
11+ }
12+
13+ fn test_expect_on_function ( ) {
14+ #![ expect( clippy:: disallowed_macros) ]
15+
16+ panic ! ( ) ;
17+ panic ! ( "message" ) ;
18+ panic ! ( "{}" , 123 ) ;
19+ panic ! ( "{} {}" , 123 , 456 ) ;
20+ println ! ( "test" ) ;
21+ println ! ( "{}" , 123 ) ;
22+ vec ! [ 1 , 2 , 3 ] ;
23+ }
24+
25+ fn test_no_attributes ( ) {
26+ panic ! ( ) ;
27+ //~^ disallowed_macros
28+ panic ! ( "message" ) ;
29+ //~^ disallowed_macros
30+ panic ! ( "{}" , 123 ) ;
31+ //~^ disallowed_macros
32+ panic ! ( "{} {}" , 123 , 456 ) ;
33+ //~^ disallowed_macros
34+ println ! ( "test" ) ;
35+ //~^ disallowed_macros
36+ println ! ( "{}" , 123 ) ;
37+ //~^ disallowed_macros
38+ vec ! [ 1 , 2 , 3 ] ;
39+ //~^ disallowed_macros
40+ }
41+
42+ #[ allow( clippy:: disallowed_macros) ]
43+ mod allowed_module {
44+ pub fn test ( ) {
45+ panic ! ( ) ;
46+ panic ! ( "message" ) ;
47+ panic ! ( "{}" , 123 ) ;
48+ println ! ( "test" ) ;
49+ vec ! [ 1 , 2 , 3 ] ;
50+ }
51+ }
52+
53+ #[ expect( clippy:: disallowed_macros) ]
54+ mod expected_module {
55+ pub fn test ( ) {
56+ panic ! ( ) ;
57+ panic ! ( "message" ) ;
58+ panic ! ( "{}" , 123 ) ;
59+ println ! ( "test" ) ;
60+ vec ! [ 1 , 2 , 3 ] ;
61+ }
62+ }
63+
64+ fn main ( ) {
65+ test_allow_on_function ( ) ;
66+ test_expect_on_function ( ) ;
67+ test_no_attributes ( ) ;
68+ allowed_module:: test ( ) ;
69+ expected_module:: test ( ) ;
70+ }
Original file line number Diff line number Diff line change 1+ error: use of a disallowed macro `std::panic`
2+ --> tests/ui-toml/disallowed_macros/disallowed_macros_regression.rs:27:5
3+ |
4+ LL | panic!();
5+ | ^^^^^^^^
6+ |
7+ = note: `-D clippy::disallowed-macros` implied by `-D warnings`
8+ = help: to override `-D warnings` add `#[allow(clippy::disallowed_macros)]`
9+
10+ error: use of a disallowed macro `std::panic`
11+ --> tests/ui-toml/disallowed_macros/disallowed_macros_regression.rs:29:5
12+ |
13+ LL | panic!("message");
14+ | ^^^^^^^^^^^^^^^^^
15+
16+ error: use of a disallowed macro `std::panic`
17+ --> tests/ui-toml/disallowed_macros/disallowed_macros_regression.rs:31:5
18+ |
19+ LL | panic!("{}", 123);
20+ | ^^^^^^^^^^^^^^^^^
21+
22+ error: use of a disallowed macro `std::panic`
23+ --> tests/ui-toml/disallowed_macros/disallowed_macros_regression.rs:33:5
24+ |
25+ LL | panic!("{} {}", 123, 456);
26+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
27+
28+ error: use of a disallowed macro `std::println`
29+ --> tests/ui-toml/disallowed_macros/disallowed_macros_regression.rs:35:5
30+ |
31+ LL | println!("test");
32+ | ^^^^^^^^^^^^^^^^
33+
34+ error: use of a disallowed macro `std::println`
35+ --> tests/ui-toml/disallowed_macros/disallowed_macros_regression.rs:37:5
36+ |
37+ LL | println!("{}", 123);
38+ | ^^^^^^^^^^^^^^^^^^^
39+
40+ error: use of a disallowed macro `std::vec`
41+ --> tests/ui-toml/disallowed_macros/disallowed_macros_regression.rs:39:5
42+ |
43+ LL | vec![1, 2, 3];
44+ | ^^^^^^^^^^^^^
45+
46+ error: aborting due to 7 previous errors
47+
You can’t perform that action at this time.
0 commit comments