Skip to content

Commit fec24e3

Browse files
committed
---
yaml --- r: 271479 b: refs/heads/auto c: 3a16f57 h: refs/heads/master i: 271477: 2121308 271475: f1e0fd1 271471: 4910c7d
1 parent 65bf8a9 commit fec24e3

File tree

18 files changed

+178
-160
lines changed

18 files changed

+178
-160
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: e752d4cde359cebad6decc2e98334ff999031eba
11+
refs/heads/auto: 3a16f57fbbd0930c10a5b467a5ab2109712c50f1
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc/mir/repr.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,13 @@ pub struct BasicBlockData<'tcx> {
228228
pub is_cleanup: bool,
229229
}
230230

231+
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
232+
pub struct Terminator<'tcx> {
233+
pub kind: TerminatorKind<'tcx>
234+
}
235+
231236
#[derive(Clone, RustcEncodable, RustcDecodable)]
232-
pub enum Terminator<'tcx> {
237+
pub enum TerminatorKind<'tcx> {
233238
/// block should have one successor in the graph; we jump there
234239
Goto {
235240
target: BasicBlock,
@@ -299,7 +304,17 @@ pub enum Terminator<'tcx> {
299304

300305
impl<'tcx> Terminator<'tcx> {
301306
pub fn successors(&self) -> Cow<[BasicBlock]> {
302-
use self::Terminator::*;
307+
self.kind.successors()
308+
}
309+
310+
pub fn successors_mut(&mut self) -> Vec<&mut BasicBlock> {
311+
self.kind.successors_mut()
312+
}
313+
}
314+
315+
impl<'tcx> TerminatorKind<'tcx> {
316+
pub fn successors(&self) -> Cow<[BasicBlock]> {
317+
use self::TerminatorKind::*;
303318
match *self {
304319
Goto { target: ref b } => slice::ref_slice(b).into_cow(),
305320
If { targets: (b1, b2), .. } => vec![b1, b2].into_cow(),
@@ -320,7 +335,7 @@ impl<'tcx> Terminator<'tcx> {
320335
// FIXME: no mootable cow. I’m honestly not sure what a “cow” between `&mut [BasicBlock]` and
321336
// `Vec<&mut BasicBlock>` would look like in the first place.
322337
pub fn successors_mut(&mut self) -> Vec<&mut BasicBlock> {
323-
use self::Terminator::*;
338+
use self::TerminatorKind::*;
324339
match *self {
325340
Goto { target: ref mut b } => vec![b],
326341
If { targets: (ref mut b1, ref mut b2), .. } => vec![b1, b2],
@@ -360,7 +375,7 @@ impl<'tcx> BasicBlockData<'tcx> {
360375
}
361376
}
362377

363-
impl<'tcx> Debug for Terminator<'tcx> {
378+
impl<'tcx> Debug for TerminatorKind<'tcx> {
364379
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
365380
self.fmt_head(fmt)?;
366381
let successors = self.successors();
@@ -387,12 +402,12 @@ impl<'tcx> Debug for Terminator<'tcx> {
387402
}
388403
}
389404

390-
impl<'tcx> Terminator<'tcx> {
405+
impl<'tcx> TerminatorKind<'tcx> {
391406
/// Write the "head" part of the terminator; that is, its name and the data it uses to pick the
392407
/// successor basic block, if any. The only information not inlcuded is the list of possible
393408
/// successors, which may be rendered differently between the text and the graphviz format.
394409
pub fn fmt_head<W: Write>(&self, fmt: &mut W) -> fmt::Result {
395-
use self::Terminator::*;
410+
use self::TerminatorKind::*;
396411
match *self {
397412
Goto { .. } => write!(fmt, "goto"),
398413
If { cond: ref lv, .. } => write!(fmt, "if({:?})", lv),
@@ -419,7 +434,7 @@ impl<'tcx> Terminator<'tcx> {
419434

420435
/// Return the list of labels for the edges to the successor basic blocks.
421436
pub fn fmt_successor_labels(&self) -> Vec<Cow<'static, str>> {
422-
use self::Terminator::*;
437+
use self::TerminatorKind::*;
423438
match *self {
424439
Return | Resume => vec![],
425440
Goto { .. } => vec!["".into()],

branches/auto/src/librustc/mir/visit.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -138,52 +138,54 @@ macro_rules! make_mir_visitor {
138138
fn super_terminator(&mut self,
139139
block: BasicBlock,
140140
terminator: &$($mutability)* Terminator<'tcx>) {
141-
match *terminator {
142-
Terminator::Goto { target } => {
141+
match terminator.kind {
142+
TerminatorKind::Goto { target } => {
143143
self.visit_branch(block, target);
144144
}
145145

146-
Terminator::If { ref $($mutability)* cond,
147-
ref $($mutability)* targets } => {
146+
TerminatorKind::If { ref $($mutability)* cond,
147+
ref $($mutability)* targets } => {
148148
self.visit_operand(cond);
149149
for &target in targets.as_slice() {
150150
self.visit_branch(block, target);
151151
}
152152
}
153153

154-
Terminator::Switch { ref $($mutability)* discr,
155-
adt_def: _,
156-
ref targets } => {
154+
TerminatorKind::Switch { ref $($mutability)* discr,
155+
adt_def: _,
156+
ref targets } => {
157157
self.visit_lvalue(discr, LvalueContext::Inspect);
158158
for &target in targets {
159159
self.visit_branch(block, target);
160160
}
161161
}
162162

163-
Terminator::SwitchInt { ref $($mutability)* discr,
164-
switch_ty: _,
165-
values: _,
166-
ref targets } => {
163+
TerminatorKind::SwitchInt { ref $($mutability)* discr,
164+
switch_ty: _,
165+
values: _,
166+
ref targets } => {
167167
self.visit_lvalue(discr, LvalueContext::Inspect);
168168
for &target in targets {
169169
self.visit_branch(block, target);
170170
}
171171
}
172172

173-
Terminator::Resume |
174-
Terminator::Return => {
173+
TerminatorKind::Resume |
174+
TerminatorKind::Return => {
175175
}
176176

177-
Terminator::Drop { ref $($mutability)* value, target, unwind } => {
177+
TerminatorKind::Drop { ref $($mutability)* value,
178+
target,
179+
unwind } => {
178180
self.visit_lvalue(value, LvalueContext::Drop);
179181
self.visit_branch(block, target);
180182
unwind.map(|t| self.visit_branch(block, t));
181183
}
182184

183-
Terminator::Call { ref $($mutability)* func,
184-
ref $($mutability)* args,
185-
ref $($mutability)* destination,
186-
cleanup } => {
185+
TerminatorKind::Call { ref $($mutability)* func,
186+
ref $($mutability)* args,
187+
ref $($mutability)* destination,
188+
cleanup } => {
187189
self.visit_operand(func);
188190
for arg in args {
189191
self.visit_operand(arg);

branches/auto/src/librustc_borrowck/borrowck/mir/dataflow.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -410,29 +410,28 @@ impl<D: BitDenotation> DataflowState<D> {
410410
bb: &repr::BasicBlockData,
411411
on_return: OnReturn) where OnReturn: Fn(&D, &mut [usize], &repr::Lvalue)
412412
{
413-
let term = if let Some(ref term) = bb.terminator { term } else { return };
414-
match *term {
415-
repr::Terminator::Return |
416-
repr::Terminator::Resume => {}
417-
repr::Terminator::Goto { ref target } |
418-
repr::Terminator::Drop { ref target, value: _, unwind: None } => {
413+
match bb.terminator().kind {
414+
repr::TerminatorKind::Return |
415+
repr::TerminatorKind::Resume => {}
416+
repr::TerminatorKind::Goto { ref target } |
417+
repr::TerminatorKind::Drop { ref target, value: _, unwind: None } => {
419418
self.propagate_bits_into_entry_set_for(in_out, changed, target);
420419
}
421-
repr::Terminator::Drop { ref target, value: _, unwind: Some(ref unwind) } => {
420+
repr::TerminatorKind::Drop { ref target, value: _, unwind: Some(ref unwind) } => {
422421
self.propagate_bits_into_entry_set_for(in_out, changed, target);
423422
self.propagate_bits_into_entry_set_for(in_out, changed, unwind);
424423
}
425-
repr::Terminator::If { ref targets, .. } => {
424+
repr::TerminatorKind::If { ref targets, .. } => {
426425
self.propagate_bits_into_entry_set_for(in_out, changed, &targets.0);
427426
self.propagate_bits_into_entry_set_for(in_out, changed, &targets.1);
428427
}
429-
repr::Terminator::Switch { ref targets, .. } |
430-
repr::Terminator::SwitchInt { ref targets, .. } => {
428+
repr::TerminatorKind::Switch { ref targets, .. } |
429+
repr::TerminatorKind::SwitchInt { ref targets, .. } => {
431430
for target in targets {
432431
self.propagate_bits_into_entry_set_for(in_out, changed, target);
433432
}
434433
}
435-
repr::Terminator::Call { ref cleanup, ref destination, func: _, args: _ } => {
434+
repr::TerminatorKind::Call { ref cleanup, ref destination, func: _, args: _ } => {
436435
if let Some(ref unwind) = *cleanup {
437436
self.propagate_bits_into_entry_set_for(in_out, changed, unwind);
438437
}

branches/auto/src/librustc_borrowck/borrowck/mir/gather_moves.rs

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use rustc::middle::ty;
1313
use rustc::mir::repr::{self, Mir, BasicBlock, Lvalue, Rvalue};
14-
use rustc::mir::repr::{StatementKind, Terminator};
14+
use rustc::mir::repr::{StatementKind, TerminatorKind};
1515
use rustc::util::nodemap::FnvHashMap;
1616

1717
use std::cell::{Cell};
@@ -577,50 +577,48 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &ty::TyCtxt<'tcx>) -> MoveData<'tcx>
577577
}
578578
}
579579

580-
if let Some(ref term) = bb_data.terminator {
581-
match *term {
582-
Terminator::Goto { target: _ } | Terminator::Resume => { }
580+
match bb_data.terminator().kind {
581+
TerminatorKind::Goto { target: _ } | TerminatorKind::Resume => { }
583582

584-
Terminator::Return => {
585-
let source = Location { block: bb,
586-
index: bb_data.statements.len() };
587-
let lval = &Lvalue::ReturnPointer.deref();
588-
bb_ctxt.on_move_out_lval(SK::Return, lval, source);
589-
}
583+
TerminatorKind::Return => {
584+
let source = Location { block: bb,
585+
index: bb_data.statements.len() };
586+
let lval = &Lvalue::ReturnPointer.deref();
587+
bb_ctxt.on_move_out_lval(SK::Return, lval, source);
588+
}
590589

591-
Terminator::If { ref cond, targets: _ } => {
592-
// The `cond` is always of (copyable) type `bool`,
593-
// so there will never be anything to move.
594-
let _ = cond;
595-
}
590+
TerminatorKind::If { ref cond, targets: _ } => {
591+
// The `cond` is always of (copyable) type `bool`,
592+
// so there will never be anything to move.
593+
let _ = cond;
594+
}
596595

597-
Terminator::SwitchInt { switch_ty: _, values: _, targets: _, ref discr } |
598-
Terminator::Switch { adt_def: _, targets: _, ref discr } => {
599-
// The `discr` is not consumed; that is instead
600-
// encoded on specific match arms (and for
601-
// SwitchInt`, it is always a copyable integer
602-
// type anyway).
603-
let _ = discr;
604-
}
596+
TerminatorKind::SwitchInt { switch_ty: _, values: _, targets: _, ref discr } |
597+
TerminatorKind::Switch { adt_def: _, targets: _, ref discr } => {
598+
// The `discr` is not consumed; that is instead
599+
// encoded on specific match arms (and for
600+
// SwitchInt`, it is always a copyable integer
601+
// type anyway).
602+
let _ = discr;
603+
}
605604

606-
Terminator::Drop { value: ref lval, target: _, unwind: _ } => {
607-
let source = Location { block: bb,
608-
index: bb_data.statements.len() };
609-
bb_ctxt.on_move_out_lval(SK::Drop, lval, source);
610-
}
605+
TerminatorKind::Drop { value: ref lval, target: _, unwind: _ } => {
606+
let source = Location { block: bb,
607+
index: bb_data.statements.len() };
608+
bb_ctxt.on_move_out_lval(SK::Drop, lval, source);
609+
}
611610

612-
Terminator::Call { ref func, ref args, ref destination, cleanup: _ } => {
613-
let source = Location { block: bb,
614-
index: bb_data.statements.len() };
615-
bb_ctxt.on_operand(SK::CallFn, func, source);
616-
for arg in args {
617-
bb_ctxt.on_operand(SK::CallArg, arg, source);
618-
}
619-
if let Some((ref destination, _bb)) = *destination {
620-
// Create MovePath for `destination`, then
621-
// discard returned index.
622-
bb_ctxt.builder.move_path_for(destination);
623-
}
611+
TerminatorKind::Call { ref func, ref args, ref destination, cleanup: _ } => {
612+
let source = Location { block: bb,
613+
index: bb_data.statements.len() };
614+
bb_ctxt.on_operand(SK::CallFn, func, source);
615+
for arg in args {
616+
bb_ctxt.on_operand(SK::CallArg, arg, source);
617+
}
618+
if let Some((ref destination, _bb)) = *destination {
619+
// Create MovePath for `destination`, then
620+
// discard returned index.
621+
bb_ctxt.builder.move_path_for(destination);
624622
}
625623
}
626624
}

branches/auto/src/librustc_mir/build/cfg.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ impl<'tcx> CFG<'tcx> {
8383

8484
pub fn terminate(&mut self,
8585
block: BasicBlock,
86-
terminator: Terminator<'tcx>) {
86+
kind: TerminatorKind<'tcx>) {
8787
debug_assert!(self.block_data(block).terminator.is_none(),
8888
"terminate: block {:?} already has a terminator set", block);
89-
self.block_data_mut(block).terminator = Some(terminator);
89+
self.block_data_mut(block).terminator = Some(Terminator {
90+
kind: kind
91+
});
9092
}
9193
}

branches/auto/src/librustc_mir/build/expr/as_lvalue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
6868

6969
let (success, failure) = (this.cfg.start_new_block(), this.cfg.start_new_block());
7070
this.cfg.terminate(block,
71-
Terminator::If {
71+
TerminatorKind::If {
7272
cond: Operand::Consume(lt),
7373
targets: (success, failure),
7474
});

branches/auto/src/librustc_mir/build/expr/into.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
5353

5454
let mut then_block = this.cfg.start_new_block();
5555
let mut else_block = this.cfg.start_new_block();
56-
this.cfg.terminate(block, Terminator::If {
56+
this.cfg.terminate(block, TerminatorKind::If {
5757
cond: operand,
5858
targets: (then_block, else_block)
5959
});
@@ -70,8 +70,8 @@ impl<'a,'tcx> Builder<'a,'tcx> {
7070
};
7171

7272
let join_block = this.cfg.start_new_block();
73-
this.cfg.terminate(then_block, Terminator::Goto { target: join_block });
74-
this.cfg.terminate(else_block, Terminator::Goto { target: join_block });
73+
this.cfg.terminate(then_block, TerminatorKind::Goto { target: join_block });
74+
this.cfg.terminate(else_block, TerminatorKind::Goto { target: join_block });
7575

7676
join_block.unit()
7777
}
@@ -97,10 +97,10 @@ impl<'a,'tcx> Builder<'a,'tcx> {
9797
LogicalOp::And => (else_block, false_block),
9898
LogicalOp::Or => (true_block, else_block),
9999
};
100-
this.cfg.terminate(block, Terminator::If { cond: lhs, targets: blocks });
100+
this.cfg.terminate(block, TerminatorKind::If { cond: lhs, targets: blocks });
101101

102102
let rhs = unpack!(else_block = this.as_operand(else_block, rhs));
103-
this.cfg.terminate(else_block, Terminator::If {
103+
this.cfg.terminate(else_block, TerminatorKind::If {
104104
cond: rhs,
105105
targets: (true_block, false_block)
106106
});
@@ -121,8 +121,8 @@ impl<'a,'tcx> Builder<'a,'tcx> {
121121
literal: this.hir.false_literal(),
122122
});
123123

124-
this.cfg.terminate(true_block, Terminator::Goto { target: join_block });
125-
this.cfg.terminate(false_block, Terminator::Goto { target: join_block });
124+
this.cfg.terminate(true_block, TerminatorKind::Goto { target: join_block });
125+
this.cfg.terminate(false_block, TerminatorKind::Goto { target: join_block });
126126

127127
join_block.unit()
128128
}
@@ -146,7 +146,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
146146
let exit_block = this.cfg.start_new_block();
147147

148148
// start the loop
149-
this.cfg.terminate(block, Terminator::Goto { target: loop_block });
149+
this.cfg.terminate(block, TerminatorKind::Goto { target: loop_block });
150150

151151
let might_break = this.in_loop_scope(loop_block, exit_block, move |this| {
152152
// conduct the test, if necessary
@@ -159,7 +159,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
159159
let cond = unpack!(loop_block_end = this.as_operand(loop_block, cond_expr));
160160
body_block = this.cfg.start_new_block();
161161
this.cfg.terminate(loop_block_end,
162-
Terminator::If {
162+
TerminatorKind::If {
163163
cond: cond,
164164
targets: (body_block, exit_block)
165165
});
@@ -175,7 +175,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
175175
let tmp = this.get_unit_temp();
176176
// Execute the body, branching back to the test.
177177
let body_block_end = unpack!(this.into(&tmp, body_block, body));
178-
this.cfg.terminate(body_block_end, Terminator::Goto { target: loop_block });
178+
this.cfg.terminate(body_block_end, TerminatorKind::Goto { target: loop_block });
179179
});
180180
// If the loop may reach its exit_block, we assign an empty tuple to the
181181
// destination to keep the MIR well-formed.
@@ -254,7 +254,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
254254

255255
let success = this.cfg.start_new_block();
256256
let cleanup = this.diverge_cleanup();
257-
this.cfg.terminate(block, Terminator::Call {
257+
this.cfg.terminate(block, TerminatorKind::Call {
258258
func: fun,
259259
args: args,
260260
cleanup: cleanup,

0 commit comments

Comments
 (0)