|
1 | 1 | use rustc_errors::Applicability;
|
2 | 2 | use rustc_hir::{Expr, ExprKind};
|
3 | 3 | use rustc_lint::{LateContext, LateLintPass, LintContext};
|
4 |
| -use rustc_span::Symbol; |
5 | 4 | use rustc_span::sym;
|
| 5 | +use rustc_span::Symbol; |
6 | 6 | use utils::span_to_snippet_macro;
|
7 | 7 |
|
8 | 8 | dylint_linting::declare_late_lint! {
|
@@ -57,17 +57,26 @@ impl<'tcx> LateLintPass<'tcx> for FoldHashmap {
|
57 | 57 | // Type check the accumulated parameter and assign the correct identity.
|
58 | 58 | // Attempting to match 'c.insert(v);'
|
59 | 59 |
|
60 |
| - let ExprKind::MethodCall(iseg, irecv, _iargs, _ispan) = &pat_expr.kind else { return; }; |
| 60 | + let ExprKind::MethodCall(iseg, irecv, _iargs, _ispan) = &pat_expr.kind else { |
| 61 | + return; |
| 62 | + }; |
61 | 63 | // Vector specific insert method
|
62 | 64 | if iseg.ident.name != Symbol::intern("insert") {
|
63 | 65 | return;
|
64 | 66 | }
|
65 | 67 | // Make sure the receiver is a variable/path to variable.
|
66 |
| - let ExprKind::Path(_) = irecv.kind else { return; }; |
| 68 | + let ExprKind::Path(_) = irecv.kind else { |
| 69 | + return; |
| 70 | + }; |
67 | 71 |
|
68 | 72 | // Make sure that this is the hashmap method call
|
69 |
| - let ty = cx.tcx.typeck(irecv.hir_id.owner.def_id).node_type(irecv.hir_id); |
70 |
| - let Some(adt) = ty.ty_adt_def() else { return; }; |
| 73 | + let ty = cx |
| 74 | + .tcx |
| 75 | + .typeck(irecv.hir_id.owner.def_id) |
| 76 | + .node_type(irecv.hir_id); |
| 77 | + let Some(adt) = ty.ty_adt_def() else { |
| 78 | + return; |
| 79 | + }; |
71 | 80 | let did = adt.did();
|
72 | 81 | if !cx.tcx.is_diagnostic_item(sym::HashMap, did) {
|
73 | 82 | return;
|
|
0 commit comments