|
1 |
| -//! # Lints in the Rust compiler |
| 1 | +//! Lints, aka compiler warnings. |
2 | 2 | //!
|
3 |
| -//! This currently only contains the definitions and implementations |
4 |
| -//! of most of the lints that `rustc` supports directly, it does not |
5 |
| -//! contain the infrastructure for defining/registering lints. That is |
6 |
| -//! available in `rustc::lint` and `rustc_driver::plugin` respectively. |
| 3 | +//! A 'lint' check is a kind of miscellaneous constraint that a user _might_ |
| 4 | +//! want to enforce, but might reasonably want to permit as well, on a |
| 5 | +//! module-by-module basis. They contrast with static constraints enforced by |
| 6 | +//! other phases of the compiler, which are generally required to hold in order |
| 7 | +//! to compile the program at all. |
| 8 | +//! |
| 9 | +//! Most lints can be written as `LintPass` instances. These run after |
| 10 | +//! all other analyses. The `LintPass`es built into rustc are defined |
| 11 | +//! within `rustc_session::lint::builtin`, |
| 12 | +//! which has further comments on how to add such a lint. |
| 13 | +//! rustc can also load user-defined lint plugins via the plugin mechanism. |
| 14 | +//! |
| 15 | +//! Some of rustc's lints are defined elsewhere in the compiler and work by |
| 16 | +//! calling `add_lint()` on the overall `Session` object. This works when |
| 17 | +//! it happens before the main lint pass, which emits the lints stored by |
| 18 | +//! `add_lint()`. To emit lints after the main lint pass (from codegen, for |
| 19 | +//! example) requires more effort. See `emit_lint` and `GatherNodeLevels` |
| 20 | +//! in `context.rs`. |
| 21 | +//! |
| 22 | +//! Some code also exists in `rustc_session::lint`, `rustc::lint`. |
7 | 23 | //!
|
8 | 24 | //! ## Note
|
9 | 25 | //!
|
|
0 commit comments