mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 23:20:39 +00:00
26812f733d
Also added test cases for internal and external macros.
48 lines
833 B
Rust
48 lines
833 B
Rust
#![allow(dead_code)]
|
|
|
|
//! Used to test that certain lints don't trigger in imported external macros
|
|
|
|
#[macro_export]
|
|
macro_rules! foofoo {
|
|
() => {
|
|
loop {}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! must_use_unit {
|
|
() => {
|
|
#[must_use]
|
|
fn foo() {}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! try_err {
|
|
() => {
|
|
pub fn try_err_fn() -> Result<i32, i32> {
|
|
let err: i32 = 1;
|
|
// To avoid warnings during rustfix
|
|
if true {
|
|
Err(err)?
|
|
} else {
|
|
Ok(2)
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! string_add {
|
|
() => {
|
|
let y = "".to_owned();
|
|
let z = y + "...";
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! take_external {
|
|
($s:expr) => {
|
|
std::mem::replace($s, Default::default())
|
|
};
|
|
}
|