1
Fork 0

Custom MIR: Support binary and unary operations

This commit is contained in:
Tomasz Miąsko 2023-01-19 00:00:00 +00:00
parent 4c83bd03a9
commit d3cfe97a8a
3 changed files with 60 additions and 0 deletions

View file

@ -141,6 +141,12 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
ExprKind::AddressOf { mutability, arg } => Ok(
Rvalue::AddressOf(*mutability, self.parse_place(*arg)?)
),
ExprKind::Binary { op, lhs, rhs } => Ok(
Rvalue::BinaryOp(*op, Box::new((self.parse_operand(*lhs)?, self.parse_operand(*rhs)?)))
),
ExprKind::Unary { op, arg } => Ok(
Rvalue::UnaryOp(*op, self.parse_operand(*arg)?)
),
_ => self.parse_operand(expr_id).map(Rvalue::Use),
)
}