Skip to content

Commit b313398

Browse files
committed
Fix CI errors
1 parent 8886b00 commit b313398

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

book/src/development/emitting_lints.md

+22-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ Note that we will not go into concrete implementation of a lint logic in this
99
chapter. We will go into details in later chapters as well as in two examples
1010
of real Clippy lints.
1111

12-
In this chapter, we'll see an example of an imaginary `LateLintPass` lint named `bar_expressions`, that checks for expresions named `bar`.
12+
In this chapter, we'll see an example of an imaginary `LateLintPass` lint named `bar_expressions`, that checks for
13+
expresions named `bar`.
1314

1415
To emit a lint with `LateLintPass`, we must implement it for the lint that we have
1516
declared. Take a look at the [LateLintPass][late_lint_pass] documentation, which
@@ -81,7 +82,10 @@ impl<'tcx> LateLintPass<'tcx> for BarExpressions {
8182
8283
## Suggestions: Automatic fixes
8384

84-
Some lints know what to change in order to fix the lint. A real world example, the lint [`range_plus`][range_plus_one] lints for ranges where the user wrote `x..y + 1` instead of using an [inclusive range][inclusive_range] (`x..=1`). The fix to this lint would be just changing your `x..y + 1` expression to `x..=y`, **this is where suggestions come in**.
85+
Some lints know what to change in order to fix the lint. A real world example, the lint
86+
[`range_plus`][range_plus_one] lints for ranges where the user wrote `x..y + 1` instead of using an
87+
[inclusive range][inclusive_range] (`x..=1`). The fix to this lint would be just changing your `x..y + 1` expression
88+
to `x..=y`, **this is where suggestions come in**.
8589

8690
A suggestion is a change that the lint provides to fix the issue it is linting.
8791
The output looks something like this (from the example earlier):
@@ -94,9 +98,12 @@ LL | for _ in 1..1 + 1 {}
9498
| ^^^^^^^^ help: use: `1..=1`
9599
```
96100

97-
**Not all suggestions are always right**, some of them require human supervision, that's why we have [Applicability][applicability].
101+
**Not all suggestions are always right**, some of them require human supervision, that's why we have
102+
[Applicability][applicability].
98103

99-
Applicability indicates confidence in the correctness of the suggestion, some are always right (`Applicability::MachineApplicable`), but we use `Applicability::MaybeIncorrect` and other when talking about a lint that may be incorrect.
104+
Applicability indicates confidence in the correctness of the suggestion, some are always right
105+
(`Applicability::MachineApplicable`), but we use `Applicability::MaybeIncorrect` and other when talking about a lint
106+
that may be incorrect.
100107

101108
---
102109

@@ -125,7 +132,8 @@ Suggestions generally use the [`format!`](format_macro) macro to interpolate the
125132

126133
## How to choose between notes, help messages and suggestions
127134

128-
Notes are presented separately from the main lint message, they provide useful information that the user needs to understand why the lint was activated. They are the most helpful when attached to a span.
135+
Notes are presented separately from the main lint message, they provide useful information that the user needs to
136+
understand why the lint was activated. They are the most helpful when attached to a span.
129137

130138
Example:
131139

@@ -146,7 +154,8 @@ note: argument has type &SomeStruct
146154

147155
---
148156

149-
Help messages are specifically to help the user. These are used in situation where you can't provide a specific machine applicable suggestion. They can also be attached to a span.
157+
Help messages are specifically to help the user. These are used in situation where you can't provide a specific
158+
machine applicable suggestion. They can also be attached to a span.
150159

151160
Example:
152161

@@ -162,7 +171,8 @@ error: constant division of 0.0 with 0.0 will always result in NaN
162171

163172
---
164173

165-
Suggestions are the most helpful, they are direct changes to the source code in order to fix the error. The magic in suggestions is that tools like rustfix can detect them and automatically fix your code.
174+
Suggestions are the most helpful, they are direct changes to the source code in order to fix the error. The magic
175+
in suggestions is that tools like rustfix can detect them and automatically fix your code.
166176

167177
Example:
168178

@@ -178,9 +188,11 @@ error: This `.fold` can be more succinctly expressed as `.any`
178188

179189
### Snippets
180190

181-
Snippets are pieces of the source code (as a string), they are extracted generally using the [`snippet`][snippet_fn] function.
191+
Snippets are pieces of the source code (as a string), they are extracted generally using the [`snippet`][snippet_fn]
192+
function.
182193

183-
For example, if you want to know how an item looks (and you know the item's span), you could use `snippet(cx, span, "..")`.
194+
For example, if you want to know how an item looks (and you know the item's span), you could use
195+
`snippet(cx, span, "..")`.
184196

185197
## Final: Run UI Tests to Emit the Lint
186198

@@ -191,8 +203,6 @@ The next step is to implement the logic properly, which is a detail that we will
191203
cover in the next chapters.
192204

193205
[diagnostics]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/diagnostics/index.html
194-
[early_check_fn]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.EarlyLintPass.html#method.check_fn
195-
[early_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.EarlyLintPass.html
196206
[late_check_expr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.LateLintPass.html#method.check_expr
197207
[late_check_fn]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.LateLintPass.html#method.check_fn
198208
[late_check_item]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.LateLintPass.html#method.check_item
@@ -204,5 +214,4 @@ cover in the next chapters.
204214
[range_plus_one]: https://rust-lang.github.io/rust-clippy/master/index.html#range_plus_one
205215
[inclusive_range]: https://doc.rust-lang.org/std/ops/struct.RangeInclusive.html
206216
[applicability]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_errors/enum.Applicability.html
207-
[format_macro]: https://doc.rust-lang.org/std/macro.format.html
208-
[snippet_fn]: https://doc.rust-lang.org/beta/nightly-rustc/clippy_utils/source/fn.snippet.html
217+
[snippet_fn]: https://doc.rust-lang.org/beta/nightly-rustc/clippy_utils/source/fn.snippet.html

0 commit comments

Comments
 (0)