@@ -37,8 +37,53 @@ extern crate syntax_pos;
37
37
38
38
use toml;
39
39
40
- // Currently, categories "style", "correctness", "complexity" and "perf" are enabled by default,
41
- // as said in the README.md of this repository. If this changes, please update README.md.
40
+ /// Macro used to declare a Clippy lint.
41
+ ///
42
+ /// Every lint declaration consists of 4 parts:
43
+ ///
44
+ /// 1. The documentation above the lint, which is used for the website
45
+ /// 2. The `LINT_NAME`. See [lint naming][lint_naming] on lint naming conventions.
46
+ /// 3. The `lint_level`, which is a mapping from *one* of our lint groups to `Allow`, `Warn` or
47
+ /// `Deny`. The lint level here has nothing to do with what lint groups the lint is a part of.
48
+ /// 4. The `description` that contains a short explanation on what's wrong with code where the
49
+ /// lint is triggered.
50
+ ///
51
+ /// Currently the categories `style`, `correctness`, `complexity` and `perf` are enabled by default.
52
+ /// As said in the README.md of this repository, if the lint level mapping changes, please update
53
+ /// README.md.
54
+ ///
55
+ /// # Example
56
+ ///
57
+ /// ```
58
+ /// # #![feature(rustc_private)]
59
+ /// # #[allow(unused_extern_crates)]
60
+ /// # extern crate rustc;
61
+ /// # #[macro_use]
62
+ /// # use clippy_lints::declare_clippy_lint;
63
+ /// use rustc::declare_tool_lint;
64
+ ///
65
+ /// /// **What it does:** Checks for ... (describe what the lint matches).
66
+ /// ///
67
+ /// /// **Why is this bad?** Supply the reason for linting the code.
68
+ /// ///
69
+ /// /// **Known problems:** None. (Or describe where it could go wrong.)
70
+ /// ///
71
+ /// /// **Example:**
72
+ /// ///
73
+ /// /// ```rust
74
+ /// /// // Bad
75
+ /// /// Insert a short example of code that triggers the lint
76
+ /// ///
77
+ /// /// // Good
78
+ /// /// Insert a short example of improved code that doesn't trigger the lint
79
+ /// /// ```
80
+ /// declare_clippy_lint! {
81
+ /// pub LINT_NAME,
82
+ /// pedantic,
83
+ /// "description"
84
+ /// }
85
+ /// ```
86
+ /// [lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
42
87
#[ macro_export]
43
88
macro_rules! declare_clippy_lint {
44
89
{ pub $name: tt, style, $description: tt } => {
@@ -211,6 +256,14 @@ mod reexport {
211
256
crate use syntax:: ast:: { Name , NodeId } ;
212
257
}
213
258
259
+ /// Register all pre expansion lints
260
+ ///
261
+ /// Pre-expansion lints run before any macro expansion has happened.
262
+ ///
263
+ /// Note that due to the architechture of the compiler, currently `cfg_attr` attributes on crate
264
+ /// level (i.e `#![cfg_attr(...)]`) will still be expanded even when using a pre-expansion pass.
265
+ ///
266
+ /// Used in `./src/driver.rs`.
214
267
pub fn register_pre_expansion_lints (
215
268
session : & rustc:: session:: Session ,
216
269
store : & mut rustc:: lint:: LintStore ,
@@ -235,6 +288,7 @@ pub fn register_pre_expansion_lints(
235
288
store. register_pre_expansion_pass ( Some ( session) , true , false , box dbg_macro:: Pass ) ;
236
289
}
237
290
291
+ #[ doc( hidden) ]
238
292
pub fn read_conf ( reg : & rustc_plugin:: Registry < ' _ > ) -> Conf {
239
293
match utils:: conf:: file_from_args ( reg. args ( ) ) {
240
294
Ok ( file_name) => {
@@ -292,6 +346,9 @@ pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
292
346
}
293
347
}
294
348
349
+ /// Register all lints and lint groups with the rustc plugin registry
350
+ ///
351
+ /// Used in `./src/driver.rs`.
295
352
#[ allow( clippy:: too_many_lines) ]
296
353
#[ rustfmt:: skip]
297
354
pub fn register_plugins ( reg : & mut rustc_plugin:: Registry < ' _ > , conf : & Conf ) {
@@ -1046,6 +1103,9 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
1046
1103
] ) ;
1047
1104
}
1048
1105
1106
+ /// Register renamed lints.
1107
+ ///
1108
+ /// Used in `./src/driver.rs`.
1049
1109
pub fn register_renamed ( ls : & mut rustc:: lint:: LintStore ) {
1050
1110
ls. register_renamed ( "clippy::stutter" , "clippy::module_name_repetitions" ) ;
1051
1111
ls. register_renamed ( "clippy::new_without_default_derive" , "clippy::new_without_default" ) ;
0 commit comments