Skip to content

Commit 6a33e8d

Browse files
committed
Update book
1 parent 9e8480e commit 6a33e8d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

book/src/development/common_tools_writing_lints.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for MyStructLint {
6868
// Check our expr is calling a method
6969
if let hir::ExprKind::MethodCall(path, _, _self_arg, ..) = &expr.kind
7070
// Check the name of this method is `some_method`
71-
&& path.ident.name == sym!(some_method)
71+
&& path.ident.name.as_str() == "some_method"
7272
// Optionally, check the type of the self argument.
7373
// - See "Checking for a specific type"
7474
{
@@ -167,7 +167,7 @@ impl<'tcx> LateLintPass<'tcx> for MyTypeImpl {
167167
// Check if item is a method/function
168168
if let ImplItemKind::Fn(ref signature, _) = impl_item.kind
169169
// Check the method is named `some_method`
170-
&& impl_item.ident.name == sym!(some_method)
170+
&& impl_item.ident.name.as_str() == "some_method"
171171
// We can also check it has a parameter `self`
172172
&& signature.decl.implicit_self.has_implicit_self()
173173
// We can go further and even check if its return type is `String`

book/src/development/method_checking.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl<'tcx> LateLintPass<'tcx> for OurFancyMethodLint {
2323
// Check our expr is calling a method with pattern matching
2424
if let hir::ExprKind::MethodCall(path, _, [self_arg, ..]) = &expr.kind
2525
// Check if the name of this method is `our_fancy_method`
26-
&& path.ident.name == sym!(our_fancy_method)
26+
&& path.ident.name.as_str() == "our_fancy_method"
2727
// We can check the type of the self argument whenever necessary.
2828
// (It's necessary if we want to check that method is specifically belonging to a specific trait,
2929
// for example, a `map` method could belong to user-defined trait instead of to `Iterator`)
@@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for MyTypeImpl {
7171
// Check if item is a method/function
7272
if let ImplItemKind::Fn(ref signature, _) = impl_item.kind
7373
// Check the method is named `our_fancy_method`
74-
&& impl_item.ident.name == sym!(our_fancy_method)
74+
&& impl_item.ident.name.as_str() == "our_fancy_method"
7575
// We can also check it has a parameter `self`
7676
&& signature.decl.implicit_self.has_implicit_self()
7777
// We can go even further and even check if its return type is `String`

0 commit comments

Comments
 (0)