summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/book
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/book')
-rw-r--r--src/tools/clippy/book/src/configuration.md2
-rw-r--r--src/tools/clippy/book/src/development/adding_lints.md24
-rw-r--r--src/tools/clippy/book/src/development/basics.md7
-rw-r--r--src/tools/clippy/book/src/development/common_tools_writing_lints.md17
4 files changed, 33 insertions, 17 deletions
diff --git a/src/tools/clippy/book/src/configuration.md b/src/tools/clippy/book/src/configuration.md
index 6e295ac31..77f1d2e87 100644
--- a/src/tools/clippy/book/src/configuration.md
+++ b/src/tools/clippy/book/src/configuration.md
@@ -7,7 +7,7 @@ basic `variable = value` mapping eg.
```toml
avoid-breaking-exported-api = false
-blacklisted-names = ["toto", "tata", "titi"]
+disallowed-names = ["toto", "tata", "titi"]
cognitive-complexity-threshold = 30
```
diff --git a/src/tools/clippy/book/src/development/adding_lints.md b/src/tools/clippy/book/src/development/adding_lints.md
index da781eb97..3c3f368a5 100644
--- a/src/tools/clippy/book/src/development/adding_lints.md
+++ b/src/tools/clippy/book/src/development/adding_lints.md
@@ -90,6 +90,7 @@ We start by opening the test file created at `tests/ui/foo_functions.rs`.
Update the file with some examples to get started:
```rust
+#![allow(unused)]
#![warn(clippy::foo_functions)]
// Impl methods
@@ -477,8 +478,27 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip {
```
Once the `msrv` is added to the lint, a relevant test case should be added to
-`tests/ui/min_rust_version_attr.rs` which verifies that the lint isn't emitted
-if the project's MSRV is lower.
+the lint's test file, `tests/ui/manual_strip.rs` in this example. It should
+have a case for the version below the MSRV and one with the same contents but
+for the MSRV version itself.
+
+```rust
+#![feature(custom_inner_attributes)]
+
+...
+
+fn msrv_1_44() {
+ #![clippy::msrv = "1.44"]
+
+ /* something that would trigger the lint */
+}
+
+fn msrv_1_45() {
+ #![clippy::msrv = "1.45"]
+
+ /* something that would trigger the lint */
+}
+```
As a last step, the lint should be added to the lint documentation. This is done
in `clippy_lints/src/utils/conf.rs`:
diff --git a/src/tools/clippy/book/src/development/basics.md b/src/tools/clippy/book/src/development/basics.md
index 44ba6e327..6fb53236e 100644
--- a/src/tools/clippy/book/src/development/basics.md
+++ b/src/tools/clippy/book/src/development/basics.md
@@ -69,7 +69,7 @@ the reference file with:
cargo dev bless
```
-For example, this is necessary, if you fix a typo in an error message of a lint
+For example, this is necessary if you fix a typo in an error message of a lint,
or if you modify a test file to add a test case.
> _Note:_ This command may update more files than you intended. In that case
@@ -101,8 +101,9 @@ cargo dev setup intellij
cargo dev dogfood
```
-More about intellij command usage and reasons
-[here](https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#intellij-rust)
+More about [intellij] command usage and reasons.
+
+[intellij]: https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#intellij-rust
## lintcheck
diff --git a/src/tools/clippy/book/src/development/common_tools_writing_lints.md b/src/tools/clippy/book/src/development/common_tools_writing_lints.md
index 15e00c7d7..f5aa06e4b 100644
--- a/src/tools/clippy/book/src/development/common_tools_writing_lints.md
+++ b/src/tools/clippy/book/src/development/common_tools_writing_lints.md
@@ -66,7 +66,7 @@ Starting with an `expr`, you can check whether it is calling a specific method
impl<'tcx> LateLintPass<'tcx> for MyStructLint {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
// Check our expr is calling a method
- if let hir::ExprKind::MethodCall(path, _, [_self_arg, ..]) = &expr.kind
+ if let hir::ExprKind::MethodCall(path, _, _self_arg, ..) = &expr.kind
// Check the name of this method is `some_method`
&& path.ident.name == sym!(some_method)
// Optionally, check the type of the self argument.
@@ -123,7 +123,8 @@ There are three ways to do this, depending on if the target trait has a
diagnostic item, lang item or neither.
```rust
-use clippy_utils::{implements_trait, is_trait_method, match_trait_method, paths};
+use clippy_utils::ty::implements_trait;
+use clippy_utils::is_trait_method;
use rustc_span::symbol::sym;
impl LateLintPass<'_> for MyStructLint {
@@ -143,13 +144,6 @@ impl LateLintPass<'_> for MyStructLint {
.map_or(false, |id| implements_trait(cx, ty, id, &[])) {
// `expr` implements `Drop` trait
}
-
- // 3. Using the type path with the expression
- // we use `match_trait_method` function from Clippy's utils
- // (This method should be avoided if possible)
- if match_trait_method(cx, expr, &paths::INTO) {
- // `expr` implements `Into` trait
- }
}
}
```
@@ -233,8 +227,9 @@ functions to deal with macros:
crates
```rust
- #[macro_use]
- extern crate a_crate_with_macros;
+ use rustc_middle::lint::in_external_macro;
+
+ use a_crate_with_macros::foo;
// `foo` is defined in `a_crate_with_macros`
foo!("bar");