Skip to content

Partially format librustc_mir with rustfmt. #28884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_mir/build/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<'tcx> CFG<'tcx> {
pub fn end_point(&self, block: BasicBlock) -> ExecutionPoint {
ExecutionPoint {
block: block,
statement: self.block_data(block).statements.len() as u32
statement: self.block_data(block).statements.len() as u32,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/build/expr/as_constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

//! See docs in build/expr/mod.rs

use build::{Builder};
use build::Builder;
use hair::*;
use repr::*;

Expand Down
15 changes: 5 additions & 10 deletions src/librustc_mir/build/expr/as_lvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,14 @@ impl<'a,'tcx> Builder<'a,'tcx> {
fn expr_as_lvalue(&mut self,
mut block: BasicBlock,
expr: Expr<'tcx>)
-> BlockAnd<Lvalue<'tcx>>
{
debug!("expr_as_lvalue(block={:?}, expr={:?})",
block, expr);
-> BlockAnd<Lvalue<'tcx>> {
debug!("expr_as_lvalue(block={:?}, expr={:?})", block, expr);

let this = self;
let expr_span = expr.span;
match expr.kind {
ExprKind::Scope { extent, value } => {
this.in_scope(extent, block, |this| {
this.as_lvalue(block, value)
})
this.in_scope(extent, block, |this| this.as_lvalue(block, value))
}
ExprKind::Field { lhs, name } => {
let lvalue = unpack!(block = this.as_lvalue(block, lhs));
Expand Down Expand Up @@ -69,12 +65,11 @@ impl<'a,'tcx> Builder<'a,'tcx> {
idx.clone(),
Operand::Consume(len)));

let (success, failure) = (this.cfg.start_new_block(),
this.cfg.start_new_block());
let (success, failure) = (this.cfg.start_new_block(), this.cfg.start_new_block());
this.cfg.terminate(block,
Terminator::If {
cond: Operand::Consume(lt),
targets: [success, failure]
targets: [success, failure],
});
this.panic(failure);
success.and(slice.index(idx))
Expand Down
17 changes: 5 additions & 12 deletions src/librustc_mir/build/expr/as_operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ impl<'a,'tcx> Builder<'a,'tcx> {
/// If `expr` is an lvalue like `x`, this will introduce a
/// temporary `tmp = x`, so that we capture the value of `x` at
/// this time.
pub fn as_operand<M>(&mut self,
block: BasicBlock,
expr: M)
-> BlockAnd<Operand<'tcx>>
where M: Mirror<'tcx, Output=Expr<'tcx>>
pub fn as_operand<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<Operand<'tcx>>
where M: Mirror<'tcx, Output = Expr<'tcx>>
{
let expr = self.hir.mirror(expr);
self.expr_as_operand(block, expr)
Expand All @@ -33,16 +30,12 @@ impl<'a,'tcx> Builder<'a,'tcx> {
fn expr_as_operand(&mut self,
mut block: BasicBlock,
expr: Expr<'tcx>)
-> BlockAnd<Operand<'tcx>>
{
debug!("expr_as_operand(block={:?}, expr={:?})",
block, expr);
-> BlockAnd<Operand<'tcx>> {
debug!("expr_as_operand(block={:?}, expr={:?})", block, expr);
let this = self;

if let ExprKind::Scope { extent, value } = expr.kind {
return this.in_scope(extent, block, |this| {
this.as_operand(block, value)
});
return this.in_scope(extent, block, |this| this.as_operand(block, value));
}

let category = Category::of(&expr.kind).unwrap();
Expand Down
23 changes: 7 additions & 16 deletions src/librustc_mir/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ use repr::*;

impl<'a,'tcx> Builder<'a,'tcx> {
/// Compile `expr`, yielding an rvalue.
pub fn as_rvalue<M>(&mut self,
block: BasicBlock,
expr: M)
-> BlockAnd<Rvalue<'tcx>>
where M: Mirror<'tcx, Output=Expr<'tcx>>
pub fn as_rvalue<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<Rvalue<'tcx>>
where M: Mirror<'tcx, Output = Expr<'tcx>>
{
let expr = self.hir.mirror(expr);
self.expr_as_rvalue(block, expr)
Expand All @@ -32,19 +29,15 @@ impl<'a,'tcx> Builder<'a,'tcx> {
fn expr_as_rvalue(&mut self,
mut block: BasicBlock,
expr: Expr<'tcx>)
-> BlockAnd<Rvalue<'tcx>>
{
debug!("expr_as_rvalue(block={:?}, expr={:?})",
block, expr);
-> BlockAnd<Rvalue<'tcx>> {
debug!("expr_as_rvalue(block={:?}, expr={:?})", block, expr);

let this = self;
let expr_span = expr.span;

match expr.kind {
ExprKind::Scope { extent, value } => {
this.in_scope(extent, block, |this| {
this.as_rvalue(block, value)
})
this.in_scope(extent, block, |this| this.as_rvalue(block, value))
}
ExprKind::InlineAsm { asm } => {
block.and(Rvalue::InlineAsm(asm))
Expand Down Expand Up @@ -162,11 +155,9 @@ impl<'a,'tcx> Builder<'a,'tcx> {
.map(|f| (f.name, unpack!(block = this.as_operand(block, f.expr))))
.collect();

let field_names =
this.hir.fields(adt_def, variant_index);
let field_names = this.hir.fields(adt_def, variant_index);

let base =
base.map(|base| unpack!(block = this.as_lvalue(block, base)));
let base = base.map(|base| unpack!(block = this.as_lvalue(block, base)));

// for the actual values we use, take either the
// expr the user specified or, if they didn't
Expand Down
24 changes: 6 additions & 18 deletions src/librustc_mir/build/expr/as_temp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,27 @@ use repr::*;
impl<'a,'tcx> Builder<'a,'tcx> {
/// Compile `expr` into a fresh temporary. This is used when building
/// up rvalues so as to freeze the value that will be consumed.
pub fn as_temp<M>(&mut self,
block: BasicBlock,
expr: M)
-> BlockAnd<Lvalue<'tcx>>
where M: Mirror<'tcx, Output=Expr<'tcx>>
pub fn as_temp<M>(&mut self, block: BasicBlock, expr: M) -> BlockAnd<Lvalue<'tcx>>
where M: Mirror<'tcx, Output = Expr<'tcx>>
{
let expr = self.hir.mirror(expr);
self.expr_as_temp(block, expr)
}

fn expr_as_temp(&mut self,
mut block: BasicBlock,
expr: Expr<'tcx>)
-> BlockAnd<Lvalue<'tcx>>
{
debug!("expr_as_temp(block={:?}, expr={:?})",
block, expr);
fn expr_as_temp(&mut self, mut block: BasicBlock, expr: Expr<'tcx>) -> BlockAnd<Lvalue<'tcx>> {
debug!("expr_as_temp(block={:?}, expr={:?})", block, expr);
let this = self;

if let ExprKind::Scope { extent, value } = expr.kind {
return this.in_scope(extent, block, |this| {
this.as_temp(block, value)
});
return this.in_scope(extent, block, |this| this.as_temp(block, value));
}

let expr_ty = expr.ty.clone();
let temp = this.temp(expr_ty.clone());
let temp_lifetime = match expr.temp_lifetime {
Some(t) => t,
None => {
this.hir.span_bug(
expr.span,
&format!("no temp_lifetime for expr"));
this.hir.span_bug(expr.span, &format!("no temp_lifetime for expr"));
}
};
this.schedule_drop(expr.span, temp_lifetime, DropKind::Deep, &temp, expr_ty);
Expand Down
11 changes: 4 additions & 7 deletions src/librustc_mir/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {

match expr.kind {
ExprKind::Scope { extent, value } => {
this.in_scope(extent, block, |this| {
this.into(destination, block, value)
})
this.in_scope(extent, block, |this| this.into(destination, block, value))
}
ExprKind::Block { body: ast_block } => {
this.ast_block(destination, block, ast_block)
Expand Down Expand Up @@ -204,8 +202,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|loop_scope| loop_scope.continue_block)
}
ExprKind::Break { label } => {
this.break_or_continue(expr_span, label, block,
|loop_scope| loop_scope.break_block)
this.break_or_continue(expr_span, label, block, |loop_scope| loop_scope.break_block)
}
ExprKind::Return { value } => {
unpack!(block = this.into(&Lvalue::ReturnPointer, block, value));
Expand All @@ -226,9 +223,9 @@ impl<'a,'tcx> Builder<'a,'tcx> {
data: CallData {
destination: destination.clone(),
func: fun,
args: args
args: args,
},
targets: [success, panic]
targets: [success, panic],
});
success.unit()
}
Expand Down
15 changes: 9 additions & 6 deletions src/librustc_mir/build/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ use hair::*;
use repr::*;

pub trait EvalInto<'tcx> {
fn eval_into<'a>(self, builder: &mut Builder<'a,'tcx>, destination: &Lvalue<'tcx>,
block: BasicBlock) -> BlockAnd<()>;
fn eval_into<'a>(self,
builder: &mut Builder<'a, 'tcx>,
destination: &Lvalue<'tcx>,
block: BasicBlock)
-> BlockAnd<()>;
}

impl<'a,'tcx> Builder<'a,'tcx> {
Expand All @@ -37,7 +40,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {

impl<'tcx> EvalInto<'tcx> for ExprRef<'tcx> {
fn eval_into<'a>(self,
builder: &mut Builder<'a,'tcx>,
builder: &mut Builder<'a, 'tcx>,
destination: &Lvalue<'tcx>,
block: BasicBlock)
-> BlockAnd<()> {
Expand All @@ -48,7 +51,7 @@ impl<'tcx> EvalInto<'tcx> for ExprRef<'tcx> {

impl<'tcx> EvalInto<'tcx> for Expr<'tcx> {
fn eval_into<'a>(self,
builder: &mut Builder<'a,'tcx>,
builder: &mut Builder<'a, 'tcx>,
destination: &Lvalue<'tcx>,
block: BasicBlock)
-> BlockAnd<()> {
Expand All @@ -58,13 +61,13 @@ impl<'tcx> EvalInto<'tcx> for Expr<'tcx> {

impl<'tcx> EvalInto<'tcx> for Option<ExprRef<'tcx>> {
fn eval_into<'a>(self,
builder: &mut Builder<'a,'tcx>,
builder: &mut Builder<'a, 'tcx>,
destination: &Lvalue<'tcx>,
block: BasicBlock)
-> BlockAnd<()> {
match self {
Some(expr) => builder.into(destination, block, expr),
None => block.unit()
None => block.unit(),
}
}
}
Loading