Skip to content

Commit

Permalink
Update docs for rustc_lint crateification.
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw committed Feb 28, 2015
1 parent 532cd5f commit 3909253
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
19 changes: 4 additions & 15 deletions src/librustc/lint/builtin.rs
Expand Up @@ -8,22 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

use lint::{LintPass, LintArray};

Expand Down
19 changes: 11 additions & 8 deletions src/librustc_lint/builtin.rs
Expand Up @@ -8,20 +8,23 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

Expand Down
10 changes: 9 additions & 1 deletion src/librustc_lint/lib.rs
Expand Up @@ -8,7 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

mod builtin;

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

0 comments on commit 3909253

Please sign in to comment.