blob: 7cc78434cf4f2e989e01980ee914b93c2ea6894c [file] [log] [blame]
Alex Crichtonccbb45d2017-05-23 10:58:24 -07001use delimited::Delimited;
David Tolnayb79ee962016-09-04 09:39:20 -07002use super::*;
3
Alex Crichton62a0a592017-05-22 13:58:53 -07004ast_enum_of_structs! {
5 /// The different kinds of types recognized by the compiler
David Tolnayfd6bf5c2017-11-12 09:41:14 -08006 pub enum Type {
Alex Crichton62a0a592017-05-22 13:58:53 -07007 /// A variable-length array (`[T]`)
David Tolnayfd6bf5c2017-11-12 09:41:14 -08008 pub Slice(TypeSlice {
David Tolnay32954ef2017-12-26 22:43:16 -05009 pub bracket_token: token::Bracket,
David Tolnayeadbda32017-12-29 02:33:47 -050010 pub elem: Box<Type>,
Alex Crichton62a0a592017-05-22 13:58:53 -070011 }),
12 /// A fixed length array (`[T; n]`)
David Tolnayfd6bf5c2017-11-12 09:41:14 -080013 pub Array(TypeArray {
David Tolnay32954ef2017-12-26 22:43:16 -050014 pub bracket_token: token::Bracket,
David Tolnayeadbda32017-12-29 02:33:47 -050015 pub elem: Box<Type>,
David Tolnayf8db7ba2017-11-11 22:52:16 -080016 pub semi_token: Token![;],
David Tolnayeadbda32017-12-29 02:33:47 -050017 pub len: Expr,
Alex Crichton62a0a592017-05-22 13:58:53 -070018 }),
19 /// A raw pointer (`*const T` or `*mut T`)
David Tolnayfd6bf5c2017-11-12 09:41:14 -080020 pub Ptr(TypePtr {
David Tolnayf8db7ba2017-11-11 22:52:16 -080021 pub star_token: Token![*],
22 pub const_token: Option<Token![const]>,
David Tolnay136aaa32017-12-29 02:37:36 -050023 pub mutability: Option<Token![mut]>,
24 pub elem: Box<Type>,
Alex Crichton62a0a592017-05-22 13:58:53 -070025 }),
26 /// A reference (`&'a T` or `&'a mut T`)
David Tolnay0a89b4d2017-11-13 00:55:45 -080027 pub Reference(TypeReference {
David Tolnayf8db7ba2017-11-11 22:52:16 -080028 pub and_token: Token![&],
Alex Crichton62a0a592017-05-22 13:58:53 -070029 pub lifetime: Option<Lifetime>,
David Tolnay136aaa32017-12-29 02:37:36 -050030 pub mutability: Option<Token![mut]>,
31 pub elem: Box<Type>,
Alex Crichton62a0a592017-05-22 13:58:53 -070032 }),
33 /// A bare function (e.g. `fn(usize) -> bool`)
David Tolnayfd6bf5c2017-11-12 09:41:14 -080034 pub BareFn(TypeBareFn {
David Tolnaybe7a9592017-12-29 02:39:53 -050035 pub unsafety: Option<Token![unsafe]>,
36 pub abi: Option<Abi>,
37 pub fn_token: Token![fn],
38 pub lifetimes: Option<BoundLifetimes>,
39 pub paren_token: token::Paren,
40 pub inputs: Delimited<BareFnArg, Token![,]>,
41 pub variadic: Option<Token![...]>,
42 pub output: ReturnType,
Alex Crichton62a0a592017-05-22 13:58:53 -070043 }),
44 /// The never type (`!`)
David Tolnayfd6bf5c2017-11-12 09:41:14 -080045 pub Never(TypeNever {
David Tolnayf8db7ba2017-11-11 22:52:16 -080046 pub bang_token: Token![!],
Alex Crichtonccbb45d2017-05-23 10:58:24 -070047 }),
Alex Crichton62a0a592017-05-22 13:58:53 -070048 /// A tuple (`(A, B, C, D, ...)`)
David Tolnay05362582017-12-26 01:33:57 -050049 pub Tuple(TypeTuple {
David Tolnay32954ef2017-12-26 22:43:16 -050050 pub paren_token: token::Paren,
David Tolnayeadbda32017-12-29 02:33:47 -050051 pub elems: Delimited<Type, Token![,]>,
Alex Crichton62a0a592017-05-22 13:58:53 -070052 }),
53 /// A path (`module::module::...::Type`), optionally
54 /// "qualified", e.g. `<Vec<T> as SomeTrait>::SomeType`.
55 ///
Nika Layzellc08227a2017-12-04 16:30:17 -050056 /// Type arguments are stored in the Path itself
David Tolnayfd6bf5c2017-11-12 09:41:14 -080057 pub Path(TypePath {
Alex Crichton62a0a592017-05-22 13:58:53 -070058 pub qself: Option<QSelf>,
59 pub path: Path,
60 }),
61 /// A trait object type `Bound1 + Bound2 + Bound3`
62 /// where `Bound` is a trait or a lifetime.
David Tolnayfd6bf5c2017-11-12 09:41:14 -080063 pub TraitObject(TypeTraitObject {
David Tolnaye45b59f2017-12-25 18:44:49 -050064 pub dyn_token: Option<Token![dyn]>,
David Tolnayfd6bf5c2017-11-12 09:41:14 -080065 pub bounds: Delimited<TypeParamBound, Token![+]>,
Alex Crichton62a0a592017-05-22 13:58:53 -070066 }),
67 /// An `impl Bound1 + Bound2 + Bound3` type
68 /// where `Bound` is a trait or a lifetime.
David Tolnayfd6bf5c2017-11-12 09:41:14 -080069 pub ImplTrait(TypeImplTrait {
David Tolnayf8db7ba2017-11-11 22:52:16 -080070 pub impl_token: Token![impl],
David Tolnayfd6bf5c2017-11-12 09:41:14 -080071 pub bounds: Delimited<TypeParamBound, Token![+]>,
Alex Crichton62a0a592017-05-22 13:58:53 -070072 }),
73 /// No-op; kept solely so that we can pretty-print faithfully
David Tolnayfd6bf5c2017-11-12 09:41:14 -080074 pub Paren(TypeParen {
David Tolnay32954ef2017-12-26 22:43:16 -050075 pub paren_token: token::Paren,
David Tolnayeadbda32017-12-29 02:33:47 -050076 pub elem: Box<Type>,
Alex Crichton62a0a592017-05-22 13:58:53 -070077 }),
Michael Layzell93c36282017-06-04 20:43:14 -040078 /// No-op: kept solely so that we can pretty-print faithfully
David Tolnayfd6bf5c2017-11-12 09:41:14 -080079 pub Group(TypeGroup {
David Tolnay32954ef2017-12-26 22:43:16 -050080 pub group_token: token::Group,
David Tolnayeadbda32017-12-29 02:33:47 -050081 pub elem: Box<Type>,
Michael Layzell93c36282017-06-04 20:43:14 -040082 }),
David Tolnayfd6bf5c2017-11-12 09:41:14 -080083 /// TypeKind::Infer means the type should be inferred instead of it having been
Alex Crichton62a0a592017-05-22 13:58:53 -070084 /// specified. This can appear anywhere in a type.
David Tolnayfd6bf5c2017-11-12 09:41:14 -080085 pub Infer(TypeInfer {
David Tolnayf8db7ba2017-11-11 22:52:16 -080086 pub underscore_token: Token![_],
Alex Crichtonccbb45d2017-05-23 10:58:24 -070087 }),
Alex Crichton62a0a592017-05-22 13:58:53 -070088 /// A macro in the type position.
David Tolnaydecf28d2017-11-11 11:56:45 -080089 pub Macro(Macro),
Alex Crichton62a0a592017-05-22 13:58:53 -070090 }
91}
92
93ast_struct! {
Alex Crichton62a0a592017-05-22 13:58:53 -070094 /// A "Path" is essentially Rust's notion of a name.
David Tolnayb79ee962016-09-04 09:39:20 -070095 ///
Alex Crichton62a0a592017-05-22 13:58:53 -070096 /// It's represented as a sequence of identifiers,
97 /// along with a bunch of supporting information.
98 ///
99 /// E.g. `std::cmp::PartialEq`
100 pub struct Path {
101 /// A `::foo` path, is relative to the crate root rather than current
102 /// module (like paths in an import).
David Tolnayf8db7ba2017-11-11 22:52:16 -0800103 pub leading_colon: Option<Token![::]>,
Alex Crichton62a0a592017-05-22 13:58:53 -0700104 /// The segments in the path: the things separated by `::`.
David Tolnayf8db7ba2017-11-11 22:52:16 -0800105 pub segments: Delimited<PathSegment, Token![::]>,
Alex Crichton62a0a592017-05-22 13:58:53 -0700106 }
David Tolnayb79ee962016-09-04 09:39:20 -0700107}
108
David Tolnay570695e2017-06-03 16:15:13 -0700109impl Path {
110 pub fn global(&self) -> bool {
111 self.leading_colon.is_some()
112 }
113}
114
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700115#[cfg(feature = "printing")]
Nika Layzell6b38b132017-10-24 23:09:39 -0400116#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
117#[cfg_attr(feature = "clone-impls", derive(Clone))]
118pub struct PathTokens<'a>(pub &'a Option<QSelf>, pub &'a Path);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700119
David Tolnaydaaf7742016-10-03 11:11:43 -0700120impl<T> From<T> for Path
David Tolnay51382052017-12-27 13:46:21 -0500121where
122 T: Into<PathSegment>,
David Tolnaydaaf7742016-10-03 11:11:43 -0700123{
David Tolnay84aa0752016-10-02 23:01:13 -0700124 fn from(segment: T) -> Self {
125 Path {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700126 leading_colon: None,
127 segments: vec![(segment.into(), None)].into(),
David Tolnay84aa0752016-10-02 23:01:13 -0700128 }
129 }
130}
131
Alex Crichton62a0a592017-05-22 13:58:53 -0700132ast_struct! {
133 /// A segment of a path: an identifier, an optional lifetime, and a set of types.
134 ///
135 /// E.g. `std`, `String` or `Box<T>`
136 pub struct PathSegment {
137 /// The identifier portion of this path segment.
138 pub ident: Ident,
Nika Layzellc08227a2017-12-04 16:30:17 -0500139 /// Type/lifetime arguments attached to this path. They come in
Alex Crichton62a0a592017-05-22 13:58:53 -0700140 /// two flavors: `Path<A,B,C>` and `Path(A,B) -> C`. Note that
141 /// this is more than just simple syntactic sugar; the use of
142 /// parens affects the region binding rules, so we preserve the
143 /// distinction.
Nika Layzellc08227a2017-12-04 16:30:17 -0500144 pub arguments: PathArguments,
Alex Crichton62a0a592017-05-22 13:58:53 -0700145 }
David Tolnayb79ee962016-09-04 09:39:20 -0700146}
147
David Tolnaydaaf7742016-10-03 11:11:43 -0700148impl<T> From<T> for PathSegment
David Tolnay51382052017-12-27 13:46:21 -0500149where
150 T: Into<Ident>,
David Tolnaydaaf7742016-10-03 11:11:43 -0700151{
David Tolnay84aa0752016-10-02 23:01:13 -0700152 fn from(ident: T) -> Self {
David Tolnayb79ee962016-09-04 09:39:20 -0700153 PathSegment {
David Tolnay84aa0752016-10-02 23:01:13 -0700154 ident: ident.into(),
Nika Layzellc08227a2017-12-04 16:30:17 -0500155 arguments: PathArguments::None,
David Tolnayb79ee962016-09-04 09:39:20 -0700156 }
157 }
158}
159
Alex Crichton62a0a592017-05-22 13:58:53 -0700160ast_enum! {
Nika Layzellc08227a2017-12-04 16:30:17 -0500161 /// Arguments of a path segment.
Alex Crichton62a0a592017-05-22 13:58:53 -0700162 ///
163 /// E.g. `<A, B>` as in `Foo<A, B>` or `(A, B)` as in `Foo(A, B)`
Nika Layzellc08227a2017-12-04 16:30:17 -0500164 pub enum PathArguments {
David Tolnay570695e2017-06-03 16:15:13 -0700165 None,
Alex Crichton62a0a592017-05-22 13:58:53 -0700166 /// The `<'a, A, B, C>` in `foo::bar::baz::<'a, A, B, C>`
Nika Layzellc08227a2017-12-04 16:30:17 -0500167 AngleBracketed(AngleBracketedGenericArguments),
Alex Crichton62a0a592017-05-22 13:58:53 -0700168 /// The `(A, B)` and `C` in `Foo(A, B) -> C`
Nika Layzellc08227a2017-12-04 16:30:17 -0500169 Parenthesized(ParenthesizedGenericArguments),
Alex Crichton62a0a592017-05-22 13:58:53 -0700170 }
David Tolnayb79ee962016-09-04 09:39:20 -0700171}
172
Nika Layzellc08227a2017-12-04 16:30:17 -0500173impl Default for PathArguments {
David Tolnay570695e2017-06-03 16:15:13 -0700174 fn default() -> Self {
Nika Layzellc08227a2017-12-04 16:30:17 -0500175 PathArguments::None
David Tolnayb79ee962016-09-04 09:39:20 -0700176 }
David Tolnay570695e2017-06-03 16:15:13 -0700177}
David Tolnay5332d4b2016-10-30 14:25:22 -0700178
Nika Layzellc08227a2017-12-04 16:30:17 -0500179impl PathArguments {
David Tolnay5332d4b2016-10-30 14:25:22 -0700180 pub fn is_empty(&self) -> bool {
181 match *self {
Nika Layzellc08227a2017-12-04 16:30:17 -0500182 PathArguments::None => true,
183 PathArguments::AngleBracketed(ref bracketed) => bracketed.args.is_empty(),
184 PathArguments::Parenthesized(_) => false,
David Tolnay5332d4b2016-10-30 14:25:22 -0700185 }
186 }
David Tolnayb79ee962016-09-04 09:39:20 -0700187}
188
Nika Layzell357885a2017-12-04 15:47:07 -0500189ast_enum! {
190 /// A individual generic argument, like `'a`, `T`, or `Item=T`.
Nika Layzellc08227a2017-12-04 16:30:17 -0500191 pub enum GenericArgument {
Nika Layzell357885a2017-12-04 15:47:07 -0500192 /// The lifetime parameters for this path segment.
193 Lifetime(Lifetime),
194 /// The type parameters for this path segment, if present.
195 Type(Type),
196 /// Bindings (equality constraints) on associated types, if present.
197 ///
198 /// E.g., `Foo<A=Bar>`.
199 TypeBinding(TypeBinding),
Nika Layzellc680e612017-12-04 19:07:20 -0500200 /// Const expression. Must be inside of a block.
201 ///
202 /// NOTE: Identity expressions are represented as Type arguments, as
203 /// they are indistinguishable syntactically.
Nika Layzellce37f332017-12-05 12:01:22 -0500204 Const(Expr),
Nika Layzell357885a2017-12-04 15:47:07 -0500205 }
206}
207
Alex Crichton62a0a592017-05-22 13:58:53 -0700208ast_struct! {
209 /// A path like `Foo<'a, T>`
Nika Layzellc08227a2017-12-04 16:30:17 -0500210 pub struct AngleBracketedGenericArguments {
David Tolnay2d4e08a2017-12-28 23:54:07 -0500211 pub colon2_token: Option<Token![::]>,
David Tolnayf8db7ba2017-11-11 22:52:16 -0800212 pub lt_token: Token![<],
Nika Layzellc08227a2017-12-04 16:30:17 -0500213 pub args: Delimited<GenericArgument, Token![,]>,
David Tolnayf8db7ba2017-11-11 22:52:16 -0800214 pub gt_token: Token![>],
Alex Crichton62a0a592017-05-22 13:58:53 -0700215 }
216}
217
218ast_struct! {
219 /// Bind a type to an associated type: `A=Foo`.
220 pub struct TypeBinding {
221 pub ident: Ident,
David Tolnayf8db7ba2017-11-11 22:52:16 -0800222 pub eq_token: Token![=],
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800223 pub ty: Type,
Alex Crichton62a0a592017-05-22 13:58:53 -0700224 }
225}
226
Alex Crichton62a0a592017-05-22 13:58:53 -0700227ast_struct! {
228 /// A path like `Foo(A,B) -> C`
Nika Layzellc08227a2017-12-04 16:30:17 -0500229 pub struct ParenthesizedGenericArguments {
David Tolnay32954ef2017-12-26 22:43:16 -0500230 pub paren_token: token::Paren,
Alex Crichton62a0a592017-05-22 13:58:53 -0700231 /// `(A, B)`
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800232 pub inputs: Delimited<Type, Token![,]>,
Alex Crichton62a0a592017-05-22 13:58:53 -0700233 /// `C`
David Tolnayf93b90d2017-11-11 19:21:26 -0800234 pub output: ReturnType,
Alex Crichton62a0a592017-05-22 13:58:53 -0700235 }
236}
237
238ast_struct! {
239 pub struct PolyTraitRef {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700240 /// The `for<'a>` in `for<'a> Foo<&'a T>`
241 pub bound_lifetimes: Option<BoundLifetimes>,
David Tolnay7d38c7e2017-12-25 22:31:50 -0500242 /// The `Foo<&'a T>` in `for<'a> Foo<&'a T>`
Alex Crichton62a0a592017-05-22 13:58:53 -0700243 pub trait_ref: Path,
244 }
245}
246
247ast_struct! {
248 /// The explicit Self type in a "qualified path". The actual
249 /// path, including the trait and the associated item, is stored
250 /// separately. `position` represents the index of the associated
251 /// item qualified with this Self type.
David Tolnayb79ee962016-09-04 09:39:20 -0700252 ///
David Tolnaybcf26022017-12-25 22:10:52 -0500253 /// ```text
Alex Crichton62a0a592017-05-22 13:58:53 -0700254 /// <Vec<T> as a::b::Trait>::AssociatedItem
David Tolnaybcf26022017-12-25 22:10:52 -0500255 /// ^~~~~~ ~~~~~~~~~~~~~~^
Alex Crichton62a0a592017-05-22 13:58:53 -0700256 /// ty position = 3
David Tolnayb79ee962016-09-04 09:39:20 -0700257 ///
Alex Crichton62a0a592017-05-22 13:58:53 -0700258 /// <Vec<T>>::AssociatedItem
David Tolnaybcf26022017-12-25 22:10:52 -0500259 /// ^~~~~~ ^
Alex Crichton62a0a592017-05-22 13:58:53 -0700260 /// ty position = 0
261 /// ```
262 pub struct QSelf {
David Tolnayf8db7ba2017-11-11 22:52:16 -0800263 pub lt_token: Token![<],
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800264 pub ty: Box<Type>,
Michael Layzell3936ceb2017-07-08 00:28:36 -0400265 pub position: usize,
David Tolnayf8db7ba2017-11-11 22:52:16 -0800266 pub as_token: Option<Token![as]>,
267 pub gt_token: Token![>],
Alex Crichton62a0a592017-05-22 13:58:53 -0700268 }
269}
270
271ast_struct! {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700272 pub struct Abi {
David Tolnayf8db7ba2017-11-11 22:52:16 -0800273 pub extern_token: Token![extern],
David Tolnayd5125762017-12-29 02:42:17 -0500274 pub name: Option<Lit>,
Alex Crichton62a0a592017-05-22 13:58:53 -0700275 }
276}
277
278ast_struct! {
279 /// An argument in a function type.
280 ///
281 /// E.g. `bar: usize` as in `fn foo(bar: usize)`
282 pub struct BareFnArg {
David Tolnayf8db7ba2017-11-11 22:52:16 -0800283 pub name: Option<(BareFnArgName, Token![:])>,
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800284 pub ty: Type,
Alex Crichton62a0a592017-05-22 13:58:53 -0700285 }
286}
287
Alex Crichton23a15f62017-08-28 12:34:23 -0700288ast_enum! {
289 /// Names of arguments in the `BareFnArg` structure
290 pub enum BareFnArgName {
291 /// Argument with the provided name
292 Named(Ident),
293 /// Argument matched with `_`
David Tolnayf8db7ba2017-11-11 22:52:16 -0800294 Wild(Token![_]),
Alex Crichton23a15f62017-08-28 12:34:23 -0700295 }
296}
Alex Crichton62a0a592017-05-22 13:58:53 -0700297
298ast_enum! {
David Tolnayf93b90d2017-11-11 19:21:26 -0800299 pub enum ReturnType {
Alex Crichton62a0a592017-05-22 13:58:53 -0700300 /// Return type is not specified.
301 ///
302 /// Functions default to `()` and
303 /// closures default to inference. Span points to where return
304 /// type would be inserted.
305 Default,
306 /// Everything else
David Tolnay4a3f59a2017-12-28 21:21:12 -0500307 Type(Token![->], Box<Type>),
Alex Crichton62a0a592017-05-22 13:58:53 -0700308 }
David Tolnayb79ee962016-09-04 09:39:20 -0700309}
310
David Tolnay86eca752016-09-04 11:26:41 -0700311#[cfg(feature = "parsing")]
David Tolnay9d8f1972016-09-04 11:58:48 -0700312pub mod parsing {
313 use super::*;
Michael Layzell92639a52017-06-01 00:07:44 -0400314 use synom::Synom;
David Tolnayda4049b2016-09-04 10:59:23 -0700315
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800316 impl Synom for Type {
Michael Layzell9bf2b002017-06-04 18:49:53 -0400317 named!(parse -> Self, call!(ambig_ty, true));
David Tolnayb79ee962016-09-04 09:39:20 -0700318
Alex Crichton954046c2017-05-30 21:49:42 -0700319 fn description() -> Option<&'static str> {
320 Some("type")
321 }
322 }
David Tolnay0047c712016-12-21 21:59:25 -0500323
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800324 impl Type {
Michael Layzell9bf2b002017-06-04 18:49:53 -0400325 /// In some positions, types may not contain the `+` character, to
326 /// disambiguate them. For example in the expression `1 as T`, T may not
327 /// contain a `+` character.
328 ///
329 /// This parser does not allow a `+`, while the default parser does.
Michael Layzell6a5a1642017-06-04 19:35:15 -0400330 named!(pub without_plus -> Self, call!(ambig_ty, false));
Michael Layzell9bf2b002017-06-04 18:49:53 -0400331 }
332
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800333 named!(ambig_ty(allow_plus: bool) -> Type, alt!(
334 syn!(TypeGroup) => { Type::Group }
Michael Layzell93c36282017-06-04 20:43:14 -0400335 |
David Tolnay05362582017-12-26 01:33:57 -0500336 // must be before TypeTuple
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800337 syn!(TypeParen) => { Type::Paren }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400338 |
David Tolnay7d38c7e2017-12-25 22:31:50 -0500339 // must be before TypePath
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800340 syn!(Macro) => { Type::Macro }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400341 |
David Tolnay7d38c7e2017-12-25 22:31:50 -0500342 // must be before TypeTraitObject
343 call!(TypePath::parse, allow_plus) => { Type::Path }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400344 |
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800345 syn!(TypeSlice) => { Type::Slice }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400346 |
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800347 syn!(TypeArray) => { Type::Array }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400348 |
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800349 syn!(TypePtr) => { Type::Ptr }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400350 |
David Tolnay0a89b4d2017-11-13 00:55:45 -0800351 syn!(TypeReference) => { Type::Reference }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400352 |
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800353 syn!(TypeBareFn) => { Type::BareFn }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400354 |
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800355 syn!(TypeNever) => { Type::Never }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400356 |
David Tolnay05362582017-12-26 01:33:57 -0500357 syn!(TypeTuple) => { Type::Tuple }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400358 |
David Tolnay7d38c7e2017-12-25 22:31:50 -0500359 // Don't try parsing more than one trait bound if we aren't allowing it
360 call!(TypeTraitObject::parse, allow_plus) => { Type::TraitObject }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400361 |
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800362 syn!(TypeImplTrait) => { Type::ImplTrait }
Alex Crichton23a15f62017-08-28 12:34:23 -0700363 |
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800364 syn!(TypeInfer) => { Type::Infer }
Michael Layzell9bf2b002017-06-04 18:49:53 -0400365 ));
366
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800367 impl Synom for TypeSlice {
Michael Layzell92639a52017-06-01 00:07:44 -0400368 named!(parse -> Self, map!(
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800369 brackets!(syn!(Type)),
370 |(ty, b)| TypeSlice {
David Tolnayeadbda32017-12-29 02:33:47 -0500371 elem: Box::new(ty),
Michael Layzell92639a52017-06-01 00:07:44 -0400372 bracket_token: b,
Alex Crichton954046c2017-05-30 21:49:42 -0700373 }
Michael Layzell92639a52017-06-01 00:07:44 -0400374 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700375 }
David Tolnayb79ee962016-09-04 09:39:20 -0700376
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800377 impl Synom for TypeArray {
Michael Layzell92639a52017-06-01 00:07:44 -0400378 named!(parse -> Self, map!(
379 brackets!(do_parse!(
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800380 elem: syn!(Type) >>
David Tolnayf8db7ba2017-11-11 22:52:16 -0800381 semi: punct!(;) >>
Michael Layzelld7ee9102017-06-07 10:02:19 -0400382 len: syn!(Expr) >>
Alex Crichton954046c2017-05-30 21:49:42 -0700383 (elem, semi, len)
Michael Layzell92639a52017-06-01 00:07:44 -0400384 )),
385 |((elem, semi, len), brackets)| {
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800386 TypeArray {
David Tolnayeadbda32017-12-29 02:33:47 -0500387 elem: Box::new(elem),
388 len: len,
Michael Layzell92639a52017-06-01 00:07:44 -0400389 bracket_token: brackets,
390 semi_token: semi,
Alex Crichton954046c2017-05-30 21:49:42 -0700391 }
392 }
Michael Layzell92639a52017-06-01 00:07:44 -0400393 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700394 }
David Tolnayfa94b6f2016-10-05 23:26:11 -0700395
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800396 impl Synom for TypePtr {
Michael Layzell92639a52017-06-01 00:07:44 -0400397 named!(parse -> Self, do_parse!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800398 star: punct!(*) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400399 mutability: alt!(
David Tolnay24237fb2017-12-29 02:15:26 -0500400 keyword!(const) => { |c| (None, Some(c)) }
Michael Layzell92639a52017-06-01 00:07:44 -0400401 |
David Tolnay24237fb2017-12-29 02:15:26 -0500402 keyword!(mut) => { |m| (Some(m), None) }
Michael Layzell92639a52017-06-01 00:07:44 -0400403 ) >>
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800404 target: call!(Type::without_plus) >>
405 (TypePtr {
Michael Layzell92639a52017-06-01 00:07:44 -0400406 const_token: mutability.1,
407 star_token: star,
David Tolnay136aaa32017-12-29 02:37:36 -0500408 mutability: mutability.0,
409 elem: Box::new(target),
Michael Layzell92639a52017-06-01 00:07:44 -0400410 })
411 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700412 }
David Tolnay9d8f1972016-09-04 11:58:48 -0700413
David Tolnay0a89b4d2017-11-13 00:55:45 -0800414 impl Synom for TypeReference {
Michael Layzell92639a52017-06-01 00:07:44 -0400415 named!(parse -> Self, do_parse!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800416 amp: punct!(&) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400417 life: option!(syn!(Lifetime)) >>
David Tolnay24237fb2017-12-29 02:15:26 -0500418 mutability: option!(keyword!(mut)) >>
Michael Layzell9bf2b002017-06-04 18:49:53 -0400419 // & binds tighter than +, so we don't allow + here.
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800420 target: call!(Type::without_plus) >>
David Tolnay0a89b4d2017-11-13 00:55:45 -0800421 (TypeReference {
Michael Layzell92639a52017-06-01 00:07:44 -0400422 lifetime: life,
David Tolnay136aaa32017-12-29 02:37:36 -0500423 mutability: mutability,
424 elem: Box::new(target),
Michael Layzell92639a52017-06-01 00:07:44 -0400425 and_token: amp,
426 })
427 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700428 }
David Tolnay9d8f1972016-09-04 11:58:48 -0700429
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800430 impl Synom for TypeBareFn {
Michael Layzell92639a52017-06-01 00:07:44 -0400431 named!(parse -> Self, do_parse!(
432 lifetimes: option!(syn!(BoundLifetimes)) >>
David Tolnay9b258702017-12-29 02:24:41 -0500433 unsafety: option!(keyword!(unsafe)) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400434 abi: option!(syn!(Abi)) >>
David Tolnayf8db7ba2017-11-11 22:52:16 -0800435 fn_: keyword!(fn) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400436 parens: parens!(do_parse!(
437 inputs: call!(Delimited::parse_terminated) >>
438 variadic: option!(cond_reduce!(inputs.is_empty() || inputs.trailing_delim(),
David Tolnayf8db7ba2017-11-11 22:52:16 -0800439 punct!(...))) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400440 (inputs, variadic)
441 )) >>
David Tolnayf93b90d2017-11-11 19:21:26 -0800442 output: syn!(ReturnType) >>
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800443 (TypeBareFn {
David Tolnaybe7a9592017-12-29 02:39:53 -0500444 unsafety: unsafety,
445 abi: abi,
446 lifetimes: lifetimes,
447 output: output,
448 variadic: (parens.0).1,
449 fn_token: fn_,
450 paren_token: parens.1,
451 inputs: (parens.0).0,
Michael Layzell92639a52017-06-01 00:07:44 -0400452 })
453 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700454 }
David Tolnay9d8f1972016-09-04 11:58:48 -0700455
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800456 impl Synom for TypeNever {
Michael Layzell92639a52017-06-01 00:07:44 -0400457 named!(parse -> Self, map!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800458 punct!(!),
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800459 |b| TypeNever { bang_token: b }
Michael Layzell92639a52017-06-01 00:07:44 -0400460 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700461 }
David Tolnay9d8f1972016-09-04 11:58:48 -0700462
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800463 impl Synom for TypeInfer {
Alex Crichton23a15f62017-08-28 12:34:23 -0700464 named!(parse -> Self, map!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800465 punct!(_),
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800466 |u| TypeInfer { underscore_token: u }
Alex Crichton23a15f62017-08-28 12:34:23 -0700467 ));
468 }
469
David Tolnay05362582017-12-26 01:33:57 -0500470 impl Synom for TypeTuple {
Michael Layzell92639a52017-06-01 00:07:44 -0400471 named!(parse -> Self, do_parse!(
472 data: parens!(call!(Delimited::parse_terminated)) >>
David Tolnay05362582017-12-26 01:33:57 -0500473 (TypeTuple {
David Tolnayeadbda32017-12-29 02:33:47 -0500474 elems: data.0,
Michael Layzell92639a52017-06-01 00:07:44 -0400475 paren_token: data.1,
Michael Layzell92639a52017-06-01 00:07:44 -0400476 })
477 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700478 }
David Tolnay9d8f1972016-09-04 11:58:48 -0700479
David Tolnay7d38c7e2017-12-25 22:31:50 -0500480 impl TypePath {
481 named!(parse(allow_plus: bool) -> Self, do_parse!(
482 qpath: qpath >>
483 parenthesized: cond!(
484 qpath.1.segments.last().unwrap().item().arguments.is_empty(),
485 option!(syn!(ParenthesizedGenericArguments))
486 ) >>
487 cond!(allow_plus, not!(peek!(punct!(+)))) >>
488 ({
489 let (qself, mut path) = qpath;
490 if let Some(Some(parenthesized)) = parenthesized {
491 let parenthesized = PathArguments::Parenthesized(parenthesized);
492 path.segments.last_mut().unwrap().item_mut().arguments = parenthesized;
493 }
494 TypePath { qself: qself, path: path }
495 })
496 ));
497 }
David Tolnay9d8f1972016-09-04 11:58:48 -0700498
David Tolnay9636c052016-10-02 17:11:17 -0700499 named!(pub qpath -> (Option<QSelf>, Path), alt!(
Alex Crichton954046c2017-05-30 21:49:42 -0700500 map!(syn!(Path), |p| (None, p))
David Tolnay9636c052016-10-02 17:11:17 -0700501 |
502 do_parse!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800503 lt: punct!(<) >>
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800504 this: syn!(Type) >>
David Tolnay7d38c7e2017-12-25 22:31:50 -0500505 path: option!(tuple!(keyword!(as), syn!(Path))) >>
David Tolnayf8db7ba2017-11-11 22:52:16 -0800506 gt: punct!(>) >>
507 colon2: punct!(::) >>
Alex Crichton954046c2017-05-30 21:49:42 -0700508 rest: call!(Delimited::parse_separated_nonempty) >>
David Tolnay9636c052016-10-02 17:11:17 -0700509 ({
Michael Layzell3936ceb2017-07-08 00:28:36 -0400510 let (pos, as_, path) = match path {
Alex Crichton954046c2017-05-30 21:49:42 -0700511 Some((as_, mut path)) => {
David Tolnay9636c052016-10-02 17:11:17 -0700512 let pos = path.segments.len();
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700513 if !path.segments.is_empty() && !path.segments.trailing_delim() {
Alex Crichton954046c2017-05-30 21:49:42 -0700514 path.segments.push_trailing(colon2);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700515 }
Alex Crichton954046c2017-05-30 21:49:42 -0700516 for item in rest {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700517 path.segments.push(item);
518 }
Michael Layzell3936ceb2017-07-08 00:28:36 -0400519 (pos, Some(as_), path)
David Tolnay9636c052016-10-02 17:11:17 -0700520 }
521 None => {
Michael Layzell3936ceb2017-07-08 00:28:36 -0400522 (0, None, Path {
David Tolnay570695e2017-06-03 16:15:13 -0700523 leading_colon: Some(colon2),
David Tolnay9636c052016-10-02 17:11:17 -0700524 segments: rest,
David Tolnay570695e2017-06-03 16:15:13 -0700525 })
David Tolnay9636c052016-10-02 17:11:17 -0700526 }
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700527 };
528 (Some(QSelf {
David Tolnay570695e2017-06-03 16:15:13 -0700529 lt_token: lt,
530 ty: Box::new(this),
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700531 position: pos,
Michael Layzell3936ceb2017-07-08 00:28:36 -0400532 as_token: as_,
Alex Crichton954046c2017-05-30 21:49:42 -0700533 gt_token: gt,
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700534 }), path)
David Tolnay9636c052016-10-02 17:11:17 -0700535 })
536 )
David Tolnay6cd2a232016-10-24 22:41:08 -0700537 |
David Tolnayf8db7ba2017-11-11 22:52:16 -0800538 map!(keyword!(self), |s| (None, s.into()))
David Tolnay9d8f1972016-09-04 11:58:48 -0700539 ));
David Tolnayb79ee962016-09-04 09:39:20 -0700540
Nika Layzellc08227a2017-12-04 16:30:17 -0500541 impl Synom for ParenthesizedGenericArguments {
Michael Layzell92639a52017-06-01 00:07:44 -0400542 named!(parse -> Self, do_parse!(
543 data: parens!(call!(Delimited::parse_terminated)) >>
David Tolnayf93b90d2017-11-11 19:21:26 -0800544 output: syn!(ReturnType) >>
Nika Layzellc08227a2017-12-04 16:30:17 -0500545 (ParenthesizedGenericArguments {
Michael Layzell92639a52017-06-01 00:07:44 -0400546 paren_token: data.1,
547 inputs: data.0,
548 output: output,
549 })
550 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700551 }
552
David Tolnayf93b90d2017-11-11 19:21:26 -0800553 impl Synom for ReturnType {
Michael Layzell92639a52017-06-01 00:07:44 -0400554 named!(parse -> Self, alt!(
555 do_parse!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800556 arrow: punct!(->) >>
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800557 ty: syn!(Type) >>
David Tolnay4a3f59a2017-12-28 21:21:12 -0500558 (ReturnType::Type(arrow, Box::new(ty)))
Michael Layzell92639a52017-06-01 00:07:44 -0400559 )
560 |
David Tolnayf93b90d2017-11-11 19:21:26 -0800561 epsilon!() => { |_| ReturnType::Default }
Michael Layzell92639a52017-06-01 00:07:44 -0400562 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700563 }
564
David Tolnay7d38c7e2017-12-25 22:31:50 -0500565 impl TypeTraitObject {
566 // Only allow multiple trait references if allow_plus is true.
567 named!(parse(allow_plus: bool) -> Self, do_parse!(
568 dyn_token: option!(keyword!(dyn)) >>
569 bounds: alt!(
570 cond_reduce!(allow_plus, call!(Delimited::parse_terminated_nonempty))
571 |
572 syn!(TypeParamBound) => { |x| vec![x].into() }
573 ) >>
574 (TypeTraitObject {
575 dyn_token: dyn_token,
576 bounds: bounds,
577 })
578 ));
579 }
David Tolnay6414da72016-10-08 00:55:17 -0700580
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800581 impl Synom for TypeImplTrait {
Michael Layzell92639a52017-06-01 00:07:44 -0400582 named!(parse -> Self, do_parse!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800583 impl_: keyword!(impl) >>
Michael Layzell9bf2b002017-06-04 18:49:53 -0400584 // NOTE: rust-lang/rust#34511 includes discussion about whether or
585 // not + should be allowed in ImplTrait directly without ().
Nika Layzellb49a9e52017-12-05 13:31:52 -0500586 elem: call!(Delimited::parse_terminated_nonempty) >>
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800587 (TypeImplTrait {
Michael Layzell92639a52017-06-01 00:07:44 -0400588 impl_token: impl_,
589 bounds: elem,
590 })
591 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700592 }
David Tolnayb79ee962016-09-04 09:39:20 -0700593
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800594 impl Synom for TypeGroup {
Michael Layzell93c36282017-06-04 20:43:14 -0400595 named!(parse -> Self, do_parse!(
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800596 data: grouped!(syn!(Type)) >>
597 (TypeGroup {
Michael Layzell93c36282017-06-04 20:43:14 -0400598 group_token: data.1,
David Tolnayeadbda32017-12-29 02:33:47 -0500599 elem: Box::new(data.0),
Michael Layzell93c36282017-06-04 20:43:14 -0400600 })
601 ));
602 }
603
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800604 impl Synom for TypeParen {
Michael Layzell92639a52017-06-01 00:07:44 -0400605 named!(parse -> Self, do_parse!(
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800606 data: parens!(syn!(Type)) >>
607 (TypeParen {
Michael Layzell92639a52017-06-01 00:07:44 -0400608 paren_token: data.1,
David Tolnayeadbda32017-12-29 02:33:47 -0500609 elem: Box::new(data.0),
Michael Layzell92639a52017-06-01 00:07:44 -0400610 })
611 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700612 }
David Tolnayb79ee962016-09-04 09:39:20 -0700613
Alex Crichton954046c2017-05-30 21:49:42 -0700614 impl Synom for Path {
Michael Layzell92639a52017-06-01 00:07:44 -0400615 named!(parse -> Self, do_parse!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800616 colon: option!(punct!(::)) >>
David Tolnaye45b59f2017-12-25 18:44:49 -0500617 segments: call!(Delimited::<PathSegment, Token![::]>::parse_separated_nonempty) >>
618 cond_reduce!(segments.first().map_or(true, |seg| seg.item().ident != "dyn"), epsilon!()) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400619 (Path {
David Tolnay570695e2017-06-03 16:15:13 -0700620 leading_colon: colon,
Michael Layzell92639a52017-06-01 00:07:44 -0400621 segments: segments,
Michael Layzell92639a52017-06-01 00:07:44 -0400622 })
623 ));
Alex Crichton36e91bf2017-07-06 14:59:56 -0700624
625 fn description() -> Option<&'static str> {
626 Some("path")
627 }
Alex Crichton954046c2017-05-30 21:49:42 -0700628 }
David Tolnay9d8f1972016-09-04 11:58:48 -0700629
Nika Layzellc680e612017-12-04 19:07:20 -0500630 #[cfg(not(feature = "full"))]
Nika Layzellc08227a2017-12-04 16:30:17 -0500631 impl Synom for GenericArgument {
Nika Layzell357885a2017-12-04 15:47:07 -0500632 named!(parse -> Self, alt!(
Nika Layzellc08227a2017-12-04 16:30:17 -0500633 call!(ty_no_eq_after) => { GenericArgument::Type }
Nika Layzell357885a2017-12-04 15:47:07 -0500634 |
Nika Layzellc08227a2017-12-04 16:30:17 -0500635 syn!(Lifetime) => { GenericArgument::Lifetime }
Nika Layzell357885a2017-12-04 15:47:07 -0500636 |
Nika Layzellc08227a2017-12-04 16:30:17 -0500637 syn!(TypeBinding) => { GenericArgument::TypeBinding }
Nika Layzell357885a2017-12-04 15:47:07 -0500638 ));
639 }
640
Nika Layzellc680e612017-12-04 19:07:20 -0500641 #[cfg(feature = "full")]
642 impl Synom for GenericArgument {
643 named!(parse -> Self, alt!(
644 call!(ty_no_eq_after) => { GenericArgument::Type }
645 |
646 syn!(Lifetime) => { GenericArgument::Lifetime }
647 |
648 syn!(TypeBinding) => { GenericArgument::TypeBinding }
649 |
David Tolnay8c91b882017-12-28 23:04:32 -0500650 syn!(ExprLit) => { |l| GenericArgument::Const(Expr::Lit(l).into()) }
Nika Layzellce37f332017-12-05 12:01:22 -0500651 |
David Tolnay8c91b882017-12-28 23:04:32 -0500652 syn!(ExprBlock) => { |b| GenericArgument::Const(Expr::Block(b).into()) }
Nika Layzellc680e612017-12-04 19:07:20 -0500653 ));
654 }
655
Nika Layzellc08227a2017-12-04 16:30:17 -0500656 impl Synom for AngleBracketedGenericArguments {
Nika Layzell357885a2017-12-04 15:47:07 -0500657 named!(parse -> Self, do_parse!(
David Tolnay2d4e08a2017-12-28 23:54:07 -0500658 colon2: option!(punct!(::)) >>
Nika Layzell357885a2017-12-04 15:47:07 -0500659 lt: punct!(<) >>
660 args: call!(Delimited::parse_terminated) >>
661 gt: punct!(>) >>
Nika Layzellc08227a2017-12-04 16:30:17 -0500662 (AngleBracketedGenericArguments {
David Tolnay2d4e08a2017-12-28 23:54:07 -0500663 colon2_token: colon2,
Nika Layzell357885a2017-12-04 15:47:07 -0500664 lt_token: lt,
665 args: args,
666 gt_token: gt,
667 })
668 ));
669 }
670
Alex Crichton954046c2017-05-30 21:49:42 -0700671 impl Synom for PathSegment {
Michael Layzell92639a52017-06-01 00:07:44 -0400672 named!(parse -> Self, alt!(
673 do_parse!(
David Tolnay570695e2017-06-03 16:15:13 -0700674 ident: syn!(Ident) >>
Nika Layzellc08227a2017-12-04 16:30:17 -0500675 arguments: syn!(AngleBracketedGenericArguments) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400676 (PathSegment {
David Tolnay570695e2017-06-03 16:15:13 -0700677 ident: ident,
Nika Layzellc08227a2017-12-04 16:30:17 -0500678 arguments: PathArguments::AngleBracketed(arguments),
Michael Layzell92639a52017-06-01 00:07:44 -0400679 })
680 )
681 |
682 mod_style_path_segment
683 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700684 }
David Tolnay570695e2017-06-03 16:15:13 -0700685
David Tolnayd60cfec2017-12-29 00:21:38 -0500686 named!(pub ty_no_eq_after -> Type, terminated!(syn!(Type), not!(punct!(=))));
David Tolnay9d8f1972016-09-04 11:58:48 -0700687
Alex Crichton954046c2017-05-30 21:49:42 -0700688 impl Path {
Michael Layzell92639a52017-06-01 00:07:44 -0400689 named!(pub parse_mod_style -> Self, do_parse!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800690 colon: option!(punct!(::)) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400691 segments: call!(Delimited::parse_separated_nonempty_with,
692 mod_style_path_segment) >>
693 (Path {
David Tolnay570695e2017-06-03 16:15:13 -0700694 leading_colon: colon,
Michael Layzell92639a52017-06-01 00:07:44 -0400695 segments: segments,
Michael Layzell92639a52017-06-01 00:07:44 -0400696 })
697 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700698 }
Arnavionf2dada12017-04-20 23:55:20 -0700699
700 named!(mod_style_path_segment -> PathSegment, alt!(
David Tolnay5f332a92017-12-26 00:42:45 -0500701 syn!(Ident) => { Into::into }
Arnavionf2dada12017-04-20 23:55:20 -0700702 |
David Tolnay5f332a92017-12-26 00:42:45 -0500703 keyword!(super) => { Into::into }
704 |
705 keyword!(self) => { Into::into }
706 |
707 keyword!(Self) => { Into::into }
708 |
709 keyword!(crate) => { Into::into }
Arnavionf2dada12017-04-20 23:55:20 -0700710 ));
711
Alex Crichton954046c2017-05-30 21:49:42 -0700712 impl Synom for TypeBinding {
Michael Layzell92639a52017-06-01 00:07:44 -0400713 named!(parse -> Self, do_parse!(
714 id: syn!(Ident) >>
David Tolnayf8db7ba2017-11-11 22:52:16 -0800715 eq: punct!(=) >>
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800716 ty: syn!(Type) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400717 (TypeBinding {
718 ident: id,
719 eq_token: eq,
720 ty: ty,
721 })
722 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700723 }
724
725 impl Synom for PolyTraitRef {
Michael Layzell92639a52017-06-01 00:07:44 -0400726 named!(parse -> Self, do_parse!(
727 bound_lifetimes: option!(syn!(BoundLifetimes)) >>
728 trait_ref: syn!(Path) >>
729 parenthesized: option!(cond_reduce!(
Nika Layzellc08227a2017-12-04 16:30:17 -0500730 trait_ref.segments.get(trait_ref.segments.len() - 1).item().arguments.is_empty(),
731 syn!(ParenthesizedGenericArguments)
Michael Layzell92639a52017-06-01 00:07:44 -0400732 )) >>
733 ({
734 let mut trait_ref = trait_ref;
735 if let Some(parenthesized) = parenthesized {
Nika Layzellc08227a2017-12-04 16:30:17 -0500736 let parenthesized = PathArguments::Parenthesized(parenthesized);
Michael Layzell92639a52017-06-01 00:07:44 -0400737 let len = trait_ref.segments.len();
Nika Layzellc08227a2017-12-04 16:30:17 -0500738 trait_ref.segments.get_mut(len - 1).item_mut().arguments = parenthesized;
Michael Layzell92639a52017-06-01 00:07:44 -0400739 }
740 PolyTraitRef {
741 bound_lifetimes: bound_lifetimes,
742 trait_ref: trait_ref,
743 }
744 })
745 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700746 }
David Tolnay9d8f1972016-09-04 11:58:48 -0700747
Alex Crichton954046c2017-05-30 21:49:42 -0700748 impl Synom for BareFnArg {
Michael Layzell92639a52017-06-01 00:07:44 -0400749 named!(parse -> Self, do_parse!(
750 name: option!(do_parse!(
Alex Crichton23a15f62017-08-28 12:34:23 -0700751 name: syn!(BareFnArgName) >>
David Tolnayf8db7ba2017-11-11 22:52:16 -0800752 not!(punct!(::)) >>
753 colon: punct!(:) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400754 (name, colon)
755 )) >>
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800756 ty: syn!(Type) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400757 (BareFnArg {
758 name: name,
759 ty: ty,
760 })
761 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700762 }
David Tolnayb8d8ef52016-10-29 14:30:08 -0700763
Alex Crichton23a15f62017-08-28 12:34:23 -0700764 impl Synom for BareFnArgName {
765 named!(parse -> Self, alt!(
766 map!(syn!(Ident), BareFnArgName::Named)
767 |
David Tolnayf8db7ba2017-11-11 22:52:16 -0800768 map!(punct!(_), BareFnArgName::Wild)
Alex Crichton23a15f62017-08-28 12:34:23 -0700769 ));
770 }
771
Alex Crichton954046c2017-05-30 21:49:42 -0700772 impl Synom for Abi {
Michael Layzell92639a52017-06-01 00:07:44 -0400773 named!(parse -> Self, do_parse!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800774 extern_: keyword!(extern) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400775 // TODO: this parses all literals, not just strings
776 name: option!(syn!(Lit)) >>
777 (Abi {
778 extern_token: extern_,
David Tolnayd5125762017-12-29 02:42:17 -0500779 name: name,
Michael Layzell92639a52017-06-01 00:07:44 -0400780 })
781 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700782 }
David Tolnay9d8f1972016-09-04 11:58:48 -0700783}
David Tolnay87d0b442016-09-04 11:52:12 -0700784
785#[cfg(feature = "printing")]
786mod printing {
787 use super::*;
David Tolnay51382052017-12-27 13:46:21 -0500788 use quote::{ToTokens, Tokens};
David Tolnay87d0b442016-09-04 11:52:12 -0700789
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800790 impl ToTokens for TypeSlice {
David Tolnay87d0b442016-09-04 11:52:12 -0700791 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700792 self.bracket_token.surround(tokens, |tokens| {
David Tolnayeadbda32017-12-29 02:33:47 -0500793 self.elem.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700794 });
Alex Crichton62a0a592017-05-22 13:58:53 -0700795 }
796 }
797
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800798 impl ToTokens for TypeArray {
Alex Crichton62a0a592017-05-22 13:58:53 -0700799 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700800 self.bracket_token.surround(tokens, |tokens| {
David Tolnayeadbda32017-12-29 02:33:47 -0500801 self.elem.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700802 self.semi_token.to_tokens(tokens);
David Tolnayeadbda32017-12-29 02:33:47 -0500803 self.len.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700804 });
Alex Crichton62a0a592017-05-22 13:58:53 -0700805 }
806 }
807
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800808 impl ToTokens for TypePtr {
Alex Crichton62a0a592017-05-22 13:58:53 -0700809 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700810 self.star_token.to_tokens(tokens);
David Tolnay136aaa32017-12-29 02:37:36 -0500811 match self.mutability {
David Tolnay24237fb2017-12-29 02:15:26 -0500812 Some(ref tok) => tok.to_tokens(tokens),
813 None => {
Alex Crichton259ee532017-07-14 06:51:02 -0700814 TokensOrDefault(&self.const_token).to_tokens(tokens);
Michael Layzell3936ceb2017-07-08 00:28:36 -0400815 }
816 }
David Tolnay136aaa32017-12-29 02:37:36 -0500817 self.elem.to_tokens(tokens);
Alex Crichton62a0a592017-05-22 13:58:53 -0700818 }
819 }
820
David Tolnay0a89b4d2017-11-13 00:55:45 -0800821 impl ToTokens for TypeReference {
Alex Crichton62a0a592017-05-22 13:58:53 -0700822 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700823 self.and_token.to_tokens(tokens);
Alex Crichton62a0a592017-05-22 13:58:53 -0700824 self.lifetime.to_tokens(tokens);
David Tolnay136aaa32017-12-29 02:37:36 -0500825 self.mutability.to_tokens(tokens);
826 self.elem.to_tokens(tokens);
Alex Crichton62a0a592017-05-22 13:58:53 -0700827 }
828 }
829
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800830 impl ToTokens for TypeBareFn {
Alex Crichton62a0a592017-05-22 13:58:53 -0700831 fn to_tokens(&self, tokens: &mut Tokens) {
David Tolnaybe7a9592017-12-29 02:39:53 -0500832 self.lifetimes.to_tokens(tokens);
833 self.unsafety.to_tokens(tokens);
834 self.abi.to_tokens(tokens);
835 self.fn_token.to_tokens(tokens);
836 self.paren_token.surround(tokens, |tokens| {
837 self.inputs.to_tokens(tokens);
838 if let Some(ref variadic) = self.variadic {
839 if !self.inputs.empty_or_trailing() {
840 let span = variadic.0[0];
841 <Token![,]>::new(span).to_tokens(tokens);
842 }
843 variadic.to_tokens(tokens);
844 }
845 });
846 self.output.to_tokens(tokens);
Alex Crichton62a0a592017-05-22 13:58:53 -0700847 }
848 }
849
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800850 impl ToTokens for TypeNever {
Alex Crichton62a0a592017-05-22 13:58:53 -0700851 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700852 self.bang_token.to_tokens(tokens);
Alex Crichton62a0a592017-05-22 13:58:53 -0700853 }
854 }
855
David Tolnay05362582017-12-26 01:33:57 -0500856 impl ToTokens for TypeTuple {
Alex Crichton62a0a592017-05-22 13:58:53 -0700857 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700858 self.paren_token.surround(tokens, |tokens| {
David Tolnayeadbda32017-12-29 02:33:47 -0500859 self.elems.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700860 })
Alex Crichton62a0a592017-05-22 13:58:53 -0700861 }
862 }
863
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800864 impl ToTokens for TypePath {
Alex Crichton62a0a592017-05-22 13:58:53 -0700865 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700866 PathTokens(&self.qself, &self.path).to_tokens(tokens);
867 }
868 }
869
870 impl<'a> ToTokens for PathTokens<'a> {
871 fn to_tokens(&self, tokens: &mut Tokens) {
872 let qself = match *self.0 {
Alex Crichton62a0a592017-05-22 13:58:53 -0700873 Some(ref qself) => qself,
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700874 None => return self.1.to_tokens(tokens),
Alex Crichton62a0a592017-05-22 13:58:53 -0700875 };
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700876 qself.lt_token.to_tokens(tokens);
Alex Crichton62a0a592017-05-22 13:58:53 -0700877 qself.ty.to_tokens(tokens);
Michael Layzell3936ceb2017-07-08 00:28:36 -0400878
879 // XXX: Gross.
880 let pos = if qself.position > 0 && qself.position >= self.1.segments.len() {
881 self.1.segments.len() - 1
882 } else {
883 qself.position
884 };
David Tolnay570695e2017-06-03 16:15:13 -0700885 let mut segments = self.1.segments.iter();
Michael Layzell3936ceb2017-07-08 00:28:36 -0400886 if pos > 0 {
Alex Crichton259ee532017-07-14 06:51:02 -0700887 TokensOrDefault(&qself.as_token).to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700888 self.1.leading_colon.to_tokens(tokens);
David Tolnay570695e2017-06-03 16:15:13 -0700889 for (i, segment) in (&mut segments).take(pos).enumerate() {
890 if i + 1 == pos {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700891 segment.item().to_tokens(tokens);
892 qself.gt_token.to_tokens(tokens);
893 segment.delimiter().to_tokens(tokens);
894 } else {
895 segment.to_tokens(tokens);
Alex Crichton62a0a592017-05-22 13:58:53 -0700896 }
Alex Crichton62a0a592017-05-22 13:58:53 -0700897 }
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700898 } else {
899 qself.gt_token.to_tokens(tokens);
David Tolnay570695e2017-06-03 16:15:13 -0700900 self.1.leading_colon.to_tokens(tokens);
Alex Crichton62a0a592017-05-22 13:58:53 -0700901 }
David Tolnay570695e2017-06-03 16:15:13 -0700902 for segment in segments {
Alex Crichton62a0a592017-05-22 13:58:53 -0700903 segment.to_tokens(tokens);
904 }
905 }
906 }
907
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800908 impl ToTokens for TypeTraitObject {
Alex Crichton62a0a592017-05-22 13:58:53 -0700909 fn to_tokens(&self, tokens: &mut Tokens) {
David Tolnaye45b59f2017-12-25 18:44:49 -0500910 self.dyn_token.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700911 self.bounds.to_tokens(tokens);
Alex Crichton62a0a592017-05-22 13:58:53 -0700912 }
913 }
914
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800915 impl ToTokens for TypeImplTrait {
Alex Crichton62a0a592017-05-22 13:58:53 -0700916 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700917 self.impl_token.to_tokens(tokens);
918 self.bounds.to_tokens(tokens);
Alex Crichton62a0a592017-05-22 13:58:53 -0700919 }
920 }
921
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800922 impl ToTokens for TypeGroup {
Michael Layzell93c36282017-06-04 20:43:14 -0400923 fn to_tokens(&self, tokens: &mut Tokens) {
924 self.group_token.surround(tokens, |tokens| {
David Tolnayeadbda32017-12-29 02:33:47 -0500925 self.elem.to_tokens(tokens);
Michael Layzell93c36282017-06-04 20:43:14 -0400926 });
927 }
928 }
929
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800930 impl ToTokens for TypeParen {
Alex Crichton62a0a592017-05-22 13:58:53 -0700931 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700932 self.paren_token.surround(tokens, |tokens| {
David Tolnayeadbda32017-12-29 02:33:47 -0500933 self.elem.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700934 });
Alex Crichton62a0a592017-05-22 13:58:53 -0700935 }
936 }
937
David Tolnayfd6bf5c2017-11-12 09:41:14 -0800938 impl ToTokens for TypeInfer {
Alex Crichton62a0a592017-05-22 13:58:53 -0700939 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700940 self.underscore_token.to_tokens(tokens);
David Tolnay87d0b442016-09-04 11:52:12 -0700941 }
942 }
943
944 impl ToTokens for Path {
945 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700946 self.leading_colon.to_tokens(tokens);
947 self.segments.to_tokens(tokens);
David Tolnay87d0b442016-09-04 11:52:12 -0700948 }
949 }
950
951 impl ToTokens for PathSegment {
952 fn to_tokens(&self, tokens: &mut Tokens) {
953 self.ident.to_tokens(tokens);
Nika Layzellc08227a2017-12-04 16:30:17 -0500954 self.arguments.to_tokens(tokens);
David Tolnay87d0b442016-09-04 11:52:12 -0700955 }
956 }
957
Nika Layzellc08227a2017-12-04 16:30:17 -0500958 impl ToTokens for PathArguments {
David Tolnay87d0b442016-09-04 11:52:12 -0700959 fn to_tokens(&self, tokens: &mut Tokens) {
960 match *self {
Nika Layzellc08227a2017-12-04 16:30:17 -0500961 PathArguments::None => {}
962 PathArguments::AngleBracketed(ref arguments) => {
963 arguments.to_tokens(tokens);
David Tolnay87d0b442016-09-04 11:52:12 -0700964 }
Nika Layzellc08227a2017-12-04 16:30:17 -0500965 PathArguments::Parenthesized(ref arguments) => {
966 arguments.to_tokens(tokens);
David Tolnay87d0b442016-09-04 11:52:12 -0700967 }
968 }
969 }
970 }
971
Nika Layzellc08227a2017-12-04 16:30:17 -0500972 impl ToTokens for GenericArgument {
David Tolnaybb4ca9f2017-12-26 12:28:58 -0500973 #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
Nika Layzell357885a2017-12-04 15:47:07 -0500974 fn to_tokens(&self, tokens: &mut Tokens) {
975 match *self {
Nika Layzellc08227a2017-12-04 16:30:17 -0500976 GenericArgument::Lifetime(ref lt) => lt.to_tokens(tokens),
977 GenericArgument::Type(ref ty) => ty.to_tokens(tokens),
978 GenericArgument::TypeBinding(ref tb) => tb.to_tokens(tokens),
David Tolnay8c91b882017-12-28 23:04:32 -0500979 GenericArgument::Const(ref e) => match *e {
980 Expr::Lit(_) => e.to_tokens(tokens),
Nika Layzellce37f332017-12-05 12:01:22 -0500981
982 // NOTE: We should probably support parsing blocks with only
983 // expressions in them without the full feature for const
984 // generics.
985 #[cfg(feature = "full")]
David Tolnay8c91b882017-12-28 23:04:32 -0500986 Expr::Block(_) => e.to_tokens(tokens),
Nika Layzellce37f332017-12-05 12:01:22 -0500987
988 // ERROR CORRECTION: Add braces to make sure that the
989 // generated code is valid.
David Tolnay32954ef2017-12-26 22:43:16 -0500990 _ => token::Brace::default().surround(tokens, |tokens| {
Nika Layzellce37f332017-12-05 12:01:22 -0500991 e.to_tokens(tokens);
992 }),
David Tolnay51382052017-12-27 13:46:21 -0500993 },
Nika Layzell357885a2017-12-04 15:47:07 -0500994 }
995 }
996 }
997
Nika Layzellc08227a2017-12-04 16:30:17 -0500998 impl ToTokens for AngleBracketedGenericArguments {
David Tolnay87d0b442016-09-04 11:52:12 -0700999 fn to_tokens(&self, tokens: &mut Tokens) {
David Tolnay2d4e08a2017-12-28 23:54:07 -05001000 self.colon2_token.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -07001001 self.lt_token.to_tokens(tokens);
Nika Layzell357885a2017-12-04 15:47:07 -05001002 self.args.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -07001003 self.gt_token.to_tokens(tokens);
David Tolnay87d0b442016-09-04 11:52:12 -07001004 }
1005 }
1006
1007 impl ToTokens for TypeBinding {
1008 fn to_tokens(&self, tokens: &mut Tokens) {
1009 self.ident.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -07001010 self.eq_token.to_tokens(tokens);
David Tolnay87d0b442016-09-04 11:52:12 -07001011 self.ty.to_tokens(tokens);
1012 }
1013 }
1014
Nika Layzellc08227a2017-12-04 16:30:17 -05001015 impl ToTokens for ParenthesizedGenericArguments {
David Tolnay87d0b442016-09-04 11:52:12 -07001016 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -07001017 self.paren_token.surround(tokens, |tokens| {
1018 self.inputs.to_tokens(tokens);
1019 });
1020 self.output.to_tokens(tokens);
1021 }
1022 }
1023
David Tolnayf93b90d2017-11-11 19:21:26 -08001024 impl ToTokens for ReturnType {
Alex Crichtonccbb45d2017-05-23 10:58:24 -07001025 fn to_tokens(&self, tokens: &mut Tokens) {
1026 match *self {
David Tolnayf93b90d2017-11-11 19:21:26 -08001027 ReturnType::Default => {}
David Tolnay4a3f59a2017-12-28 21:21:12 -05001028 ReturnType::Type(ref arrow, ref ty) => {
Alex Crichtonccbb45d2017-05-23 10:58:24 -07001029 arrow.to_tokens(tokens);
1030 ty.to_tokens(tokens);
1031 }
David Tolnay87d0b442016-09-04 11:52:12 -07001032 }
1033 }
1034 }
1035
1036 impl ToTokens for PolyTraitRef {
1037 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -07001038 self.bound_lifetimes.to_tokens(tokens);
David Tolnay87d0b442016-09-04 11:52:12 -07001039 self.trait_ref.to_tokens(tokens);
1040 }
1041 }
1042
David Tolnay62f374c2016-10-02 13:37:00 -07001043 impl ToTokens for BareFnArg {
David Tolnay42602292016-10-01 22:25:45 -07001044 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -07001045 if let Some((ref name, ref colon)) = self.name {
David Tolnay62f374c2016-10-02 13:37:00 -07001046 name.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -07001047 colon.to_tokens(tokens);
David Tolnay42602292016-10-01 22:25:45 -07001048 }
1049 self.ty.to_tokens(tokens);
David Tolnay87d0b442016-09-04 11:52:12 -07001050 }
1051 }
David Tolnayb8d8ef52016-10-29 14:30:08 -07001052
Alex Crichton23a15f62017-08-28 12:34:23 -07001053 impl ToTokens for BareFnArgName {
1054 fn to_tokens(&self, tokens: &mut Tokens) {
1055 match *self {
1056 BareFnArgName::Named(ref t) => t.to_tokens(tokens),
1057 BareFnArgName::Wild(ref t) => t.to_tokens(tokens),
1058 }
1059 }
1060 }
1061
David Tolnayb8d8ef52016-10-29 14:30:08 -07001062 impl ToTokens for Abi {
1063 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichtonccbb45d2017-05-23 10:58:24 -07001064 self.extern_token.to_tokens(tokens);
David Tolnayd5125762017-12-29 02:42:17 -05001065 self.name.to_tokens(tokens);
David Tolnayb8d8ef52016-10-29 14:30:08 -07001066 }
1067 }
David Tolnay87d0b442016-09-04 11:52:12 -07001068}