]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/auxiliary/macro_rules.rs
Rollup merge of #78354 - 12101111:rustbuild_profiler, r=Mark-Simulacrum
[rust.git] / src / tools / clippy / tests / ui / auxiliary / macro_rules.rs
1 #![allow(dead_code)]
2
3 //! Used to test that certain lints don't trigger in imported external macros
4
5 #[macro_export]
6 macro_rules! foofoo {
7     () => {
8         loop {}
9     };
10 }
11
12 #[macro_export]
13 macro_rules! must_use_unit {
14     () => {
15         #[must_use]
16         fn foo() {}
17     };
18 }
19
20 #[macro_export]
21 macro_rules! try_err {
22     () => {
23         pub fn try_err_fn() -> Result<i32, i32> {
24             let err: i32 = 1;
25             // To avoid warnings during rustfix
26             if true {
27                 Err(err)?
28             } else {
29                 Ok(2)
30             }
31         }
32     };
33 }
34
35 #[macro_export]
36 macro_rules! string_add {
37     () => {
38         let y = "".to_owned();
39         let z = y + "...";
40     };
41 }
42
43 #[macro_export]
44 macro_rules! take_external {
45     ($s:expr) => {
46         std::mem::replace($s, Default::default())
47     };
48 }
49
50 #[macro_export]
51 macro_rules! option_env_unwrap_external {
52     ($env: expr) => {
53         option_env!($env).unwrap()
54     };
55     ($env: expr, $message: expr) => {
56         option_env!($env).expect($message)
57     };
58 }
59
60 #[macro_export]
61 macro_rules! ref_arg_binding {
62     () => {
63         let ref _y = 42;
64     };
65 }
66
67 #[macro_export]
68 macro_rules! ref_arg_function {
69     () => {
70         fn fun_example(ref _x: usize) {}
71     };
72 }