这段代码:
#[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)不起作用。
发布于 2017-08-02 15:30:50
编译器警告声明:
= note: #[warn(unused_macros)] on by default这与未使用的函数导致的警告非常相似:
= note: #[warn(dead_code)] on by default您可以使用相同的方式禁用这些警告,但需要使用匹配的宏属性:
#[allow(unused_macros)]
macro_rules! test {
($x:expr) => {{}}
}https://stackoverflow.com/questions/45449525
复制相似问题