Skip to content

Commit e8d79b8

Browse files
committed
Formatting
1 parent 9e4a2d7 commit e8d79b8

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

book/src/development/method_checking.md

+15-16
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,24 @@ impl<'tcx> LateLintPass<'tcx> for OurFancyMethodLint {
3737
```
3838

3939
Take a closer look at the `ExprKind` enum variant [`MethodCall`] for more
40-
information on the pattern matching.
41-
As mentioned in [Define Lints](define_lints.md#lint-types),
42-
the `methods` lint type is full of pattern matching with `Methodcall`
43-
in case the reader wishes to explore more.
40+
information on the pattern matching. As mentioned in [Define
41+
Lints](define_lints.md#lint-types), the `methods` lint type is full of pattern
42+
matching with `MethodCall` in case the reader wishes to explore more.
4443

45-
Additionally, we use the [`clippy_utils::sym!`][sym] macro to conveniently convert
46-
an input `our_fancy_method` into a `Symbol` and compare that symbol to the [`ident`][Ident]'s name in the [`PathSegment`]
47-
in the [`MethodCall`].
44+
Additionally, we use the [`clippy_utils::sym!`][sym] macro to conveniently
45+
convert an input `our_fancy_method` into a `Symbol` and compare that symbol to
46+
the [`Ident`]'s name in the [`PathSegment`] in the [`MethodCall`].
4847

4948
## Checking if a `impl` block implements a method
5049

51-
While sometimes we want to check whether a method is being called or not,
52-
other times we want to know if our `Ty` defines a method.
50+
While sometimes we want to check whether a method is being called or not, other
51+
times we want to know if our `Ty` defines a method.
5352

54-
To check if our `impl` block defines a method `our_fancy_method`,
55-
we will utilize the [`check_impl_item`] method that is available
56-
in our beloved [`LateLintPass`] (for more information, refer to the
57-
["Lint Passes"](lint_passes.md) chapter in Clippy book).
58-
This method provides us with an [`ImplItem`] struct, which represents
59-
anything within an `impl` block.
53+
To check if our `impl` block defines a method `our_fancy_method`, we will
54+
utilize the [`check_impl_item`] method that is available in our beloved
55+
[`LateLintPass`] (for more information, refer to the ["Lint
56+
Passes"](lint_passes.md) chapter in the Clippy book). This method provides us
57+
with an [`ImplItem`] struct, which represents anything within an `impl` block.
6058

6159
Let us take a look at how we might check for the implementation of
6260
`our_fancy_method` on a type:
@@ -67,6 +65,7 @@ use clippy_utils::return_ty;
6765
use rustc_hir::{ImplItem, ImplItemKind};
6866
use rustc_lint::{LateContext, LateLintPass};
6967
use rustc_span::symbol::sym;
68+
7069
impl<'tcx> LateLintPass<'tcx> for MyTypeImpl {
7170
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) {
7271
// Check if item is a method/function
@@ -86,7 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for MyTypeImpl {
8685

8786
[`check_impl_item`]: https://doc.rust-lang.org/stable/nightly-rustc/rustc_lint/trait.LateLintPass.html#method.check_impl_item
8887
[`ExprKind`]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_hir/hir/enum.ExprKind.html
89-
[Ident]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_span/symbol/struct.Ident.html
88+
[`Ident`]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_span/symbol/struct.Ident.html
9089
[`ImplItem`]: https://doc.rust-lang.org/stable/nightly-rustc/rustc_hir/hir/struct.ImplItem.html
9190
[`LateLintPass`]: https://doc.rust-lang.org/stable/nightly-rustc/rustc_lint/trait.LateLintPass.html
9291
[`MethodCall`]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_hir/hir/enum.ExprKind.html#variant.MethodCall

0 commit comments

Comments
 (0)