Skip to content

Commit 1509637

Browse files
committed
[MIR] Get rid of that nasty unit_ty temporary lval
1 parent 21b025f commit 1509637

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

src/librustc_mir/build/expr/into.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ impl<'a,'tcx> Builder<'a,'tcx> {
157157
}
158158

159159
// execute the body, branching back to the test
160-
let unit_temp = this.unit_temp.clone();
161-
let body_block_end = unpack!(this.into(&unit_temp, body_block, body));
160+
// FIXME(#30636): this should not create or request any sort of destination at
161+
// all.
162+
let body_block_end = unpack!(this.into(destination, body_block, body));
162163
this.cfg.terminate(body_block_end, Terminator::Goto { target: loop_block });
163164

164165
// final point is exit_block

src/librustc_mir/build/mod.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub struct Builder<'a, 'tcx: 'a> {
2323
cfg: CFG<'tcx>,
2424
scopes: Vec<scope::Scope<'tcx>>,
2525
loop_scopes: Vec<scope::LoopScope>,
26-
unit_temp: Lvalue<'tcx>,
2726
var_decls: Vec<VarDecl<'tcx>>,
2827
var_indices: FnvHashMap<ast::NodeId, u32>,
2928
temp_decls: Vec<TempDecl<'tcx>>,
@@ -79,7 +78,7 @@ macro_rules! unpack {
7978
///////////////////////////////////////////////////////////////////////////
8079
// construct() -- the main entry point for building MIR for a function
8180

82-
pub fn construct<'a,'tcx>(mut hir: Cx<'a,'tcx>,
81+
pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
8382
_span: Span,
8483
implicit_arguments: Vec<Ty<'tcx>>,
8584
explicit_arguments: Vec<(Ty<'tcx>, &'tcx hir::Pat)>,
@@ -89,20 +88,14 @@ pub fn construct<'a,'tcx>(mut hir: Cx<'a,'tcx>,
8988
-> Mir<'tcx> {
9089
let cfg = CFG { basic_blocks: vec![] };
9190

92-
// it's handy to have a temporary of type `()` sometimes, so make
93-
// one from the start and keep it available
94-
let temp_decls = vec![TempDecl::<'tcx> { ty: hir.unit_ty() }];
95-
let unit_temp = Lvalue::Temp(0);
96-
9791
let mut builder = Builder {
9892
hir: hir,
9993
cfg: cfg,
10094
scopes: vec![],
10195
loop_scopes: vec![],
102-
temp_decls: temp_decls,
96+
temp_decls: vec![],
10397
var_decls: vec![],
10498
var_indices: FnvHashMap(),
105-
unit_temp: unit_temp,
10699
};
107100

108101
assert_eq!(builder.cfg.start_new_block(), START_BLOCK);

src/librustc_mir/hair/cx/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ impl<'a,'tcx:'a> Cx<'a, 'tcx> {
4646
ast.make_mirror(self)
4747
}
4848

49-
pub fn unit_ty(&mut self) -> Ty<'tcx> {
50-
self.tcx.mk_nil()
51-
}
52-
5349
pub fn usize_ty(&mut self) -> Ty<'tcx> {
5450
self.tcx.types.usize
5551
}

0 commit comments

Comments
 (0)