]> git.lizzy.rs Git - rust.git/blobdiff - doc/adding_lints.md
Auto merge of #5155 - krishna-veerareddy:remove-unused-imports, r=flip1995
[rust.git] / doc / adding_lints.md
index deecbf80a228272ad80e86ccc3b3ac08a1748230..e1f4ce016c5c0cd81de6878d9d01a20b95b1fc75 100644 (file)
@@ -39,10 +39,10 @@ lint. Fortunately, you can use the clippy dev tools to handle this for you. We
 are naming our new lint `foo_functions` (lints are generally written in snake
 case), and we don't need type information so it will have an early pass type
 (more on this later on). To get started on this lint you can run
-`./util/dev new_lint --name=foo_functions --pass=early --category=pedantic`
+`cargo dev new_lint --name=foo_functions --pass=early --category=pedantic`
 (category will default to nursery if not provided). This command will create
 two files: `tests/ui/foo_functions.rs` and `clippy_lints/src/foo_functions.rs`,
-as well as run `./util/dev update_lints` to register the new lint. Next, we'll
+as well as run `cargo dev update_lints` to register the new lint. Next, we'll
 open up these files and add our lint!
 
 ### Testing
@@ -138,7 +138,7 @@ at `clippy_lints/src/foo_functions.rs`. That's the crate where all the
 lint code is. This file has already imported some initial things we will need:
 
 ```rust
-use rustc::lint::{LintArray, LintPass, EarlyLintPass, EarlyContext};
+use rustc_lint::{EarlyLintPass, EarlyContext};
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 use syntax::ast::*;
 ```
@@ -249,14 +249,14 @@ Depending on how complex we want our lint message to be, we can choose from a
 variety of lint emission functions. They can all be found in
 [`clippy_lints/src/utils/diagnostics.rs`][diagnostics].
 
-`span_help_and_lint` seems most appropriate in this case. It allows us to
+`span_lint_and_help` seems most appropriate in this case. It allows us to
 provide an extra help message and we can't really suggest a better name
 automatically. This is how it looks:
 
 ```rust
 impl EarlyLintPass for FooFunctions {
     fn check_fn(&mut self, cx: &EarlyContext<'_>, _: FnKind<'_>, _: &FnDecl, span: Span, _: NodeId) {
-        span_help_and_lint(
+        span_lint_and_help(
             cx,
             FOO_FUNCTIONS,
             span,
@@ -284,7 +284,7 @@ With that we can expand our `check_fn` method to:
 impl EarlyLintPass for FooFunctions {
     fn check_fn(&mut self, cx: &EarlyContext<'_>, fn_kind: FnKind<'_>, _: &FnDecl, span: Span, _: NodeId) {
         if is_foo_fn(fn_kind) {
-            span_help_and_lint(
+            span_lint_and_help(
                 cx,
                 FOO_FUNCTIONS,
                 span,
@@ -386,7 +386,7 @@ It can be installed via `rustup`:
 rustup component add rustfmt --toolchain=nightly
 ```
 
-Use `./util/dev fmt` to format the whole codebase. Make sure that `rustfmt` is
+Use `cargo dev fmt` to format the whole codebase. Make sure that `rustfmt` is
 installed for the nightly toolchain.
 
 ### Debugging
@@ -404,9 +404,9 @@ Before submitting your PR make sure you followed all of the basic requirements:
 - [ ] Followed [lint naming conventions][lint_naming]
 - [ ] Added passing UI tests (including committed `.stderr` file)
 - [ ] `cargo test` passes locally
-- [ ] Executed `./util/dev update_lints`
+- [ ] Executed `cargo dev update_lints`
 - [ ] Added lint documentation
-- [ ] Run `./util/dev fmt`
+- [ ] Run `cargo dev fmt`
 
 ### Cheatsheet