dead_code

The compiler provides a dead_code lint that will warn about unused functions. An attribute can be used to disable the lint.

1. fn used_function() {}

3. // `#[allow(dead_code)]` is an attribute that disables the `dead_code` lint
4. #[allow(dead_code)]
5. fn unused_function() {}

7. fn noisy_unused_function() {}
8. // FIXME ^ Add an attribute to suppress the warning

10. fn main() {
11. used_function();
12. }

Note that in real programs, you should eliminate dead code. In these examples we’ll allow dead code in some places because of the interactive nature of the examples.