]> git.lizzy.rs Git - rust.git/blob - clippy_lints/src/utils/higher.rs
Add a module to pretty-print suggestions
[rust.git] / clippy_lints / src / utils / higher.rs
1 //! This module contains functions for retrieve the original AST from lowered `hir`.
2
3 use rustc::hir;
4 use syntax::ast;
5
6 /// Convert a hir binary operator to the corresponding `ast` type.
7 pub fn binop(op: hir::BinOp_) -> ast::BinOpKind {
8     match op {
9         hir::BiEq => ast::BinOpKind::Eq,
10         hir::BiGe => ast::BinOpKind::Ge,
11         hir::BiGt => ast::BinOpKind::Gt,
12         hir::BiLe => ast::BinOpKind::Le,
13         hir::BiLt => ast::BinOpKind::Lt,
14         hir::BiNe => ast::BinOpKind::Ne,
15         hir::BiOr => ast::BinOpKind::Or,
16         hir::BiAdd => ast::BinOpKind::Add,
17         hir::BiAnd => ast::BinOpKind::And,
18         hir::BiBitAnd => ast::BinOpKind::BitAnd,
19         hir::BiBitOr => ast::BinOpKind::BitOr,
20         hir::BiBitXor => ast::BinOpKind::BitXor,
21         hir::BiDiv => ast::BinOpKind::Div,
22         hir::BiMul => ast::BinOpKind::Mul,
23         hir::BiRem => ast::BinOpKind::Rem,
24         hir::BiShl => ast::BinOpKind::Shl,
25         hir::BiShr => ast::BinOpKind::Shr,
26         hir::BiSub => ast::BinOpKind::Sub,
27     }
28 }