Remove box syntax from rustc_mir
This commit is contained in:
parent
dcdadc4d8d
commit
99db8fa9c2
20 changed files with 119 additions and 101 deletions
|
@ -464,12 +464,12 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||||
|
|
||||||
let body_with_facts = if return_body_with_facts {
|
let body_with_facts = if return_body_with_facts {
|
||||||
let output_facts = mbcx.polonius_output.expect("Polonius output was not computed");
|
let output_facts = mbcx.polonius_output.expect("Polonius output was not computed");
|
||||||
Some(box BodyWithBorrowckFacts {
|
Some(Box::new(BodyWithBorrowckFacts {
|
||||||
body: body_owned,
|
body: body_owned,
|
||||||
input_facts: *polonius_input.expect("Polonius input facts were not generated"),
|
input_facts: *polonius_input.expect("Polonius input facts were not generated"),
|
||||||
output_facts,
|
output_facts,
|
||||||
location_table: location_table_owned,
|
location_table: location_table_owned,
|
||||||
})
|
}))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,6 @@ Rust MIR: a lowered representation of Rust.
|
||||||
#![cfg_attr(bootstrap, feature(bindings_after_at))]
|
#![cfg_attr(bootstrap, feature(bindings_after_at))]
|
||||||
#![feature(bool_to_option)]
|
#![feature(bool_to_option)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(box_syntax)]
|
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(decl_macro)]
|
#![feature(decl_macro)]
|
||||||
#![feature(exact_size_is_empty)]
|
#![feature(exact_size_is_empty)]
|
||||||
|
|
|
@ -174,7 +174,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
|
||||||
0,
|
0,
|
||||||
Statement {
|
Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Retag(RetagKind::Raw, box (dropee_ptr)),
|
kind: StatementKind::Retag(RetagKind::Raw, Box::new(dropee_ptr)),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -388,10 +388,10 @@ impl CloneShimBuilder<'tcx> {
|
||||||
|
|
||||||
fn copy_shim(&mut self) {
|
fn copy_shim(&mut self) {
|
||||||
let rcvr = self.tcx.mk_place_deref(Place::from(Local::new(1 + 0)));
|
let rcvr = self.tcx.mk_place_deref(Place::from(Local::new(1 + 0)));
|
||||||
let ret_statement = self.make_statement(StatementKind::Assign(box (
|
let ret_statement = self.make_statement(StatementKind::Assign(Box::new((
|
||||||
Place::return_place(),
|
Place::return_place(),
|
||||||
Rvalue::Use(Operand::Copy(rcvr)),
|
Rvalue::Use(Operand::Copy(rcvr)),
|
||||||
)));
|
))));
|
||||||
self.block(vec![ret_statement], TerminatorKind::Return, false);
|
self.block(vec![ret_statement], TerminatorKind::Return, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,11 +418,11 @@ impl CloneShimBuilder<'tcx> {
|
||||||
|
|
||||||
// `func == Clone::clone(&ty) -> ty`
|
// `func == Clone::clone(&ty) -> ty`
|
||||||
let func_ty = tcx.mk_fn_def(self.def_id, substs);
|
let func_ty = tcx.mk_fn_def(self.def_id, substs);
|
||||||
let func = Operand::Constant(box Constant {
|
let func = Operand::Constant(Box::new(Constant {
|
||||||
span: self.span,
|
span: self.span,
|
||||||
user_ty: None,
|
user_ty: None,
|
||||||
literal: ty::Const::zero_sized(tcx, func_ty).into(),
|
literal: ty::Const::zero_sized(tcx, func_ty).into(),
|
||||||
});
|
}));
|
||||||
|
|
||||||
let ref_loc = self.make_place(
|
let ref_loc = self.make_place(
|
||||||
Mutability::Not,
|
Mutability::Not,
|
||||||
|
@ -430,10 +430,10 @@ impl CloneShimBuilder<'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
// `let ref_loc: &ty = &src;`
|
// `let ref_loc: &ty = &src;`
|
||||||
let statement = self.make_statement(StatementKind::Assign(box (
|
let statement = self.make_statement(StatementKind::Assign(Box::new((
|
||||||
ref_loc,
|
ref_loc,
|
||||||
Rvalue::Ref(tcx.lifetimes.re_erased, BorrowKind::Shared, src),
|
Rvalue::Ref(tcx.lifetimes.re_erased, BorrowKind::Shared, src),
|
||||||
)));
|
))));
|
||||||
|
|
||||||
// `let loc = Clone::clone(ref_loc);`
|
// `let loc = Clone::clone(ref_loc);`
|
||||||
self.block(
|
self.block(
|
||||||
|
@ -461,10 +461,10 @@ impl CloneShimBuilder<'tcx> {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
|
||||||
let cond = self.make_place(Mutability::Mut, tcx.types.bool);
|
let cond = self.make_place(Mutability::Mut, tcx.types.bool);
|
||||||
let compute_cond = self.make_statement(StatementKind::Assign(box (
|
let compute_cond = self.make_statement(StatementKind::Assign(Box::new((
|
||||||
cond,
|
cond,
|
||||||
Rvalue::BinaryOp(BinOp::Ne, box (Operand::Copy(end), Operand::Copy(beg))),
|
Rvalue::BinaryOp(BinOp::Ne, Box::new((Operand::Copy(end), Operand::Copy(beg)))),
|
||||||
)));
|
))));
|
||||||
|
|
||||||
// `if end != beg { goto loop_body; } else { goto loop_end; }`
|
// `if end != beg { goto loop_body; } else { goto loop_end; }`
|
||||||
self.block(
|
self.block(
|
||||||
|
@ -475,11 +475,11 @@ impl CloneShimBuilder<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_usize(&self, value: u64) -> Box<Constant<'tcx>> {
|
fn make_usize(&self, value: u64) -> Box<Constant<'tcx>> {
|
||||||
box Constant {
|
Box::new(Constant {
|
||||||
span: self.span,
|
span: self.span,
|
||||||
user_ty: None,
|
user_ty: None,
|
||||||
literal: ty::Const::from_usize(self.tcx, value).into(),
|
literal: ty::Const::from_usize(self.tcx, value).into(),
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn array_shim(
|
fn array_shim(
|
||||||
|
@ -500,18 +500,18 @@ impl CloneShimBuilder<'tcx> {
|
||||||
// `let end = len;`
|
// `let end = len;`
|
||||||
// `goto #1;`
|
// `goto #1;`
|
||||||
let inits = vec![
|
let inits = vec![
|
||||||
self.make_statement(StatementKind::Assign(box (
|
self.make_statement(StatementKind::Assign(Box::new((
|
||||||
Place::from(beg),
|
Place::from(beg),
|
||||||
Rvalue::Use(Operand::Constant(self.make_usize(0))),
|
Rvalue::Use(Operand::Constant(self.make_usize(0))),
|
||||||
))),
|
)))),
|
||||||
self.make_statement(StatementKind::Assign(box (
|
self.make_statement(StatementKind::Assign(Box::new((
|
||||||
end,
|
end,
|
||||||
Rvalue::Use(Operand::Constant(box Constant {
|
Rvalue::Use(Operand::Constant(Box::new(Constant {
|
||||||
span: self.span,
|
span: self.span,
|
||||||
user_ty: None,
|
user_ty: None,
|
||||||
literal: len.into(),
|
literal: len.into(),
|
||||||
})),
|
}))),
|
||||||
))),
|
)))),
|
||||||
];
|
];
|
||||||
self.block(inits, TerminatorKind::Goto { target: BasicBlock::new(1) }, false);
|
self.block(inits, TerminatorKind::Goto { target: BasicBlock::new(1) }, false);
|
||||||
|
|
||||||
|
@ -532,13 +532,13 @@ impl CloneShimBuilder<'tcx> {
|
||||||
// BB #3
|
// BB #3
|
||||||
// `beg = beg + 1;`
|
// `beg = beg + 1;`
|
||||||
// `goto #1`;
|
// `goto #1`;
|
||||||
let statements = vec![self.make_statement(StatementKind::Assign(box (
|
let statements = vec![self.make_statement(StatementKind::Assign(Box::new((
|
||||||
Place::from(beg),
|
Place::from(beg),
|
||||||
Rvalue::BinaryOp(
|
Rvalue::BinaryOp(
|
||||||
BinOp::Add,
|
BinOp::Add,
|
||||||
box (Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1))),
|
Box::new((Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1)))),
|
||||||
),
|
),
|
||||||
)))];
|
))))];
|
||||||
self.block(statements, TerminatorKind::Goto { target: BasicBlock::new(1) }, false);
|
self.block(statements, TerminatorKind::Goto { target: BasicBlock::new(1) }, false);
|
||||||
|
|
||||||
// BB #4
|
// BB #4
|
||||||
|
@ -551,10 +551,10 @@ impl CloneShimBuilder<'tcx> {
|
||||||
// goto #6;
|
// goto #6;
|
||||||
let end = beg;
|
let end = beg;
|
||||||
let beg = self.local_decls.push(LocalDecl::new(tcx.types.usize, span));
|
let beg = self.local_decls.push(LocalDecl::new(tcx.types.usize, span));
|
||||||
let init = self.make_statement(StatementKind::Assign(box (
|
let init = self.make_statement(StatementKind::Assign(Box::new((
|
||||||
Place::from(beg),
|
Place::from(beg),
|
||||||
Rvalue::Use(Operand::Constant(self.make_usize(0))),
|
Rvalue::Use(Operand::Constant(self.make_usize(0))),
|
||||||
)));
|
))));
|
||||||
self.block(vec![init], TerminatorKind::Goto { target: BasicBlock::new(6) }, true);
|
self.block(vec![init], TerminatorKind::Goto { target: BasicBlock::new(6) }, true);
|
||||||
|
|
||||||
// BB #6 (cleanup): loop {
|
// BB #6 (cleanup): loop {
|
||||||
|
@ -585,13 +585,13 @@ impl CloneShimBuilder<'tcx> {
|
||||||
// BB #8 (cleanup)
|
// BB #8 (cleanup)
|
||||||
// `beg = beg + 1;`
|
// `beg = beg + 1;`
|
||||||
// `goto #6;`
|
// `goto #6;`
|
||||||
let statement = self.make_statement(StatementKind::Assign(box (
|
let statement = self.make_statement(StatementKind::Assign(Box::new((
|
||||||
Place::from(beg),
|
Place::from(beg),
|
||||||
Rvalue::BinaryOp(
|
Rvalue::BinaryOp(
|
||||||
BinOp::Add,
|
BinOp::Add,
|
||||||
box (Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1))),
|
Box::new((Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1)))),
|
||||||
),
|
),
|
||||||
)));
|
))));
|
||||||
self.block(vec![statement], TerminatorKind::Goto { target: BasicBlock::new(6) }, true);
|
self.block(vec![statement], TerminatorKind::Goto { target: BasicBlock::new(6) }, true);
|
||||||
|
|
||||||
// BB #9 (resume)
|
// BB #9 (resume)
|
||||||
|
@ -748,10 +748,10 @@ fn build_call_shim<'tcx>(
|
||||||
let borrow_kind = BorrowKind::Mut { allow_two_phase_borrow: false };
|
let borrow_kind = BorrowKind::Mut { allow_two_phase_borrow: false };
|
||||||
statements.push(Statement {
|
statements.push(Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Assign(box (
|
kind: StatementKind::Assign(Box::new((
|
||||||
Place::from(ref_rcvr),
|
Place::from(ref_rcvr),
|
||||||
Rvalue::Ref(tcx.lifetimes.re_erased, borrow_kind, rcvr_place()),
|
Rvalue::Ref(tcx.lifetimes.re_erased, borrow_kind, rcvr_place()),
|
||||||
)),
|
))),
|
||||||
});
|
});
|
||||||
Operand::Move(Place::from(ref_rcvr))
|
Operand::Move(Place::from(ref_rcvr))
|
||||||
}
|
}
|
||||||
|
@ -765,11 +765,11 @@ fn build_call_shim<'tcx>(
|
||||||
CallKind::Direct(def_id) => {
|
CallKind::Direct(def_id) => {
|
||||||
let ty = tcx.type_of(def_id);
|
let ty = tcx.type_of(def_id);
|
||||||
(
|
(
|
||||||
Operand::Constant(box Constant {
|
Operand::Constant(Box::new(Constant {
|
||||||
span,
|
span,
|
||||||
user_ty: None,
|
user_ty: None,
|
||||||
literal: ty::Const::zero_sized(tcx, ty).into(),
|
literal: ty::Const::zero_sized(tcx, ty).into(),
|
||||||
}),
|
})),
|
||||||
rcvr.into_iter().collect::<Vec<_>>(),
|
rcvr.into_iter().collect::<Vec<_>>(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
|
||||||
0..0,
|
0..0,
|
||||||
places.map(|place| Statement {
|
places.map(|place| Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Retag(RetagKind::FnEntry, box (place)),
|
kind: StatementKind::Retag(RetagKind::FnEntry, Box::new(place)),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
|
||||||
0,
|
0,
|
||||||
Statement {
|
Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Retag(RetagKind::Default, box (dest_place)),
|
kind: StatementKind::Retag(RetagKind::Default, Box::new(dest_place)),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,10 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
|
||||||
let source_info = block_data.statements[i].source_info;
|
let source_info = block_data.statements[i].source_info;
|
||||||
block_data.statements.insert(
|
block_data.statements.insert(
|
||||||
i + 1,
|
i + 1,
|
||||||
Statement { source_info, kind: StatementKind::Retag(retag_kind, box (place)) },
|
Statement {
|
||||||
|
source_info,
|
||||||
|
kind: StatementKind::Retag(retag_kind, Box::new(place)),
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -491,15 +491,19 @@ fn bcb_filtered_successors<'a, 'tcx>(
|
||||||
term_kind: &'tcx TerminatorKind<'tcx>,
|
term_kind: &'tcx TerminatorKind<'tcx>,
|
||||||
) -> Box<dyn Iterator<Item = &'a BasicBlock> + 'a> {
|
) -> Box<dyn Iterator<Item = &'a BasicBlock> + 'a> {
|
||||||
let mut successors = term_kind.successors();
|
let mut successors = term_kind.successors();
|
||||||
box match &term_kind {
|
Box::new(
|
||||||
// SwitchInt successors are never unwind, and all of them should be traversed.
|
match &term_kind {
|
||||||
TerminatorKind::SwitchInt { .. } => successors,
|
// SwitchInt successors are never unwind, and all of them should be traversed.
|
||||||
// For all other kinds, return only the first successor, if any, and ignore unwinds.
|
TerminatorKind::SwitchInt { .. } => successors,
|
||||||
// NOTE: `chain(&[])` is required to coerce the `option::iter` (from
|
// For all other kinds, return only the first successor, if any, and ignore unwinds.
|
||||||
// `next().into_iter()`) into the `mir::Successors` aliased type.
|
// NOTE: `chain(&[])` is required to coerce the `option::iter` (from
|
||||||
_ => successors.next().into_iter().chain(&[]),
|
// `next().into_iter()`) into the `mir::Successors` aliased type.
|
||||||
}
|
_ => successors.next().into_iter().chain(&[]),
|
||||||
.filter(move |&&successor| body[successor].terminator().kind != TerminatorKind::Unreachable)
|
}
|
||||||
|
.filter(move |&&successor| {
|
||||||
|
body[successor].terminator().kind != TerminatorKind::Unreachable
|
||||||
|
}),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Maintains separate worklists for each loop in the BasicCoverageBlock CFG, plus one for the
|
/// Maintains separate worklists for each loop in the BasicCoverageBlock CFG, plus one for the
|
||||||
|
|
|
@ -478,10 +478,10 @@ fn inject_statement(
|
||||||
let source_info = data.terminator().source_info;
|
let source_info = data.terminator().source_info;
|
||||||
let statement = Statement {
|
let statement = Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Coverage(box Coverage {
|
kind: StatementKind::Coverage(Box::new(Coverage {
|
||||||
kind: counter_kind,
|
kind: counter_kind,
|
||||||
code_region: some_code_region,
|
code_region: some_code_region,
|
||||||
}),
|
})),
|
||||||
};
|
};
|
||||||
data.statements.insert(0, statement);
|
data.statements.insert(0, statement);
|
||||||
}
|
}
|
||||||
|
@ -495,7 +495,7 @@ fn inject_intermediate_expression(mir_body: &mut mir::Body<'tcx>, expression: Co
|
||||||
let source_info = data.terminator().source_info;
|
let source_info = data.terminator().source_info;
|
||||||
let statement = Statement {
|
let statement = Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Coverage(box Coverage { kind: expression, code_region: None }),
|
kind: StatementKind::Coverage(Box::new(Coverage { kind: expression, code_region: None })),
|
||||||
};
|
};
|
||||||
data.statements.push(statement);
|
data.statements.push(statement);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,11 @@ const TEMP_BLOCK: BasicBlock = BasicBlock::MAX;
|
||||||
|
|
||||||
fn dummy_ty() -> &'static TyS<'static> {
|
fn dummy_ty() -> &'static TyS<'static> {
|
||||||
thread_local! {
|
thread_local! {
|
||||||
static DUMMY_TYS: &'static TyS<'static> = Box::leak(box TyS::make_for_test(
|
static DUMMY_TYS: &'static TyS<'static> = Box::leak(Box::new(TyS::make_for_test(
|
||||||
ty::Bool,
|
ty::Bool,
|
||||||
TypeFlags::empty(),
|
TypeFlags::empty(),
|
||||||
DebruijnIndex::from_usize(0),
|
DebruijnIndex::from_usize(0),
|
||||||
));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
&DUMMY_TYS.with(|tys| *tys)
|
&DUMMY_TYS.with(|tys| *tys)
|
||||||
|
|
|
@ -96,14 +96,14 @@ impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
|
||||||
opt_to_apply.infos[0].first_switch_info.discr_used_in_switch;
|
opt_to_apply.infos[0].first_switch_info.discr_used_in_switch;
|
||||||
let not_equal_rvalue = Rvalue::BinaryOp(
|
let not_equal_rvalue = Rvalue::BinaryOp(
|
||||||
not_equal,
|
not_equal,
|
||||||
box (
|
Box::new((
|
||||||
Operand::Copy(Place::from(second_discriminant_temp)),
|
Operand::Copy(Place::from(second_discriminant_temp)),
|
||||||
Operand::Copy(first_descriminant_place),
|
Operand::Copy(first_descriminant_place),
|
||||||
),
|
)),
|
||||||
);
|
);
|
||||||
patch.add_statement(
|
patch.add_statement(
|
||||||
end_of_block_location,
|
end_of_block_location,
|
||||||
StatementKind::Assign(box (Place::from(not_equal_temp), not_equal_rvalue)),
|
StatementKind::Assign(Box::new((Place::from(not_equal_temp), not_equal_rvalue))),
|
||||||
);
|
);
|
||||||
|
|
||||||
let new_targets = opt_to_apply
|
let new_targets = opt_to_apply
|
||||||
|
|
|
@ -409,7 +409,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
||||||
assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported");
|
assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported");
|
||||||
|
|
||||||
let assign = Statement {
|
let assign = Statement {
|
||||||
kind: StatementKind::Assign(box (place, Rvalue::Use(value.clone()))),
|
kind: StatementKind::Assign(Box::new((place, Rvalue::Use(value.clone())))),
|
||||||
source_info: terminator.source_info,
|
source_info: terminator.source_info,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ impl TransformVisitor<'tcx> {
|
||||||
Statement {
|
Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::SetDiscriminant {
|
kind: StatementKind::SetDiscriminant {
|
||||||
place: box self_place,
|
place: Box::new(self_place),
|
||||||
variant_index: state_disc,
|
variant_index: state_disc,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ impl TransformVisitor<'tcx> {
|
||||||
let self_place = Place::from(SELF_ARG);
|
let self_place = Place::from(SELF_ARG);
|
||||||
let assign = Statement {
|
let assign = Statement {
|
||||||
source_info: SourceInfo::outermost(body.span),
|
source_info: SourceInfo::outermost(body.span),
|
||||||
kind: StatementKind::Assign(box (temp, Rvalue::Discriminant(self_place))),
|
kind: StatementKind::Assign(Box::new((temp, Rvalue::Discriminant(self_place)))),
|
||||||
};
|
};
|
||||||
(assign, temp)
|
(assign, temp)
|
||||||
}
|
}
|
||||||
|
@ -954,7 +954,7 @@ fn create_generator_drop_shim<'tcx>(
|
||||||
0,
|
0,
|
||||||
Statement {
|
Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Retag(RetagKind::Raw, box Place::from(SELF_ARG)),
|
kind: StatementKind::Retag(RetagKind::Raw, Box::new(Place::from(SELF_ARG))),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -984,11 +984,11 @@ fn insert_panic_block<'tcx>(
|
||||||
) -> BasicBlock {
|
) -> BasicBlock {
|
||||||
let assert_block = BasicBlock::new(body.basic_blocks().len());
|
let assert_block = BasicBlock::new(body.basic_blocks().len());
|
||||||
let term = TerminatorKind::Assert {
|
let term = TerminatorKind::Assert {
|
||||||
cond: Operand::Constant(box Constant {
|
cond: Operand::Constant(Box::new(Constant {
|
||||||
span: body.span,
|
span: body.span,
|
||||||
user_ty: None,
|
user_ty: None,
|
||||||
literal: ty::Const::from_bool(tcx, false).into(),
|
literal: ty::Const::from_bool(tcx, false).into(),
|
||||||
}),
|
})),
|
||||||
expected: true,
|
expected: true,
|
||||||
msg: message,
|
msg: message,
|
||||||
target: assert_block,
|
target: assert_block,
|
||||||
|
@ -1207,10 +1207,10 @@ fn create_cases<'tcx>(
|
||||||
let resume_arg = Local::new(2); // 0 = return, 1 = self
|
let resume_arg = Local::new(2); // 0 = return, 1 = self
|
||||||
statements.push(Statement {
|
statements.push(Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Assign(box (
|
kind: StatementKind::Assign(Box::new((
|
||||||
point.resume_arg,
|
point.resume_arg,
|
||||||
Rvalue::Use(Operand::Move(resume_arg.into())),
|
Rvalue::Use(Operand::Move(resume_arg.into())),
|
||||||
)),
|
))),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1287,10 +1287,10 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
|
||||||
0,
|
0,
|
||||||
Statement {
|
Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Assign(box (
|
kind: StatementKind::Assign(Box::new((
|
||||||
new_resume_local.into(),
|
new_resume_local.into(),
|
||||||
Rvalue::Use(Operand::Move(resume_local.into())),
|
Rvalue::Use(Operand::Move(resume_local.into())),
|
||||||
)),
|
))),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -520,7 +520,7 @@ impl Inliner<'tcx> {
|
||||||
let temp = Place::from(self.new_call_temp(caller_body, &callsite, dest_ty));
|
let temp = Place::from(self.new_call_temp(caller_body, &callsite, dest_ty));
|
||||||
caller_body[callsite.block].statements.push(Statement {
|
caller_body[callsite.block].statements.push(Statement {
|
||||||
source_info: callsite.source_info,
|
source_info: callsite.source_info,
|
||||||
kind: StatementKind::Assign(box (temp, dest)),
|
kind: StatementKind::Assign(Box::new((temp, dest))),
|
||||||
});
|
});
|
||||||
self.tcx.mk_place_deref(temp)
|
self.tcx.mk_place_deref(temp)
|
||||||
} else {
|
} else {
|
||||||
|
@ -729,7 +729,7 @@ impl Inliner<'tcx> {
|
||||||
let local = self.new_call_temp(caller_body, callsite, arg_ty);
|
let local = self.new_call_temp(caller_body, callsite, arg_ty);
|
||||||
caller_body[callsite.block].statements.push(Statement {
|
caller_body[callsite.block].statements.push(Statement {
|
||||||
source_info: callsite.source_info,
|
source_info: callsite.source_info,
|
||||||
kind: StatementKind::Assign(box (Place::from(local), Rvalue::Use(arg))),
|
kind: StatementKind::Assign(Box::new((Place::from(local), Rvalue::Use(arg)))),
|
||||||
});
|
});
|
||||||
local
|
local
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ impl<'tcx, 'a> InstCombineContext<'tcx, 'a> {
|
||||||
|
|
||||||
let constant =
|
let constant =
|
||||||
Constant { span: source_info.span, literal: len.into(), user_ty: None };
|
Constant { span: source_info.span, literal: len.into(), user_ty: None };
|
||||||
*rvalue = Rvalue::Use(Operand::Constant(box constant));
|
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,14 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
|
||||||
if let Some((destination, target)) = *destination {
|
if let Some((destination, target)) = *destination {
|
||||||
block.statements.push(Statement {
|
block.statements.push(Statement {
|
||||||
source_info: terminator.source_info,
|
source_info: terminator.source_info,
|
||||||
kind: StatementKind::Assign(box (
|
kind: StatementKind::Assign(Box::new((
|
||||||
destination,
|
destination,
|
||||||
Rvalue::Use(Operand::Constant(box Constant {
|
Rvalue::Use(Operand::Constant(Box::new(Constant {
|
||||||
span: terminator.source_info.span,
|
span: terminator.source_info.span,
|
||||||
user_ty: None,
|
user_ty: None,
|
||||||
literal: ty::Const::zero_sized(tcx, tcx.types.unit).into(),
|
literal: ty::Const::zero_sized(tcx, tcx.types.unit).into(),
|
||||||
})),
|
}))),
|
||||||
)),
|
))),
|
||||||
});
|
});
|
||||||
terminator.kind = TerminatorKind::Goto { target };
|
terminator.kind = TerminatorKind::Goto { target };
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,13 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
|
||||||
let mut args = args.drain(..);
|
let mut args = args.drain(..);
|
||||||
block.statements.push(Statement {
|
block.statements.push(Statement {
|
||||||
source_info: terminator.source_info,
|
source_info: terminator.source_info,
|
||||||
kind: StatementKind::CopyNonOverlapping(
|
kind: StatementKind::CopyNonOverlapping(Box::new(
|
||||||
box rustc_middle::mir::CopyNonOverlapping {
|
rustc_middle::mir::CopyNonOverlapping {
|
||||||
src: args.next().unwrap(),
|
src: args.next().unwrap(),
|
||||||
dst: args.next().unwrap(),
|
dst: args.next().unwrap(),
|
||||||
count: args.next().unwrap(),
|
count: args.next().unwrap(),
|
||||||
},
|
},
|
||||||
),
|
)),
|
||||||
});
|
});
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
args.next(),
|
args.next(),
|
||||||
|
@ -79,10 +79,10 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
|
||||||
};
|
};
|
||||||
block.statements.push(Statement {
|
block.statements.push(Statement {
|
||||||
source_info: terminator.source_info,
|
source_info: terminator.source_info,
|
||||||
kind: StatementKind::Assign(box (
|
kind: StatementKind::Assign(Box::new((
|
||||||
destination,
|
destination,
|
||||||
Rvalue::BinaryOp(bin_op, box (lhs, rhs)),
|
Rvalue::BinaryOp(bin_op, Box::new((lhs, rhs))),
|
||||||
)),
|
))),
|
||||||
});
|
});
|
||||||
terminator.kind = TerminatorKind::Goto { target };
|
terminator.kind = TerminatorKind::Goto { target };
|
||||||
}
|
}
|
||||||
|
@ -97,10 +97,10 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
|
||||||
let tp_ty = substs.type_at(0);
|
let tp_ty = substs.type_at(0);
|
||||||
block.statements.push(Statement {
|
block.statements.push(Statement {
|
||||||
source_info: terminator.source_info,
|
source_info: terminator.source_info,
|
||||||
kind: StatementKind::Assign(box (
|
kind: StatementKind::Assign(Box::new((
|
||||||
destination,
|
destination,
|
||||||
Rvalue::NullaryOp(NullOp::SizeOf, tp_ty),
|
Rvalue::NullaryOp(NullOp::SizeOf, tp_ty),
|
||||||
)),
|
))),
|
||||||
});
|
});
|
||||||
terminator.kind = TerminatorKind::Goto { target };
|
terminator.kind = TerminatorKind::Goto { target };
|
||||||
}
|
}
|
||||||
|
@ -112,10 +112,10 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
|
||||||
let arg = tcx.mk_place_deref(arg);
|
let arg = tcx.mk_place_deref(arg);
|
||||||
block.statements.push(Statement {
|
block.statements.push(Statement {
|
||||||
source_info: terminator.source_info,
|
source_info: terminator.source_info,
|
||||||
kind: StatementKind::Assign(box (
|
kind: StatementKind::Assign(Box::new((
|
||||||
destination,
|
destination,
|
||||||
Rvalue::Discriminant(arg),
|
Rvalue::Discriminant(arg),
|
||||||
)),
|
))),
|
||||||
});
|
});
|
||||||
terminator.kind = TerminatorKind::Goto { target };
|
terminator.kind = TerminatorKind::Goto { target };
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,11 +140,11 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
|
||||||
let op = if f_b { BinOp::Eq } else { BinOp::Ne };
|
let op = if f_b { BinOp::Eq } else { BinOp::Ne };
|
||||||
let rhs = Rvalue::BinaryOp(
|
let rhs = Rvalue::BinaryOp(
|
||||||
op,
|
op,
|
||||||
box (Operand::Copy(Place::from(discr_local)), const_cmp),
|
Box::new((Operand::Copy(Place::from(discr_local)), const_cmp)),
|
||||||
);
|
);
|
||||||
Statement {
|
Statement {
|
||||||
source_info: f.source_info,
|
source_info: f.source_info,
|
||||||
kind: StatementKind::Assign(box (*lhs, rhs)),
|
kind: StatementKind::Assign(Box::new((*lhs, rhs))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,10 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
|
||||||
.push(Statement { source_info, kind: StatementKind::StorageLive(discr_local) });
|
.push(Statement { source_info, kind: StatementKind::StorageLive(discr_local) });
|
||||||
from.statements.push(Statement {
|
from.statements.push(Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Assign(box (Place::from(discr_local), Rvalue::Use(discr))),
|
kind: StatementKind::Assign(Box::new((
|
||||||
|
Place::from(discr_local),
|
||||||
|
Rvalue::Use(discr),
|
||||||
|
))),
|
||||||
});
|
});
|
||||||
from.statements.extend(new_stmts);
|
from.statements.extend(new_stmts);
|
||||||
from.statements
|
from.statements
|
||||||
|
|
|
@ -719,7 +719,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
||||||
let data = &mut self.promoted[last];
|
let data = &mut self.promoted[last];
|
||||||
data.statements.push(Statement {
|
data.statements.push(Statement {
|
||||||
source_info: SourceInfo::outermost(span),
|
source_info: SourceInfo::outermost(span),
|
||||||
kind: StatementKind::Assign(box (Place::from(dest), rvalue)),
|
kind: StatementKind::Assign(Box::new((Place::from(dest), rvalue))),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -774,11 +774,11 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
||||||
if self.keep_original {
|
if self.keep_original {
|
||||||
rhs.clone()
|
rhs.clone()
|
||||||
} else {
|
} else {
|
||||||
let unit = Rvalue::Use(Operand::Constant(box Constant {
|
let unit = Rvalue::Use(Operand::Constant(Box::new(Constant {
|
||||||
span: statement.source_info.span,
|
span: statement.source_info.span,
|
||||||
user_ty: None,
|
user_ty: None,
|
||||||
literal: ty::Const::zero_sized(self.tcx, self.tcx.types.unit).into(),
|
literal: ty::Const::zero_sized(self.tcx, self.tcx.types.unit).into(),
|
||||||
}));
|
})));
|
||||||
mem::replace(rhs, unit)
|
mem::replace(rhs, unit)
|
||||||
},
|
},
|
||||||
statement.source_info,
|
statement.source_info,
|
||||||
|
|
|
@ -382,10 +382,10 @@ fn save_unreachable_coverage(
|
||||||
for (source_info, code_region) in dropped_coverage {
|
for (source_info, code_region) in dropped_coverage {
|
||||||
start_block.statements.push(Statement {
|
start_block.statements.push(Statement {
|
||||||
source_info,
|
source_info,
|
||||||
kind: StatementKind::Coverage(box Coverage {
|
kind: StatementKind::Coverage(Box::new(Coverage {
|
||||||
kind: CoverageKind::Unreachable,
|
kind: CoverageKind::Unreachable,
|
||||||
code_region: Some(code_region),
|
code_region: Some(code_region),
|
||||||
}),
|
})),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,10 +420,10 @@ impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity {
|
||||||
|
|
||||||
let stmt = &mut bb.statements[opt_info.stmt_to_overwrite];
|
let stmt = &mut bb.statements[opt_info.stmt_to_overwrite];
|
||||||
stmt.source_info = opt_info.source_info;
|
stmt.source_info = opt_info.source_info;
|
||||||
stmt.kind = StatementKind::Assign(box (
|
stmt.kind = StatementKind::Assign(Box::new((
|
||||||
opt_info.local_0.into(),
|
opt_info.local_0.into(),
|
||||||
Rvalue::Use(Operand::Move(opt_info.local_1.into())),
|
Rvalue::Use(Operand::Move(opt_info.local_1.into())),
|
||||||
));
|
)));
|
||||||
|
|
||||||
bb.statements.retain(|stmt| stmt.kind != StatementKind::Nop);
|
bb.statements.retain(|stmt| stmt.kind != StatementKind::Nop);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub fn expand_aggregate<'tcx>(
|
||||||
AggregateKind::Adt(adt_def, variant_index, _, _, active_field_index) => {
|
AggregateKind::Adt(adt_def, variant_index, _, _, active_field_index) => {
|
||||||
if adt_def.is_enum() {
|
if adt_def.is_enum() {
|
||||||
set_discriminant = Some(Statement {
|
set_discriminant = Some(Statement {
|
||||||
kind: StatementKind::SetDiscriminant { place: box (lhs), variant_index },
|
kind: StatementKind::SetDiscriminant { place: Box::new(lhs), variant_index },
|
||||||
source_info,
|
source_info,
|
||||||
});
|
});
|
||||||
lhs = tcx.mk_place_downcast(lhs, adt_def, variant_index);
|
lhs = tcx.mk_place_downcast(lhs, adt_def, variant_index);
|
||||||
|
@ -37,7 +37,7 @@ pub fn expand_aggregate<'tcx>(
|
||||||
// variant 0 (Unresumed).
|
// variant 0 (Unresumed).
|
||||||
let variant_index = VariantIdx::new(0);
|
let variant_index = VariantIdx::new(0);
|
||||||
set_discriminant = Some(Statement {
|
set_discriminant = Some(Statement {
|
||||||
kind: StatementKind::SetDiscriminant { place: box (lhs), variant_index },
|
kind: StatementKind::SetDiscriminant { place: Box::new(lhs), variant_index },
|
||||||
source_info,
|
source_info,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -66,7 +66,10 @@ pub fn expand_aggregate<'tcx>(
|
||||||
let field = Field::new(active_field_index.unwrap_or(i));
|
let field = Field::new(active_field_index.unwrap_or(i));
|
||||||
tcx.mk_place_field(lhs, field, ty)
|
tcx.mk_place_field(lhs, field, ty)
|
||||||
};
|
};
|
||||||
Statement { source_info, kind: StatementKind::Assign(box (lhs_field, Rvalue::Use(op))) }
|
Statement {
|
||||||
|
source_info,
|
||||||
|
kind: StatementKind::Assign(Box::new((lhs_field, Rvalue::Use(op)))),
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.chain(set_discriminant)
|
.chain(set_discriminant)
|
||||||
}
|
}
|
||||||
|
|
|
@ -680,12 +680,12 @@ where
|
||||||
let (ptr_next, cur_next) = if ptr_based {
|
let (ptr_next, cur_next) = if ptr_based {
|
||||||
(
|
(
|
||||||
Rvalue::Use(copy(cur.into())),
|
Rvalue::Use(copy(cur.into())),
|
||||||
Rvalue::BinaryOp(BinOp::Offset, box (move_(cur.into()), one)),
|
Rvalue::BinaryOp(BinOp::Offset, Box::new((move_(cur.into()), one))),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)),
|
Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)),
|
||||||
Rvalue::BinaryOp(BinOp::Add, box (move_(cur.into()), one)),
|
Rvalue::BinaryOp(BinOp::Add, Box::new((move_(cur.into()), one))),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -703,7 +703,10 @@ where
|
||||||
let loop_block = BasicBlockData {
|
let loop_block = BasicBlockData {
|
||||||
statements: vec![self.assign(
|
statements: vec![self.assign(
|
||||||
can_go,
|
can_go,
|
||||||
Rvalue::BinaryOp(BinOp::Eq, box (copy(Place::from(cur)), copy(length_or_end))),
|
Rvalue::BinaryOp(
|
||||||
|
BinOp::Eq,
|
||||||
|
Box::new((copy(Place::from(cur)), copy(length_or_end))),
|
||||||
|
),
|
||||||
)],
|
)],
|
||||||
is_cleanup: unwind.is_cleanup(),
|
is_cleanup: unwind.is_cleanup(),
|
||||||
terminator: Some(Terminator {
|
terminator: Some(Terminator {
|
||||||
|
@ -821,7 +824,7 @@ where
|
||||||
length_or_end,
|
length_or_end,
|
||||||
Rvalue::BinaryOp(
|
Rvalue::BinaryOp(
|
||||||
BinOp::Offset,
|
BinOp::Offset,
|
||||||
box (Operand::Copy(cur), Operand::Move(length)),
|
Box::new((Operand::Copy(cur), Operand::Move(length))),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -1032,14 +1035,17 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn constant_usize(&self, val: u16) -> Operand<'tcx> {
|
fn constant_usize(&self, val: u16) -> Operand<'tcx> {
|
||||||
Operand::Constant(box Constant {
|
Operand::Constant(Box::new(Constant {
|
||||||
span: self.source_info.span,
|
span: self.source_info.span,
|
||||||
user_ty: None,
|
user_ty: None,
|
||||||
literal: ty::Const::from_usize(self.tcx(), val.into()).into(),
|
literal: ty::Const::from_usize(self.tcx(), val.into()).into(),
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assign(&self, lhs: Place<'tcx>, rhs: Rvalue<'tcx>) -> Statement<'tcx> {
|
fn assign(&self, lhs: Place<'tcx>, rhs: Rvalue<'tcx>) -> Statement<'tcx> {
|
||||||
Statement { source_info: self.source_info, kind: StatementKind::Assign(box (lhs, rhs)) }
|
Statement {
|
||||||
|
source_info: self.source_info,
|
||||||
|
kind: StatementKind::Assign(Box::new((lhs, rhs))),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl<'tcx> MirPatch<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_assign(&mut self, loc: Location, place: Place<'tcx>, rv: Rvalue<'tcx>) {
|
pub fn add_assign(&mut self, loc: Location, place: Place<'tcx>, rv: Rvalue<'tcx>) {
|
||||||
self.add_statement(loc, StatementKind::Assign(box (place, rv)));
|
self.add_statement(loc, StatementKind::Assign(Box::new((place, rv))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply(self, body: &mut Body<'tcx>) {
|
pub fn apply(self, body: &mut Body<'tcx>) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue