@@ -36,7 +36,7 @@ use rustc_span::{Span, DUMMY_SP};
36
36
use std:: convert:: TryFrom ;
37
37
use std:: fmt;
38
38
use std:: mem;
39
- use thin_vec:: ThinVec ;
39
+ use thin_vec:: { thin_vec , ThinVec } ;
40
40
41
41
/// A "Label" is an identifier of some point in sources,
42
42
/// e.g. in the following code:
@@ -90,7 +90,7 @@ pub struct Path {
90
90
pub span : Span ,
91
91
/// The segments in the path: the things separated by `::`.
92
92
/// Global paths begin with `kw::PathRoot`.
93
- pub segments : Vec < PathSegment > ,
93
+ pub segments : ThinVec < PathSegment > ,
94
94
pub tokens : Option < LazyAttrTokenStream > ,
95
95
}
96
96
@@ -114,7 +114,7 @@ impl Path {
114
114
// Convert a span and an identifier to the corresponding
115
115
// one-segment path.
116
116
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 }
118
118
}
119
119
120
120
pub fn is_global ( & self ) -> bool {
@@ -718,10 +718,10 @@ pub enum PatKind {
718
718
719
719
/// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
720
720
/// 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 ) ,
722
722
723
723
/// 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 > > ) ,
725
725
726
726
/// An or-pattern `A | B | C`.
727
727
/// Invariant: `pats.len() >= 2`.
@@ -731,7 +731,7 @@ pub enum PatKind {
731
731
/// Unqualified path patterns `A::B::C` can legally refer to variants, structs, constants
732
732
/// or associated constants. Qualified path patterns `<A>::B::C`/`<A as Trait>::B::C` can
733
733
/// only legally refer to associated constants.
734
- Path ( Option < QSelf > , Path ) ,
734
+ Path ( Option < P < QSelf > > , Path ) ,
735
735
736
736
/// A tuple pattern (`(a, b)`).
737
737
Tuple ( Vec < P < Pat > > ) ,
@@ -1272,6 +1272,18 @@ impl Expr {
1272
1272
}
1273
1273
}
1274
1274
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
+
1275
1287
/// Limit types of a range (inclusive or exclusive)
1276
1288
#[ derive( Copy , Clone , PartialEq , Encodable , Decodable , Debug ) ]
1277
1289
pub enum RangeLimits {
@@ -1281,6 +1293,20 @@ pub enum RangeLimits {
1281
1293
Closed ,
1282
1294
}
1283
1295
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
+
1284
1310
#[ derive( Clone , Encodable , Decodable , Debug ) ]
1285
1311
pub enum StructRest {
1286
1312
/// `..x`.
@@ -1293,7 +1319,7 @@ pub enum StructRest {
1293
1319
1294
1320
#[ derive( Clone , Encodable , Decodable , Debug ) ]
1295
1321
pub struct StructExpr {
1296
- pub qself : Option < QSelf > ,
1322
+ pub qself : Option < P < QSelf > > ,
1297
1323
pub path : Path ,
1298
1324
pub fields : Vec < ExprField > ,
1299
1325
pub rest : StructRest ,
@@ -1314,17 +1340,8 @@ pub enum ExprKind {
1314
1340
/// This also represents calling the constructor of
1315
1341
/// tuple-like ADTs such as tuple structs and enum variants.
1316
1342
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 > ) ,
1328
1345
/// A tuple (e.g., `(a, b, c, d)`).
1329
1346
Tup ( Vec < P < Expr > > ) ,
1330
1347
/// A binary operation (e.g., `a + b`, `a * b`).
@@ -1363,9 +1380,7 @@ pub enum ExprKind {
1363
1380
/// A `match` block.
1364
1381
Match ( P < Expr > , Vec < Arm > ) ,
1365
1382
/// 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 > ) ,
1369
1384
/// A block (`'label: { ... }`).
1370
1385
Block ( P < Block > , Option < Label > ) ,
1371
1386
/// An async block (`async move { ... }`).
@@ -1403,7 +1418,7 @@ pub enum ExprKind {
1403
1418
/// parameters (e.g., `foo::bar::<baz>`).
1404
1419
///
1405
1420
/// Optionally "qualified" (e.g., `<Vec<T> as SomeTrait>::SomeType`).
1406
- Path ( Option < QSelf > , Path ) ,
1421
+ Path ( Option < P < QSelf > > , Path ) ,
1407
1422
1408
1423
/// A referencing operation (`&a`, `&mut a`, `&raw const a` or `&raw mut a`).
1409
1424
AddrOf ( BorrowKind , Mutability , P < Expr > ) ,
@@ -2006,7 +2021,7 @@ pub enum TyKind {
2006
2021
/// "qualified", e.g., `<Vec<T> as SomeTrait>::SomeType`.
2007
2022
///
2008
2023
/// Type parameters are stored in the `Path` itself.
2009
- Path ( Option < QSelf > , Path ) ,
2024
+ Path ( Option < P < QSelf > > , Path ) ,
2010
2025
/// A trait object type `Bound1 + Bound2 + Bound3`
2011
2026
/// where `Bound` is a trait or a lifetime.
2012
2027
TraitObject ( GenericBounds , TraitObjectSyntax ) ,
@@ -2138,7 +2153,7 @@ impl InlineAsmTemplatePiece {
2138
2153
#[ derive( Clone , Encodable , Decodable , Debug ) ]
2139
2154
pub struct InlineAsmSym {
2140
2155
pub id : NodeId ,
2141
- pub qself : Option < QSelf > ,
2156
+ pub qself : Option < P < QSelf > > ,
2142
2157
pub path : Path ,
2143
2158
}
2144
2159
@@ -3031,28 +3046,28 @@ mod size_asserts {
3031
3046
static_assert_size ! ( AssocItemKind , 32 ) ;
3032
3047
static_assert_size ! ( Attribute , 32 ) ;
3033
3048
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 ) ;
3036
3051
static_assert_size ! ( Fn , 184 ) ;
3037
3052
static_assert_size ! ( ForeignItem , 96 ) ;
3038
3053
static_assert_size ! ( ForeignItemKind , 24 ) ;
3039
3054
static_assert_size ! ( GenericArg , 24 ) ;
3040
- static_assert_size ! ( GenericBound , 88 ) ;
3055
+ static_assert_size ! ( GenericBound , 72 ) ;
3041
3056
static_assert_size ! ( Generics , 72 ) ;
3042
- static_assert_size ! ( Impl , 200 ) ;
3057
+ static_assert_size ! ( Impl , 184 ) ;
3043
3058
static_assert_size ! ( Item , 184 ) ;
3044
3059
static_assert_size ! ( ItemKind , 112 ) ;
3045
3060
static_assert_size ! ( Lit , 48 ) ;
3046
3061
static_assert_size ! ( LitKind , 24 ) ;
3047
3062
static_assert_size ! ( Local , 72 ) ;
3048
3063
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 ) ;
3051
3066
static_assert_size ! ( PathSegment , 24 ) ;
3052
- static_assert_size ! ( PatKind , 96 ) ;
3067
+ static_assert_size ! ( PatKind , 64 ) ;
3053
3068
static_assert_size ! ( Stmt , 32 ) ;
3054
3069
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 ) ;
3057
3072
// tidy-alphabetical-end
3058
3073
}
0 commit comments