]> git.lizzy.rs Git - rust.git/blob - src/doc/rustc/src/lints/index.md
Auto merge of #50275 - kennytm:rollup, r=kennytm
[rust.git] / src / doc / rustc / src / lints / index.md
1 # Lints
2
3 In software, a "lint" is a tool used to help improve your source code. The
4 Rust compiler contains a number of lints, and when it compiles your code, it will
5 also run the lints. These lints may produce a warning, an error, or nothing at all,
6 depending on how you've configured things.
7
8 Here's a small example:
9
10 ```bash
11 $ cat main.rs
12 fn main() {
13     let x = 5;
14 }
15 > rustc main.rs
16 warning: unused variable: `x`
17  --> main.rs:2:9
18   |
19 2 |     let x = 5;
20   |         ^
21   |
22   = note: #[warn(unused_variables)] on by default
23   = note: to avoid this warning, consider using `_x` instead
24 ```
25
26 This is the `unused_variables` lint, and it tells you that you've introduced
27 a variable that you don't use in your code. That's not *wrong*, so it's not
28 an error, but it might be a bug, so you get a warning.