@@ -34,13 +34,14 @@ use util::nodemap::{NodeMap, FxHashSet};
3434use  syntax_pos:: { Span ,  DUMMY_SP } ; 
3535use  syntax:: codemap:: { self ,  Spanned } ; 
3636use  syntax:: abi:: Abi ; 
37- use  syntax:: ast:: { Ident ,  Name ,  NodeId ,  DUMMY_NODE_ID ,  AsmDialect } ; 
37+ use  syntax:: ast:: { self ,   Ident ,  Name ,  NodeId ,  DUMMY_NODE_ID ,  AsmDialect } ; 
3838use  syntax:: ast:: { Attribute ,  Lit ,  StrStyle ,  FloatTy ,  IntTy ,  UintTy ,  MetaItem } ; 
3939use  syntax:: ext:: hygiene:: SyntaxContext ; 
4040use  syntax:: ptr:: P ; 
4141use  syntax:: symbol:: { Symbol ,  keywords} ; 
4242use  syntax:: tokenstream:: TokenStream ; 
4343use  syntax:: util:: ThinVec ; 
44+ use  syntax:: util:: parser:: ExprPrecedence ; 
4445use  ty:: AdtKind ; 
4546
4647use  rustc_data_structures:: indexed_vec; 
@@ -958,6 +959,31 @@ impl BinOp_ {
958959    } 
959960} 
960961
962+ impl  Into < ast:: BinOpKind >  for  BinOp_  { 
963+     fn  into ( self )  -> ast:: BinOpKind  { 
964+         match  self  { 
965+             BiAdd  => ast:: BinOpKind :: Add , 
966+             BiSub  => ast:: BinOpKind :: Sub , 
967+             BiMul  => ast:: BinOpKind :: Mul , 
968+             BiDiv  => ast:: BinOpKind :: Div , 
969+             BiRem  => ast:: BinOpKind :: Rem , 
970+             BiAnd  => ast:: BinOpKind :: And , 
971+             BiOr  => ast:: BinOpKind :: Or , 
972+             BiBitXor  => ast:: BinOpKind :: BitXor , 
973+             BiBitAnd  => ast:: BinOpKind :: BitAnd , 
974+             BiBitOr  => ast:: BinOpKind :: BitOr , 
975+             BiShl  => ast:: BinOpKind :: Shl , 
976+             BiShr  => ast:: BinOpKind :: Shr , 
977+             BiEq  => ast:: BinOpKind :: Eq , 
978+             BiLt  => ast:: BinOpKind :: Lt , 
979+             BiLe  => ast:: BinOpKind :: Le , 
980+             BiNe  => ast:: BinOpKind :: Ne , 
981+             BiGe  => ast:: BinOpKind :: Ge , 
982+             BiGt  => ast:: BinOpKind :: Gt , 
983+         } 
984+     } 
985+ } 
986+ 
961987pub  type  BinOp  = Spanned < BinOp_ > ; 
962988
963989#[ derive( Clone ,  PartialEq ,  Eq ,  RustcEncodable ,  RustcDecodable ,  Hash ,  Debug ,  Copy ) ]  
@@ -1166,6 +1192,42 @@ pub struct Expr {
11661192    pub  hir_id :  HirId , 
11671193} 
11681194
1195+ impl  Expr  { 
1196+     pub  fn  precedence ( & self )  -> ExprPrecedence  { 
1197+         match  self . node  { 
1198+             ExprBox ( _)  => ExprPrecedence :: Box , 
1199+             ExprArray ( _)  => ExprPrecedence :: Array , 
1200+             ExprCall ( ..)  => ExprPrecedence :: Call , 
1201+             ExprMethodCall ( ..)  => ExprPrecedence :: MethodCall , 
1202+             ExprTup ( _)  => ExprPrecedence :: Tup , 
1203+             ExprBinary ( op,  ..)  => ExprPrecedence :: Binary ( op. node . into ( ) ) , 
1204+             ExprUnary ( ..)  => ExprPrecedence :: Unary , 
1205+             ExprLit ( _)  => ExprPrecedence :: Lit , 
1206+             ExprType ( ..)  | ExprCast ( ..)  => ExprPrecedence :: Cast , 
1207+             ExprIf ( ..)  => ExprPrecedence :: If , 
1208+             ExprWhile ( ..)  => ExprPrecedence :: While , 
1209+             ExprLoop ( ..)  => ExprPrecedence :: Loop , 
1210+             ExprMatch ( ..)  => ExprPrecedence :: Match , 
1211+             ExprClosure ( ..)  => ExprPrecedence :: Closure , 
1212+             ExprBlock ( ..)  => ExprPrecedence :: Block , 
1213+             ExprAssign ( ..)  => ExprPrecedence :: Assign , 
1214+             ExprAssignOp ( ..)  => ExprPrecedence :: AssignOp , 
1215+             ExprField ( ..)  => ExprPrecedence :: Field , 
1216+             ExprTupField ( ..)  => ExprPrecedence :: TupField , 
1217+             ExprIndex ( ..)  => ExprPrecedence :: Index , 
1218+             ExprPath ( ..)  => ExprPrecedence :: Path , 
1219+             ExprAddrOf ( ..)  => ExprPrecedence :: AddrOf , 
1220+             ExprBreak ( ..)  => ExprPrecedence :: Break , 
1221+             ExprAgain ( ..)  => ExprPrecedence :: Continue , 
1222+             ExprRet ( ..)  => ExprPrecedence :: Ret , 
1223+             ExprInlineAsm ( ..)  => ExprPrecedence :: InlineAsm , 
1224+             ExprStruct ( ..)  => ExprPrecedence :: Struct , 
1225+             ExprRepeat ( ..)  => ExprPrecedence :: Repeat , 
1226+             ExprYield ( ..)  => ExprPrecedence :: Yield , 
1227+         } 
1228+     } 
1229+ } 
1230+ 
11691231impl  fmt:: Debug  for  Expr  { 
11701232    fn  fmt ( & self ,  f :  & mut  fmt:: Formatter )  -> fmt:: Result  { 
11711233        write ! ( f,  "expr({}: {})" ,  self . id, 
0 commit comments