Skip to content

Commit 8747691

Browse files
author
Michael Wright
committed
Run rustfmt
1 parent f51f017 commit 8747691

File tree

7 files changed

+48
-46
lines changed

7 files changed

+48
-46
lines changed

clippy_lints/src/escape.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,20 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
121121
let id = map.hir_to_node_id(cmt.hir_id);
122122
if let Some(Node::Stmt(st)) = map.find(map.get_parent_node(id)) {
123123
if let StmtKind::Local(ref loc) = st.node {
124-
if let Some(ref ex) = loc.init {
125-
if let ExprKind::Box(..) = ex.node {
126-
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
127-
// let x = box (...)
128-
self.set.insert(consume_pat.id);
129-
}
130-
// TODO Box::new
131-
// TODO vec![]
132-
// TODO "foo".to_owned() and friends
124+
if let Some(ref ex) = loc.init {
125+
if let ExprKind::Box(..) = ex.node {
126+
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
127+
// let x = box (...)
128+
self.set.insert(consume_pat.id);
133129
}
130+
// TODO Box::new
131+
// TODO vec![]
132+
// TODO "foo".to_owned() and friends
134133
}
135134
}
136135
}
137136
}
137+
}
138138
if let Categorization::Local(lid) = cmt.cat {
139139
if self.set.contains(&lid) {
140140
// let y = x where x is known

clippy_lints/src/eval_order_dependence.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
9090
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
9191
match stmt.node {
9292
StmtKind::Local(ref local) => {
93-
if let Local { init: Some(ref e), .. } = **local {
94-
DivergenceVisitor { cx }.visit_expr(e);
95-
}
93+
if let Local { init: Some(ref e), .. } = **local {
94+
DivergenceVisitor { cx }.visit_expr(e);
95+
}
9696
},
9797
StmtKind::Expr(ref e) | StmtKind::Semi(ref e) => DivergenceVisitor { cx }.maybe_walk_expr(e),
9898
StmtKind::Item(..) => {},
@@ -271,9 +271,10 @@ fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> St
271271
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => check_expr(vis, expr),
272272
// If the declaration is of a local variable, check its initializer
273273
// expression if it has one. Otherwise, keep going.
274-
StmtKind::Local(ref local) => {
275-
local.init.as_ref().map_or(StopEarly::KeepGoing, |expr| check_expr(vis, expr))
276-
},
274+
StmtKind::Local(ref local) => local
275+
.init
276+
.as_ref()
277+
.map_or(StopEarly::KeepGoing, |expr| check_expr(vis, expr)),
277278
_ => StopEarly::KeepGoing,
278279
}
279280
}

clippy_lints/src/loops.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1971,11 +1971,11 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> {
19711971
return None;
19721972
}
19731973
if let StmtKind::Local(ref local) = block.stmts[0].node {
1974-
if let Some(ref expr) = local.init {
1975-
Some(expr)
1976-
} else {
1977-
None
1978-
}
1974+
if let Some(ref expr) = local.init {
1975+
Some(expr)
1976+
} else {
1977+
None
1978+
}
19791979
} else {
19801980
None
19811981
}

clippy_lints/src/methods/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1337,10 +1337,10 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
13371337
},
13381338
hir::Node::Stmt(stmt) => {
13391339
if let hir::StmtKind::Local(ref loc) = stmt.node {
1340-
if let hir::PatKind::Ref(..) = loc.pat.node {
1341-
// let ref y = *x borrows x, let ref y = x.clone() does not
1342-
return;
1343-
}
1340+
if let hir::PatKind::Ref(..) = loc.pat.node {
1341+
// let ref y = *x borrows x, let ref y = x.clone() does not
1342+
return;
1343+
}
13441344
}
13451345
},
13461346
_ => {},

clippy_lints/src/shadow.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,22 @@ fn check_local<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, local: &'tcx Local, binding
133133
if higher::is_from_for_desugar(local) {
134134
return;
135135
}
136-
let Local {
137-
ref pat,
138-
ref ty,
139-
ref init,
140-
span,
141-
..
142-
} = *local;
143-
if let Some(ref t) = *ty {
144-
check_ty(cx, t, bindings)
145-
}
146-
if let Some(ref o) = *init {
147-
check_expr(cx, o, bindings);
148-
check_pat(cx, pat, Some(o), span, bindings);
149-
} else {
150-
check_pat(cx, pat, None, span, bindings);
151-
}
136+
let Local {
137+
ref pat,
138+
ref ty,
139+
ref init,
140+
span,
141+
..
142+
} = *local;
143+
if let Some(ref t) = *ty {
144+
check_ty(cx, t, bindings)
145+
}
146+
if let Some(ref o) = *init {
147+
check_expr(cx, o, bindings);
148+
check_pat(cx, pat, Some(o), span, bindings);
149+
} else {
150+
check_pat(cx, pat, None, span, bindings);
151+
}
152152
}
153153

154154
fn is_binding(cx: &LateContext<'_, '_>, pat_id: HirId) -> bool {

clippy_lints/src/utils/hir_utils.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
4343
/// Check whether two statements are the same.
4444
pub fn eq_stmt(&mut self, left: &Stmt, right: &Stmt) -> bool {
4545
match (&left.node, &right.node) {
46-
(&StmtKind::Local(ref l), &StmtKind::Local(ref r)) =>
46+
(&StmtKind::Local(ref l), &StmtKind::Local(ref r)) => {
4747
self.eq_pat(&l.pat, &r.pat)
4848
&& both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r))
4949
&& both(&l.init, &r.init, |l, r| self.eq_expr(l, r))
50-
,
51-
(&StmtKind::Expr(ref l), &StmtKind::Expr(ref r))
52-
| (&StmtKind::Semi(ref l), &StmtKind::Semi(ref r)) => self.eq_expr(l, r),
50+
},
51+
(&StmtKind::Expr(ref l), &StmtKind::Expr(ref r)) | (&StmtKind::Semi(ref l), &StmtKind::Semi(ref r)) => {
52+
self.eq_expr(l, r)
53+
},
5354
_ => false,
5455
}
5556
}
@@ -649,7 +650,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
649650
StmtKind::Item(..) => {
650651
let c: fn(_) -> _ = StmtKind::Item;
651652
c.hash(&mut self.s);
652-
}
653+
},
653654
StmtKind::Expr(ref expr) => {
654655
let c: fn(_) -> _ = StmtKind::Expr;
655656
c.hash(&mut self.s);

clippy_lints/src/utils/inspector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
130130
println!("init expression:");
131131
print_expr(cx, e, 0);
132132
}
133-
}
133+
},
134134
hir::StmtKind::Item(_) => println!("item decl"),
135135
hir::StmtKind::Expr(ref e) | hir::StmtKind::Semi(ref e) => print_expr(cx, e, 0),
136136
}

0 commit comments

Comments
 (0)