]> git.proxmox.com Git - rustc.git/blob - src/doc/rust-by-example/src/attribute/unused.md
New upstream version 1.25.0+dfsg1
[rustc.git] / src / doc / rust-by-example / src / attribute / unused.md
1 # `dead_code`
2
3 The compiler provides a `dead_code`
4 [*lint*][lint] that will warn
5 about unused functions. An *attribute* can be used to disable the lint.
6
7 ```rust,editable
8 fn used_function() {}
9
10 // `#[allow(dead_code)]` is an attribute that disables the `dead_code` lint
11 #[allow(dead_code)]
12 fn unused_function() {}
13
14 fn noisy_unused_function() {}
15 // FIXME ^ Add an attribute to suppress the warning
16
17 fn main() {
18 used_function();
19 }
20 ```
21
22 Note that in real programs, you should eliminate dead code. In these examples
23 we'll allow dead code in some places because of the interactive nature of the
24 examples.
25
26 [lint]: https://en.wikipedia.org/wiki/Lint_%28software%29