Skip to content

Commit 9f45d58

Browse files
committed
Update Rust
See rust-lang/rust#31487
1 parent d492f22 commit 9f45d58

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/lib.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ extern crate syntax;
77
use std::borrow::ToOwned;
88
use std::rc::Rc;
99
use syntax::ast::{
10-
BinOp_, BiAdd, BiSub, BiMul, BiDiv, BiRem, BiShl, BiShr, UnNeg,
11-
Delimited, Expr, ExprAssign, ExprAssignOp, ExprBinary, ExprUnary,
12-
Ident, Mac, TokenTree
10+
BinOpKind, Delimited, Expr, ExprKind,
11+
Ident, Mac, TokenTree, UnOp
1312
};
1413
use rustc_plugin::Registry;
1514
use syntax::codemap::{DUMMY_SP, Span};
@@ -33,15 +32,15 @@ impl<'cx> Folder for WrappingFolder<'cx> {
3332

3433
fn fold_expr(&mut self, expr: P<Expr>) -> P<Expr> {
3534
expr.map(|expr| { match expr.node {
36-
ExprUnary(UnNeg, inner) => {
35+
ExprKind::Unary(UnOp::Neg, inner) => {
3736
// Recurse in sub-expressions
3837
let inner = self.fold_expr(inner);
3938
// Rewrite `-a` to `a.wrapping_neg()`
4039
let method = token::str_to_ident("wrapping_neg");
4140
self.cx.expr_method_call(expr.span, inner, method, vec![])
4241
.and_then(|e| e)
4342
}
44-
ExprBinary(op, left, right) => {
43+
ExprKind::Binary(op, left, right) => {
4544
// Recurse in sub-expressions
4645
let left = self.fold_expr(left);
4746
let right = self.fold_expr(right);
@@ -51,12 +50,12 @@ impl<'cx> Folder for WrappingFolder<'cx> {
5150
expr.span, left, method, vec![right]).and_then(|e| e),
5251
None =>
5352
Expr {
54-
node: ExprBinary(op, left, right),
53+
node: ExprKind::Binary(op, left, right),
5554
..expr
5655
},
5756
}
5857
},
59-
ExprAssignOp(op, target, source) => {
58+
ExprKind::AssignOp(op, target, source) => {
6059
// Recurse in sub-expressions
6160
let source = self.fold_expr(source);
6261
// Rewrite e.g. `a += b` to `a = a.wrapping_add(b)`
@@ -65,9 +64,9 @@ impl<'cx> Folder for WrappingFolder<'cx> {
6564
Some(method) => {
6665
let call = self.cx.expr_method_call(
6766
expr.span, target.clone(), method, vec![source]);
68-
ExprAssign(target, call)
67+
ExprKind::Assign(target, call)
6968
},
70-
None => ExprAssignOp(op, target, source),
69+
None => ExprKind::AssignOp(op, target, source),
7170
},
7271
..expr
7372
}
@@ -78,15 +77,15 @@ impl<'cx> Folder for WrappingFolder<'cx> {
7877
}
7978

8079
/// Returns the wrapping version of an operator, if applicable.
81-
fn wrapping_method(op: BinOp_) -> Option<Ident> {
80+
fn wrapping_method(op: BinOpKind) -> Option<Ident> {
8281
Some(token::str_to_ident(match op {
83-
BiAdd => "wrapping_add",
84-
BiSub => "wrapping_sub",
85-
BiMul => "wrapping_mul",
86-
BiDiv => "wrapping_div",
87-
BiRem => "wrapping_rem",
88-
BiShl => "wrapping_shl",
89-
BiShr => "wrapping_shr",
82+
BinOpKind::Add => "wrapping_add",
83+
BinOpKind::Sub => "wrapping_sub",
84+
BinOpKind::Mul => "wrapping_mul",
85+
BinOpKind::Div => "wrapping_div",
86+
BinOpKind::Rem => "wrapping_rem",
87+
BinOpKind::Shl => "wrapping_shl",
88+
BinOpKind::Shr => "wrapping_shr",
9089
_ => return None,
9190
}))
9291
}

0 commit comments

Comments
 (0)