@@ -7,8 +7,8 @@ use crate::LangItem;
77use rustc_ast as ast;
88use rustc_ast:: util:: parser:: ExprPrecedence ;
99use rustc_ast:: { Attribute , FloatTy , IntTy , Label , LitKind , TraitObjectSyntax , UintTy } ;
10- pub use rustc_ast:: { BindingAnnotation , BorrowKind , ByRef , ImplPolarity , IsAuto } ;
11- pub use rustc_ast:: { CaptureBy , Movability , Mutability } ;
10+ pub use rustc_ast:: { BinOp , BinOpKind , BindingAnnotation , BorrowKind , ByRef , CaptureBy } ;
11+ pub use rustc_ast:: { ImplPolarity , IsAuto , Movability , Mutability , UnOp } ;
1212use rustc_ast:: { InlineAsmOptions , InlineAsmTemplatePiece } ;
1313use rustc_data_structures:: fingerprint:: Fingerprint ;
1414use rustc_data_structures:: fx:: FxHashMap ;
@@ -1174,155 +1174,6 @@ pub enum PatKind<'hir> {
11741174 Slice ( & ' hir [ Pat < ' hir > ] , Option < & ' hir Pat < ' hir > > , & ' hir [ Pat < ' hir > ] ) ,
11751175}
11761176
1177- #[ derive( Copy , Clone , PartialEq , Debug , HashStable_Generic ) ]
1178- pub enum BinOpKind {
1179- /// The `+` operator (addition).
1180- Add ,
1181- /// The `-` operator (subtraction).
1182- Sub ,
1183- /// The `*` operator (multiplication).
1184- Mul ,
1185- /// The `/` operator (division).
1186- Div ,
1187- /// The `%` operator (modulus).
1188- Rem ,
1189- /// The `&&` operator (logical and).
1190- And ,
1191- /// The `||` operator (logical or).
1192- Or ,
1193- /// The `^` operator (bitwise xor).
1194- BitXor ,
1195- /// The `&` operator (bitwise and).
1196- BitAnd ,
1197- /// The `|` operator (bitwise or).
1198- BitOr ,
1199- /// The `<<` operator (shift left).
1200- Shl ,
1201- /// The `>>` operator (shift right).
1202- Shr ,
1203- /// The `==` operator (equality).
1204- Eq ,
1205- /// The `<` operator (less than).
1206- Lt ,
1207- /// The `<=` operator (less than or equal to).
1208- Le ,
1209- /// The `!=` operator (not equal to).
1210- Ne ,
1211- /// The `>=` operator (greater than or equal to).
1212- Ge ,
1213- /// The `>` operator (greater than).
1214- Gt ,
1215- }
1216-
1217- impl BinOpKind {
1218- pub fn as_str ( self ) -> & ' static str {
1219- match self {
1220- BinOpKind :: Add => "+" ,
1221- BinOpKind :: Sub => "-" ,
1222- BinOpKind :: Mul => "*" ,
1223- BinOpKind :: Div => "/" ,
1224- BinOpKind :: Rem => "%" ,
1225- BinOpKind :: And => "&&" ,
1226- BinOpKind :: Or => "||" ,
1227- BinOpKind :: BitXor => "^" ,
1228- BinOpKind :: BitAnd => "&" ,
1229- BinOpKind :: BitOr => "|" ,
1230- BinOpKind :: Shl => "<<" ,
1231- BinOpKind :: Shr => ">>" ,
1232- BinOpKind :: Eq => "==" ,
1233- BinOpKind :: Lt => "<" ,
1234- BinOpKind :: Le => "<=" ,
1235- BinOpKind :: Ne => "!=" ,
1236- BinOpKind :: Ge => ">=" ,
1237- BinOpKind :: Gt => ">" ,
1238- }
1239- }
1240-
1241- pub fn is_lazy ( self ) -> bool {
1242- matches ! ( self , BinOpKind :: And | BinOpKind :: Or )
1243- }
1244-
1245- pub fn is_comparison ( self ) -> bool {
1246- match self {
1247- BinOpKind :: Eq
1248- | BinOpKind :: Lt
1249- | BinOpKind :: Le
1250- | BinOpKind :: Ne
1251- | BinOpKind :: Gt
1252- | BinOpKind :: Ge => true ,
1253- BinOpKind :: And
1254- | BinOpKind :: Or
1255- | BinOpKind :: Add
1256- | BinOpKind :: Sub
1257- | BinOpKind :: Mul
1258- | BinOpKind :: Div
1259- | BinOpKind :: Rem
1260- | BinOpKind :: BitXor
1261- | BinOpKind :: BitAnd
1262- | BinOpKind :: BitOr
1263- | BinOpKind :: Shl
1264- | BinOpKind :: Shr => false ,
1265- }
1266- }
1267-
1268- /// Returns `true` if the binary operator takes its arguments by value.
1269- pub fn is_by_value ( self ) -> bool {
1270- !self . is_comparison ( )
1271- }
1272- }
1273-
1274- impl Into < ast:: BinOpKind > for BinOpKind {
1275- fn into ( self ) -> ast:: BinOpKind {
1276- match self {
1277- BinOpKind :: Add => ast:: BinOpKind :: Add ,
1278- BinOpKind :: Sub => ast:: BinOpKind :: Sub ,
1279- BinOpKind :: Mul => ast:: BinOpKind :: Mul ,
1280- BinOpKind :: Div => ast:: BinOpKind :: Div ,
1281- BinOpKind :: Rem => ast:: BinOpKind :: Rem ,
1282- BinOpKind :: And => ast:: BinOpKind :: And ,
1283- BinOpKind :: Or => ast:: BinOpKind :: Or ,
1284- BinOpKind :: BitXor => ast:: BinOpKind :: BitXor ,
1285- BinOpKind :: BitAnd => ast:: BinOpKind :: BitAnd ,
1286- BinOpKind :: BitOr => ast:: BinOpKind :: BitOr ,
1287- BinOpKind :: Shl => ast:: BinOpKind :: Shl ,
1288- BinOpKind :: Shr => ast:: BinOpKind :: Shr ,
1289- BinOpKind :: Eq => ast:: BinOpKind :: Eq ,
1290- BinOpKind :: Lt => ast:: BinOpKind :: Lt ,
1291- BinOpKind :: Le => ast:: BinOpKind :: Le ,
1292- BinOpKind :: Ne => ast:: BinOpKind :: Ne ,
1293- BinOpKind :: Ge => ast:: BinOpKind :: Ge ,
1294- BinOpKind :: Gt => ast:: BinOpKind :: Gt ,
1295- }
1296- }
1297- }
1298-
1299- pub type BinOp = Spanned < BinOpKind > ;
1300-
1301- #[ derive( Copy , Clone , PartialEq , Debug , HashStable_Generic ) ]
1302- pub enum UnOp {
1303- /// The `*` operator (dereferencing).
1304- Deref ,
1305- /// The `!` operator (logical negation).
1306- Not ,
1307- /// The `-` operator (negation).
1308- Neg ,
1309- }
1310-
1311- impl UnOp {
1312- pub fn as_str ( self ) -> & ' static str {
1313- match self {
1314- Self :: Deref => "*" ,
1315- Self :: Not => "!" ,
1316- Self :: Neg => "-" ,
1317- }
1318- }
1319-
1320- /// Returns `true` if the unary operator takes its argument by value.
1321- pub fn is_by_value ( self ) -> bool {
1322- matches ! ( self , Self :: Neg | Self :: Not )
1323- }
1324- }
1325-
13261177/// A statement.
13271178#[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
13281179pub struct Stmt < ' hir > {
0 commit comments