mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
Fix translation of Assign
/AssignOp
as rvalues
In code like `let x = y = z;`, `y = z` goes through `as_rvalue`, which didn't handle it. Now it translates the assignment and produces `()` directly.
This commit is contained in:
parent
869172305f
commit
89edd96be8
@ -189,6 +189,11 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
||||
block.and(Rvalue::Aggregate(AggregateKind::Adt(adt_def, variant_index, substs),
|
||||
fields))
|
||||
}
|
||||
ExprKind::Assign { .. } |
|
||||
ExprKind::AssignOp { .. } => {
|
||||
block = unpack!(this.stmt_expr(block, expr));
|
||||
block.and(this.unit_rvalue())
|
||||
}
|
||||
ExprKind::Literal { .. } |
|
||||
ExprKind::Block { .. } |
|
||||
ExprKind::Match { .. } |
|
||||
@ -201,8 +206,6 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
||||
ExprKind::Index { .. } |
|
||||
ExprKind::VarRef { .. } |
|
||||
ExprKind::SelfRef |
|
||||
ExprKind::Assign { .. } |
|
||||
ExprKind::AssignOp { .. } |
|
||||
ExprKind::Break { .. } |
|
||||
ExprKind::Continue { .. } |
|
||||
ExprKind::Return { .. } |
|
||||
|
@ -46,6 +46,10 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
||||
Operand::Constant(constant)
|
||||
}
|
||||
|
||||
pub fn unit_rvalue(&mut self) -> Rvalue<'tcx> {
|
||||
Rvalue::Aggregate(AggregateKind::Tuple, vec![])
|
||||
}
|
||||
|
||||
pub fn push_usize(&mut self,
|
||||
block: BasicBlock,
|
||||
scope_id: ScopeId,
|
||||
|
Loading…
Reference in New Issue
Block a user