blob: fb510529bdc64a71d6ce3d60c685cb23e076d14c [file] [log] [blame]
David Tolnayb79ee962016-09-04 09:39:20 -07001use super::*;
Alex Crichtonccbb45d2017-05-23 10:58:24 -07002use delimited::Delimited;
David Tolnayb79ee962016-09-04 09:39:20 -07003
David Tolnay4a51dc72016-10-01 00:40:31 -07004use std::iter;
5
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -07006use proc_macro2::{self, Delimiter, TokenNode, Spacing};
Alex Crichtonccbb45d2017-05-23 10:58:24 -07007
Alex Crichton62a0a592017-05-22 13:58:53 -07008ast_struct! {
9 /// Doc-comments are promoted to attributes that have `is_sugared_doc` = true
10 pub struct Attribute {
11 pub style: AttrStyle,
David Tolnayf8db7ba2017-11-11 22:52:16 -080012 pub pound_token: Token![#],
Alex Crichtonccbb45d2017-05-23 10:58:24 -070013 pub bracket_token: tokens::Bracket,
Arnavion44d2bf32017-04-19 02:47:55 -070014
Alex Crichton62a0a592017-05-22 13:58:53 -070015 /// The path of the attribute.
16 ///
17 /// E.g. `derive` in `#[derive(Copy)]`
18 /// E.g. `crate::precondition` in `#[crate::precondition x < 5]`
19 pub path: Path,
Arnavion44d2bf32017-04-19 02:47:55 -070020
Alex Crichton62a0a592017-05-22 13:58:53 -070021 /// Any tokens after the path.
22 ///
23 /// E.g. `( Copy )` in `#[derive(Copy)]`
24 /// E.g. `x < 5` in `#[crate::precondition x < 5]`
25 pub tts: Vec<TokenTree>,
Arnavion44d2bf32017-04-19 02:47:55 -070026
Alex Crichton62a0a592017-05-22 13:58:53 -070027 pub is_sugared_doc: bool,
28 }
David Tolnayb79ee962016-09-04 09:39:20 -070029}
30
David Tolnay02d77cc2016-10-02 09:52:08 -070031impl Attribute {
Arnavion44d2bf32017-04-19 02:47:55 -070032 /// Parses the tokens after the path as a [`MetaItem`](enum.MetaItem.html) if possible.
Arnavionbf395bf2017-04-15 15:35:22 -070033 pub fn meta_item(&self) -> Option<MetaItem> {
Arnavion95f8a7a2017-04-19 03:29:56 -070034 let name = if self.path.segments.len() == 1 {
Alex Crichtonccbb45d2017-05-23 10:58:24 -070035 &self.path.segments.get(0).item().ident
Arnavion95f8a7a2017-04-19 03:29:56 -070036 } else {
37 return None;
38 };
39
Arnavionbf395bf2017-04-15 15:35:22 -070040 if self.tts.is_empty() {
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -070041 return Some(MetaItem::Term(name.clone()));
Arnavionbf395bf2017-04-15 15:35:22 -070042 }
43
44 if self.tts.len() == 1 {
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -070045 if let TokenNode::Group(Delimiter::Parenthesis, ref ts) = self.tts[0].0.kind {
Alex Crichtonccbb45d2017-05-23 10:58:24 -070046 let tokens = ts.clone().into_iter().collect::<Vec<_>>();
47 if let Some(nested_meta_items) = list_of_nested_meta_items_from_tokens(&tokens) {
Alex Crichton62a0a592017-05-22 13:58:53 -070048 return Some(MetaItem::List(MetaItemList {
Alex Crichtonccbb45d2017-05-23 10:58:24 -070049 paren_token: tokens::Paren(Span(self.tts[0].0.span)),
Alex Crichton62a0a592017-05-22 13:58:53 -070050 ident: name.clone(),
51 nested: nested_meta_items,
52 }));
Arnavionbf395bf2017-04-15 15:35:22 -070053 }
54 }
55 }
56
57 if self.tts.len() == 2 {
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -070058 if let TokenNode::Op('=', Spacing::Alone) = self.tts[0].0.kind {
59 if let TokenNode::Literal(ref lit) = self.tts[1].0.kind {
Alex Crichton62a0a592017-05-22 13:58:53 -070060 return Some(MetaItem::NameValue(MetaNameValue {
61 ident: name.clone(),
David Tolnayf8db7ba2017-11-11 22:52:16 -080062 eq_token: Token![=]([Span(self.tts[0].0.span)]),
Alex Crichtonccbb45d2017-05-23 10:58:24 -070063 lit: Lit {
64 value: LitKind::Other(lit.clone()),
65 span: Span(self.tts[1].0.span),
66 },
Alex Crichton62a0a592017-05-22 13:58:53 -070067 }));
Arnavionbf395bf2017-04-15 15:35:22 -070068 }
Arnavionbf395bf2017-04-15 15:35:22 -070069 }
70 }
71
72 None
David Tolnay02d77cc2016-10-02 09:52:08 -070073 }
74}
75
Alex Crichtonccbb45d2017-05-23 10:58:24 -070076fn nested_meta_item_from_tokens(tts: &[proc_macro2::TokenTree])
77 -> Option<(NestedMetaItem, &[proc_macro2::TokenTree])>
78{
79 assert!(!tts.is_empty());
80
81 match tts[0].kind {
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -070082 TokenNode::Literal(ref lit) => {
Alex Crichtonccbb45d2017-05-23 10:58:24 -070083 let lit = Lit {
84 value: LitKind::Other(lit.clone()),
85 span: Span(tts[0].span),
86 };
87 Some((NestedMetaItem::Literal(lit), &tts[1..]))
88 }
89
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -070090 TokenNode::Term(sym) => {
Alex Crichtonccbb45d2017-05-23 10:58:24 -070091 let ident = Ident::new(sym, Span(tts[0].span));
92 if tts.len() >= 3 {
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -070093 if let TokenNode::Op('=', Spacing::Alone) = tts[1].kind {
94 if let TokenNode::Literal(ref lit) = tts[2].kind {
Alex Crichtonccbb45d2017-05-23 10:58:24 -070095 let pair = MetaNameValue {
96 ident: Ident::new(sym, Span(tts[0].span)),
David Tolnayf8db7ba2017-11-11 22:52:16 -080097 eq_token: Token![=]([Span(tts[1].span)]),
Alex Crichtonccbb45d2017-05-23 10:58:24 -070098 lit: Lit {
99 value: LitKind::Other(lit.clone()),
100 span: Span(tts[2].span),
101 },
102 };
103 return Some((MetaItem::NameValue(pair).into(), &tts[3..]));
104 }
105 }
106 }
107
108 if tts.len() >= 2 {
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -0700109 if let TokenNode::Group(Delimiter::Parenthesis, ref inner_tts) = tts[1].kind {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700110 let inner_tts = inner_tts.clone().into_iter().collect::<Vec<_>>();
111 return match list_of_nested_meta_items_from_tokens(&inner_tts) {
112 Some(nested_meta_items) => {
113 let list = MetaItemList {
114 ident: ident,
115 paren_token: tokens::Paren(Span(tts[1].span)),
116 nested: nested_meta_items,
117 };
118 Some((MetaItem::List(list).into(), &tts[2..]))
119 }
120
121 None => None
122 };
123 }
124 }
125
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -0700126 Some((MetaItem::Term(ident).into(), &tts[1..]))
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700127 }
128
129 _ => None
130 }
131}
132
133fn list_of_nested_meta_items_from_tokens(mut tts: &[proc_macro2::TokenTree])
David Tolnayf8db7ba2017-11-11 22:52:16 -0800134 -> Option<Delimited<NestedMetaItem, Token![,]>>
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700135{
136 let mut delimited = Delimited::new();
137 let mut first = true;
138
139 while !tts.is_empty() {
140 let prev_comma = if first {
141 first = false;
142 None
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -0700143 } else if let TokenNode::Op(',', Spacing::Alone) = tts[0].kind {
David Tolnayf8db7ba2017-11-11 22:52:16 -0800144 let tok = Token![,]([Span(tts[0].span)]);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700145 tts = &tts[1..];
146 if tts.is_empty() {
147 break
148 }
149 Some(tok)
150 } else {
151 return None
152 };
153 let (nested, rest) = match nested_meta_item_from_tokens(tts) {
154 Some(pair) => pair,
155 None => return None,
156 };
157 match prev_comma {
158 Some(comma) => delimited.push_next(nested, comma),
159 None => delimited.push_first(nested),
160 }
161 tts = rest;
162 }
163
164 Some(delimited)
165}
166
167
Alex Crichton62a0a592017-05-22 13:58:53 -0700168ast_enum! {
169 /// Distinguishes between Attributes that decorate items and Attributes that
170 /// are contained as statements within items. These two cases need to be
171 /// distinguished for pretty-printing.
Alex Crichton2e0229c2017-05-23 09:34:50 -0700172 #[cfg_attr(feature = "clone-impls", derive(Copy))]
Alex Crichton62a0a592017-05-22 13:58:53 -0700173 pub enum AttrStyle {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700174 /// Attribute of the form `#[...]`.
Alex Crichton62a0a592017-05-22 13:58:53 -0700175 Outer,
Clar Charrd22b5702017-03-10 15:24:56 -0500176
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700177 /// Attribute of the form `#![...]`.
David Tolnayf8db7ba2017-11-11 22:52:16 -0800178 Inner(Token![!]),
Alex Crichton62a0a592017-05-22 13:58:53 -0700179 }
David Tolnay4a51dc72016-10-01 00:40:31 -0700180}
181
Alex Crichton62a0a592017-05-22 13:58:53 -0700182ast_enum_of_structs! {
183 /// A compile-time attribute item.
David Tolnayb79ee962016-09-04 09:39:20 -0700184 ///
Alex Crichton62a0a592017-05-22 13:58:53 -0700185 /// E.g. `#[test]`, `#[derive(..)]` or `#[feature = "foo"]`
186 pub enum MetaItem {
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -0700187 /// Term meta item.
Alex Crichton62a0a592017-05-22 13:58:53 -0700188 ///
189 /// E.g. `test` as in `#[test]`
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -0700190 pub Term(Ident),
Clar Charrd22b5702017-03-10 15:24:56 -0500191
Alex Crichton62a0a592017-05-22 13:58:53 -0700192 /// List meta item.
193 ///
194 /// E.g. `derive(..)` as in `#[derive(..)]`
195 pub List(MetaItemList {
196 /// Name of this attribute.
197 ///
198 /// E.g. `derive` in `#[derive(..)]`
199 pub ident: Ident,
Clar Charrd22b5702017-03-10 15:24:56 -0500200
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700201 pub paren_token: tokens::Paren,
202
Alex Crichton62a0a592017-05-22 13:58:53 -0700203 /// Arguments to this attribute
204 ///
205 /// E.g. `..` in `#[derive(..)]`
David Tolnayf8db7ba2017-11-11 22:52:16 -0800206 pub nested: Delimited<NestedMetaItem, Token![,]>,
Alex Crichton62a0a592017-05-22 13:58:53 -0700207 }),
208
209 /// Name-value meta item.
210 ///
211 /// E.g. `feature = "foo"` as in `#[feature = "foo"]`
212 pub NameValue(MetaNameValue {
213 /// Name of this attribute.
214 ///
215 /// E.g. `feature` in `#[feature = "foo"]`
216 pub ident: Ident,
217
David Tolnayf8db7ba2017-11-11 22:52:16 -0800218 pub eq_token: Token![=],
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700219
Alex Crichton62a0a592017-05-22 13:58:53 -0700220 /// Arguments to this attribute
221 ///
222 /// E.g. `"foo"` in `#[feature = "foo"]`
223 pub lit: Lit,
224 }),
225 }
Arnavion95f8a7a2017-04-19 03:29:56 -0700226}
227
228impl MetaItem {
229 /// Name of the item.
230 ///
231 /// E.g. `test` as in `#[test]`, `derive` as in `#[derive(..)]`, and
232 /// `feature` as in `#[feature = "foo"]`.
233 pub fn name(&self) -> &str {
234 match *self {
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -0700235 MetaItem::Term(ref name) => name.as_ref(),
Alex Crichton62a0a592017-05-22 13:58:53 -0700236 MetaItem::NameValue(ref pair) => pair.ident.as_ref(),
237 MetaItem::List(ref list) => list.ident.as_ref(),
Arnavion95f8a7a2017-04-19 03:29:56 -0700238 }
239 }
David Tolnay8e661e22016-09-27 00:00:04 -0700240}
241
Alex Crichton62a0a592017-05-22 13:58:53 -0700242ast_enum_of_structs! {
243 /// Possible values inside of compile-time attribute lists.
David Tolnayb7fa2b62016-10-30 10:50:47 -0700244 ///
Alex Crichton62a0a592017-05-22 13:58:53 -0700245 /// E.g. the '..' in `#[name(..)]`.
246 pub enum NestedMetaItem {
247 /// A full `MetaItem`.
248 ///
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -0700249 /// E.g. `Copy` in `#[derive(Copy)]` would be a `MetaItem::Term(Ident::from("Copy"))`.
Alex Crichton62a0a592017-05-22 13:58:53 -0700250 pub MetaItem(MetaItem),
Clar Charrd22b5702017-03-10 15:24:56 -0500251
Alex Crichton62a0a592017-05-22 13:58:53 -0700252 /// A Rust literal.
253 ///
254 /// E.g. `"name"` in `#[rename("name")]`.
255 pub Literal(Lit),
256 }
David Tolnayb7fa2b62016-10-30 10:50:47 -0700257}
258
David Tolnay4a51dc72016-10-01 00:40:31 -0700259pub trait FilterAttrs<'a> {
260 type Ret: Iterator<Item = &'a Attribute>;
261
262 fn outer(self) -> Self::Ret;
263 fn inner(self) -> Self::Ret;
264}
265
David Tolnaydaaf7742016-10-03 11:11:43 -0700266impl<'a, T> FilterAttrs<'a> for T
267 where T: IntoIterator<Item = &'a Attribute>
268{
David Tolnay4a51dc72016-10-01 00:40:31 -0700269 type Ret = iter::Filter<T::IntoIter, fn(&&Attribute) -> bool>;
270
271 fn outer(self) -> Self::Ret {
272 fn is_outer(attr: &&Attribute) -> bool {
Alex Crichton2e0229c2017-05-23 09:34:50 -0700273 match attr.style {
274 AttrStyle::Outer => true,
275 _ => false,
276 }
David Tolnay4a51dc72016-10-01 00:40:31 -0700277 }
278 self.into_iter().filter(is_outer)
279 }
280
281 fn inner(self) -> Self::Ret {
282 fn is_inner(attr: &&Attribute) -> bool {
Alex Crichton2e0229c2017-05-23 09:34:50 -0700283 match attr.style {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700284 AttrStyle::Inner(_) => true,
Alex Crichton2e0229c2017-05-23 09:34:50 -0700285 _ => false,
286 }
David Tolnay4a51dc72016-10-01 00:40:31 -0700287 }
288 self.into_iter().filter(is_inner)
289 }
290}
291
David Tolnay86eca752016-09-04 11:26:41 -0700292#[cfg(feature = "parsing")]
David Tolnay9d8f1972016-09-04 11:58:48 -0700293pub mod parsing {
294 use super::*;
Michael Layzell92639a52017-06-01 00:07:44 -0400295 use synom::{PResult, Cursor, parse_error};
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -0700296 use proc_macro2::{TokenNode, Spacing, TokenTree};
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700297
298 fn eq() -> TokenTree {
Alex Crichton954046c2017-05-30 21:49:42 -0700299 TokenTree {
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700300 span: Default::default(),
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -0700301 kind: TokenNode::Op('=', Spacing::Alone),
Alex Crichton954046c2017-05-30 21:49:42 -0700302 }
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700303 }
304
Alex Crichton954046c2017-05-30 21:49:42 -0700305 impl Attribute {
306 #[cfg(feature = "full")]
Michael Layzell92639a52017-06-01 00:07:44 -0400307 named!(pub parse_inner -> Self, alt!(
308 do_parse!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800309 pound: punct!(#) >>
310 bang: punct!(!) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400311 path_and_tts: brackets!(tuple!(
312 call!(::Path::parse_mod_style),
313 call!(::TokenTree::parse_list)
314 )) >>
315 ({
316 let ((path, tts), bracket) = path_and_tts;
Alex Crichton954046c2017-05-30 21:49:42 -0700317
Michael Layzell92639a52017-06-01 00:07:44 -0400318 Attribute {
319 style: AttrStyle::Inner(bang),
320 path: path,
321 tts: tts,
322 is_sugared_doc: false,
323 pound_token: pound,
324 bracket_token: bracket,
Alex Crichton954046c2017-05-30 21:49:42 -0700325 }
Michael Layzell92639a52017-06-01 00:07:44 -0400326 })
327 )
328 |
329 map!(
330 lit_doc_comment,
331 |lit| Attribute {
David Tolnayf8db7ba2017-11-11 22:52:16 -0800332 style: AttrStyle::Inner(<Token![!]>::default()),
Michael Layzell92639a52017-06-01 00:07:44 -0400333 path: "doc".into(),
334 tts: vec![
335 ::TokenTree(eq()),
336 ::TokenTree(lit),
337 ],
338 is_sugared_doc: true,
David Tolnayf8db7ba2017-11-11 22:52:16 -0800339 pound_token: <Token![#]>::default(),
Michael Layzell92639a52017-06-01 00:07:44 -0400340 bracket_token: tokens::Bracket::default(),
341 }
342 )
343 ));
Alex Crichton954046c2017-05-30 21:49:42 -0700344
Michael Layzell92639a52017-06-01 00:07:44 -0400345 named!(pub parse_outer -> Self, alt!(
346 do_parse!(
David Tolnayf8db7ba2017-11-11 22:52:16 -0800347 pound: punct!(#) >>
Michael Layzell92639a52017-06-01 00:07:44 -0400348 path_and_tts: brackets!(tuple!(
349 call!(::Path::parse_mod_style),
350 call!(::TokenTree::parse_list)
351 )) >>
352 ({
353 let ((path, tts), bracket) = path_and_tts;
Alex Crichton954046c2017-05-30 21:49:42 -0700354
Michael Layzell92639a52017-06-01 00:07:44 -0400355 Attribute {
Alex Crichton954046c2017-05-30 21:49:42 -0700356 style: AttrStyle::Outer,
Michael Layzell92639a52017-06-01 00:07:44 -0400357 path: path,
358 tts: tts,
359 is_sugared_doc: false,
360 pound_token: pound,
361 bracket_token: bracket,
Alex Crichton954046c2017-05-30 21:49:42 -0700362 }
Michael Layzell92639a52017-06-01 00:07:44 -0400363 })
364 )
365 |
366 map!(
367 lit_doc_comment,
368 |lit| Attribute {
369 style: AttrStyle::Outer,
370 path: "doc".into(),
371 tts: vec![
372 ::TokenTree(eq()),
373 ::TokenTree(lit),
374 ],
375 is_sugared_doc: true,
David Tolnayf8db7ba2017-11-11 22:52:16 -0800376 pound_token: <Token![#]>::default(),
Michael Layzell92639a52017-06-01 00:07:44 -0400377 bracket_token: tokens::Bracket::default(),
378 }
379 )
380 ));
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700381 }
David Tolnayb79ee962016-09-04 09:39:20 -0700382
Michael Layzell92639a52017-06-01 00:07:44 -0400383 fn lit_doc_comment(input: Cursor) -> PResult<TokenTree> {
Michael Layzell589a8f42017-06-02 19:47:01 -0400384 match input.literal() {
385 Some((rest, span, lit)) => {
386 let literal = lit.to_string();
387 if literal.starts_with("//") || literal.starts_with("/*") {
388 Ok((rest, TokenTree {
389 span: span,
Alex Crichtonf9e8f1a2017-07-05 18:20:44 -0700390 kind: TokenNode::Literal(lit)
Michael Layzell589a8f42017-06-02 19:47:01 -0400391 }))
392 } else {
393 parse_error()
394 }
395 }
396 _ => parse_error()
Alex Crichton954046c2017-05-30 21:49:42 -0700397 }
398 }
David Tolnay9d8f1972016-09-04 11:58:48 -0700399}
David Tolnay87d0b442016-09-04 11:52:12 -0700400
401#[cfg(feature = "printing")]
402mod printing {
403 use super::*;
404 use quote::{Tokens, ToTokens};
405
406 impl ToTokens for Attribute {
407 fn to_tokens(&self, tokens: &mut Tokens) {
Arnavion44d2bf32017-04-19 02:47:55 -0700408 // If this was a sugared doc, emit it in its original form instead of `#[doc = "..."]`
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700409 if self.is_sugared_doc {
410 if let Some(MetaItem::NameValue(ref pair)) = self.meta_item() {
411 if pair.ident == "doc" {
412 let value = pair.lit.value.to_string();
Alex Crichton954046c2017-05-30 21:49:42 -0700413 if value.starts_with('/') {
414 pair.lit.to_tokens(tokens);
415 return
David Tolnay14cbdeb2016-10-01 12:13:59 -0700416 }
David Tolnay4a51dc72016-10-01 00:40:31 -0700417 }
David Tolnayc91dd672016-10-01 01:03:56 -0700418 }
419 }
David Tolnay14cbdeb2016-10-01 12:13:59 -0700420
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700421 self.pound_token.to_tokens(tokens);
422 if let AttrStyle::Inner(ref b) = self.style {
423 b.to_tokens(tokens);
David Tolnay14cbdeb2016-10-01 12:13:59 -0700424 }
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700425 self.bracket_token.surround(tokens, |tokens| {
426 self.path.to_tokens(tokens);
427 tokens.append_all(&self.tts);
428 });
David Tolnay87d0b442016-09-04 11:52:12 -0700429 }
430 }
431
Alex Crichton62a0a592017-05-22 13:58:53 -0700432 impl ToTokens for MetaItemList {
David Tolnay87d0b442016-09-04 11:52:12 -0700433 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichton62a0a592017-05-22 13:58:53 -0700434 self.ident.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700435 self.paren_token.surround(tokens, |tokens| {
436 self.nested.to_tokens(tokens);
437 })
David Tolnay87d0b442016-09-04 11:52:12 -0700438 }
439 }
David Tolnayb7fa2b62016-10-30 10:50:47 -0700440
Alex Crichton62a0a592017-05-22 13:58:53 -0700441 impl ToTokens for MetaNameValue {
David Tolnayb7fa2b62016-10-30 10:50:47 -0700442 fn to_tokens(&self, tokens: &mut Tokens) {
Alex Crichton62a0a592017-05-22 13:58:53 -0700443 self.ident.to_tokens(tokens);
Alex Crichtonccbb45d2017-05-23 10:58:24 -0700444 self.eq_token.to_tokens(tokens);
Alex Crichton62a0a592017-05-22 13:58:53 -0700445 self.lit.to_tokens(tokens);
David Tolnayb7fa2b62016-10-30 10:50:47 -0700446 }
447 }
David Tolnay87d0b442016-09-04 11:52:12 -0700448}