An inner attribute is a Rust attribute written with #! that affects the contents of its enclosing file or module. Unlike an outer attribute, which applies to the item that follows it, an inner attribute applies inward. section 13.1.5
Remember these practical rules:
- Place an inner attribute at the very top of its file or module, before other code. section 13.1.5
- Use #![allow(unused)] when you want to silence warnings about unused variables and dead code. section 13.1.5
- If the attribute appears too late, the compiler reports that an inner attribute is not permitted in that context. section 13.1.5
Silencing unused-code warnings
Place the attribute before the rest of the file: #![allow(dead_code)] and #![allow(unused_variables)]. The compiler can then remain quiet about unused structs and variables while the code is being developed. section 13.1.5
fn empty_function() {}
#![allow(dead_code)]
A minimal listing shows the required #! syntax and its file-level placement. section 13.1.5
