Skip to content

Commit 19730cc

Browse files
csmoeoli-obk
authored andcommitted
Fix tidy
1 parent 5b0cf56 commit 19730cc

File tree

15 files changed

+131
-42
lines changed

15 files changed

+131
-42
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,13 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
519519
// visit_enum_def() takes care of visiting the Item's NodeId
520520
visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span)
521521
}
522-
ItemKind::Impl(.., ref type_parameters, ref opt_trait_reference, ref typ, ref impl_item_refs) => {
522+
ItemKind::Impl(
523+
..,
524+
ref type_parameters,
525+
ref opt_trait_reference,
526+
ref typ,
527+
ref impl_item_refs
528+
) => {
523529
visitor.visit_id(item.id);
524530
visitor.visit_generics(type_parameters);
525531
walk_list!(visitor, visit_trait_ref, opt_trait_reference);

src/librustc/hir/lowering.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,7 +3877,9 @@ impl<'a> LoweringContext<'a> {
38773877
let expr = opt_expr
38783878
.as_ref()
38793879
.map(|x| self.lower_expr(x))
3880-
.unwrap_or_else(|| self.expr(e.span, hir::ExprKind::Tup(hir_vec![]), ThinVec::new()));
3880+
.unwrap_or_else(||
3881+
self.expr(e.span, hir::ExprKind::Tup(hir_vec![]), ThinVec::new())
3882+
);
38813883
hir::ExprKind::Yield(P(expr))
38823884
}
38833885

@@ -4053,11 +4055,18 @@ impl<'a> LoweringContext<'a> {
40534055

40544056
P(self.expr(
40554057
head_sp,
4056-
hir::ExprKind::Match(next_expr, arms, hir::MatchSource::ForLoopDesugar),
4058+
hir::ExprKind::Match(
4059+
next_expr,
4060+
arms,
4061+
hir::MatchSource::ForLoopDesugar
4062+
),
40574063
ThinVec::new(),
40584064
))
40594065
};
4060-
let match_stmt = respan(head_sp, hir::StmtKind::Expr(match_expr, self.next_id().node_id));
4066+
let match_stmt = respan(
4067+
head_sp,
4068+
hir::StmtKind::Expr(match_expr, self.next_id().node_id)
4069+
);
40614070

40624071
let next_expr = P(self.expr_ident(head_sp, next_ident, next_pat.id));
40634072

@@ -4076,7 +4085,10 @@ impl<'a> LoweringContext<'a> {
40764085

40774086
let body_block = self.with_loop_scope(e.id, |this| this.lower_block(body, false));
40784087
let body_expr = P(self.expr_block(body_block, ThinVec::new()));
4079-
let body_stmt = respan(body.span, hir::StmtKind::Expr(body_expr, self.next_id().node_id));
4088+
let body_stmt = respan(
4089+
body.span,
4090+
hir::StmtKind::Expr(body_expr, self.next_id().node_id)
4091+
);
40804092

40814093
let loop_block = P(self.block_all(
40824094
e.span,

src/librustc/middle/liveness.rs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,10 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
486486
}
487487

488488
// live nodes required for interesting control flow:
489-
hir::ExprKind::If(..) | hir::ExprKind::Match(..) | hir::ExprKind::While(..) | hir::ExprKind::Loop(..) => {
489+
hir::ExprKind::If(..) |
490+
hir::ExprKind::Match(..) |
491+
hir::ExprKind::While(..) |
492+
hir::ExprKind::Loop(..) => {
490493
ir.add_live_node_for_node(expr.hir_id, ExprNode(expr.span));
491494
intravisit::walk_expr(ir, expr);
492495
}
@@ -496,15 +499,30 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
496499
}
497500

498501
// otherwise, live nodes are not required:
499-
hir::ExprKind::Index(..) | hir::ExprKind::Field(..) |
500-
hir::ExprKind::Array(..) | hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) |
501-
hir::ExprKind::Tup(..) | hir::ExprKind::Binary(..) | hir::ExprKind::AddrOf(..) |
502-
hir::ExprKind::Cast(..) | hir::ExprKind::Unary(..) | hir::ExprKind::Break(..) |
503-
hir::ExprKind::Continue(_) | hir::ExprKind::Lit(_) | hir::ExprKind::Ret(..) |
504-
hir::ExprKind::Block(..) | hir::ExprKind::Assign(..) | hir::ExprKind::AssignOp(..) |
505-
hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) |
506-
hir::ExprKind::InlineAsm(..) | hir::ExprKind::Box(..) | hir::ExprKind::Yield(..) |
507-
hir::ExprKind::Type(..) | hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => {
502+
hir::ExprKind::Index(..) |
503+
hir::ExprKind::Field(..) |
504+
hir::ExprKind::Array(..) |
505+
hir::ExprKind::Call(..) |
506+
hir::ExprKind::MethodCall(..) |
507+
hir::ExprKind::Tup(..) |
508+
hir::ExprKind::Binary(..) |
509+
hir::ExprKind::AddrOf(..) |
510+
hir::ExprKind::Cast(..) |
511+
hir::ExprKind::Unary(..) |
512+
hir::ExprKind::Break(..) |
513+
hir::ExprKind::Continue(_) |
514+
hir::ExprKind::Lit(_) |
515+
hir::ExprKind::Ret(..) |
516+
hir::ExprKind::Block(..) |
517+
hir::ExprKind::Assign(..) |
518+
hir::ExprKind::AssignOp(..) |
519+
hir::ExprKind::Struct(..) |
520+
hir::ExprKind::Repeat(..) |
521+
hir::ExprKind::InlineAsm(..) |
522+
hir::ExprKind::Box(..) |
523+
hir::ExprKind::Yield(..) |
524+
hir::ExprKind::Type(..) |
525+
hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => {
508526
intravisit::walk_expr(ir, expr);
509527
}
510528
}

src/librustc/middle/reachable.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,20 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
279279
// These are normal, nothing reachable about these
280280
// inherently and their children are already in the
281281
// worklist, as determined by the privacy pass
282-
hir::ItemKind::ExternCrate(_) | hir::ItemKind::Use(..) |
282+
hir::ItemKind::ExternCrate(_) |
283+
hir::ItemKind::Use(..) |
283284
hir::ItemKind::Existential(..) |
284-
hir::ItemKind::Ty(..) | hir::ItemKind::Static(..) |
285-
hir::ItemKind::Mod(..) | hir::ItemKind::ForeignMod(..) |
286-
hir::ItemKind::Impl(..) | hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) |
287-
hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) |
288-
hir::ItemKind::Union(..) | hir::ItemKind::GlobalAsm(..) => {}
285+
hir::ItemKind::Ty(..) |
286+
hir::ItemKind::Static(..) |
287+
hir::ItemKind::Mod(..) |
288+
hir::ItemKind::ForeignMod(..) |
289+
hir::ItemKind::Impl(..) |
290+
hir::ItemKind::Trait(..) |
291+
hir::ItemKind::TraitAlias(..) |
292+
hir::ItemKind::Struct(..) |
293+
hir::ItemKind::Enum(..) |
294+
hir::ItemKind::Union(..) |
295+
hir::ItemKind::GlobalAsm(..) => {}
289296
}
290297
}
291298
hir_map::NodeTraitItem(trait_method) => {

src/librustc/middle/resolve_lifetime.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,9 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
675675
// ^ ^ this gets resolved in the scope of
676676
// the exist_ty generics
677677
let (generics, bounds) = match self.tcx.hir.expect_item(id).node {
678-
hir::ItemKind::Existential(hir::ExistTy{ ref generics, ref bounds, .. }) => (
678+
hir::ItemKind::Existential(
679+
hir::ExistTy { ref generics, ref bounds, .. }
680+
) => (
679681
generics,
680682
bounds,
681683
),

src/librustc_lint/types.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
285285

286286
fn is_comparison(binop: hir::BinOp) -> bool {
287287
match binop.node {
288-
hir::BinOpKind::Eq | hir::BinOpKind::Lt | hir::BinOpKind::Le | hir::BinOpKind::Ne | hir::BinOpKind::Ge | hir::BinOpKind::Gt => true,
288+
hir::BinOpKind::Eq |
289+
hir::BinOpKind::Lt |
290+
hir::BinOpKind::Le |
291+
hir::BinOpKind::Ne |
292+
hir::BinOpKind::Ge |
293+
hir::BinOpKind::Gt => true,
289294
_ => false,
290295
}
291296
}

src/librustc_lint/unused.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,29 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
102102
// attribute which does exist on the comparison trait methods
103103
hir::ExprKind::Binary(bin_op, ..) => {
104104
match bin_op.node {
105-
hir::BinOpKind::Eq | hir::BinOpKind::Lt | hir::BinOpKind::Le | hir::BinOpKind::Ne | hir::BinOpKind::Ge | hir::BinOpKind::Gt => {
105+
hir::BinOpKind::Eq |
106+
hir::BinOpKind::Lt |
107+
hir::BinOpKind::Le |
108+
hir::BinOpKind::Ne |
109+
hir::BinOpKind::Ge |
110+
hir::BinOpKind::Gt => {
106111
Some("comparison")
107112
},
108-
hir::BinOpKind::Add | hir::BinOpKind::Sub | hir::BinOpKind::Div | hir::BinOpKind::Mul | hir::BinOpKind::Rem => {
113+
hir::BinOpKind::Add |
114+
hir::BinOpKind::Sub |
115+
hir::BinOpKind::Div |
116+
hir::BinOpKind::Mul |
117+
hir::BinOpKind::Rem => {
109118
Some("arithmetic operation")
110119
},
111120
hir::BinOpKind::And | hir::BinOpKind::Or => {
112121
Some("logical operation")
113122
},
114-
hir::BinOpKind::BitXor | hir::BinOpKind::BitAnd | hir::BinOpKind::BitOr | hir::BinOpKind::Shl | hir::BinOpKind::Shr => {
123+
hir::BinOpKind::BitXor |
124+
hir::BinOpKind::BitAnd |
125+
hir::BinOpKind::BitOr |
126+
hir::BinOpKind::Shl |
127+
hir::BinOpKind::Shr => {
115128
Some("bitwise operation")
116129
},
117130
}

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
263263
//
264264
// &
265265
// - let's call the lifetime of this reference `'1`
266-
(ty::TyRef(region, referent_ty, _), hir::TyKind::Rptr(_lifetime, referent_hir_ty)) => {
266+
(
267+
ty::TyRef(region, referent_ty, _),
268+
hir::TyKind::Rptr(_lifetime, referent_hir_ty),
269+
) => {
267270
if region.to_region_vid() == needle_fr {
268271
let region_name = self.synthesize_region_name(counter);
269272

@@ -287,7 +290,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
287290
}
288291

289292
// Match up something like `Foo<'1>`
290-
(ty::TyAdt(_adt_def, substs), hir::TyKind::Path(hir::QPath::Resolved(None, path))) => {
293+
(
294+
ty::TyAdt(_adt_def, substs),
295+
hir::TyKind::Path(hir::QPath::Resolved(None, path)),
296+
) => {
291297
if let Some(last_segment) = path.segments.last() {
292298
if let Some(name) = self.match_adt_and_segment(
293299
substs,

src/librustc_mir/hair/cx/expr.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
238238
args: vec![fun.to_ref(), tupled_args.to_ref()],
239239
}
240240
} else {
241-
let adt_data = if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = fun.node {
241+
let adt_data = if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) =
242+
fun.node
243+
{
242244
// Tuple-like ADTs are represented as ExprKind::Call. We convert them here.
243245
expr_ty.ty_adt_def().and_then(|adt_def| {
244246
match path.def {

src/librustc_privacy/lib.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,15 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
216216
}
217217
}
218218
hir::ItemKind::Existential(..) |
219-
hir::ItemKind::Use(..) | hir::ItemKind::Static(..) | hir::ItemKind::Const(..) |
220-
hir::ItemKind::GlobalAsm(..) | hir::ItemKind::Ty(..) | hir::ItemKind::Mod(..) | hir::ItemKind::TraitAlias(..) |
221-
hir::ItemKind::Fn(..) | hir::ItemKind::ExternCrate(..) => {}
219+
hir::ItemKind::Use(..) |
220+
hir::ItemKind::Static(..) |
221+
hir::ItemKind::Const(..) |
222+
hir::ItemKind::GlobalAsm(..) |
223+
hir::ItemKind::Ty(..) |
224+
hir::ItemKind::Mod(..) |
225+
hir::ItemKind::TraitAlias(..) |
226+
hir::ItemKind::Fn(..) |
227+
hir::ItemKind::ExternCrate(..) => {}
222228
}
223229

224230
// Mark all items in interfaces of reachable items as reachable
@@ -373,7 +379,8 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
373379
loop {
374380
let module = if module_id == ast::CRATE_NODE_ID {
375381
&self.tcx.hir.krate().module
376-
} else if let hir::ItemKind::Mod(ref module) = self.tcx.hir.expect_item(module_id).node {
382+
} else if let hir::ItemKind::Mod(ref module) = self.tcx.hir.expect_item(module_id).node
383+
{
377384
module
378385
} else {
379386
unreachable!()

src/librustc_typeck/check/demand.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
306306
if self.can_coerce(ref_ty, expected) {
307307
if let Ok(src) = cm.span_to_snippet(sp) {
308308
let sugg_expr = match expr.node { // parenthesize if needed (Issue #46756)
309-
hir::ExprKind::Cast(_, _) | hir::ExprKind::Binary(_, _, _) => format!("({})", src),
309+
hir::ExprKind::Cast(_, _) |
310+
hir::ExprKind::Binary(_, _, _) => format!("({})", src),
310311
_ => src,
311312
};
312313
if let Some(sugg) = self.can_use_as_ref(expr) {

src/librustc_typeck/check/method/suggest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
389389
if let Some(expr) = rcvr_expr {
390390
if let Ok(expr_string) = tcx.sess.codemap().span_to_snippet(expr.span) {
391391
report_function!(expr.span, expr_string);
392-
} else if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = expr.node {
392+
} else if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) =
393+
expr.node
394+
{
393395
if let Some(segment) = path.segments.last() {
394396
report_function!(expr.span, segment.ident);
395397
}

src/librustc_typeck/check/op.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
363363
hir::BinOpKind::BitOr => Some("std::ops::BitOr"),
364364
hir::BinOpKind::Shl => Some("std::ops::Shl"),
365365
hir::BinOpKind::Shr => Some("std::ops::Shr"),
366-
hir::BinOpKind::Eq | hir::BinOpKind::Ne => Some("std::cmp::PartialEq"),
367-
hir::BinOpKind::Lt | hir::BinOpKind::Le | hir::BinOpKind::Gt | hir::BinOpKind::Ge =>
368-
Some("std::cmp::PartialOrd"),
369-
_ => None
366+
hir::BinOpKind::Eq |
367+
hir::BinOpKind::Ne => Some("std::cmp::PartialEq"),
368+
hir::BinOpKind::Lt |
369+
hir::BinOpKind::Le |
370+
hir::BinOpKind::Gt |
371+
hir::BinOpKind::Ge => Some("std::cmp::PartialOrd"),
372+
_ => None
370373
};
371374
if let Some(missing_trait) = missing_trait {
372375
if op.node == hir::BinOpKind::Add &&

src/librustc_typeck/check/writeback.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
117117
// operating on scalars, we clear the overload.
118118
fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) {
119119
match e.node {
120-
hir::ExprKind::Unary(hir::UnNeg, ref inner) | hir::ExprKind::Unary(hir::UnNot, ref inner) => {
120+
hir::ExprKind::Unary(hir::UnNeg, ref inner) |
121+
hir::ExprKind::Unary(hir::UnNot, ref inner) => {
121122
let inner_ty = self.fcx.node_ty(inner.hir_id);
122123
let inner_ty = self.fcx.resolve_type_vars_if_possible(&inner_ty);
123124

src/librustc_typeck/collect.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,10 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
420420
}
421421
},
422422
hir::ItemKind::Existential(..) => {}
423-
hir::ItemKind::Ty(..) | hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | hir::ItemKind::Fn(..) => {
423+
hir::ItemKind::Ty(..) |
424+
hir::ItemKind::Static(..) |
425+
hir::ItemKind::Const(..) |
426+
hir::ItemKind::Fn(..) => {
424427
tcx.generics_of(def_id);
425428
tcx.type_of(def_id);
426429
tcx.predicates_of(def_id);
@@ -840,7 +843,8 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
840843
generics
841844
}
842845

843-
ItemKind::Trait(_, _, ref generics, ..) | ItemKind::TraitAlias(ref generics, ..) => {
846+
ItemKind::Trait(_, _, ref generics, ..) |
847+
ItemKind::TraitAlias(ref generics, ..) => {
844848
// Add in the self type parameter.
845849
//
846850
// Something of a hack: use the node id for the trait, also as

0 commit comments

Comments
 (0)