此代码:
#[allow(dead_code)]
macro_rules! test {
($x:expr) => {{}}
}
fn main() {
println!("Results:")
}
生成有关未使用宏定义的以下警告:
warning: unused macro definition
--> /home/xxx/.emacs.d/rust-playground/at-2017-08-02-031315/snippet.rs:10:1
|
10 | / macro_rules! test {
11 | | ($x:expr) => {{}}
12 | | }
| |_^
|
= note: #[warn(unused_macros)] on by default
有可能压制它吗?正如你所看到的,在宏的情况下,#[allow(dead_code)
没有帮助.