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() {}
  2. // `#[allow(dead_code)]` is an attribute that disables the `dead_code` lint
  3. #[allow(dead_code)]
  4. fn unused_function() {}
  5. fn noisy_unused_function() {}
  6. // FIXME ^ Add an attribute to suppress the warning
  7. fn main() {
  8. used_function();
  9. }

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.