Skip to content

Commit e50298f

Browse files
committed
Auto merge of #28884 - Ms2ger:fmt-mir, r=nikomatsakis
This commit contains some of the changes proposed by a rustfmt invocation, chosen based on the fairly non-deterministic metric of how much I liked the change. I expect we will run rustfmt on this crate again later, probably accepting more of its changes. For now, this is already an improvement over the status-quo.
2 parents babe953 + c73e78c commit e50298f

24 files changed

+651
-529
lines changed

src/librustc_mir/build/cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<'tcx> CFG<'tcx> {
2929
pub fn end_point(&self, block: BasicBlock) -> ExecutionPoint {
3030
ExecutionPoint {
3131
block: block,
32-
statement: self.block_data(block).statements.len() as u32
32+
statement: self.block_data(block).statements.len() as u32,
3333
}
3434
}
3535

src/librustc_mir/build/expr/as_constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! See docs in build/expr/mod.rs
1212
13-
use build::{Builder};
13+
use build::Builder;
1414
use hair::*;
1515
use repr::*;
1616

src/librustc_mir/build/expr/as_lvalue.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,14 @@ impl<'a,'tcx> Builder<'a,'tcx> {
3030
fn expr_as_lvalue(&mut self,
3131
mut block: BasicBlock,
3232
expr: Expr<'tcx>)
33-
-> BlockAnd<Lvalue<'tcx>>
34-
{
35-
debug!("expr_as_lvalue(block={:?}, expr={:?})",
36-
block, expr);
33+
-> BlockAnd<Lvalue<'tcx>> {
34+
debug!("expr_as_lvalue(block={:?}, expr={:?})", block, expr);
3735

3836
let this = self;
3937
let expr_span = expr.span;
4038
match expr.kind {
4139
ExprKind::Scope { extent, value } => {
42-
this.in_scope(extent, block, |this| {
43-
this.as_lvalue(block, value)
44-
})
40+
this.in_scope(extent, block, |this| this.as_lvalue(block, value))
4541
}
4642
ExprKind::Field { lhs, name } => {
4743
let lvalue = unpack!(block = this.as_lvalue(block, lhs));
@@ -69,12 +65,11 @@ impl<'a,'tcx> Builder<'a,'tcx> {
6965
idx.clone(),
7066
Operand::Consume(len)));
7167

72-
let (success, failure) = (this.cfg.start_new_block(),
73-
this.cfg.start_new_block());
68+
let (success, failure) = (this.cfg.start_new_block(), this.cfg.start_new_block());
7469
this.cfg.terminate(block,
7570
Terminator::If {
7671
cond: Operand::Consume(lt),
77-
targets: [success, failure]
72+
targets: [success, failure],
7873
});
7974
this.panic(failure);
8075
success.and(slice.index(idx))

src/librustc_mir/build/expr/as_operand.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ impl<'a,'tcx> Builder<'a,'tcx> {
2020
/// If `expr` is an lvalue like `x`, this will introduce a
2121
/// temporary `tmp = x`, so that we capture the value of `x` at
2222
/// this time.
23-
pub fn as_operand<M>(&mut self,
24-
block: BasicBlock,
25-
expr: M)
26-
-> BlockAnd<Operand<'tcx>>
27-
where M: Mirror<'tcx, Output=Expr<'tcx>>
23+
pub fn as_operand<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<Operand<'tcx>>
24+
where M: Mirror<'tcx, Output = Expr<'tcx>>
2825
{
2926
let expr = self.hir.mirror(expr);
3027
self.expr_as_operand(block, expr)
@@ -33,16 +30,12 @@ impl<'a,'tcx> Builder<'a,'tcx> {
3330
fn expr_as_operand(&mut self,
3431
mut block: BasicBlock,
3532
expr: Expr<'tcx>)
36-
-> BlockAnd<Operand<'tcx>>
37-
{
38-
debug!("expr_as_operand(block={:?}, expr={:?})",
39-
block, expr);
33+
-> BlockAnd<Operand<'tcx>> {
34+
debug!("expr_as_operand(block={:?}, expr={:?})", block, expr);
4035
let this = self;
4136

4237
if let ExprKind::Scope { extent, value } = expr.kind {
43-
return this.in_scope(extent, block, |this| {
44-
this.as_operand(block, value)
45-
});
38+
return this.in_scope(extent, block, |this| this.as_operand(block, value));
4639
}
4740

4841
let category = Category::of(&expr.kind).unwrap();

src/librustc_mir/build/expr/as_rvalue.rs

+7-16
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ use repr::*;
1919

2020
impl<'a,'tcx> Builder<'a,'tcx> {
2121
/// Compile `expr`, yielding an rvalue.
22-
pub fn as_rvalue<M>(&mut self,
23-
block: BasicBlock,
24-
expr: M)
25-
-> BlockAnd<Rvalue<'tcx>>
26-
where M: Mirror<'tcx, Output=Expr<'tcx>>
22+
pub fn as_rvalue<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<Rvalue<'tcx>>
23+
where M: Mirror<'tcx, Output = Expr<'tcx>>
2724
{
2825
let expr = self.hir.mirror(expr);
2926
self.expr_as_rvalue(block, expr)
@@ -32,19 +29,15 @@ impl<'a,'tcx> Builder<'a,'tcx> {
3229
fn expr_as_rvalue(&mut self,
3330
mut block: BasicBlock,
3431
expr: Expr<'tcx>)
35-
-> BlockAnd<Rvalue<'tcx>>
36-
{
37-
debug!("expr_as_rvalue(block={:?}, expr={:?})",
38-
block, expr);
32+
-> BlockAnd<Rvalue<'tcx>> {
33+
debug!("expr_as_rvalue(block={:?}, expr={:?})", block, expr);
3934

4035
let this = self;
4136
let expr_span = expr.span;
4237

4338
match expr.kind {
4439
ExprKind::Scope { extent, value } => {
45-
this.in_scope(extent, block, |this| {
46-
this.as_rvalue(block, value)
47-
})
40+
this.in_scope(extent, block, |this| this.as_rvalue(block, value))
4841
}
4942
ExprKind::InlineAsm { asm } => {
5043
block.and(Rvalue::InlineAsm(asm))
@@ -162,11 +155,9 @@ impl<'a,'tcx> Builder<'a,'tcx> {
162155
.map(|f| (f.name, unpack!(block = this.as_operand(block, f.expr))))
163156
.collect();
164157

165-
let field_names =
166-
this.hir.fields(adt_def, variant_index);
158+
let field_names = this.hir.fields(adt_def, variant_index);
167159

168-
let base =
169-
base.map(|base| unpack!(block = this.as_lvalue(block, base)));
160+
let base = base.map(|base| unpack!(block = this.as_lvalue(block, base)));
170161

171162
// for the actual values we use, take either the
172163
// expr the user specified or, if they didn't

src/librustc_mir/build/expr/as_temp.rs

+6-18
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,27 @@ use repr::*;
1818
impl<'a,'tcx> Builder<'a,'tcx> {
1919
/// Compile `expr` into a fresh temporary. This is used when building
2020
/// up rvalues so as to freeze the value that will be consumed.
21-
pub fn as_temp<M>(&mut self,
22-
block: BasicBlock,
23-
expr: M)
24-
-> BlockAnd<Lvalue<'tcx>>
25-
where M: Mirror<'tcx, Output=Expr<'tcx>>
21+
pub fn as_temp<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<Lvalue<'tcx>>
22+
where M: Mirror<'tcx, Output = Expr<'tcx>>
2623
{
2724
let expr = self.hir.mirror(expr);
2825
self.expr_as_temp(block, expr)
2926
}
3027

31-
fn expr_as_temp(&mut self,
32-
mut block: BasicBlock,
33-
expr: Expr<'tcx>)
34-
-> BlockAnd<Lvalue<'tcx>>
35-
{
36-
debug!("expr_as_temp(block={:?}, expr={:?})",
37-
block, expr);
28+
fn expr_as_temp(&mut self, mut block: BasicBlock, expr: Expr<'tcx>) -> BlockAnd<Lvalue<'tcx>> {
29+
debug!("expr_as_temp(block={:?}, expr={:?})", block, expr);
3830
let this = self;
3931

4032
if let ExprKind::Scope { extent, value } = expr.kind {
41-
return this.in_scope(extent, block, |this| {
42-
this.as_temp(block, value)
43-
});
33+
return this.in_scope(extent, block, |this| this.as_temp(block, value));
4434
}
4535

4636
let expr_ty = expr.ty.clone();
4737
let temp = this.temp(expr_ty.clone());
4838
let temp_lifetime = match expr.temp_lifetime {
4939
Some(t) => t,
5040
None => {
51-
this.hir.span_bug(
52-
expr.span,
53-
&format!("no temp_lifetime for expr"));
41+
this.hir.span_bug(expr.span, &format!("no temp_lifetime for expr"));
5442
}
5543
};
5644
this.schedule_drop(expr.span, temp_lifetime, DropKind::Deep, &temp, expr_ty);

src/librustc_mir/build/expr/into.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
3838

3939
match expr.kind {
4040
ExprKind::Scope { extent, value } => {
41-
this.in_scope(extent, block, |this| {
42-
this.into(destination, block, value)
43-
})
41+
this.in_scope(extent, block, |this| this.into(destination, block, value))
4442
}
4543
ExprKind::Block { body: ast_block } => {
4644
this.ast_block(destination, block, ast_block)
@@ -204,8 +202,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
204202
|loop_scope| loop_scope.continue_block)
205203
}
206204
ExprKind::Break { label } => {
207-
this.break_or_continue(expr_span, label, block,
208-
|loop_scope| loop_scope.break_block)
205+
this.break_or_continue(expr_span, label, block, |loop_scope| loop_scope.break_block)
209206
}
210207
ExprKind::Return { value } => {
211208
unpack!(block = this.into(&Lvalue::ReturnPointer, block, value));
@@ -226,9 +223,9 @@ impl<'a,'tcx> Builder<'a,'tcx> {
226223
data: CallData {
227224
destination: destination.clone(),
228225
func: fun,
229-
args: args
226+
args: args,
230227
},
231-
targets: [success, panic]
228+
targets: [success, panic],
232229
});
233230
success.unit()
234231
}

src/librustc_mir/build/into.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ use hair::*;
1919
use repr::*;
2020

2121
pub trait EvalInto<'tcx> {
22-
fn eval_into<'a>(self, builder: &mut Builder<'a,'tcx>, destination: &Lvalue<'tcx>,
23-
block: BasicBlock) -> BlockAnd<()>;
22+
fn eval_into<'a>(self,
23+
builder: &mut Builder<'a, 'tcx>,
24+
destination: &Lvalue<'tcx>,
25+
block: BasicBlock)
26+
-> BlockAnd<()>;
2427
}
2528

2629
impl<'a,'tcx> Builder<'a,'tcx> {
@@ -37,7 +40,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
3740

3841
impl<'tcx> EvalInto<'tcx> for ExprRef<'tcx> {
3942
fn eval_into<'a>(self,
40-
builder: &mut Builder<'a,'tcx>,
43+
builder: &mut Builder<'a, 'tcx>,
4144
destination: &Lvalue<'tcx>,
4245
block: BasicBlock)
4346
-> BlockAnd<()> {
@@ -48,7 +51,7 @@ impl<'tcx> EvalInto<'tcx> for ExprRef<'tcx> {
4851

4952
impl<'tcx> EvalInto<'tcx> for Expr<'tcx> {
5053
fn eval_into<'a>(self,
51-
builder: &mut Builder<'a,'tcx>,
54+
builder: &mut Builder<'a, 'tcx>,
5255
destination: &Lvalue<'tcx>,
5356
block: BasicBlock)
5457
-> BlockAnd<()> {
@@ -58,13 +61,13 @@ impl<'tcx> EvalInto<'tcx> for Expr<'tcx> {
5861

5962
impl<'tcx> EvalInto<'tcx> for Option<ExprRef<'tcx>> {
6063
fn eval_into<'a>(self,
61-
builder: &mut Builder<'a,'tcx>,
64+
builder: &mut Builder<'a, 'tcx>,
6265
destination: &Lvalue<'tcx>,
6366
block: BasicBlock)
6467
-> BlockAnd<()> {
6568
match self {
6669
Some(expr) => builder.into(destination, block, expr),
67-
None => block.unit()
70+
None => block.unit(),
6871
}
6972
}
7073
}

0 commit comments

Comments
 (0)