Alex Crichton | a914a61 | 2018-04-04 07:48:44 -0700 | [diff] [blame] | 1 | #![cfg_attr(not(procmacro2_semver_exempt), allow(dead_code))] |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 2 | |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 3 | use std::fmt; |
| 4 | use std::iter; |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 5 | use std::str::FromStr; |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 6 | use std::panic; |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 7 | |
| 8 | use proc_macro; |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 9 | use stable; |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 10 | |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 11 | use {Delimiter, Group, Punct, Spacing, TokenTree}; |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 12 | |
| 13 | #[derive(Clone)] |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 14 | pub enum TokenStream { |
| 15 | Nightly(proc_macro::TokenStream), |
| 16 | Stable(stable::TokenStream), |
| 17 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 18 | |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 19 | pub enum LexError { |
| 20 | Nightly(proc_macro::LexError), |
| 21 | Stable(stable::LexError), |
| 22 | } |
| 23 | |
| 24 | fn nightly_works() -> bool { |
| 25 | use std::sync::atomic::*; |
| 26 | static WORKS: AtomicUsize = ATOMIC_USIZE_INIT; |
| 27 | |
| 28 | match WORKS.load(Ordering::SeqCst) { |
| 29 | 1 => return false, |
| 30 | 2 => return true, |
| 31 | _ => {} |
| 32 | } |
| 33 | let works = panic::catch_unwind(|| proc_macro::Span::call_site()).is_ok(); |
| 34 | WORKS.store(works as usize + 1, Ordering::SeqCst); |
| 35 | works |
| 36 | } |
| 37 | |
| 38 | fn mismatch() -> ! { |
| 39 | panic!("stable/nightly mismatch") |
| 40 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 41 | |
| 42 | impl TokenStream { |
| 43 | pub fn empty() -> TokenStream { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 44 | if nightly_works() { |
| 45 | TokenStream::Nightly(proc_macro::TokenStream::empty()) |
| 46 | } else { |
| 47 | TokenStream::Stable(stable::TokenStream::empty()) |
| 48 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | pub fn is_empty(&self) -> bool { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 52 | match self { |
| 53 | TokenStream::Nightly(tts) => tts.is_empty(), |
| 54 | TokenStream::Stable(tts) => tts.is_empty(), |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | fn unwrap_nightly(self) -> proc_macro::TokenStream { |
| 59 | match self { |
| 60 | TokenStream::Nightly(s) => s, |
| 61 | TokenStream::Stable(_) => mismatch(), |
| 62 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | |
| 66 | impl FromStr for TokenStream { |
| 67 | type Err = LexError; |
| 68 | |
| 69 | fn from_str(src: &str) -> Result<TokenStream, LexError> { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 70 | if nightly_works() { |
| 71 | Ok(TokenStream::Nightly(src.parse()?)) |
| 72 | } else { |
| 73 | Ok(TokenStream::Stable(src.parse()?)) |
| 74 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 75 | } |
| 76 | } |
| 77 | |
| 78 | impl fmt::Display for TokenStream { |
| 79 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 80 | match self { |
| 81 | TokenStream::Nightly(tts) => tts.fmt(f), |
| 82 | TokenStream::Stable(tts) => tts.fmt(f), |
| 83 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 84 | } |
| 85 | } |
| 86 | |
| 87 | impl From<proc_macro::TokenStream> for TokenStream { |
| 88 | fn from(inner: proc_macro::TokenStream) -> TokenStream { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 89 | TokenStream::Nightly(inner) |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 90 | } |
| 91 | } |
| 92 | |
| 93 | impl From<TokenStream> for proc_macro::TokenStream { |
| 94 | fn from(inner: TokenStream) -> proc_macro::TokenStream { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 95 | match inner { |
| 96 | TokenStream::Nightly(inner) => inner, |
| 97 | TokenStream::Stable(inner) => inner.to_string().parse().unwrap(), |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | impl From<stable::TokenStream> for TokenStream { |
| 103 | fn from(inner: stable::TokenStream) -> TokenStream { |
| 104 | TokenStream::Stable(inner) |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 105 | } |
| 106 | } |
| 107 | |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 108 | impl From<TokenTree> for TokenStream { |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 109 | fn from(token: TokenTree) -> TokenStream { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 110 | if !nightly_works() { |
| 111 | return TokenStream::Stable(token.into()) |
| 112 | } |
Alex Crichton | 9cd80a6 | 2018-04-05 17:46:58 -0700 | [diff] [blame] | 113 | let tt: proc_macro::TokenTree = match token { |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 114 | TokenTree::Group(tt) => { |
| 115 | let delim = match tt.delimiter() { |
| 116 | Delimiter::Parenthesis => proc_macro::Delimiter::Parenthesis, |
| 117 | Delimiter::Bracket => proc_macro::Delimiter::Bracket, |
| 118 | Delimiter::Brace => proc_macro::Delimiter::Brace, |
| 119 | Delimiter::None => proc_macro::Delimiter::None, |
| 120 | }; |
Alex Crichton | 9cd80a6 | 2018-04-05 17:46:58 -0700 | [diff] [blame] | 121 | let span = tt.span(); |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 122 | let mut group = proc_macro::Group::new(delim, tt.stream.inner.unwrap_nightly()); |
| 123 | group.set_span(span.inner.unwrap_nightly()); |
Alex Crichton | 9cd80a6 | 2018-04-05 17:46:58 -0700 | [diff] [blame] | 124 | group.into() |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 125 | } |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 126 | TokenTree::Punct(tt) => { |
Alex Crichton | 9cd80a6 | 2018-04-05 17:46:58 -0700 | [diff] [blame] | 127 | let spacing = match tt.spacing() { |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 128 | Spacing::Joint => proc_macro::Spacing::Joint, |
| 129 | Spacing::Alone => proc_macro::Spacing::Alone, |
| 130 | }; |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 131 | let mut op = proc_macro::Punct::new(tt.as_char(), spacing); |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 132 | op.set_span(tt.span().inner.unwrap_nightly()); |
Alex Crichton | 9cd80a6 | 2018-04-05 17:46:58 -0700 | [diff] [blame] | 133 | op.into() |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 134 | } |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 135 | TokenTree::Ident(tt) => tt.inner.unwrap_nightly().into(), |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 136 | TokenTree::Literal(tt) => tt.inner.unwrap_nightly().into(), |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 137 | }; |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 138 | TokenStream::Nightly(tt.into()) |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 139 | } |
| 140 | } |
| 141 | |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 142 | impl iter::FromIterator<TokenTree> for TokenStream { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 143 | fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self { |
| 144 | if nightly_works() { |
| 145 | let trees = trees.into_iter() |
| 146 | .map(TokenStream::from) |
| 147 | .flat_map(|t| { |
| 148 | match t { |
| 149 | TokenStream::Nightly(s) => s, |
| 150 | TokenStream::Stable(_) => mismatch(), |
| 151 | } |
| 152 | }); |
| 153 | TokenStream::Nightly(trees.collect()) |
| 154 | } else { |
| 155 | TokenStream::Stable(trees.into_iter().collect()) |
| 156 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 157 | } |
| 158 | } |
| 159 | |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 160 | impl Extend<TokenTree> for TokenStream { |
| 161 | fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, streams: I) { |
| 162 | match self { |
| 163 | TokenStream::Nightly(tts) => { |
| 164 | *tts = tts.clone() |
| 165 | .into_iter() |
| 166 | .chain( |
| 167 | streams.into_iter() |
| 168 | .map(TokenStream::from) |
| 169 | .flat_map(|t| { |
| 170 | match t { |
| 171 | TokenStream::Nightly(tts) => tts.into_iter(), |
| 172 | _ => panic!() |
| 173 | } |
| 174 | }) |
| 175 | ) |
| 176 | .collect(); |
| 177 | } |
| 178 | TokenStream::Stable(tts) => tts.extend(streams), |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 183 | impl fmt::Debug for TokenStream { |
| 184 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 185 | match self { |
| 186 | TokenStream::Nightly(tts) => tts.fmt(f), |
| 187 | TokenStream::Stable(tts) => tts.fmt(f), |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | impl From<proc_macro::LexError> for LexError { |
| 193 | fn from(e: proc_macro::LexError) -> LexError { |
| 194 | LexError::Nightly(e) |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | impl From<stable::LexError> for LexError { |
| 199 | fn from(e: stable::LexError) -> LexError { |
| 200 | LexError::Stable(e) |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | |
| 204 | impl fmt::Debug for LexError { |
| 205 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 206 | match self { |
| 207 | LexError::Nightly(e) => e.fmt(f), |
| 208 | LexError::Stable(e) => e.fmt(f), |
| 209 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 210 | } |
| 211 | } |
| 212 | |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 213 | pub enum TokenTreeIter { |
| 214 | Nightly(proc_macro::token_stream::IntoIter), |
| 215 | Stable(stable::TokenTreeIter), |
| 216 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 217 | |
| 218 | impl IntoIterator for TokenStream { |
| 219 | type Item = TokenTree; |
Alex Crichton | 1a7f762 | 2017-07-05 17:47:15 -0700 | [diff] [blame] | 220 | type IntoIter = TokenTreeIter; |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 221 | |
Alex Crichton | 1a7f762 | 2017-07-05 17:47:15 -0700 | [diff] [blame] | 222 | fn into_iter(self) -> TokenTreeIter { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 223 | match self { |
| 224 | TokenStream::Nightly(tts) => TokenTreeIter::Nightly(tts.into_iter()), |
| 225 | TokenStream::Stable(tts) => TokenTreeIter::Stable(tts.into_iter()), |
| 226 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 227 | } |
| 228 | } |
| 229 | |
Alex Crichton | 1a7f762 | 2017-07-05 17:47:15 -0700 | [diff] [blame] | 230 | impl Iterator for TokenTreeIter { |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 231 | type Item = TokenTree; |
| 232 | |
| 233 | fn next(&mut self) -> Option<TokenTree> { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 234 | let token = match self { |
| 235 | TokenTreeIter::Nightly(iter) => iter.next()?, |
| 236 | TokenTreeIter::Stable(iter) => return iter.next(), |
| 237 | }; |
Alex Crichton | 9cd80a6 | 2018-04-05 17:46:58 -0700 | [diff] [blame] | 238 | Some(match token { |
| 239 | proc_macro::TokenTree::Group(tt) => { |
| 240 | let delim = match tt.delimiter() { |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 241 | proc_macro::Delimiter::Parenthesis => Delimiter::Parenthesis, |
| 242 | proc_macro::Delimiter::Bracket => Delimiter::Bracket, |
| 243 | proc_macro::Delimiter::Brace => Delimiter::Brace, |
| 244 | proc_macro::Delimiter::None => Delimiter::None, |
| 245 | }; |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 246 | let stream = ::TokenStream::_new(TokenStream::Nightly(tt.stream())); |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 247 | let mut g = Group::new(delim, stream); |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 248 | g.set_span(::Span::_new(Span::Nightly(tt.span()))); |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 249 | g.into() |
| 250 | } |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 251 | proc_macro::TokenTree::Punct(tt) => { |
Alex Crichton | 9cd80a6 | 2018-04-05 17:46:58 -0700 | [diff] [blame] | 252 | let spacing = match tt.spacing() { |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 253 | proc_macro::Spacing::Joint => Spacing::Joint, |
| 254 | proc_macro::Spacing::Alone => Spacing::Alone, |
| 255 | }; |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 256 | let mut o = Punct::new(tt.as_char(), spacing); |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 257 | o.set_span(::Span::_new(Span::Nightly(tt.span()))); |
Alex Crichton | af5bad4 | 2018-03-27 14:45:10 -0700 | [diff] [blame] | 258 | o.into() |
| 259 | } |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 260 | proc_macro::TokenTree::Ident(s) => ::Ident::_new(Ident::Nightly(s)).into(), |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 261 | proc_macro::TokenTree::Literal(l) => ::Literal::_new(Literal::Nightly(l)).into(), |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 262 | }) |
| 263 | } |
| 264 | |
| 265 | fn size_hint(&self) -> (usize, Option<usize>) { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 266 | match self { |
| 267 | TokenTreeIter::Nightly(tts) => tts.size_hint(), |
| 268 | TokenTreeIter::Stable(tts) => tts.size_hint(), |
| 269 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 270 | } |
| 271 | } |
| 272 | |
Alex Crichton | 1a7f762 | 2017-07-05 17:47:15 -0700 | [diff] [blame] | 273 | impl fmt::Debug for TokenTreeIter { |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 274 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
Alex Crichton | 1a7f762 | 2017-07-05 17:47:15 -0700 | [diff] [blame] | 275 | f.debug_struct("TokenTreeIter").finish() |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 276 | } |
| 277 | } |
| 278 | |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 279 | pub use stable::FileName; |
Nika Layzell | b35a9a3 | 2017-12-30 14:34:35 -0500 | [diff] [blame] | 280 | |
| 281 | // NOTE: We have to generate our own filename object here because we can't wrap |
| 282 | // the one provided by proc_macro. |
| 283 | #[derive(Clone, PartialEq, Eq)] |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 284 | pub enum SourceFile { |
| 285 | Nightly(proc_macro::SourceFile, FileName), |
| 286 | Stable(stable::SourceFile), |
| 287 | } |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 288 | |
| 289 | impl SourceFile { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 290 | fn nightly(sf: proc_macro::SourceFile) -> Self { |
| 291 | let filename = stable::file_name(sf.path().to_string()); |
| 292 | SourceFile::Nightly(sf, filename) |
Nika Layzell | b35a9a3 | 2017-12-30 14:34:35 -0500 | [diff] [blame] | 293 | } |
| 294 | |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 295 | /// Get the path to this source file as a string. |
Nika Layzell | b35a9a3 | 2017-12-30 14:34:35 -0500 | [diff] [blame] | 296 | pub fn path(&self) -> &FileName { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 297 | match self { |
| 298 | SourceFile::Nightly(_, f) => f, |
| 299 | SourceFile::Stable(a) => a.path(), |
| 300 | } |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | pub fn is_real(&self) -> bool { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 304 | match self { |
| 305 | SourceFile::Nightly(a, _) => a.is_real(), |
| 306 | SourceFile::Stable(a) => a.is_real(), |
| 307 | } |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | |
Nika Layzell | b35a9a3 | 2017-12-30 14:34:35 -0500 | [diff] [blame] | 311 | impl AsRef<FileName> for SourceFile { |
| 312 | fn as_ref(&self) -> &FileName { |
| 313 | self.path() |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 314 | } |
| 315 | } |
| 316 | |
| 317 | impl fmt::Debug for SourceFile { |
| 318 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 319 | match self { |
| 320 | SourceFile::Nightly(a, _) => a.fmt(f), |
| 321 | SourceFile::Stable(a) => a.fmt(f), |
| 322 | } |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 323 | } |
| 324 | } |
| 325 | |
Nika Layzell | 1ecb6ce | 2017-12-30 14:34:05 -0500 | [diff] [blame] | 326 | pub struct LineColumn { |
| 327 | pub line: usize, |
| 328 | pub column: usize, |
| 329 | } |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 330 | |
Alex Crichton | 9cd80a6 | 2018-04-05 17:46:58 -0700 | [diff] [blame] | 331 | #[derive(Copy, Clone)] |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 332 | pub enum Span { |
| 333 | Nightly(proc_macro::Span), |
| 334 | Stable(stable::Span), |
Sergio Benitez | 1380508 | 2018-01-04 01:25:45 -0800 | [diff] [blame] | 335 | } |
| 336 | |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 337 | impl Span { |
| 338 | pub fn call_site() -> Span { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 339 | if nightly_works() { |
| 340 | Span::Nightly(proc_macro::Span::call_site()) |
| 341 | } else { |
| 342 | Span::Stable(stable::Span::call_site()) |
| 343 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 344 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 345 | |
Alex Crichton | e6085b7 | 2017-11-21 07:24:25 -0800 | [diff] [blame] | 346 | pub fn def_site() -> Span { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 347 | if nightly_works() { |
| 348 | Span::Nightly(proc_macro::Span::def_site()) |
| 349 | } else { |
| 350 | Span::Stable(stable::Span::def_site()) |
| 351 | } |
Alex Crichton | 998f642 | 2017-11-19 08:06:27 -0800 | [diff] [blame] | 352 | } |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 353 | |
David Tolnay | 4e8e397 | 2018-01-05 18:10:22 -0800 | [diff] [blame] | 354 | pub fn resolved_at(&self, other: Span) -> Span { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 355 | match (self, other) { |
| 356 | (Span::Nightly(a), Span::Nightly(b)) => Span::Nightly(a.resolved_at(b)), |
| 357 | (Span::Stable(a), Span::Stable(b)) => Span::Stable(a.resolved_at(b)), |
| 358 | _ => mismatch(), |
| 359 | } |
David Tolnay | 4e8e397 | 2018-01-05 18:10:22 -0800 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | pub fn located_at(&self, other: Span) -> Span { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 363 | match (self, other) { |
| 364 | (Span::Nightly(a), Span::Nightly(b)) => Span::Nightly(a.located_at(b)), |
| 365 | (Span::Stable(a), Span::Stable(b)) => Span::Stable(a.located_at(b)), |
| 366 | _ => mismatch(), |
| 367 | } |
David Tolnay | 4e8e397 | 2018-01-05 18:10:22 -0800 | [diff] [blame] | 368 | } |
| 369 | |
David Tolnay | 16a1720 | 2017-12-31 10:47:24 -0500 | [diff] [blame] | 370 | pub fn unstable(self) -> proc_macro::Span { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 371 | match self { |
| 372 | Span::Nightly(s) => s, |
| 373 | Span::Stable(_) => mismatch(), |
| 374 | } |
David Tolnay | 16a1720 | 2017-12-31 10:47:24 -0500 | [diff] [blame] | 375 | } |
| 376 | |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 377 | #[cfg(procmacro2_semver_exempt)] |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 378 | pub fn source_file(&self) -> SourceFile { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 379 | match self { |
| 380 | Span::Nightly(s) => SourceFile::nightly(s.source_file()), |
| 381 | Span::Stable(s) => SourceFile::Stable(s.source_file()), |
| 382 | } |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 383 | } |
| 384 | |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 385 | #[cfg(procmacro2_semver_exempt)] |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 386 | pub fn start(&self) -> LineColumn { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 387 | match self { |
| 388 | Span::Nightly(s) => { |
| 389 | let proc_macro::LineColumn { line, column } = s.start(); |
| 390 | LineColumn { line, column } |
| 391 | } |
| 392 | Span::Stable(s) => { |
| 393 | let stable::LineColumn { line, column } = s.start(); |
| 394 | LineColumn { line, column } |
| 395 | } |
| 396 | } |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 397 | } |
| 398 | |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 399 | #[cfg(procmacro2_semver_exempt)] |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 400 | pub fn end(&self) -> LineColumn { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 401 | match self { |
| 402 | Span::Nightly(s) => { |
| 403 | let proc_macro::LineColumn { line, column } = s.end(); |
| 404 | LineColumn { line, column } |
| 405 | } |
| 406 | Span::Stable(s) => { |
| 407 | let stable::LineColumn { line, column } = s.end(); |
| 408 | LineColumn { line, column } |
| 409 | } |
| 410 | } |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 411 | } |
| 412 | |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 413 | #[cfg(procmacro2_semver_exempt)] |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 414 | pub fn join(&self, other: Span) -> Option<Span> { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 415 | let ret = match (self, other) { |
| 416 | (Span::Nightly(a), Span::Nightly(b)) => Span::Nightly(a.join(b)?), |
| 417 | (Span::Stable(a), Span::Stable(b)) => Span::Stable(a.join(b)?), |
| 418 | _ => return None, |
| 419 | }; |
| 420 | Some(ret) |
Nika Layzell | f8d5f21 | 2017-12-11 14:07:02 -0500 | [diff] [blame] | 421 | } |
Alex Crichton | e24f734 | 2018-04-05 17:58:11 -0700 | [diff] [blame] | 422 | |
| 423 | pub fn eq(&self, other: &Span) -> bool { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 424 | match (self, other) { |
| 425 | (Span::Nightly(a), Span::Nightly(b)) => a.eq(b), |
| 426 | (Span::Stable(a), Span::Stable(b)) => a.eq(b), |
| 427 | _ => false, |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | fn unwrap_nightly(self) -> proc_macro::Span { |
| 432 | match self { |
| 433 | Span::Nightly(s) => s, |
| 434 | Span::Stable(_) => mismatch(), |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | impl From<proc_macro::Span> for ::Span { |
| 440 | fn from(proc_span: proc_macro::Span) -> ::Span { |
| 441 | ::Span::_new(Span::Nightly(proc_span)) |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | impl From<stable::Span> for Span { |
| 446 | fn from(inner: stable::Span) -> Span { |
| 447 | Span::Stable(inner) |
Alex Crichton | e24f734 | 2018-04-05 17:58:11 -0700 | [diff] [blame] | 448 | } |
Alex Crichton | 998f642 | 2017-11-19 08:06:27 -0800 | [diff] [blame] | 449 | } |
| 450 | |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 451 | impl fmt::Debug for Span { |
| 452 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 453 | match self { |
| 454 | Span::Nightly(s) => s.fmt(f), |
| 455 | Span::Stable(s) => s.fmt(f), |
| 456 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 457 | } |
| 458 | } |
| 459 | |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 460 | #[derive(Clone)] |
| 461 | pub enum Ident { |
| 462 | Nightly(proc_macro::Ident), |
| 463 | Stable(stable::Ident), |
Alex Crichton | b2c9462 | 2018-04-04 07:36:41 -0700 | [diff] [blame] | 464 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 465 | |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 466 | impl Ident { |
| 467 | pub fn new(string: &str, span: Span) -> Ident { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 468 | match span { |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 469 | Span::Nightly(s) => Ident::Nightly(proc_macro::Ident::new(string, s)), |
| 470 | Span::Stable(s) => Ident::Stable(stable::Ident::new(string, s)), |
Alex Crichton | b2c9462 | 2018-04-04 07:36:41 -0700 | [diff] [blame] | 471 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 472 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 473 | |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 474 | pub fn new_raw(string: &str, span: Span) -> Ident { |
| 475 | match span { |
| 476 | Span::Nightly(s) => Ident::Nightly(proc_macro::Ident::new_raw(string, s)), |
| 477 | Span::Stable(s) => Ident::Stable(stable::Ident::new_raw(string, s)), |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 478 | } |
Alex Crichton | b2c9462 | 2018-04-04 07:36:41 -0700 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | pub fn span(&self) -> Span { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 482 | match self { |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 483 | Ident::Nightly(t) => Span::Nightly(t.span()), |
| 484 | Ident::Stable(t) => Span::Stable(t.span()), |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 485 | } |
Alex Crichton | b2c9462 | 2018-04-04 07:36:41 -0700 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | pub fn set_span(&mut self, span: Span) { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 489 | match (self, span) { |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 490 | (Ident::Nightly(t), Span::Nightly(s)) => t.set_span(s), |
| 491 | (Ident::Stable(t), Span::Stable(s)) => t.set_span(s), |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 492 | _ => mismatch(), |
| 493 | } |
| 494 | } |
| 495 | |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 496 | fn unwrap_nightly(self) -> proc_macro::Ident { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 497 | match self { |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 498 | Ident::Nightly(s) => s, |
| 499 | Ident::Stable(_) => mismatch(), |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 500 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 501 | } |
| 502 | } |
| 503 | |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 504 | impl fmt::Display for Ident { |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 505 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 506 | match self { |
Alex Crichton | f388843 | 2018-05-16 09:11:05 -0700 | [diff] [blame] | 507 | Ident::Nightly(t) => t.fmt(f), |
| 508 | Ident::Stable(t) => t.fmt(f), |
| 509 | } |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | impl fmt::Debug for Ident { |
| 514 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 515 | match self { |
| 516 | Ident::Nightly(t) => t.fmt(f), |
| 517 | Ident::Stable(t) => t.fmt(f), |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 518 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 519 | } |
| 520 | } |
| 521 | |
| 522 | #[derive(Clone)] |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 523 | pub enum Literal { |
| 524 | Nightly(proc_macro::Literal), |
| 525 | Stable(stable::Literal), |
Alex Crichton | b2c9462 | 2018-04-04 07:36:41 -0700 | [diff] [blame] | 526 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 527 | |
Alex Crichton | a914a61 | 2018-04-04 07:48:44 -0700 | [diff] [blame] | 528 | macro_rules! suffixed_numbers { |
| 529 | ($($name:ident => $kind:ident,)*) => ($( |
| 530 | pub fn $name(n: $kind) -> Literal { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 531 | if nightly_works() { |
| 532 | Literal::Nightly(proc_macro::Literal::$name(n)) |
| 533 | } else { |
| 534 | Literal::Stable(stable::Literal::$name(n)) |
| 535 | } |
Alex Crichton | a914a61 | 2018-04-04 07:48:44 -0700 | [diff] [blame] | 536 | } |
| 537 | )*) |
| 538 | } |
| 539 | |
| 540 | macro_rules! unsuffixed_integers { |
| 541 | ($($name:ident => $kind:ident,)*) => ($( |
| 542 | pub fn $name(n: $kind) -> Literal { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 543 | if nightly_works() { |
| 544 | Literal::Nightly(proc_macro::Literal::$name(n)) |
| 545 | } else { |
| 546 | Literal::Stable(stable::Literal::$name(n)) |
| 547 | } |
Alex Crichton | a914a61 | 2018-04-04 07:48:44 -0700 | [diff] [blame] | 548 | } |
| 549 | )*) |
| 550 | } |
| 551 | |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 552 | impl Literal { |
Alex Crichton | a914a61 | 2018-04-04 07:48:44 -0700 | [diff] [blame] | 553 | suffixed_numbers! { |
| 554 | u8_suffixed => u8, |
| 555 | u16_suffixed => u16, |
| 556 | u32_suffixed => u32, |
| 557 | u64_suffixed => u64, |
| 558 | usize_suffixed => usize, |
| 559 | i8_suffixed => i8, |
| 560 | i16_suffixed => i16, |
| 561 | i32_suffixed => i32, |
| 562 | i64_suffixed => i64, |
| 563 | isize_suffixed => isize, |
| 564 | |
| 565 | f32_suffixed => f32, |
| 566 | f64_suffixed => f64, |
| 567 | } |
| 568 | |
| 569 | unsuffixed_integers! { |
| 570 | u8_unsuffixed => u8, |
| 571 | u16_unsuffixed => u16, |
| 572 | u32_unsuffixed => u32, |
| 573 | u64_unsuffixed => u64, |
| 574 | usize_unsuffixed => usize, |
| 575 | i8_unsuffixed => i8, |
| 576 | i16_unsuffixed => i16, |
| 577 | i32_unsuffixed => i32, |
| 578 | i64_unsuffixed => i64, |
| 579 | isize_unsuffixed => isize, |
| 580 | } |
| 581 | |
| 582 | pub fn f32_unsuffixed(f: f32) -> Literal { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 583 | if nightly_works() { |
| 584 | Literal::Nightly(proc_macro::Literal::f32_unsuffixed(f)) |
| 585 | } else { |
| 586 | Literal::Stable(stable::Literal::f32_unsuffixed(f)) |
| 587 | } |
Alex Crichton | a914a61 | 2018-04-04 07:48:44 -0700 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | pub fn f64_unsuffixed(f: f64) -> Literal { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 591 | if nightly_works() { |
| 592 | Literal::Nightly(proc_macro::Literal::f64_unsuffixed(f)) |
| 593 | } else { |
| 594 | Literal::Stable(stable::Literal::f64_unsuffixed(f)) |
| 595 | } |
Alex Crichton | a914a61 | 2018-04-04 07:48:44 -0700 | [diff] [blame] | 596 | } |
| 597 | |
Alex Crichton | a914a61 | 2018-04-04 07:48:44 -0700 | [diff] [blame] | 598 | pub fn string(t: &str) -> Literal { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 599 | if nightly_works() { |
| 600 | Literal::Nightly(proc_macro::Literal::string(t)) |
| 601 | } else { |
| 602 | Literal::Stable(stable::Literal::string(t)) |
| 603 | } |
Alex Crichton | a914a61 | 2018-04-04 07:48:44 -0700 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | pub fn character(t: char) -> Literal { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 607 | if nightly_works() { |
| 608 | Literal::Nightly(proc_macro::Literal::character(t)) |
| 609 | } else { |
| 610 | Literal::Stable(stable::Literal::character(t)) |
| 611 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | pub fn byte_string(bytes: &[u8]) -> Literal { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 615 | if nightly_works() { |
| 616 | Literal::Nightly(proc_macro::Literal::byte_string(bytes)) |
| 617 | } else { |
| 618 | Literal::Stable(stable::Literal::byte_string(bytes)) |
| 619 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 620 | } |
| 621 | |
Alex Crichton | b2c9462 | 2018-04-04 07:36:41 -0700 | [diff] [blame] | 622 | pub fn span(&self) -> Span { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 623 | match self { |
| 624 | Literal::Nightly(lit) => Span::Nightly(lit.span()), |
| 625 | Literal::Stable(lit) => Span::Stable(lit.span()), |
| 626 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 627 | } |
| 628 | |
Alex Crichton | b2c9462 | 2018-04-04 07:36:41 -0700 | [diff] [blame] | 629 | pub fn set_span(&mut self, span: Span) { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 630 | match (self, span) { |
| 631 | (Literal::Nightly(lit), Span::Nightly(s)) => lit.set_span(s), |
| 632 | (Literal::Stable(lit), Span::Stable(s)) => lit.set_span(s), |
| 633 | _ => mismatch(), |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | fn unwrap_nightly(self) -> proc_macro::Literal { |
| 638 | match self { |
| 639 | Literal::Nightly(s) => s, |
| 640 | Literal::Stable(_) => mismatch(), |
| 641 | } |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | impl From<stable::Literal> for Literal { |
| 646 | fn from(s: stable::Literal) -> Literal { |
| 647 | Literal::Stable(s) |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 648 | } |
| 649 | } |
| 650 | |
| 651 | impl fmt::Display for Literal { |
| 652 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 653 | match self { |
| 654 | Literal::Nightly(t) => t.fmt(f), |
| 655 | Literal::Stable(t) => t.fmt(f), |
| 656 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 657 | } |
| 658 | } |
| 659 | |
| 660 | impl fmt::Debug for Literal { |
| 661 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
Alex Crichton | 30a4e9e | 2018-04-27 17:02:19 -0700 | [diff] [blame] | 662 | match self { |
| 663 | Literal::Nightly(t) => t.fmt(f), |
| 664 | Literal::Stable(t) => t.fmt(f), |
| 665 | } |
Alex Crichton | cbec8ec | 2017-06-02 13:19:33 -0700 | [diff] [blame] | 666 | } |
| 667 | } |