Skip to content

Commit 98759ad

Browse files
committed
formatting
1 parent 053769b commit 98759ad

File tree

6 files changed

+34
-17
lines changed

6 files changed

+34
-17
lines changed

lints/fold/src/hashmap.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use rustc_errors::Applicability;
22
use rustc_hir::{Expr, ExprKind};
33
use rustc_lint::{LateContext, LateLintPass, LintContext};
4-
use rustc_span::Symbol;
54
use rustc_span::sym;
5+
use rustc_span::Symbol;
66
use utils::span_to_snippet_macro;
77

88
dylint_linting::declare_late_lint! {
@@ -57,17 +57,26 @@ impl<'tcx> LateLintPass<'tcx> for FoldHashmap {
5757
// Type check the accumulated parameter and assign the correct identity.
5858
// Attempting to match 'c.insert(v);'
5959

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+
};
6163
// Vector specific insert method
6264
if iseg.ident.name != Symbol::intern("insert") {
6365
return;
6466
}
6567
// 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+
};
6771

6872
// 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+
};
7180
let did = adt.did();
7281
if !cx.tcx.is_diagnostic_item(sym::HashMap, did) {
7382
return;

lints/fold/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
extern crate rustc_errors;
66
extern crate rustc_hir;
7-
extern crate rustc_span;
87
extern crate rustc_lint;
98
extern crate rustc_session;
9+
extern crate rustc_span;
1010

1111
mod hashmap;
1212
mod simple;

lints/fold/src/vec.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use rustc_errors::Applicability;
22
use rustc_hir::{Expr, ExprKind};
33
use rustc_lint::{LateContext, LateLintPass, LintContext};
4-
use rustc_span::Symbol;
54
use rustc_span::sym;
5+
use rustc_span::Symbol;
66
use utils::span_to_snippet_macro;
77

88
dylint_linting::declare_late_lint! {
@@ -57,17 +57,26 @@ impl<'tcx> LateLintPass<'tcx> for FoldVec {
5757
// Type check the accumulated parameter and assign the correct identity.
5858
// Attempting to match 'c.push(v);'
5959

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+
};
6163
// Vector specific insert method
6264
if iseg.ident.name != Symbol::intern("push") {
6365
return;
6466
}
6567
// 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+
};
6771

6872
// Make sure that this is the vec 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+
};
7180
let did = adt.did();
7281
if !cx.tcx.is_diagnostic_item(sym::Vec, did) {
7382
return;

lints/par_fold/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ extern crate rustc_session;
1414
extern crate rustc_span;
1515

1616
mod par_fold_simple;
17-
mod vec;
1817
mod rayon_import;
18+
mod vec;
1919

2020
#[allow(clippy::no_mangle_with_rust_abi)]
2121
#[cfg_attr(not(feature = "rlib"), no_mangle)]

lints/par_fold/src/vec.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ impl<'tcx> LateLintPass<'tcx> for ParFoldVec {
6262

6363
let fold_snip = format!("fold(|| Vec::new(), {cls_snip})");
6464
let reduce_snip = "reduce(|| Vec::new(), |mut a, b| { a.extend(b); a })";
65-
let mut extend_snip = format!("{{ {id_snip}.extend({recv_snip}.{fold_snip}.{reduce_snip}); {id_snip} }}");
65+
let mut extend_snip =
66+
format!("{{ {id_snip}.extend({recv_snip}.{fold_snip}.{reduce_snip}); {id_snip} }}");
6667
extend_snip = extend_snip.replace(".iter()", ".par_iter()");
6768
extend_snip = extend_snip.replace(".iter_mut()", ".par_iter_mut()");
6869
extend_snip = extend_snip.replace(".into_iter()", ".into_par_iter()");

utils/src/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,15 @@ pub fn get_pat_expr_and_spans<'a>(
8484
Ok((pat_expr, local_defs_span, body_span))
8585
}
8686

87-
pub fn get_penult_stmt<'a>(
88-
expr: &'a Expr<'a>,
89-
) -> Result<&'a Stmt<'a>, ()> {
87+
pub fn get_penult_stmt<'a>(expr: &'a Expr<'a>) -> Result<&'a Stmt<'a>, ()> {
9088
if let ExprKind::Block(block, _) = &expr.kind {
9189
match block.stmts.len() {
9290
0 => Err(()),
9391
l => {
9492
if l == 1 && block.expr.is_none() {
9593
Err(())
9694
} else {
97-
Ok(&block.stmts[l - 1])
95+
Ok(&block.stmts[l - 1])
9896
}
9997
}
10098
}

0 commit comments

Comments
 (0)