David Tolnay | 5553501 | 2018-01-05 16:39:23 -0800 | [diff] [blame] | 1 | // Copyright 2018 Syn Developers |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 4 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 5 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 6 | // option. This file may not be copied, modified, or distributed |
| 7 | // except according to those terms. |
| 8 | |
David Tolnay | f733f7e | 2016-11-25 10:36:25 -0800 | [diff] [blame] | 9 | use std::borrow::Cow; |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 10 | use std::cmp::Ordering; |
David Tolnay | 42f5029 | 2016-09-04 13:54:21 -0700 | [diff] [blame] | 11 | use std::fmt::{self, Display}; |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 12 | use std::hash::{Hash, Hasher}; |
David Tolnay | 42f5029 | 2016-09-04 13:54:21 -0700 | [diff] [blame] | 13 | |
Alex Crichton | f9e8f1a | 2017-07-05 18:20:44 -0700 | [diff] [blame] | 14 | use proc_macro2::Term; |
David Tolnay | 570695e | 2017-06-03 16:15:13 -0700 | [diff] [blame] | 15 | use unicode_xid::UnicodeXID; |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 16 | |
David Tolnay | 9894256 | 2017-12-26 21:24:35 -0500 | [diff] [blame] | 17 | use proc_macro2::Span; |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 18 | |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 19 | /// A word of Rust code, which may be a keyword or legal variable name. |
David Tolnay | 570695e | 2017-06-03 16:15:13 -0700 | [diff] [blame] | 20 | /// |
| 21 | /// An identifier consists of at least one Unicode code point, the first of |
| 22 | /// which has the XID_Start property and the rest of which have the XID_Continue |
| 23 | /// property. An underscore may be used as the first character as long as it is |
| 24 | /// not the only character. |
| 25 | /// |
| 26 | /// - The empty string is not an identifier. Use `Option<Ident>`. |
| 27 | /// - An underscore by itself is not an identifier. Use |
David Tolnay | f8db7ba | 2017-11-11 22:52:16 -0800 | [diff] [blame] | 28 | /// `Token![_]` instead. |
David Tolnay | 570695e | 2017-06-03 16:15:13 -0700 | [diff] [blame] | 29 | /// - A lifetime is not an identifier. Use `syn::Lifetime` instead. |
| 30 | /// |
| 31 | /// An identifier constructed with `Ident::new` is permitted to be a Rust |
David Tolnay | 1cf8091 | 2017-12-31 18:35:12 -0500 | [diff] [blame] | 32 | /// keyword, though parsing one through its [`Synom`] implementation rejects |
| 33 | /// Rust keywords. |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 34 | /// |
David Tolnay | 1cf8091 | 2017-12-31 18:35:12 -0500 | [diff] [blame] | 35 | /// [`Synom`]: synom/trait.Synom.html |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 36 | /// |
| 37 | /// # Examples |
| 38 | /// |
| 39 | /// A new ident can be created from a string using the `Ident::from` function. |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 40 | /// Idents produced by `Ident::from` are set to resolve at the procedural macro |
| 41 | /// *def site* by default. A different span can be provided explicitly by using |
| 42 | /// `Ident::new`. |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 43 | /// |
| 44 | /// ```rust |
| 45 | /// extern crate syn; |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 46 | /// extern crate proc_macro2; |
| 47 | /// |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 48 | /// use syn::Ident; |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 49 | /// use proc_macro2::Span; |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 50 | /// |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 51 | /// fn main() { |
| 52 | /// let def_ident = Ident::from("definitely"); |
| 53 | /// let call_ident = Ident::new("calligraphy", Span::call_site()); |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 54 | /// |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 55 | /// println!("{} {}", def_ident, call_ident); |
| 56 | /// } |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 57 | /// ``` |
| 58 | /// |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 59 | /// An ident can be interpolated into a token stream using the `quote!` macro. |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 60 | /// |
| 61 | /// ```rust |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 62 | /// #[macro_use] |
| 63 | /// extern crate quote; |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 64 | /// |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 65 | /// extern crate syn; |
| 66 | /// use syn::Ident; |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 67 | /// |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 68 | /// fn main() { |
| 69 | /// let ident = Ident::from("demo"); |
| 70 | /// |
| 71 | /// // Create a variable binding whose name is this ident. |
| 72 | /// let expanded = quote! { let #ident = 10; }; |
| 73 | /// |
| 74 | /// // Create a variable binding with a slightly different name. |
| 75 | /// let temp_ident = Ident::from(format!("new_{}", ident)); |
| 76 | /// let expanded = quote! { let #temp_ident = 10; }; |
| 77 | /// } |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 78 | /// ``` |
| 79 | /// |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 80 | /// A string representation of the ident is available through the `as_ref()` and |
| 81 | /// `to_string()` methods. |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 82 | /// |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 83 | /// ```rust |
| 84 | /// # use syn::Ident; |
| 85 | /// # let ident = Ident::from("another_identifier"); |
| 86 | /// # |
| 87 | /// // Examine the ident as a &str. |
| 88 | /// let ident_str = ident.as_ref(); |
| 89 | /// if ident_str.len() > 60 { |
| 90 | /// println!("Very long identifier: {}", ident_str) |
| 91 | /// } |
| 92 | /// |
| 93 | /// // Create a String from the ident. |
| 94 | /// let ident_string = ident.to_string(); |
| 95 | /// give_away(ident_string); |
| 96 | /// |
| 97 | /// fn give_away(s: String) { /* ... */ } |
| 98 | /// ``` |
David Tolnay | 570695e | 2017-06-03 16:15:13 -0700 | [diff] [blame] | 99 | #[derive(Copy, Clone, Debug)] |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 100 | pub struct Ident { |
David Tolnay | 73c98de | 2017-12-31 15:56:56 -0500 | [diff] [blame] | 101 | term: Term, |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 102 | pub span: Span, |
| 103 | } |
David Tolnay | 42f5029 | 2016-09-04 13:54:21 -0700 | [diff] [blame] | 104 | |
| 105 | impl Ident { |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 106 | /// Creates an ident with the given string representation. |
Mikko Rantanen | a87ac03 | 2017-10-30 08:19:00 +0200 | [diff] [blame] | 107 | /// |
David Tolnay | 9c92c41 | 2018-01-23 00:28:30 -0800 | [diff] [blame] | 108 | /// # Panics |
| 109 | /// |
| 110 | /// Panics if the input string is neither a keyword nor a legal variable |
| 111 | /// name. |
David Tolnay | eb771d7 | 2017-12-27 22:11:06 -0500 | [diff] [blame] | 112 | pub fn new(s: &str, span: Span) -> Self { |
David Tolnay | 570695e | 2017-06-03 16:15:13 -0700 | [diff] [blame] | 113 | if s.is_empty() { |
| 114 | panic!("ident is not allowed to be empty; use Option<Ident>"); |
| 115 | } |
| 116 | |
| 117 | if s.starts_with('\'') { |
| 118 | panic!("ident is not allowed to be a lifetime; use syn::Lifetime"); |
| 119 | } |
| 120 | |
| 121 | if s == "_" { |
David Tolnay | 32954ef | 2017-12-26 22:43:16 -0500 | [diff] [blame] | 122 | panic!("`_` is not a valid ident; use syn::token::Underscore"); |
David Tolnay | 570695e | 2017-06-03 16:15:13 -0700 | [diff] [blame] | 123 | } |
| 124 | |
David Tolnay | 1498201 | 2017-12-29 00:49:51 -0500 | [diff] [blame] | 125 | if s.bytes().all(|digit| digit >= b'0' && digit <= b'9') { |
| 126 | panic!("ident cannot be a number, use syn::Index instead"); |
| 127 | } |
| 128 | |
David Tolnay | 570695e | 2017-06-03 16:15:13 -0700 | [diff] [blame] | 129 | fn xid_ok(s: &str) -> bool { |
| 130 | let mut chars = s.chars(); |
| 131 | let first = chars.next().unwrap(); |
| 132 | if !(UnicodeXID::is_xid_start(first) || first == '_') { |
| 133 | return false; |
| 134 | } |
| 135 | for ch in chars { |
| 136 | if !UnicodeXID::is_xid_continue(ch) { |
| 137 | return false; |
| 138 | } |
| 139 | } |
| 140 | true |
| 141 | } |
| 142 | |
David Tolnay | 1498201 | 2017-12-29 00:49:51 -0500 | [diff] [blame] | 143 | if !xid_ok(s) { |
David Tolnay | 570695e | 2017-06-03 16:15:13 -0700 | [diff] [blame] | 144 | panic!("{:?} is not a valid ident", s); |
| 145 | } |
| 146 | |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 147 | Ident { |
David Tolnay | 73c98de | 2017-12-31 15:56:56 -0500 | [diff] [blame] | 148 | term: Term::intern(s), |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 149 | span: span, |
| 150 | } |
David Tolnay | 42f5029 | 2016-09-04 13:54:21 -0700 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | |
| 154 | impl<'a> From<&'a str> for Ident { |
| 155 | fn from(s: &str) -> Self { |
David Tolnay | 66bb8d5 | 2018-01-08 08:22:31 -0800 | [diff] [blame] | 156 | Ident::new(s, Span::def_site()) |
David Tolnay | 42f5029 | 2016-09-04 13:54:21 -0700 | [diff] [blame] | 157 | } |
| 158 | } |
| 159 | |
David Tolnay | f8db7ba | 2017-11-11 22:52:16 -0800 | [diff] [blame] | 160 | impl From<Token![self]> for Ident { |
| 161 | fn from(tok: Token![self]) -> Self { |
David Tolnay | eb771d7 | 2017-12-27 22:11:06 -0500 | [diff] [blame] | 162 | Ident::new("self", tok.0) |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 163 | } |
| 164 | } |
| 165 | |
David Tolnay | f8db7ba | 2017-11-11 22:52:16 -0800 | [diff] [blame] | 166 | impl From<Token![Self]> for Ident { |
| 167 | fn from(tok: Token![Self]) -> Self { |
David Tolnay | eb771d7 | 2017-12-27 22:11:06 -0500 | [diff] [blame] | 168 | Ident::new("Self", tok.0) |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 169 | } |
| 170 | } |
| 171 | |
David Tolnay | f8db7ba | 2017-11-11 22:52:16 -0800 | [diff] [blame] | 172 | impl From<Token![super]> for Ident { |
| 173 | fn from(tok: Token![super]) -> Self { |
David Tolnay | eb771d7 | 2017-12-27 22:11:06 -0500 | [diff] [blame] | 174 | Ident::new("super", tok.0) |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 175 | } |
| 176 | } |
| 177 | |
David Tolnay | dfc6df7 | 2017-12-25 23:44:08 -0500 | [diff] [blame] | 178 | impl From<Token![crate]> for Ident { |
| 179 | fn from(tok: Token![crate]) -> Self { |
David Tolnay | eb771d7 | 2017-12-27 22:11:06 -0500 | [diff] [blame] | 180 | Ident::new("crate", tok.0) |
David Tolnay | dfc6df7 | 2017-12-25 23:44:08 -0500 | [diff] [blame] | 181 | } |
| 182 | } |
| 183 | |
David Tolnay | f733f7e | 2016-11-25 10:36:25 -0800 | [diff] [blame] | 184 | impl<'a> From<Cow<'a, str>> for Ident { |
| 185 | fn from(s: Cow<'a, str>) -> Self { |
David Tolnay | 66bb8d5 | 2018-01-08 08:22:31 -0800 | [diff] [blame] | 186 | Ident::new(&s, Span::def_site()) |
David Tolnay | f733f7e | 2016-11-25 10:36:25 -0800 | [diff] [blame] | 187 | } |
| 188 | } |
| 189 | |
David Tolnay | 42f5029 | 2016-09-04 13:54:21 -0700 | [diff] [blame] | 190 | impl From<String> for Ident { |
| 191 | fn from(s: String) -> Self { |
David Tolnay | 66bb8d5 | 2018-01-08 08:22:31 -0800 | [diff] [blame] | 192 | Ident::new(&s, Span::def_site()) |
David Tolnay | 42f5029 | 2016-09-04 13:54:21 -0700 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | |
David Tolnay | 2646907 | 2016-09-04 13:59:48 -0700 | [diff] [blame] | 196 | impl AsRef<str> for Ident { |
| 197 | fn as_ref(&self) -> &str { |
David Tolnay | 73c98de | 2017-12-31 15:56:56 -0500 | [diff] [blame] | 198 | self.term.as_str() |
David Tolnay | 42f5029 | 2016-09-04 13:54:21 -0700 | [diff] [blame] | 199 | } |
| 200 | } |
| 201 | |
| 202 | impl Display for Ident { |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 203 | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
David Tolnay | 73c98de | 2017-12-31 15:56:56 -0500 | [diff] [blame] | 204 | self.term.as_str().fmt(formatter) |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | |
David Tolnay | daaf774 | 2016-10-03 11:11:43 -0700 | [diff] [blame] | 208 | impl<T: ?Sized> PartialEq<T> for Ident |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 209 | where |
| 210 | T: AsRef<str>, |
David Tolnay | daaf774 | 2016-10-03 11:11:43 -0700 | [diff] [blame] | 211 | { |
David Tolnay | 5533772 | 2016-09-11 12:58:56 -0700 | [diff] [blame] | 212 | fn eq(&self, other: &T) -> bool { |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 213 | self.as_ref() == other.as_ref() |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | impl Eq for Ident {} |
| 218 | |
| 219 | impl PartialOrd for Ident { |
| 220 | fn partial_cmp(&self, other: &Ident) -> Option<Ordering> { |
| 221 | Some(self.cmp(other)) |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | impl Ord for Ident { |
| 226 | fn cmp(&self, other: &Ident) -> Ordering { |
| 227 | self.as_ref().cmp(other.as_ref()) |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | impl Hash for Ident { |
| 232 | fn hash<H: Hasher>(&self, h: &mut H) { |
David Tolnay | 85b69a4 | 2017-12-27 20:43:10 -0500 | [diff] [blame] | 233 | self.as_ref().hash(h); |
David Tolnay | 5533772 | 2016-09-11 12:58:56 -0700 | [diff] [blame] | 234 | } |
David Tolnay | b79ee96 | 2016-09-04 09:39:20 -0700 | [diff] [blame] | 235 | } |
| 236 | |
David Tolnay | 86eca75 | 2016-09-04 11:26:41 -0700 | [diff] [blame] | 237 | #[cfg(feature = "parsing")] |
David Tolnay | 9d8f197 | 2016-09-04 11:58:48 -0700 | [diff] [blame] | 238 | pub mod parsing { |
| 239 | use super::*; |
David Tolnay | c5ab8c6 | 2017-12-26 16:43:39 -0500 | [diff] [blame] | 240 | use synom::Synom; |
David Tolnay | dfc886b | 2018-01-06 08:03:09 -0800 | [diff] [blame] | 241 | use buffer::Cursor; |
David Tolnay | 203557a | 2017-12-27 23:59:33 -0500 | [diff] [blame] | 242 | use parse_error; |
| 243 | use synom::PResult; |
David Tolnay | 9d8f197 | 2016-09-04 11:58:48 -0700 | [diff] [blame] | 244 | |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 245 | impl Synom for Ident { |
Michael Layzell | 92639a5 | 2017-06-01 00:07:44 -0400 | [diff] [blame] | 246 | fn parse(input: Cursor) -> PResult<Self> { |
David Tolnay | 6572948 | 2017-12-31 16:14:50 -0500 | [diff] [blame] | 247 | let (span, term, rest) = match input.term() { |
David Tolnay | 73c98de | 2017-12-31 15:56:56 -0500 | [diff] [blame] | 248 | Some(term) => term, |
Michael Layzell | 92639a5 | 2017-06-01 00:07:44 -0400 | [diff] [blame] | 249 | _ => return parse_error(), |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 250 | }; |
David Tolnay | 73c98de | 2017-12-31 15:56:56 -0500 | [diff] [blame] | 251 | if term.as_str().starts_with('\'') { |
Michael Layzell | 92639a5 | 2017-06-01 00:07:44 -0400 | [diff] [blame] | 252 | return parse_error(); |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 253 | } |
David Tolnay | 73c98de | 2017-12-31 15:56:56 -0500 | [diff] [blame] | 254 | match term.as_str() { |
Michael Layzell | 416724e | 2017-05-24 21:12:34 -0400 | [diff] [blame] | 255 | // From https://doc.rust-lang.org/grammar.html#keywords |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 256 | "abstract" | "alignof" | "as" | "become" | "box" | "break" | "const" |
| 257 | | "continue" | "crate" | "do" | "else" | "enum" | "extern" | "false" | "final" |
| 258 | | "fn" | "for" | "if" | "impl" | "in" | "let" | "loop" | "macro" | "match" |
| 259 | | "mod" | "move" | "mut" | "offsetof" | "override" | "priv" | "proc" | "pub" |
| 260 | | "pure" | "ref" | "return" | "Self" | "self" | "sizeof" | "static" | "struct" |
| 261 | | "super" | "trait" | "true" | "type" | "typeof" | "unsafe" | "unsized" | "use" |
| 262 | | "virtual" | "where" | "while" | "yield" => return parse_error(), |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 263 | _ => {} |
Michael Layzell | 416724e | 2017-05-24 21:12:34 -0400 | [diff] [blame] | 264 | } |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 265 | |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 266 | Ok(( |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 267 | Ident { |
| 268 | span: span, |
David Tolnay | 73c98de | 2017-12-31 15:56:56 -0500 | [diff] [blame] | 269 | term: term, |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 270 | }, |
David Tolnay | f4aa6b4 | 2017-12-31 16:40:33 -0500 | [diff] [blame] | 271 | rest, |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 272 | )) |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | fn description() -> Option<&'static str> { |
| 276 | Some("identifier") |
David Tolnay | 05f462f | 2016-10-24 22:19:42 -0700 | [diff] [blame] | 277 | } |
| 278 | } |
David Tolnay | b79ee96 | 2016-09-04 09:39:20 -0700 | [diff] [blame] | 279 | } |
David Tolnay | 2646907 | 2016-09-04 13:59:48 -0700 | [diff] [blame] | 280 | |
| 281 | #[cfg(feature = "printing")] |
| 282 | mod printing { |
| 283 | use super::*; |
David Tolnay | 5138205 | 2017-12-27 13:46:21 -0500 | [diff] [blame] | 284 | use quote::{ToTokens, Tokens}; |
| 285 | use proc_macro2::{TokenNode, TokenTree}; |
David Tolnay | 2646907 | 2016-09-04 13:59:48 -0700 | [diff] [blame] | 286 | |
| 287 | impl ToTokens for Ident { |
| 288 | fn to_tokens(&self, tokens: &mut Tokens) { |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 289 | tokens.append(TokenTree { |
David Tolnay | 9894256 | 2017-12-26 21:24:35 -0500 | [diff] [blame] | 290 | span: self.span, |
David Tolnay | 73c98de | 2017-12-31 15:56:56 -0500 | [diff] [blame] | 291 | kind: TokenNode::Term(self.term), |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 292 | }) |
David Tolnay | 2646907 | 2016-09-04 13:59:48 -0700 | [diff] [blame] | 293 | } |
| 294 | } |
| 295 | } |