@@ -17,13 +17,13 @@ pub struct Node {
1717#[ derive( Debug , PartialEq ) ]
1818pub enum Top {
1919 Program ( Program ) ,
20- Statement ( Vec < LocatedStatement > ) ,
20+ Statement ( Vec < Statement > ) ,
2121 Expression ( Expression ) ,
2222}
2323
2424#[ derive( Debug , PartialEq ) ]
2525pub struct Program {
26- pub statements : Vec < LocatedStatement > ,
26+ pub statements : Vec < Statement > ,
2727}
2828
2929#[ derive( Debug , PartialEq ) ]
@@ -38,12 +38,12 @@ pub struct Located<T> {
3838 pub node : T ,
3939}
4040
41- pub type LocatedStatement = Located < Statement > ;
41+ pub type Statement = Located < StatementType > ;
4242
4343/// Abstract syntax tree nodes for python statements.
4444#[ allow( clippy:: large_enum_variant) ]
4545#[ derive( Debug , PartialEq ) ]
46- pub enum Statement {
46+ pub enum StatementType {
4747 Break ,
4848 Continue ,
4949 Return {
@@ -85,58 +85,58 @@ pub enum Statement {
8585 } ,
8686 If {
8787 test : Expression ,
88- body : Vec < LocatedStatement > ,
89- orelse : Option < Vec < LocatedStatement > > ,
88+ body : Vec < Statement > ,
89+ orelse : Option < Vec < Statement > > ,
9090 } ,
9191 While {
9292 test : Expression ,
93- body : Vec < LocatedStatement > ,
94- orelse : Option < Vec < LocatedStatement > > ,
93+ body : Vec < Statement > ,
94+ orelse : Option < Vec < Statement > > ,
9595 } ,
9696 With {
9797 items : Vec < WithItem > ,
98- body : Vec < LocatedStatement > ,
98+ body : Vec < Statement > ,
9999 } ,
100100 For {
101101 target : Expression ,
102102 iter : Expression ,
103- body : Vec < LocatedStatement > ,
104- orelse : Option < Vec < LocatedStatement > > ,
103+ body : Vec < Statement > ,
104+ orelse : Option < Vec < Statement > > ,
105105 } ,
106106 AsyncFor {
107107 target : Expression ,
108108 iter : Expression ,
109- body : Vec < LocatedStatement > ,
110- orelse : Option < Vec < LocatedStatement > > ,
109+ body : Vec < Statement > ,
110+ orelse : Option < Vec < Statement > > ,
111111 } ,
112112 Raise {
113113 exception : Option < Expression > ,
114114 cause : Option < Expression > ,
115115 } ,
116116 Try {
117- body : Vec < LocatedStatement > ,
117+ body : Vec < Statement > ,
118118 handlers : Vec < ExceptHandler > ,
119- orelse : Option < Vec < LocatedStatement > > ,
120- finalbody : Option < Vec < LocatedStatement > > ,
119+ orelse : Option < Vec < Statement > > ,
120+ finalbody : Option < Vec < Statement > > ,
121121 } ,
122122 ClassDef {
123123 name : String ,
124- body : Vec < LocatedStatement > ,
124+ body : Vec < Statement > ,
125125 bases : Vec < Expression > ,
126126 keywords : Vec < Keyword > ,
127127 decorator_list : Vec < Expression > ,
128128 } ,
129129 FunctionDef {
130130 name : String ,
131131 args : Parameters ,
132- body : Vec < LocatedStatement > ,
132+ body : Vec < Statement > ,
133133 decorator_list : Vec < Expression > ,
134134 returns : Option < Expression > ,
135135 } ,
136136 AsyncFunctionDef {
137137 name : String ,
138138 args : Parameters ,
139- body : Vec < LocatedStatement > ,
139+ body : Vec < Statement > ,
140140 decorator_list : Vec < Expression > ,
141141 returns : Option < Expression > ,
142142 } ,
@@ -148,8 +148,10 @@ pub struct WithItem {
148148 pub optional_vars : Option < Expression > ,
149149}
150150
151+ pub type Expression = Located < ExpressionType > ;
152+
151153#[ derive( Debug , PartialEq ) ]
152- pub enum Expression {
154+ pub enum ExpressionType {
153155 BoolOp {
154156 a : Box < Expression > ,
155157 op : BooleanOperator ,
@@ -242,10 +244,10 @@ pub enum Expression {
242244impl Expression {
243245 /// Returns a short name for the node suitable for use in error messages.
244246 pub fn name ( & self ) -> & ' static str {
245- use self :: Expression :: * ;
247+ use self :: ExpressionType :: * ;
246248 use self :: StringGroup :: * ;
247249
248- match self {
250+ match & self . node {
249251 BoolOp { .. } | Binop { .. } | Unop { .. } => "operator" ,
250252 Subscript { .. } => "subscript" ,
251253 Await { .. } => "await expression" ,
@@ -330,7 +332,7 @@ pub struct Keyword {
330332pub struct ExceptHandler {
331333 pub typ : Option < Expression > ,
332334 pub name : Option < String > ,
333- pub body : Vec < LocatedStatement > ,
335+ pub body : Vec < Statement > ,
334336}
335337
336338#[ derive( Debug , PartialEq ) ]
0 commit comments