[MIR] Get rid of that nasty unit_ty temporary lval
This commit is contained in:
parent
21b025f55f
commit
15096371dc
@ -157,8 +157,9 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
||||
}
|
||||
|
||||
// execute the body, branching back to the test
|
||||
let unit_temp = this.unit_temp.clone();
|
||||
let body_block_end = unpack!(this.into(&unit_temp, body_block, body));
|
||||
// FIXME(#30636): this should not create or request any sort of destination at
|
||||
// all.
|
||||
let body_block_end = unpack!(this.into(destination, body_block, body));
|
||||
this.cfg.terminate(body_block_end, Terminator::Goto { target: loop_block });
|
||||
|
||||
// final point is exit_block
|
||||
|
@ -23,7 +23,6 @@ pub struct Builder<'a, 'tcx: 'a> {
|
||||
cfg: CFG<'tcx>,
|
||||
scopes: Vec<scope::Scope<'tcx>>,
|
||||
loop_scopes: Vec<scope::LoopScope>,
|
||||
unit_temp: Lvalue<'tcx>,
|
||||
var_decls: Vec<VarDecl<'tcx>>,
|
||||
var_indices: FnvHashMap<ast::NodeId, u32>,
|
||||
temp_decls: Vec<TempDecl<'tcx>>,
|
||||
@ -79,7 +78,7 @@ macro_rules! unpack {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// construct() -- the main entry point for building MIR for a function
|
||||
|
||||
pub fn construct<'a,'tcx>(mut hir: Cx<'a,'tcx>,
|
||||
pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
|
||||
_span: Span,
|
||||
implicit_arguments: Vec<Ty<'tcx>>,
|
||||
explicit_arguments: Vec<(Ty<'tcx>, &'tcx hir::Pat)>,
|
||||
@ -89,20 +88,14 @@ pub fn construct<'a,'tcx>(mut hir: Cx<'a,'tcx>,
|
||||
-> Mir<'tcx> {
|
||||
let cfg = CFG { basic_blocks: vec![] };
|
||||
|
||||
// it's handy to have a temporary of type `()` sometimes, so make
|
||||
// one from the start and keep it available
|
||||
let temp_decls = vec![TempDecl::<'tcx> { ty: hir.unit_ty() }];
|
||||
let unit_temp = Lvalue::Temp(0);
|
||||
|
||||
let mut builder = Builder {
|
||||
hir: hir,
|
||||
cfg: cfg,
|
||||
scopes: vec![],
|
||||
loop_scopes: vec![],
|
||||
temp_decls: temp_decls,
|
||||
temp_decls: vec![],
|
||||
var_decls: vec![],
|
||||
var_indices: FnvHashMap(),
|
||||
unit_temp: unit_temp,
|
||||
};
|
||||
|
||||
assert_eq!(builder.cfg.start_new_block(), START_BLOCK);
|
||||
|
@ -46,10 +46,6 @@ impl<'a,'tcx:'a> Cx<'a, 'tcx> {
|
||||
ast.make_mirror(self)
|
||||
}
|
||||
|
||||
pub fn unit_ty(&mut self) -> Ty<'tcx> {
|
||||
self.tcx.mk_nil()
|
||||
}
|
||||
|
||||
pub fn usize_ty(&mut self) -> Ty<'tcx> {
|
||||
self.tcx.types.usize
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user