Promote Repeats to constants instead of statics
This commit is contained in:
parent
1688719214
commit
2508f17ac2
1 changed files with 19 additions and 4 deletions
|
|
@ -1002,10 +1002,25 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
|||
StatementKind::Assign(box (_, Rvalue::Repeat(ref mut operand, _))) => {
|
||||
let ty = operand.ty(local_decls, self.tcx);
|
||||
let span = statement.source_info.span;
|
||||
Rvalue::Use(mem::replace(
|
||||
operand,
|
||||
Operand::Copy(promoted_place(ty, span)),
|
||||
))
|
||||
|
||||
promoted.span = span;
|
||||
promoted.local_decls[RETURN_PLACE] =
|
||||
LocalDecl::new_return_place(ty, span);
|
||||
|
||||
let promoted_operand = Operand::Constant(Box::new(Constant {
|
||||
span,
|
||||
user_ty: None,
|
||||
literal: tcx.mk_const(ty::Const {
|
||||
ty,
|
||||
val: ty::ConstKind::Unevaluated(
|
||||
def_id,
|
||||
InternalSubsts::identity_for_item(tcx, def_id),
|
||||
Some(promoted_id),
|
||||
),
|
||||
}),
|
||||
}));
|
||||
|
||||
Rvalue::Use(mem::replace(operand, promoted_operand))
|
||||
}
|
||||
_ => bug!(),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue