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