@@ -36,7 +36,7 @@ use rustc_span::{Span, DUMMY_SP};
3636use std:: convert:: TryFrom ;
3737use std:: fmt;
3838use std:: mem;
39- use thin_vec:: ThinVec ;
39+ use thin_vec:: { thin_vec , ThinVec } ;
4040
4141/// A "Label" is an identifier of some point in sources,
4242/// e.g. in the following code:
@@ -90,7 +90,7 @@ pub struct Path {
9090 pub span : Span ,
9191 /// The segments in the path: the things separated by `::`.
9292 /// Global paths begin with `kw::PathRoot`.
93- pub segments : Vec < PathSegment > ,
93+ pub segments : ThinVec < PathSegment > ,
9494 pub tokens : Option < LazyAttrTokenStream > ,
9595}
9696
@@ -114,7 +114,7 @@ impl Path {
114114 // Convert a span and an identifier to the corresponding
115115 // one-segment path.
116116 pub fn from_ident ( ident : Ident ) -> Path {
117- Path { segments : vec ! [ PathSegment :: from_ident( ident) ] , span : ident. span , tokens : None }
117+ Path { segments : thin_vec ! [ PathSegment :: from_ident( ident) ] , span : ident. span , tokens : None }
118118 }
119119
120120 pub fn is_global ( & self ) -> bool {
@@ -718,10 +718,10 @@ pub enum PatKind {
718718
719719 /// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
720720 /// The `bool` is `true` in the presence of a `..`.
721- Struct ( Option < QSelf > , Path , Vec < PatField > , /* recovered */ bool ) ,
721+ Struct ( Option < P < QSelf > > , Path , Vec < PatField > , /* recovered */ bool ) ,
722722
723723 /// A tuple struct/variant pattern (`Variant(x, y, .., z)`).
724- TupleStruct ( Option < QSelf > , Path , Vec < P < Pat > > ) ,
724+ TupleStruct ( Option < P < QSelf > > , Path , Vec < P < Pat > > ) ,
725725
726726 /// An or-pattern `A | B | C`.
727727 /// Invariant: `pats.len() >= 2`.
@@ -731,7 +731,7 @@ pub enum PatKind {
731731 /// Unqualified path patterns `A::B::C` can legally refer to variants, structs, constants
732732 /// or associated constants. Qualified path patterns `<A>::B::C`/`<A as Trait>::B::C` can
733733 /// only legally refer to associated constants.
734- Path ( Option < QSelf > , Path ) ,
734+ Path ( Option < P < QSelf > > , Path ) ,
735735
736736 /// A tuple pattern (`(a, b)`).
737737 Tuple ( Vec < P < Pat > > ) ,
@@ -1272,6 +1272,18 @@ impl Expr {
12721272 }
12731273}
12741274
1275+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
1276+ pub struct Closure {
1277+ pub binder : ClosureBinder ,
1278+ pub capture_clause : CaptureBy ,
1279+ pub asyncness : Async ,
1280+ pub movability : Movability ,
1281+ pub fn_decl : P < FnDecl > ,
1282+ pub body : P < Expr > ,
1283+ /// The span of the argument block `|...|`.
1284+ pub fn_decl_span : Span ,
1285+ }
1286+
12751287/// Limit types of a range (inclusive or exclusive)
12761288#[ derive( Copy , Clone , PartialEq , Encodable , Decodable , Debug ) ]
12771289pub enum RangeLimits {
@@ -1281,6 +1293,20 @@ pub enum RangeLimits {
12811293 Closed ,
12821294}
12831295
1296+ /// A method call (e.g. `x.foo::<Bar, Baz>(a, b, c)`).
1297+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
1298+ pub struct MethodCall {
1299+ /// The method name and its generic arguments, e.g. `foo::<Bar, Baz>`.
1300+ pub seg : PathSegment ,
1301+ /// The receiver, e.g. `x`.
1302+ pub receiver : P < Expr > ,
1303+ /// The arguments, e.g. `a, b, c`.
1304+ pub args : Vec < P < Expr > > ,
1305+ /// The span of the function, without the dot and receiver e.g. `foo::<Bar,
1306+ /// Baz>(a, b, c)`.
1307+ pub span : Span ,
1308+ }
1309+
12841310#[ derive( Clone , Encodable , Decodable , Debug ) ]
12851311pub enum StructRest {
12861312 /// `..x`.
@@ -1293,7 +1319,7 @@ pub enum StructRest {
12931319
12941320#[ derive( Clone , Encodable , Decodable , Debug ) ]
12951321pub struct StructExpr {
1296- pub qself : Option < QSelf > ,
1322+ pub qself : Option < P < QSelf > > ,
12971323 pub path : Path ,
12981324 pub fields : Vec < ExprField > ,
12991325 pub rest : StructRest ,
@@ -1314,17 +1340,8 @@ pub enum ExprKind {
13141340 /// This also represents calling the constructor of
13151341 /// tuple-like ADTs such as tuple structs and enum variants.
13161342 Call ( P < Expr > , Vec < P < Expr > > ) ,
1317- /// A method call (`x.foo::<'static, Bar, Baz>(a, b, c, d)`)
1318- ///
1319- /// The `PathSegment` represents the method name and its generic arguments
1320- /// (within the angle brackets).
1321- /// The standalone `Expr` is the receiver expression.
1322- /// The vector of `Expr` is the arguments.
1323- /// `x.foo::<Bar, Baz>(a, b, c, d)` is represented as
1324- /// `ExprKind::MethodCall(PathSegment { foo, [Bar, Baz] }, x, [a, b, c, d])`.
1325- /// This `Span` is the span of the function, without the dot and receiver
1326- /// (e.g. `foo(a, b)` in `x.foo(a, b)`
1327- MethodCall ( PathSegment , P < Expr > , Vec < P < Expr > > , Span ) ,
1343+ /// A method call (e.g. `x.foo::<Bar, Baz>(a, b, c)`).
1344+ MethodCall ( Box < MethodCall > ) ,
13281345 /// A tuple (e.g., `(a, b, c, d)`).
13291346 Tup ( Vec < P < Expr > > ) ,
13301347 /// A binary operation (e.g., `a + b`, `a * b`).
@@ -1363,9 +1380,7 @@ pub enum ExprKind {
13631380 /// A `match` block.
13641381 Match ( P < Expr > , Vec < Arm > ) ,
13651382 /// A closure (e.g., `move |a, b, c| a + b + c`).
1366- ///
1367- /// The final span is the span of the argument block `|...|`.
1368- Closure ( ClosureBinder , CaptureBy , Async , Movability , P < FnDecl > , P < Expr > , Span ) ,
1383+ Closure ( Box < Closure > ) ,
13691384 /// A block (`'label: { ... }`).
13701385 Block ( P < Block > , Option < Label > ) ,
13711386 /// An async block (`async move { ... }`).
@@ -1403,7 +1418,7 @@ pub enum ExprKind {
14031418 /// parameters (e.g., `foo::bar::<baz>`).
14041419 ///
14051420 /// Optionally "qualified" (e.g., `<Vec<T> as SomeTrait>::SomeType`).
1406- Path ( Option < QSelf > , Path ) ,
1421+ Path ( Option < P < QSelf > > , Path ) ,
14071422
14081423 /// A referencing operation (`&a`, `&mut a`, `&raw const a` or `&raw mut a`).
14091424 AddrOf ( BorrowKind , Mutability , P < Expr > ) ,
@@ -2006,7 +2021,7 @@ pub enum TyKind {
20062021 /// "qualified", e.g., `<Vec<T> as SomeTrait>::SomeType`.
20072022 ///
20082023 /// Type parameters are stored in the `Path` itself.
2009- Path ( Option < QSelf > , Path ) ,
2024+ Path ( Option < P < QSelf > > , Path ) ,
20102025 /// A trait object type `Bound1 + Bound2 + Bound3`
20112026 /// where `Bound` is a trait or a lifetime.
20122027 TraitObject ( GenericBounds , TraitObjectSyntax ) ,
@@ -2138,7 +2153,7 @@ impl InlineAsmTemplatePiece {
21382153#[ derive( Clone , Encodable , Decodable , Debug ) ]
21392154pub struct InlineAsmSym {
21402155 pub id : NodeId ,
2141- pub qself : Option < QSelf > ,
2156+ pub qself : Option < P < QSelf > > ,
21422157 pub path : Path ,
21432158}
21442159
@@ -3031,28 +3046,28 @@ mod size_asserts {
30313046 static_assert_size ! ( AssocItemKind , 32 ) ;
30323047 static_assert_size ! ( Attribute , 32 ) ;
30333048 static_assert_size ! ( Block , 48 ) ;
3034- static_assert_size ! ( Expr , 104 ) ;
3035- static_assert_size ! ( ExprKind , 72 ) ;
3049+ static_assert_size ! ( Expr , 72 ) ;
3050+ static_assert_size ! ( ExprKind , 40 ) ;
30363051 static_assert_size ! ( Fn , 184 ) ;
30373052 static_assert_size ! ( ForeignItem , 96 ) ;
30383053 static_assert_size ! ( ForeignItemKind , 24 ) ;
30393054 static_assert_size ! ( GenericArg , 24 ) ;
3040- static_assert_size ! ( GenericBound , 88 ) ;
3055+ static_assert_size ! ( GenericBound , 72 ) ;
30413056 static_assert_size ! ( Generics , 72 ) ;
3042- static_assert_size ! ( Impl , 200 ) ;
3057+ static_assert_size ! ( Impl , 184 ) ;
30433058 static_assert_size ! ( Item , 184 ) ;
30443059 static_assert_size ! ( ItemKind , 112 ) ;
30453060 static_assert_size ! ( Lit , 48 ) ;
30463061 static_assert_size ! ( LitKind , 24 ) ;
30473062 static_assert_size ! ( Local , 72 ) ;
30483063 static_assert_size ! ( Param , 40 ) ;
3049- static_assert_size ! ( Pat , 120 ) ;
3050- static_assert_size ! ( Path , 40 ) ;
3064+ static_assert_size ! ( Pat , 88 ) ;
3065+ static_assert_size ! ( Path , 24 ) ;
30513066 static_assert_size ! ( PathSegment , 24 ) ;
3052- static_assert_size ! ( PatKind , 96 ) ;
3067+ static_assert_size ! ( PatKind , 64 ) ;
30533068 static_assert_size ! ( Stmt , 32 ) ;
30543069 static_assert_size ! ( StmtKind , 16 ) ;
3055- static_assert_size ! ( Ty , 96 ) ;
3056- static_assert_size ! ( TyKind , 72 ) ;
3070+ static_assert_size ! ( Ty , 64 ) ;
3071+ static_assert_size ! ( TyKind , 40 ) ;
30573072 // tidy-alphabetical-end
30583073}
0 commit comments