Skip to content

Commit fe8955b

Browse files
csmoeoli-obk
authored andcommitted
BinOpKind
1 parent 3d5753f commit fe8955b

File tree

14 files changed

+297
-293
lines changed

14 files changed

+297
-293
lines changed

src/librustc/hir/lowering.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3314,24 +3314,24 @@ impl<'a> LoweringContext<'a> {
33143314
fn lower_binop(&mut self, b: BinOp) -> hir::BinOp {
33153315
Spanned {
33163316
node: match b.node {
3317-
BinOpKind::Add => hir::BiAdd,
3318-
BinOpKind::Sub => hir::BiSub,
3319-
BinOpKind::Mul => hir::BiMul,
3320-
BinOpKind::Div => hir::BiDiv,
3321-
BinOpKind::Rem => hir::BiRem,
3322-
BinOpKind::And => hir::BiAnd,
3323-
BinOpKind::Or => hir::BiOr,
3324-
BinOpKind::BitXor => hir::BiBitXor,
3325-
BinOpKind::BitAnd => hir::BiBitAnd,
3326-
BinOpKind::BitOr => hir::BiBitOr,
3327-
BinOpKind::Shl => hir::BiShl,
3328-
BinOpKind::Shr => hir::BiShr,
3329-
BinOpKind::Eq => hir::BiEq,
3330-
BinOpKind::Lt => hir::BiLt,
3331-
BinOpKind::Le => hir::BiLe,
3332-
BinOpKind::Ne => hir::BiNe,
3333-
BinOpKind::Ge => hir::BiGe,
3334-
BinOpKind::Gt => hir::BiGt,
3317+
BinOpKind::Add => hir::BinOpKind::Add,
3318+
BinOpKind::Sub => hir::BinOpKind::Sub,
3319+
BinOpKind::Mul => hir::BinOpKind::Mul,
3320+
BinOpKind::Div => hir::BinOpKind::Div,
3321+
BinOpKind::Rem => hir::BinOpKind::Rem,
3322+
BinOpKind::And => hir::BinOpKind::And,
3323+
BinOpKind::Or => hir::BinOpKind::Or,
3324+
BinOpKind::BitXor => hir::BinOpKind::BitXor,
3325+
BinOpKind::BitAnd => hir::BinOpKind::BitAnd,
3326+
BinOpKind::BitOr => hir::BinOpKind::BitOr,
3327+
BinOpKind::Shl => hir::BinOpKind::Shl,
3328+
BinOpKind::Shr => hir::BinOpKind::Shr,
3329+
BinOpKind::Eq => hir::BinOpKind::Eq,
3330+
BinOpKind::Lt => hir::BinOpKind::Lt,
3331+
BinOpKind::Le => hir::BinOpKind::Le,
3332+
BinOpKind::Ne => hir::BinOpKind::Ne,
3333+
BinOpKind::Ge => hir::BinOpKind::Ge,
3334+
BinOpKind::Gt => hir::BinOpKind::Gt,
33353335
},
33363336
span: b.span,
33373337
}

src/librustc/hir/mod.rs

Lines changed: 78 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// The Rust HIR.
1212

13-
pub use self::BinOp_::*;
1413
pub use self::BlockCheckMode::*;
1514
pub use self::CaptureClause::*;
1615
pub use self::Decl_::*;
@@ -941,98 +940,103 @@ impl Mutability {
941940
}
942941

943942
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, Hash)]
944-
pub enum BinOp_ {
943+
pub enum BinOpKind {
945944
/// The `+` operator (addition)
946-
BiAdd,
945+
Add,
947946
/// The `-` operator (subtraction)
948-
BiSub,
947+
Sub,
949948
/// The `*` operator (multiplication)
950-
BiMul,
949+
Mul,
951950
/// The `/` operator (division)
952-
BiDiv,
951+
Div,
953952
/// The `%` operator (modulus)
954-
BiRem,
953+
Rem,
955954
/// The `&&` operator (logical and)
956-
BiAnd,
955+
And,
957956
/// The `||` operator (logical or)
958-
BiOr,
957+
Or,
959958
/// The `^` operator (bitwise xor)
960-
BiBitXor,
959+
BitXor,
961960
/// The `&` operator (bitwise and)
962-
BiBitAnd,
961+
BitAnd,
963962
/// The `|` operator (bitwise or)
964-
BiBitOr,
963+
BitOr,
965964
/// The `<<` operator (shift left)
966-
BiShl,
965+
Shl,
967966
/// The `>>` operator (shift right)
968-
BiShr,
967+
Shr,
969968
/// The `==` operator (equality)
970-
BiEq,
969+
Eq,
971970
/// The `<` operator (less than)
972-
BiLt,
971+
Lt,
973972
/// The `<=` operator (less than or equal to)
974-
BiLe,
973+
Le,
975974
/// The `!=` operator (not equal to)
976-
BiNe,
975+
Ne,
977976
/// The `>=` operator (greater than or equal to)
978-
BiGe,
977+
Ge,
979978
/// The `>` operator (greater than)
980-
BiGt,
979+
Gt,
981980
}
982981

983-
impl BinOp_ {
982+
impl BinOpKind {
984983
pub fn as_str(self) -> &'static str {
985984
match self {
986-
BiAdd => "+",
987-
BiSub => "-",
988-
BiMul => "*",
989-
BiDiv => "/",
990-
BiRem => "%",
991-
BiAnd => "&&",
992-
BiOr => "||",
993-
BiBitXor => "^",
994-
BiBitAnd => "&",
995-
BiBitOr => "|",
996-
BiShl => "<<",
997-
BiShr => ">>",
998-
BiEq => "==",
999-
BiLt => "<",
1000-
BiLe => "<=",
1001-
BiNe => "!=",
1002-
BiGe => ">=",
1003-
BiGt => ">",
985+
BinOpKind::Add => "+",
986+
BinOpKind::Sub => "-",
987+
BinOpKind::Mul => "*",
988+
BinOpKind::Div => "/",
989+
BinOpKind::Rem => "%",
990+
BinOpKind::And => "&&",
991+
BinOpKind::Or => "||",
992+
BinOpKind::BitXor => "^",
993+
BinOpKind::BitAnd => "&",
994+
BinOpKind::BitOr => "|",
995+
BinOpKind::Shl => "<<",
996+
BinOpKind::Shr => ">>",
997+
BinOpKind::Eq => "==",
998+
BinOpKind::Lt => "<",
999+
BinOpKind::Le => "<=",
1000+
BinOpKind::Ne => "!=",
1001+
BinOpKind::Ge => ">=",
1002+
BinOpKind::Gt => ">",
10041003
}
10051004
}
10061005

10071006
pub fn is_lazy(self) -> bool {
10081007
match self {
1009-
BiAnd | BiOr => true,
1008+
BinOpKind::And | BinOpKind::Or => true,
10101009
_ => false,
10111010
}
10121011
}
10131012

10141013
pub fn is_shift(self) -> bool {
10151014
match self {
1016-
BiShl | BiShr => true,
1015+
BinOpKind::Shl | BinOpKind::Shr => true,
10171016
_ => false,
10181017
}
10191018
}
10201019

10211020
pub fn is_comparison(self) -> bool {
10221021
match self {
1023-
BiEq | BiLt | BiLe | BiNe | BiGt | BiGe => true,
1024-
BiAnd |
1025-
BiOr |
1026-
BiAdd |
1027-
BiSub |
1028-
BiMul |
1029-
BiDiv |
1030-
BiRem |
1031-
BiBitXor |
1032-
BiBitAnd |
1033-
BiBitOr |
1034-
BiShl |
1035-
BiShr => false,
1022+
BinOpKind::Eq |
1023+
BinOpKind::Lt |
1024+
BinOpKind::Le |
1025+
BinOpKind::Ne |
1026+
BinOpKind::Gt |
1027+
BinOpKind::Ge => true,
1028+
BinOpKind::And |
1029+
BinOpKind::Or |
1030+
BinOpKind::Add |
1031+
BinOpKind::Sub |
1032+
BinOpKind::Mul |
1033+
BinOpKind::Div |
1034+
BinOpKind::Rem |
1035+
BinOpKind::BitXor |
1036+
BinOpKind::BitAnd |
1037+
BinOpKind::BitOr |
1038+
BinOpKind::Shl |
1039+
BinOpKind::Shr => false,
10361040
}
10371041
}
10381042

@@ -1042,32 +1046,32 @@ impl BinOp_ {
10421046
}
10431047
}
10441048

1045-
impl Into<ast::BinOpKind> for BinOp_ {
1049+
impl Into<ast::BinOpKind> for BinOpKind {
10461050
fn into(self) -> ast::BinOpKind {
10471051
match self {
1048-
BiAdd => ast::BinOpKind::Add,
1049-
BiSub => ast::BinOpKind::Sub,
1050-
BiMul => ast::BinOpKind::Mul,
1051-
BiDiv => ast::BinOpKind::Div,
1052-
BiRem => ast::BinOpKind::Rem,
1053-
BiAnd => ast::BinOpKind::And,
1054-
BiOr => ast::BinOpKind::Or,
1055-
BiBitXor => ast::BinOpKind::BitXor,
1056-
BiBitAnd => ast::BinOpKind::BitAnd,
1057-
BiBitOr => ast::BinOpKind::BitOr,
1058-
BiShl => ast::BinOpKind::Shl,
1059-
BiShr => ast::BinOpKind::Shr,
1060-
BiEq => ast::BinOpKind::Eq,
1061-
BiLt => ast::BinOpKind::Lt,
1062-
BiLe => ast::BinOpKind::Le,
1063-
BiNe => ast::BinOpKind::Ne,
1064-
BiGe => ast::BinOpKind::Ge,
1065-
BiGt => ast::BinOpKind::Gt,
1052+
BinOpKind::Add => ast::BinOpKind::Add,
1053+
BinOpKind::Sub => ast::BinOpKind::Sub,
1054+
BinOpKind::Mul => ast::BinOpKind::Mul,
1055+
BinOpKind::Div => ast::BinOpKind::Div,
1056+
BinOpKind::Rem => ast::BinOpKind::Rem,
1057+
BinOpKind::And => ast::BinOpKind::And,
1058+
BinOpKind::Or => ast::BinOpKind::Or,
1059+
BinOpKind::BitXor => ast::BinOpKind::BitXor,
1060+
BinOpKind::BitAnd => ast::BinOpKind::BitAnd,
1061+
BinOpKind::BitOr => ast::BinOpKind::BitOr,
1062+
BinOpKind::Shl => ast::BinOpKind::Shl,
1063+
BinOpKind::Shr => ast::BinOpKind::Shr,
1064+
BinOpKind::Eq => ast::BinOpKind::Eq,
1065+
BinOpKind::Lt => ast::BinOpKind::Lt,
1066+
BinOpKind::Le => ast::BinOpKind::Le,
1067+
BinOpKind::Ne => ast::BinOpKind::Ne,
1068+
BinOpKind::Ge => ast::BinOpKind::Ge,
1069+
BinOpKind::Gt => ast::BinOpKind::Gt,
10661070
}
10671071
}
10681072
}
10691073

1070-
pub type BinOp = Spanned<BinOp_>;
1074+
pub type BinOp = Spanned<BinOpKind>;
10711075

10721076
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, Hash)]
10731077
pub enum UnOp {

src/librustc/hir/print.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,8 +1292,8 @@ impl<'a> State<'a> {
12921292
// These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is
12931293
// the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead
12941294
// of `(x as i32) < ...`. We need to convince it _not_ to do that.
1295-
(&hir::ExprCast { .. }, hir::BinOp_::BiLt) |
1296-
(&hir::ExprCast { .. }, hir::BinOp_::BiShl) => parser::PREC_FORCE_PAREN,
1295+
(&hir::ExprCast { .. }, hir::BinOpKind::Lt) |
1296+
(&hir::ExprCast { .. }, hir::BinOpKind::Shl) => parser::PREC_FORCE_PAREN,
12971297
_ => left_prec,
12981298
};
12991299

@@ -2413,30 +2413,30 @@ fn stmt_ends_with_semi(stmt: &hir::Stmt_) -> bool {
24132413
}
24142414
}
24152415

2416-
fn bin_op_to_assoc_op(op: hir::BinOp_) -> AssocOp {
2417-
use hir::BinOp_::*;
2416+
fn bin_op_to_assoc_op(op: hir::BinOpKind) -> AssocOp {
2417+
use hir::BinOpKind::*;
24182418
match op {
2419-
BiAdd => AssocOp::Add,
2420-
BiSub => AssocOp::Subtract,
2421-
BiMul => AssocOp::Multiply,
2422-
BiDiv => AssocOp::Divide,
2423-
BiRem => AssocOp::Modulus,
2424-
2425-
BiAnd => AssocOp::LAnd,
2426-
BiOr => AssocOp::LOr,
2427-
2428-
BiBitXor => AssocOp::BitXor,
2429-
BiBitAnd => AssocOp::BitAnd,
2430-
BiBitOr => AssocOp::BitOr,
2431-
BiShl => AssocOp::ShiftLeft,
2432-
BiShr => AssocOp::ShiftRight,
2433-
2434-
BiEq => AssocOp::Equal,
2435-
BiLt => AssocOp::Less,
2436-
BiLe => AssocOp::LessEqual,
2437-
BiNe => AssocOp::NotEqual,
2438-
BiGe => AssocOp::GreaterEqual,
2439-
BiGt => AssocOp::Greater,
2419+
Add => AssocOp::Add,
2420+
Sub => AssocOp::Subtract,
2421+
Mul => AssocOp::Multiply,
2422+
Div => AssocOp::Divide,
2423+
Rem => AssocOp::Modulus,
2424+
2425+
And => AssocOp::LAnd,
2426+
Or => AssocOp::LOr,
2427+
2428+
BitXor => AssocOp::BitXor,
2429+
BitAnd => AssocOp::BitAnd,
2430+
BitOr => AssocOp::BitOr,
2431+
Shl => AssocOp::ShiftLeft,
2432+
Shr => AssocOp::ShiftRight,
2433+
2434+
Eq => AssocOp::Equal,
2435+
Lt => AssocOp::Less,
2436+
Le => AssocOp::LessEqual,
2437+
Ne => AssocOp::NotEqual,
2438+
Ge => AssocOp::GreaterEqual,
2439+
Gt => AssocOp::Greater,
24402440
}
24412441
}
24422442

src/librustc/ich/impls_hir.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -437,28 +437,28 @@ impl_stable_hash_for!(enum hir::PatKind {
437437
Slice(one, two, three)
438438
});
439439

440-
impl_stable_hash_for!(enum hir::BinOp_ {
441-
BiAdd,
442-
BiSub,
443-
BiMul,
444-
BiDiv,
445-
BiRem,
446-
BiAnd,
447-
BiOr,
448-
BiBitXor,
449-
BiBitAnd,
450-
BiBitOr,
451-
BiShl,
452-
BiShr,
453-
BiEq,
454-
BiLt,
455-
BiLe,
456-
BiNe,
457-
BiGe,
458-
BiGt
459-
});
460-
461-
impl_stable_hash_for_spanned!(hir::BinOp_);
440+
impl_stable_hash_for!(enum hir::BinOpKind {
441+
Add,
442+
Sub,
443+
Mul,
444+
Div,
445+
Rem,
446+
And,
447+
Or,
448+
BitXor,
449+
BitAnd,
450+
BitOr,
451+
Shl,
452+
Shr,
453+
Eq,
454+
Lt,
455+
Le,
456+
Ne,
457+
Ge,
458+
Gt
459+
});
460+
461+
impl_stable_hash_for_spanned!(hir::BinOpKind);
462462

463463
impl_stable_hash_for!(enum hir::UnOp {
464464
UnDeref,

src/librustc/middle/region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,8 +943,8 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr:
943943
// scopes, meaning that temporaries cannot outlive them.
944944
// This ensures fixed size stacks.
945945

946-
hir::ExprBinary(codemap::Spanned { node: hir::BiAnd, .. }, _, ref r) |
947-
hir::ExprBinary(codemap::Spanned { node: hir::BiOr, .. }, _, ref r) => {
946+
hir::ExprKind::Binary(codemap::Spanned { node: hir::BinOpKind::And, .. }, _, ref r) |
947+
hir::ExprKind::Binary(codemap::Spanned { node: hir::BinOpKind::Or, .. }, _, ref r) => {
948948
// For shortcircuiting operators, mark the RHS as a terminating
949949
// scope since it only executes conditionally.
950950
terminating(r.hir_id.local_id);

0 commit comments

Comments
 (0)