Skip to content

Commit

Permalink
Remove bin_op_to_assoc_op and invoke AssocOp::from_ast_binop dire…
Browse files Browse the repository at this point in the history
…ctly
  • Loading branch information
oli-obk committed Apr 11, 2024
1 parent 07a9854 commit 0c8aad6
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ impl<'a> State<'a> {
}

fn print_expr_binary(&mut self, op: hir::BinOp, lhs: &hir::Expr<'_>, rhs: &hir::Expr<'_>) {
let assoc_op = bin_op_to_assoc_op(op.node);
let assoc_op = AssocOp::from_ast_binop(op.node);
let prec = assoc_op.precedence() as i8;
let fixity = assoc_op.fixity();

Expand Down Expand Up @@ -2328,33 +2328,6 @@ fn stmt_ends_with_semi(stmt: &hir::StmtKind<'_>) -> bool {
}
}

fn bin_op_to_assoc_op(op: hir::BinOpKind) -> AssocOp {
use crate::hir::BinOpKind::*;
match op {
Add => AssocOp::Add,
Sub => AssocOp::Subtract,
Mul => AssocOp::Multiply,
Div => AssocOp::Divide,
Rem => AssocOp::Modulus,

And => AssocOp::LAnd,
Or => AssocOp::LOr,

BitXor => AssocOp::BitXor,
BitAnd => AssocOp::BitAnd,
BitOr => AssocOp::BitOr,
Shl => AssocOp::ShiftLeft,
Shr => AssocOp::ShiftRight,

Eq => AssocOp::Equal,
Lt => AssocOp::Less,
Le => AssocOp::LessEqual,
Ne => AssocOp::NotEqual,
Ge => AssocOp::GreaterEqual,
Gt => AssocOp::Greater,
}
}

/// Expressions that syntactically contain an "exterior" struct literal, i.e., not surrounded by any
/// parens or other delimiters, e.g., `X { y: 1 }`, `X { y: 1 }.method()`, `foo == X { y: 1 }` and
/// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not.
Expand Down

0 comments on commit 0c8aad6

Please sign in to comment.