Skip to content

Commit 0c8aad6

Browse files
committed
Remove bin_op_to_assoc_op and invoke AssocOp::from_ast_binop directly
1 parent 07a9854 commit 0c8aad6

File tree

1 file changed

+1
-28
lines changed
  • compiler/rustc_hir_pretty/src

1 file changed

+1
-28
lines changed

compiler/rustc_hir_pretty/src/lib.rs

+1-28
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ impl<'a> State<'a> {
11421142
}
11431143

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

@@ -2328,33 +2328,6 @@ fn stmt_ends_with_semi(stmt: &hir::StmtKind<'_>) -> bool {
23282328
}
23292329
}
23302330

2331-
fn bin_op_to_assoc_op(op: hir::BinOpKind) -> AssocOp {
2332-
use crate::hir::BinOpKind::*;
2333-
match op {
2334-
Add => AssocOp::Add,
2335-
Sub => AssocOp::Subtract,
2336-
Mul => AssocOp::Multiply,
2337-
Div => AssocOp::Divide,
2338-
Rem => AssocOp::Modulus,
2339-
2340-
And => AssocOp::LAnd,
2341-
Or => AssocOp::LOr,
2342-
2343-
BitXor => AssocOp::BitXor,
2344-
BitAnd => AssocOp::BitAnd,
2345-
BitOr => AssocOp::BitOr,
2346-
Shl => AssocOp::ShiftLeft,
2347-
Shr => AssocOp::ShiftRight,
2348-
2349-
Eq => AssocOp::Equal,
2350-
Lt => AssocOp::Less,
2351-
Le => AssocOp::LessEqual,
2352-
Ne => AssocOp::NotEqual,
2353-
Ge => AssocOp::GreaterEqual,
2354-
Gt => AssocOp::Greater,
2355-
}
2356-
}
2357-
23582331
/// Expressions that syntactically contain an "exterior" struct literal, i.e., not surrounded by any
23592332
/// parens or other delimiters, e.g., `X { y: 1 }`, `X { y: 1 }.method()`, `foo == X { y: 1 }` and
23602333
/// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not.

0 commit comments

Comments
 (0)