Skip to content

Commit 3909253

Browse files
committed
Update docs for rustc_lint crateification.
1 parent 532cd5f commit 3909253

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

src/librustc/lint/builtin.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Lints built in to rustc.
11+
//! Some lints that are built in to the compiler.
1212
//!
13-
//! This is a sibling of `lint::context` in order to ensure that
14-
//! lints implemented here use the same public API as lint plugins.
15-
//!
16-
//! To add a new lint to rustc, declare it here using `declare_lint!()`.
17-
//! Then add code to emit the new lint in the appropriate circumstances.
18-
//! You can do that in an existing `LintPass` if it makes sense, or in
19-
//! a new `LintPass`, or using `Session::add_lint` elsewhere in the
20-
//! compiler. Only do the latter if the check can't be written cleanly
21-
//! as a `LintPass`.
22-
//!
23-
//! If you define a new `LintPass`, you will also need to add it to the
24-
//! `add_builtin!` or `add_builtin_with_new!` invocation in `context.rs`.
25-
//! Use the former for unit-like structs and the latter for structs with
26-
//! a `pub fn new()`.
13+
//! These are the built-in lints that are emitted direct in the main
14+
//! compiler code, rather than using their own custom pass. Those
15+
//! lints are all available in `rustc_lint::builtin`.
2716
2817
use lint::{LintPass, LintArray};
2918

src/librustc_lint/builtin.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,23 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Lints built in to rustc.
11+
//! Lints in the Rust compiler.
1212
//!
13-
//! This is a sibling of `lint::context` in order to ensure that
14-
//! lints implemented here use the same public API as lint plugins.
13+
//! This contains lints which can feasibly be implemented as their own
14+
//! AST visitor. Also see `rustc::lint::builtin`, which contains the
15+
//! definitions of lints that are emitted directly inside the main
16+
//! compiler.
1517
//!
1618
//! To add a new lint to rustc, declare it here using `declare_lint!()`.
1719
//! Then add code to emit the new lint in the appropriate circumstances.
18-
//! You can do that in an existing `LintPass` if it makes sense, or in
19-
//! a new `LintPass`, or using `Session::add_lint` elsewhere in the
20-
//! compiler. Only do the latter if the check can't be written cleanly
21-
//! as a `LintPass`.
20+
//! You can do that in an existing `LintPass` if it makes sense, or in a
21+
//! new `LintPass`, or using `Session::add_lint` elsewhere in the
22+
//! compiler. Only do the latter if the check can't be written cleanly as a
23+
//! `LintPass` (also, note that such lints will need to be defined in
24+
//! `rustc::lint::builtin`, not here).
2225
//!
2326
//! If you define a new `LintPass`, you will also need to add it to the
24-
//! `add_builtin!` or `add_builtin_with_new!` invocation in `context.rs`.
27+
//! `add_builtin!` or `add_builtin_with_new!` invocation in `lib.rs`.
2528
//! Use the former for unit-like structs and the latter for structs with
2629
//! a `pub fn new()`.
2730

src/librustc_lint/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Many of the lints built into the Rust compiler.
11+
//! Lints in the Rust compiler.
12+
//!
13+
//! This currently only contains the definitions and implementations
14+
//! of most of the lints that `rustc` supports directly, it does not
15+
//! contain the infrastructure for defining/registering lints. That is
16+
//! available in `rustc::lint` and `rustc::plugin` respectively.
1217
//!
1318
//! # Note
1419
//!
@@ -54,6 +59,9 @@ use lint::{LintPassObject, LintId};
5459

5560
mod builtin;
5661

62+
/// Tell the `LintStore` about all the built-in lints (the ones
63+
/// defined in this crate and the ones defined in
64+
/// `rustc::lint::builtin`).
5765
pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
5866
macro_rules! add_builtin {
5967
($sess:ident, $($name:ident),*,) => (

0 commit comments

Comments
 (0)