-use crate::token::{self, Token, BinOpToken};
-use crate::symbol::kw;
use crate::ast::{self, BinOpKind};
+use crate::token::{self, BinOpToken, Token};
+use rustc_span::symbol::kw;
/// Associative operator with precedence.
///
/// The operator is right-associative
Right,
/// The operator is not associative
- None
+ None,
}
impl AssocOp {
// `<-` should probably be `< -`
token::LArrow => Some(Less),
_ if t.is_keyword(kw::As) => Some(As),
- _ => None
+ _ => None,
}
}
BinOpKind::BitXor => BitXor,
BinOpKind::BitOr => BitOr,
BinOpKind::And => LAnd,
- BinOpKind::Or => LOr
+ BinOpKind::Or => LOr,
}
}
// NOTE: it is a bug to have an operators that has same precedence but different fixities!
match *self {
Assign | AssignOp(_) => Fixity::Right,
- As | Multiply | Divide | Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd |
- BitXor | BitOr | Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual |
- LAnd | LOr | Colon => Fixity::Left,
- DotDot | DotDotEq => Fixity::None
+ As | Multiply | Divide | Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd
+ | BitXor | BitOr | Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual
+ | LAnd | LOr | Colon => Fixity::Left,
+ DotDot | DotDotEq => Fixity::None,
}
}
use AssocOp::*;
match *self {
Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual => true,
- Assign | AssignOp(_) | As | Multiply | Divide | Modulus | Add |
- Subtract | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd | LOr |
- DotDot | DotDotEq | Colon => false
+ Assign | AssignOp(_) | As | Multiply | Divide | Modulus | Add | Subtract
+ | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd | LOr | DotDot | DotDotEq
+ | Colon => false,
}
}
use AssocOp::*;
match *self {
Assign | AssignOp(_) => true,
- Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual | As | Multiply | Divide |
- Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd |
- LOr | DotDot | DotDotEq | Colon => false
+ Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual | As | Multiply
+ | Divide | Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd | BitXor
+ | BitOr | LAnd | LOr | DotDot | DotDotEq | Colon => false,
}
}
BitOr => Some(BinOpKind::BitOr),
LAnd => Some(BinOpKind::And),
LOr => Some(BinOpKind::Or),
- Assign | AssignOp(_) | As | DotDot | DotDotEq | Colon => None
+ Assign | AssignOp(_) | As | DotDot | DotDotEq | Colon => None,
}
}
match value.kind {
ast::ExprKind::Struct(..) => true,
- ast::ExprKind::Assign(ref lhs, ref rhs) |
- ast::ExprKind::AssignOp(_, ref lhs, ref rhs) |
- ast::ExprKind::Binary(_, ref lhs, ref rhs) => {
+ ast::ExprKind::Assign(ref lhs, ref rhs, _)
+ | ast::ExprKind::AssignOp(_, ref lhs, ref rhs)
+ | ast::ExprKind::Binary(_, ref lhs, ref rhs) => {
// X { y: 1 } + X { y: 2 }
contains_exterior_struct_lit(&lhs) || contains_exterior_struct_lit(&rhs)
}
- ast::ExprKind::Await(ref x) |
- ast::ExprKind::Unary(_, ref x) |
- ast::ExprKind::Cast(ref x, _) |
- ast::ExprKind::Type(ref x, _) |
- ast::ExprKind::Field(ref x, _) |
- ast::ExprKind::Index(ref x, _) => {
+ ast::ExprKind::Await(ref x)
+ | ast::ExprKind::Unary(_, ref x)
+ | ast::ExprKind::Cast(ref x, _)
+ | ast::ExprKind::Type(ref x, _)
+ | ast::ExprKind::Field(ref x, _)
+ | ast::ExprKind::Index(ref x, _) => {
// &X { y: 1 }, X { y: 1 }.y
contains_exterior_struct_lit(&x)
}