]> git.lizzy.rs Git - rust.git/blob - tests/ui/auxiliary/macro_rules.rs
Prevent `mem_replace_with_default` lint within macros
[rust.git] / 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 }