2019-05-12 10:10:23 +00:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2019-09-18 06:37:41 +00:00
|
|
|
//! Used to test that certain lints don't trigger in imported external macros
|
2019-10-24 05:52:01 +00:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! try_err {
|
|
|
|
() => {
|
|
|
|
pub fn try_err_fn() -> Result<i32, i32> {
|
|
|
|
let err: i32 = 1;
|
|
|
|
// To avoid warnings during rustfix
|
2021-03-12 14:30:50 +00:00
|
|
|
if true { Err(err)? } else { Ok(2) }
|
2019-10-24 05:52:01 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2019-12-05 10:06:13 +00:00
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! string_add {
|
|
|
|
() => {
|
|
|
|
let y = "".to_owned();
|
|
|
|
let z = y + "...";
|
|
|
|
};
|
|
|
|
}
|
2019-12-08 19:46:21 +00:00
|
|
|
|
2023-05-05 15:45:49 +00:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! string_lit_as_bytes {
|
|
|
|
($s:literal) => {
|
|
|
|
const C: &[u8] = $s.as_bytes();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-10-21 11:11:36 +00:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! mut_mut {
|
|
|
|
() => {
|
|
|
|
let mut_mut_ty: &mut &mut u32 = &mut &mut 1u32;
|
|
|
|
};
|
|
|
|
}
|
2022-02-26 13:26:21 +00:00
|
|
|
|
|
|
|
#[macro_export]
|
2023-03-24 13:04:35 +00:00
|
|
|
macro_rules! issue_10421 {
|
2022-06-30 08:50:09 +00:00
|
|
|
() => {
|
2023-03-24 13:04:35 +00:00
|
|
|
let mut a = 1;
|
|
|
|
let mut b = 2;
|
|
|
|
a = b;
|
|
|
|
b = a;
|
2023-02-10 13:01:19 +00:00
|
|
|
};
|
|
|
|
}
|
2023-07-02 12:35:19 +00:00
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! macro_with_panic {
|
|
|
|
() => {
|
|
|
|
panic!()
|
|
|
|
};
|
|
|
|
}
|
2024-04-04 17:52:55 +00:00
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! bad_transmute {
|
|
|
|
($e:expr) => {
|
|
|
|
std::mem::transmute($e)
|
|
|
|
};
|
|
|
|
}
|