]> git.pld-linux.org Git - packages/thunderbird.git/blame - rust-1.47.patch
fix build with rust 1.47
[packages/thunderbird.git] / rust-1.47.patch
CommitLineData
97d60ae0
JP
1
2# HG changeset patch
3# User Emilio Cobos Álvarez <emilio@crisal.io>
4# Date 1599584448 0
5# Node ID 85c38ea4d34969797eb5d24265cd90cc6841e6ae
6# Parent 5aa243a2fe9d77578dd95ce3ab3a2aa6c1e92604
7Bug 1663715 - Update syn and proc-macro2 so that Firefox can build on Rust nightly again. r=froydnj, a=RyanVM
8
9Generated with:
10
11 cargo update -p syn --precise 1.0.40
12 ./mach vendor rust
13
14Rust issue: https://github.com/rust-lang/rust/issues/76482
15
16Differential Revision: https://phabricator.services.mozilla.com/D89473
17
18diff --git a/Cargo.lock b/Cargo.lock
19--- a/Cargo.lock
20+++ b/Cargo.lock
21@@ -3712,19 +3712,19 @@ checksum = "ecd45702f76d6d3c75a80564378a
22 dependencies = [
23 "proc-macro2",
24 "quote",
25 "syn",
26 ]
27
28 [[package]]
29 name = "proc-macro2"
30-version = "1.0.5"
31-source = "registry+https://github.com/rust-lang/crates.io-index"
32-checksum = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0"
33+version = "1.0.20"
34+source = "registry+https://github.com/rust-lang/crates.io-index"
35+checksum = "175c513d55719db99da20232b06cda8bab6b83ec2d04e3283edf0213c37c1a29"
36 dependencies = [
37 "unicode-xid",
38 ]
39
40 [[package]]
41 name = "procedural-masquerade"
42 version = "0.1.1"
43 source = "registry+https://github.com/rust-lang/crates.io-index"
44@@ -4642,19 +4642,19 @@ dependencies = [
45 "cc",
46 "gleam",
47 "glsl-to-cxx",
48 "webrender_build",
49 ]
50
51 [[package]]
52 name = "syn"
53-version = "1.0.5"
54-source = "registry+https://github.com/rust-lang/crates.io-index"
55-checksum = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf"
56+version = "1.0.40"
57+source = "registry+https://github.com/rust-lang/crates.io-index"
58+checksum = "963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350"
59 dependencies = [
60 "proc-macro2",
61 "quote",
62 "unicode-xid",
63 ]
64
65 [[package]]
66 name = "sync-guid"
67diff --git a/third_party/rust/proc-macro2/.cargo-checksum.json b/third_party/rust/proc-macro2/.cargo-checksum.json
68--- a/third_party/rust/proc-macro2/.cargo-checksum.json
69+++ b/third_party/rust/proc-macro2/.cargo-checksum.json
70@@ -1,1 +1,1 @@
71-{"files":{"Cargo.toml":"e2c1fc6ed317eeef8462fcd192f6b6389e1d84f0d7afeac78f12c23903deddf8","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"362a2156f7645528061b6e8487a2eb0f32f1693012ed82ee57afa05c039bba0d","build.rs":"0cc6e2cb919ddbff59cf1d810283939f97a59f0037540c0f2ee3453237635ff8","src/fallback.rs":"5c6379a90735e27abcc40253b223158c6b1e5784f3850bc423335363e87ef038","src/lib.rs":"ae5251296ad3fcd8b600919a993fec0afd8b56da3e11fef6bc7265b273129936","src/strnom.rs":"37f7791f73f123817ad5403af1d4e2a0714be27401729a2d451bc80b1f26bac9","src/wrapper.rs":"81372e910604217a625aa71c47d43e65f4e008456eae93ac39325c9abf10701a","tests/features.rs":"a86deb8644992a4eb64d9fd493eff16f9cf9c5cb6ade3a634ce0c990cf87d559","tests/marker.rs":"c2652e3ae1dfcb94d2e6313b29712c5dcbd0fe62026913e67bb7cebd7560aade","tests/test.rs":"8c427be9cba1fa8d4a16647e53e3545e5863e29e2c0b311c93c9dd1399abf6a1"},"package":"90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0"}
72\ No newline at end of file
73+{"files":{"Cargo.toml":"c20c4c52342e65ea11ad8382edc636e628e8f8c5ab7cffddc32426b2fe8fe4cd","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"e1f9d4fc22cff2c049f166a403b41458632a94357890d31cf0e3ad83807fb430","build.rs":"332185d7ad4c859210f5edd7a76bc95146c8277726a2f81417f34927c4424d68","src/detection.rs":"9d25d896889e65330858f2d6f6223c1b98cd1dad189813ad4161ff189fbda2b8","src/fallback.rs":"239f9a25c0f2ab57592288d944c7f1a0f887536b6d4dc2428a17640af8d10a41","src/lib.rs":"2b1d98424c9b23b547dabf85554120e5e65472026a0f3f711b3a097bca7c32fe","src/parse.rs":"500edee9773132e27e44d0fdaa042b1cb9451e29e65124493986f51710c0664c","src/wrapper.rs":"d36c0dced7ec0e7585c1f935cda836080bcae6de1de3d7851d962e9e11a3ac48","tests/comments.rs":"ea6cbe6f4c8852e6a0612893c7d4f2c144a2e6a134a6c3db641a320cbfc3c800","tests/features.rs":"a86deb8644992a4eb64d9fd493eff16f9cf9c5cb6ade3a634ce0c990cf87d559","tests/marker.rs":"c2652e3ae1dfcb94d2e6313b29712c5dcbd0fe62026913e67bb7cebd7560aade","tests/test.rs":"310c856e27ff61c9ec7f0a5cd96031aac02971557b1621f5e17b089d58e79bcd","tests/test_fmt.rs":"745dfdc41d09c5308c221395eb43f2041f0a1413d2927a813bc2ad4554438fe2"},"package":"175c513d55719db99da20232b06cda8bab6b83ec2d04e3283edf0213c37c1a29"}
74\ No newline at end of file
75diff --git a/third_party/rust/proc-macro2/Cargo.toml b/third_party/rust/proc-macro2/Cargo.toml
76--- a/third_party/rust/proc-macro2/Cargo.toml
77+++ b/third_party/rust/proc-macro2/Cargo.toml
78@@ -8,36 +8,35 @@
79 # If you believe there's an error in this file please file an
80 # issue against the rust-lang/cargo repository. If you're
81 # editing this file be aware that the upstream Cargo.toml
82 # will likely look very different (and much more reasonable)
83
84 [package]
85 edition = "2018"
86 name = "proc-macro2"
87-version = "1.0.5"
88-authors = ["Alex Crichton <alex@alexcrichton.com>"]
89-description = "A stable implementation of the upcoming new `proc_macro` API. Comes with an\noption, off by default, to also reimplement itself in terms of the upstream\nunstable API.\n"
90-homepage = "https://github.com/alexcrichton/proc-macro2"
91+version = "1.0.20"
92+authors = ["Alex Crichton <alex@alexcrichton.com>", "David Tolnay <dtolnay@gmail.com>"]
93+description = "A substitute implementation of the compiler's `proc_macro` API to decouple\ntoken-based libraries from the procedural macro use case.\n"
94 documentation = "https://docs.rs/proc-macro2"
95 readme = "README.md"
96 keywords = ["macros"]
97+categories = ["development-tools::procedural-macro-helpers"]
98 license = "MIT OR Apache-2.0"
99 repository = "https://github.com/alexcrichton/proc-macro2"
100 [package.metadata.docs.rs]
101 rustc-args = ["--cfg", "procmacro2_semver_exempt"]
102 rustdoc-args = ["--cfg", "procmacro2_semver_exempt"]
103+targets = ["x86_64-unknown-linux-gnu"]
104
105-[lib]
106-name = "proc_macro2"
107+[package.metadata.playground]
108+features = ["span-locations"]
109 [dependencies.unicode-xid]
110 version = "0.2"
111 [dev-dependencies.quote]
112 version = "1.0"
113 default_features = false
114
115 [features]
116 default = ["proc-macro"]
117 nightly = []
118 proc-macro = []
119 span-locations = []
120-[badges.travis-ci]
121-repository = "alexcrichton/proc-macro2"
122diff --git a/third_party/rust/proc-macro2/README.md b/third_party/rust/proc-macro2/README.md
123--- a/third_party/rust/proc-macro2/README.md
124+++ b/third_party/rust/proc-macro2/README.md
125@@ -1,11 +1,11 @@
126 # proc-macro2
127
128-[![Build Status](https://api.travis-ci.com/alexcrichton/proc-macro2.svg?branch=master)](https://travis-ci.com/alexcrichton/proc-macro2)
129+[![Build Status](https://img.shields.io/github/workflow/status/alexcrichton/proc-macro2/build%20and%20test)](https://github.com/alexcrichton/proc-macro2/actions)
130 [![Latest Version](https://img.shields.io/crates/v/proc-macro2.svg)](https://crates.io/crates/proc-macro2)
131 [![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/proc-macro2)
132
133 A wrapper around the procedural macro API of the compiler's `proc_macro` crate.
134 This library serves two purposes:
135
136 - **Bring proc-macro-like functionality to other contexts like build.rs and
137 main.rs.** Types from `proc_macro` are entirely specific to procedural macros
138diff --git a/third_party/rust/proc-macro2/build.rs b/third_party/rust/proc-macro2/build.rs
139--- a/third_party/rust/proc-macro2/build.rs
140+++ b/third_party/rust/proc-macro2/build.rs
141@@ -9,16 +9,20 @@
142 // "wrap_proc_macro"
143 // Wrap types from libproc_macro rather than polyfilling the whole API.
144 // Enabled on rustc 1.29+ as long as procmacro2_semver_exempt is not set,
145 // because we can't emulate the unstable API without emulating everything
146 // else. Also enabled unconditionally on nightly, in which case the
147 // procmacro2_semver_exempt surface area is implemented by using the
148 // nightly-only proc_macro API.
149 //
150+// "hygiene"
151+// Enable Span::mixed_site() and non-dummy behavior of Span::resolved_at
152+// and Span::located_at. Enabled on Rust 1.45+.
153+//
154 // "proc_macro_span"
155 // Enable non-dummy behavior of Span::start and Span::end methods which
156 // requires an unstable compiler feature. Enabled when building with
157 // nightly, unless `-Z allow-feature` in RUSTFLAGS disallows unstable
158 // features.
159 //
160 // "super_unstable"
161 // Implement the semver exempt API in terms of the nightly-only proc_macro
162@@ -52,16 +56,24 @@ fn main() {
163 // https://github.com/alexcrichton/proc-macro2/issues/147
164 println!("cargo:rustc-cfg=procmacro2_semver_exempt");
165 }
166
167 if semver_exempt || cfg!(feature = "span-locations") {
168 println!("cargo:rustc-cfg=span_locations");
169 }
170
171+ if version.minor < 39 {
172+ println!("cargo:rustc-cfg=no_bind_by_move_pattern_guard");
173+ }
174+
175+ if version.minor >= 45 {
176+ println!("cargo:rustc-cfg=hygiene");
177+ }
178+
179 let target = env::var("TARGET").unwrap();
180 if !enable_use_proc_macro(&target) {
181 return;
182 }
183
184 println!("cargo:rustc-cfg=use_proc_macro");
185
186 if version.nightly || !semver_exempt {
187diff --git a/third_party/rust/proc-macro2/src/detection.rs b/third_party/rust/proc-macro2/src/detection.rs
188new file mode 100644
189--- /dev/null
190+++ b/third_party/rust/proc-macro2/src/detection.rs
191@@ -0,0 +1,67 @@
192+use std::panic::{self, PanicInfo};
193+use std::sync::atomic::*;
194+use std::sync::Once;
195+
196+static WORKS: AtomicUsize = AtomicUsize::new(0);
197+static INIT: Once = Once::new();
198+
199+pub(crate) fn inside_proc_macro() -> bool {
200+ match WORKS.load(Ordering::SeqCst) {
201+ 1 => return false,
202+ 2 => return true,
203+ _ => {}
204+ }
205+
206+ INIT.call_once(initialize);
207+ inside_proc_macro()
208+}
209+
210+pub(crate) fn force_fallback() {
211+ WORKS.store(1, Ordering::SeqCst);
212+}
213+
214+pub(crate) fn unforce_fallback() {
215+ initialize();
216+}
217+
218+// Swap in a null panic hook to avoid printing "thread panicked" to stderr,
219+// then use catch_unwind to determine whether the compiler's proc_macro is
220+// working. When proc-macro2 is used from outside of a procedural macro all
221+// of the proc_macro crate's APIs currently panic.
222+//
223+// The Once is to prevent the possibility of this ordering:
224+//
225+// thread 1 calls take_hook, gets the user's original hook
226+// thread 1 calls set_hook with the null hook
227+// thread 2 calls take_hook, thinks null hook is the original hook
228+// thread 2 calls set_hook with the null hook
229+// thread 1 calls set_hook with the actual original hook
230+// thread 2 calls set_hook with what it thinks is the original hook
231+//
232+// in which the user's hook has been lost.
233+//
234+// There is still a race condition where a panic in a different thread can
235+// happen during the interval that the user's original panic hook is
236+// unregistered such that their hook is incorrectly not called. This is
237+// sufficiently unlikely and less bad than printing panic messages to stderr
238+// on correct use of this crate. Maybe there is a libstd feature request
239+// here. For now, if a user needs to guarantee that this failure mode does
240+// not occur, they need to call e.g. `proc_macro2::Span::call_site()` from
241+// the main thread before launching any other threads.
242+fn initialize() {
243+ type PanicHook = dyn Fn(&PanicInfo) + Sync + Send + 'static;
244+
245+ let null_hook: Box<PanicHook> = Box::new(|_panic_info| { /* ignore */ });
246+ let sanity_check = &*null_hook as *const PanicHook;
247+ let original_hook = panic::take_hook();
248+ panic::set_hook(null_hook);
249+
250+ let works = panic::catch_unwind(proc_macro::Span::call_site).is_ok();
251+ WORKS.store(works as usize + 1, Ordering::SeqCst);
252+
253+ let hopefully_null_hook = panic::take_hook();
254+ panic::set_hook(original_hook);
255+ if sanity_check != &*hopefully_null_hook {
256+ panic!("observed race condition in proc_macro2::inside_proc_macro");
257+ }
258+}
259diff --git a/third_party/rust/proc-macro2/src/fallback.rs b/third_party/rust/proc-macro2/src/fallback.rs
260--- a/third_party/rust/proc-macro2/src/fallback.rs
261+++ b/third_party/rust/proc-macro2/src/fallback.rs
262@@ -1,41 +1,121 @@
263+use crate::parse::{token_stream, Cursor};
264+use crate::{Delimiter, Spacing, TokenTree};
265 #[cfg(span_locations)]
266 use std::cell::RefCell;
267 #[cfg(span_locations)]
268 use std::cmp;
269-use std::fmt;
270-use std::iter;
271+use std::fmt::{self, Debug, Display};
272+use std::iter::FromIterator;
273+use std::mem;
274 use std::ops::RangeBounds;
275 #[cfg(procmacro2_semver_exempt)]
276 use std::path::Path;
277 use std::path::PathBuf;
278 use std::str::FromStr;
279 use std::vec;
280-
281-use crate::strnom::{block_comment, skip_whitespace, whitespace, word_break, Cursor, PResult};
282-use crate::{Delimiter, Punct, Spacing, TokenTree};
283 use unicode_xid::UnicodeXID;
284
285+/// Force use of proc-macro2's fallback implementation of the API for now, even
286+/// if the compiler's implementation is available.
287+pub fn force() {
288+ #[cfg(wrap_proc_macro)]
289+ crate::detection::force_fallback();
290+}
291+
292+/// Resume using the compiler's implementation of the proc macro API if it is
293+/// available.
294+pub fn unforce() {
295+ #[cfg(wrap_proc_macro)]
296+ crate::detection::unforce_fallback();
297+}
298+
299 #[derive(Clone)]
300-pub struct TokenStream {
301- inner: Vec<TokenTree>,
302+pub(crate) struct TokenStream {
303+ pub(crate) inner: Vec<TokenTree>,
304 }
305
306 #[derive(Debug)]
307-pub struct LexError;
308+pub(crate) struct LexError;
309
310 impl TokenStream {
311 pub fn new() -> TokenStream {
312 TokenStream { inner: Vec::new() }
313 }
314
315 pub fn is_empty(&self) -> bool {
316 self.inner.len() == 0
317 }
318+
319+ fn take_inner(&mut self) -> Vec<TokenTree> {
320+ mem::replace(&mut self.inner, Vec::new())
321+ }
322+
323+ fn push_token(&mut self, token: TokenTree) {
324+ // https://github.com/alexcrichton/proc-macro2/issues/235
325+ match token {
326+ #[cfg(not(no_bind_by_move_pattern_guard))]
327+ TokenTree::Literal(crate::Literal {
328+ #[cfg(wrap_proc_macro)]
329+ inner: crate::imp::Literal::Fallback(literal),
330+ #[cfg(not(wrap_proc_macro))]
331+ inner: literal,
332+ ..
333+ }) if literal.text.starts_with('-') => {
334+ push_negative_literal(self, literal);
335+ }
336+ #[cfg(no_bind_by_move_pattern_guard)]
337+ TokenTree::Literal(crate::Literal {
338+ #[cfg(wrap_proc_macro)]
339+ inner: crate::imp::Literal::Fallback(literal),
340+ #[cfg(not(wrap_proc_macro))]
341+ inner: literal,
342+ ..
343+ }) => {
344+ if literal.text.starts_with('-') {
345+ push_negative_literal(self, literal);
346+ } else {
347+ self.inner
348+ .push(TokenTree::Literal(crate::Literal::_new_stable(literal)));
349+ }
350+ }
351+ _ => self.inner.push(token),
352+ }
353+
354+ #[cold]
355+ fn push_negative_literal(stream: &mut TokenStream, mut literal: Literal) {
356+ literal.text.remove(0);
357+ let mut punct = crate::Punct::new('-', Spacing::Alone);
358+ punct.set_span(crate::Span::_new_stable(literal.span));
359+ stream.inner.push(TokenTree::Punct(punct));
360+ stream
361+ .inner
362+ .push(TokenTree::Literal(crate::Literal::_new_stable(literal)));
363+ }
364+ }
365+}
366+
367+// Nonrecursive to prevent stack overflow.
368+impl Drop for TokenStream {
369+ fn drop(&mut self) {
370+ while let Some(token) = self.inner.pop() {
371+ let group = match token {
372+ TokenTree::Group(group) => group.inner,
373+ _ => continue,
374+ };
375+ #[cfg(wrap_proc_macro)]
376+ let group = match group {
377+ crate::imp::Group::Fallback(group) => group,
378+ _ => continue,
379+ };
380+ let mut group = group;
381+ self.inner.extend(group.stream.take_inner());
382+ }
383+ }
384 }
385
386 #[cfg(span_locations)]
387 fn get_cursor(src: &str) -> Cursor {
388 // Create a dummy file & add it to the source map
389 SOURCE_MAP.with(|cm| {
390 let mut cm = cm.borrow_mut();
391 let name = format!("<parsed string {}>", cm.files.len());
392@@ -54,68 +134,49 @@ fn get_cursor(src: &str) -> Cursor {
393
394 impl FromStr for TokenStream {
395 type Err = LexError;
396
397 fn from_str(src: &str) -> Result<TokenStream, LexError> {
398 // Create a dummy file & add it to the source map
399 let cursor = get_cursor(src);
400
401- match token_stream(cursor) {
402- Ok((input, output)) => {
403- if skip_whitespace(input).len() != 0 {
404- Err(LexError)
405- } else {
406- Ok(output)
407- }
408- }
409- Err(LexError) => Err(LexError),
410+ let (rest, tokens) = token_stream(cursor)?;
411+ if rest.is_empty() {
412+ Ok(tokens)
413+ } else {
414+ Err(LexError)
415 }
416 }
417 }
418
419-impl fmt::Display for TokenStream {
420+impl Display for TokenStream {
421 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
422 let mut joint = false;
423 for (i, tt) in self.inner.iter().enumerate() {
424 if i != 0 && !joint {
425 write!(f, " ")?;
426 }
427 joint = false;
428- match *tt {
429- TokenTree::Group(ref tt) => {
430- let (start, end) = match tt.delimiter() {
431- Delimiter::Parenthesis => ("(", ")"),
432- Delimiter::Brace => ("{", "}"),
433- Delimiter::Bracket => ("[", "]"),
434- Delimiter::None => ("", ""),
435- };
436- if tt.stream().into_iter().next().is_none() {
437- write!(f, "{} {}", start, end)?
438- } else {
439- write!(f, "{} {} {}", start, tt.stream(), end)?
440- }
441+ match tt {
442+ TokenTree::Group(tt) => Display::fmt(tt, f),
443+ TokenTree::Ident(tt) => Display::fmt(tt, f),
444+ TokenTree::Punct(tt) => {
445+ joint = tt.spacing() == Spacing::Joint;
446+ Display::fmt(tt, f)
447 }
448- TokenTree::Ident(ref tt) => write!(f, "{}", tt)?,
449- TokenTree::Punct(ref tt) => {
450- write!(f, "{}", tt.as_char())?;
451- match tt.spacing() {
452- Spacing::Alone => {}
453- Spacing::Joint => joint = true,
454- }
455- }
456- TokenTree::Literal(ref tt) => write!(f, "{}", tt)?,
457- }
458+ TokenTree::Literal(tt) => Display::fmt(tt, f),
459+ }?
460 }
461
462 Ok(())
463 }
464 }
465
466-impl fmt::Debug for TokenStream {
467+impl Debug for TokenStream {
468 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
469 f.write_str("TokenStream ")?;
470 f.debug_list().entries(self.clone()).finish()
471 }
472 }
473
474 #[cfg(use_proc_macro)]
475 impl From<proc_macro::TokenStream> for TokenStream {
476@@ -134,122 +195,107 @@ impl From<TokenStream> for proc_macro::T
477 .to_string()
478 .parse()
479 .expect("failed to parse to compiler tokens")
480 }
481 }
482
483 impl From<TokenTree> for TokenStream {
484 fn from(tree: TokenTree) -> TokenStream {
485- TokenStream { inner: vec![tree] }
486+ let mut stream = TokenStream::new();
487+ stream.push_token(tree);
488+ stream
489 }
490 }
491
492-impl iter::FromIterator<TokenTree> for TokenStream {
493- fn from_iter<I: IntoIterator<Item = TokenTree>>(streams: I) -> Self {
494- let mut v = Vec::new();
495-
496- for token in streams.into_iter() {
497- v.push(token);
498- }
499-
500- TokenStream { inner: v }
501+impl FromIterator<TokenTree> for TokenStream {
502+ fn from_iter<I: IntoIterator<Item = TokenTree>>(tokens: I) -> Self {
503+ let mut stream = TokenStream::new();
504+ stream.extend(tokens);
505+ stream
506 }
507 }
508
509-impl iter::FromIterator<TokenStream> for TokenStream {
510+impl FromIterator<TokenStream> for TokenStream {
511 fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self {
512 let mut v = Vec::new();
513
514- for stream in streams.into_iter() {
515- v.extend(stream.inner);
516+ for mut stream in streams {
517+ v.extend(stream.take_inner());
518 }
519
520 TokenStream { inner: v }
521 }
522 }
523
524 impl Extend<TokenTree> for TokenStream {
525- fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, streams: I) {
526- self.inner.extend(streams);
527+ fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, tokens: I) {
528+ tokens.into_iter().for_each(|token| self.push_token(token));
529 }
530 }
531
532 impl Extend<TokenStream> for TokenStream {
533 fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I) {
534- self.inner
535- .extend(streams.into_iter().flat_map(|stream| stream));
536+ self.inner.extend(streams.into_iter().flatten());
537 }
538 }
539
540-pub type TokenTreeIter = vec::IntoIter<TokenTree>;
541+pub(crate) type TokenTreeIter = vec::IntoIter<TokenTree>;
542
543 impl IntoIterator for TokenStream {
544 type Item = TokenTree;
545 type IntoIter = TokenTreeIter;
546
547- fn into_iter(self) -> TokenTreeIter {
548- self.inner.into_iter()
549+ fn into_iter(mut self) -> TokenTreeIter {
550+ self.take_inner().into_iter()
551 }
552 }
553
554 #[derive(Clone, PartialEq, Eq)]
555-pub struct SourceFile {
556+pub(crate) struct SourceFile {
557 path: PathBuf,
558 }
559
560 impl SourceFile {
561 /// Get the path to this source file as a string.
562 pub fn path(&self) -> PathBuf {
563 self.path.clone()
564 }
565
566 pub fn is_real(&self) -> bool {
567 // XXX(nika): Support real files in the future?
568 false
569 }
570 }
571
572-impl fmt::Debug for SourceFile {
573+impl Debug for SourceFile {
574 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
575 f.debug_struct("SourceFile")
576 .field("path", &self.path())
577 .field("is_real", &self.is_real())
578 .finish()
579 }
580 }
581
582 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
583-pub struct LineColumn {
584+pub(crate) struct LineColumn {
585 pub line: usize,
586 pub column: usize,
587 }
588
589 #[cfg(span_locations)]
590 thread_local! {
591 static SOURCE_MAP: RefCell<SourceMap> = RefCell::new(SourceMap {
592 // NOTE: We start with a single dummy file which all call_site() and
593 // def_site() spans reference.
594- files: vec![{
595+ files: vec![FileInfo {
596 #[cfg(procmacro2_semver_exempt)]
597- {
598- FileInfo {
599- name: "<unspecified>".to_owned(),
600- span: Span { lo: 0, hi: 0 },
601- lines: vec![0],
602- }
603- }
604-
605- #[cfg(not(procmacro2_semver_exempt))]
606- {
607- FileInfo {
608- span: Span { lo: 0, hi: 0 },
609- lines: vec![0],
610- }
611- }
612+ name: "<unspecified>".to_owned(),
613+ span: Span { lo: 0, hi: 0 },
614+ lines: vec![0],
615 }],
616 });
617 }
618
619 #[cfg(span_locations)]
620 struct FileInfo {
621 #[cfg(procmacro2_semver_exempt)]
622 name: String,
623@@ -277,26 +323,31 @@ impl FileInfo {
624 }
625 }
626
627 fn span_within(&self, span: Span) -> bool {
628 span.lo >= self.span.lo && span.hi <= self.span.hi
629 }
630 }
631
632-/// Computesthe offsets of each line in the given source string.
633+/// Computes the offsets of each line in the given source string
634+/// and the total number of characters
635 #[cfg(span_locations)]
636-fn lines_offsets(s: &str) -> Vec<usize> {
637+fn lines_offsets(s: &str) -> (usize, Vec<usize>) {
638 let mut lines = vec![0];
639- let mut prev = 0;
640- while let Some(len) = s[prev..].find('\n') {
641- prev += len + 1;
642- lines.push(prev);
643+ let mut total = 0;
644+
645+ for ch in s.chars() {
646+ total += 1;
647+ if ch == '\n' {
648+ lines.push(total);
649+ }
650 }
651- lines
652+
653+ (total, lines)
654 }
655
656 #[cfg(span_locations)]
657 struct SourceMap {
658 files: Vec<FileInfo>,
659 }
660
661 #[cfg(span_locations)]
662@@ -305,81 +356,83 @@ impl SourceMap {
663 // Add 1 so there's always space between files.
664 //
665 // We'll always have at least 1 file, as we initialize our files list
666 // with a dummy file.
667 self.files.last().unwrap().span.hi + 1
668 }
669
670 fn add_file(&mut self, name: &str, src: &str) -> Span {
671- let lines = lines_offsets(src);
672+ let (len, lines) = lines_offsets(src);
673 let lo = self.next_start_pos();
674 // XXX(nika): Shouild we bother doing a checked cast or checked add here?
675 let span = Span {
676 lo,
677- hi: lo + (src.len() as u32),
678+ hi: lo + (len as u32),
679 };
680
681- #[cfg(procmacro2_semver_exempt)]
682 self.files.push(FileInfo {
683+ #[cfg(procmacro2_semver_exempt)]
684 name: name.to_owned(),
685 span,
686 lines,
687 });
688
689 #[cfg(not(procmacro2_semver_exempt))]
690- self.files.push(FileInfo { span, lines });
691 let _ = name;
692
693 span
694 }
695
696 fn fileinfo(&self, span: Span) -> &FileInfo {
697 for file in &self.files {
698 if file.span_within(span) {
699 return file;
700 }
701 }
702 panic!("Invalid span with no related FileInfo!");
703 }
704 }
705
706 #[derive(Clone, Copy, PartialEq, Eq)]
707-pub struct Span {
708+pub(crate) struct Span {
709 #[cfg(span_locations)]
710- lo: u32,
711+ pub(crate) lo: u32,
712 #[cfg(span_locations)]
713- hi: u32,
714+ pub(crate) hi: u32,
715 }
716
717 impl Span {
718 #[cfg(not(span_locations))]
719 pub fn call_site() -> Span {
720 Span {}
721 }
722
723 #[cfg(span_locations)]
724 pub fn call_site() -> Span {
725 Span { lo: 0, hi: 0 }
726 }
727
728+ #[cfg(hygiene)]
729+ pub fn mixed_site() -> Span {
730+ Span::call_site()
731+ }
732+
733 #[cfg(procmacro2_semver_exempt)]
734 pub fn def_site() -> Span {
735 Span::call_site()
736 }
737
738- #[cfg(procmacro2_semver_exempt)]
739 pub fn resolved_at(&self, _other: Span) -> Span {
740 // Stable spans consist only of line/column information, so
741 // `resolved_at` and `located_at` only select which span the
742 // caller wants line/column information from.
743 *self
744 }
745
746- #[cfg(procmacro2_semver_exempt)]
747 pub fn located_at(&self, other: Span) -> Span {
748 other
749 }
750
751 #[cfg(procmacro2_semver_exempt)]
752 pub fn source_file(&self) -> SourceFile {
753 SOURCE_MAP.with(|cm| {
754 let cm = cm.borrow();
755@@ -422,36 +475,69 @@ impl Span {
756 return None;
757 }
758 Some(Span {
759 lo: cmp::min(self.lo, other.lo),
760 hi: cmp::max(self.hi, other.hi),
761 })
762 })
763 }
764+
765+ #[cfg(not(span_locations))]
766+ fn first_byte(self) -> Self {
767+ self
768+ }
769+
770+ #[cfg(span_locations)]
771+ fn first_byte(self) -> Self {
772+ Span {
773+ lo: self.lo,
774+ hi: cmp::min(self.lo.saturating_add(1), self.hi),
775+ }
776+ }
777+
778+ #[cfg(not(span_locations))]
779+ fn last_byte(self) -> Self {
780+ self
781+ }
782+
783+ #[cfg(span_locations)]
784+ fn last_byte(self) -> Self {
785+ Span {
786+ lo: cmp::max(self.hi.saturating_sub(1), self.lo),
787+ hi: self.hi,
788+ }
789+ }
790 }
791
792-impl fmt::Debug for Span {
793+impl Debug for Span {
794 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
795- #[cfg(procmacro2_semver_exempt)]
796+ #[cfg(span_locations)]
797 return write!(f, "bytes({}..{})", self.lo, self.hi);
798
799- #[cfg(not(procmacro2_semver_exempt))]
800+ #[cfg(not(span_locations))]
801 write!(f, "Span")
802 }
803 }
804
805-pub fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) {
806- if cfg!(procmacro2_semver_exempt) {
807+pub(crate) fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) {
808+ #[cfg(span_locations)]
809+ {
810+ if span.lo == 0 && span.hi == 0 {
811+ return;
812+ }
813+ }
814+
815+ if cfg!(span_locations) {
816 debug.field("span", &span);
817 }
818 }
819
820 #[derive(Clone)]
821-pub struct Group {
822+pub(crate) struct Group {
823 delimiter: Delimiter,
824 stream: TokenStream,
825 span: Span,
826 }
827
828 impl Group {
829 pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group {
830 Group {
831@@ -469,58 +555,67 @@ impl Group {
832 self.stream.clone()
833 }
834
835 pub fn span(&self) -> Span {
836 self.span
837 }
838
839 pub fn span_open(&self) -> Span {
840- self.span
841+ self.span.first_byte()
842 }
843
844 pub fn span_close(&self) -> Span {
845- self.span
846+ self.span.last_byte()
847 }
848
849 pub fn set_span(&mut self, span: Span) {
850 self.span = span;
851 }
852 }
853
854-impl fmt::Display for Group {
855+impl Display for Group {
856+ // We attempt to match libproc_macro's formatting.
857+ // Empty parens: ()
858+ // Nonempty parens: (...)
859+ // Empty brackets: []
860+ // Nonempty brackets: [...]
861+ // Empty braces: { }
862+ // Nonempty braces: { ... }
863 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
864- let (left, right) = match self.delimiter {
865+ let (open, close) = match self.delimiter {
866 Delimiter::Parenthesis => ("(", ")"),
867- Delimiter::Brace => ("{", "}"),
868+ Delimiter::Brace => ("{ ", "}"),
869 Delimiter::Bracket => ("[", "]"),
870 Delimiter::None => ("", ""),
871 };
872
873- f.write_str(left)?;
874- self.stream.fmt(f)?;
875- f.write_str(right)?;
876+ f.write_str(open)?;
877+ Display::fmt(&self.stream, f)?;
878+ if self.delimiter == Delimiter::Brace && !self.stream.inner.is_empty() {
879+ f.write_str(" ")?;
880+ }
881+ f.write_str(close)?;
882
883 Ok(())
884 }
885 }
886
887-impl fmt::Debug for Group {
888+impl Debug for Group {
889 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
890 let mut debug = fmt.debug_struct("Group");
891 debug.field("delimiter", &self.delimiter);
892 debug.field("stream", &self.stream);
893- #[cfg(procmacro2_semver_exempt)]
894- debug.field("span", &self.span);
895+ debug_span_field_if_nontrivial(&mut debug, self.span);
896 debug.finish()
897 }
898 }
899
900 #[derive(Clone)]
901-pub struct Ident {
902+pub(crate) struct Ident {
903 sym: String,
904 span: Span,
905 raw: bool,
906 }
907
908 impl Ident {
909 fn _new(string: &str, raw: bool, span: Span) -> Ident {
910 validate_ident(string);
911@@ -544,26 +639,24 @@ impl Ident {
912 self.span
913 }
914
915 pub fn set_span(&mut self, span: Span) {
916 self.span = span;
917 }
918 }
919
920-#[inline]
921-fn is_ident_start(c: char) -> bool {
922+pub(crate) fn is_ident_start(c: char) -> bool {
923 ('a' <= c && c <= 'z')
924 || ('A' <= c && c <= 'Z')
925 || c == '_'
926 || (c > '\x7f' && UnicodeXID::is_xid_start(c))
927 }
928
929-#[inline]
930-fn is_ident_continue(c: char) -> bool {
931+pub(crate) fn is_ident_continue(c: char) -> bool {
932 ('a' <= c && c <= 'z')
933 || ('A' <= c && c <= 'Z')
934 || c == '_'
935 || ('0' <= c && c <= '9')
936 || (c > '\x7f' && UnicodeXID::is_xid_continue(c))
937 }
938
939 fn validate_ident(string: &str) {
940@@ -610,49 +703,49 @@ where
941 if self.raw {
942 other.starts_with("r#") && self.sym == other[2..]
943 } else {
944 self.sym == other
945 }
946 }
947 }
948
949-impl fmt::Display for Ident {
950+impl Display for Ident {
951 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
952 if self.raw {
953- "r#".fmt(f)?;
954+ f.write_str("r#")?;
955 }
956- self.sym.fmt(f)
957+ Display::fmt(&self.sym, f)
958 }
959 }
960
961-impl fmt::Debug for Ident {
962+impl Debug for Ident {
963 // Ident(proc_macro), Ident(r#union)
964- #[cfg(not(procmacro2_semver_exempt))]
965+ #[cfg(not(span_locations))]
966 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
967 let mut debug = f.debug_tuple("Ident");
968 debug.field(&format_args!("{}", self));
969 debug.finish()
970 }
971
972 // Ident {
973 // sym: proc_macro,
974 // span: bytes(128..138)
975 // }
976- #[cfg(procmacro2_semver_exempt)]
977+ #[cfg(span_locations)]
978 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
979 let mut debug = f.debug_struct("Ident");
980 debug.field("sym", &format_args!("{}", self));
981- debug.field("span", &self.span);
982+ debug_span_field_if_nontrivial(&mut debug, self.span);
983 debug.finish()
984 }
985 }
986
987 #[derive(Clone)]
988-pub struct Literal {
989+pub(crate) struct Literal {
990 text: String,
991 span: Span,
992 }
993
994 macro_rules! suffixed_numbers {
995 ($($name:ident => $kind:ident,)*) => ($(
996 pub fn $name(n: $kind) -> Literal {
997 Literal::_new(format!(concat!("{}", stringify!($kind)), n))
998@@ -664,17 +757,17 @@ macro_rules! unsuffixed_numbers {
999 ($($name:ident => $kind:ident,)*) => ($(
1000 pub fn $name(n: $kind) -> Literal {
1001 Literal::_new(n.to_string())
1002 }
1003 )*)
1004 }
1005
1006 impl Literal {
1007- fn _new(text: String) -> Literal {
1008+ pub(crate) fn _new(text: String) -> Literal {
1009 Literal {
1010 text,
1011 span: Span::call_site(),
1012 }
1013 }
1014
1015 suffixed_numbers! {
1016 u8_suffixed => u8,
1017@@ -706,61 +799,62 @@ impl Literal {
1018 i32_unsuffixed => i32,
1019 i64_unsuffixed => i64,
1020 i128_unsuffixed => i128,
1021 isize_unsuffixed => isize,
1022 }
1023
1024 pub fn f32_unsuffixed(f: f32) -> Literal {
1025 let mut s = f.to_string();
1026- if !s.contains(".") {
1027+ if !s.contains('.') {
1028 s.push_str(".0");
1029 }
1030 Literal::_new(s)
1031 }
1032
1033 pub fn f64_unsuffixed(f: f64) -> Literal {
1034 let mut s = f.to_string();
1035- if !s.contains(".") {
1036+ if !s.contains('.') {
1037 s.push_str(".0");
1038 }
1039 Literal::_new(s)
1040 }
1041
1042 pub fn string(t: &str) -> Literal {
1043 let mut text = String::with_capacity(t.len() + 2);
1044 text.push('"');
1045 for c in t.chars() {
1046 if c == '\'' {
1047- // escape_default turns this into "\'" which is unnecessary.
1048+ // escape_debug turns this into "\'" which is unnecessary.
1049 text.push(c);
1050 } else {
1051- text.extend(c.escape_default());
1052+ text.extend(c.escape_debug());
1053 }
1054 }
1055 text.push('"');
1056 Literal::_new(text)
1057 }
1058
1059 pub fn character(t: char) -> Literal {
1060 let mut text = String::new();
1061 text.push('\'');
1062 if t == '"' {
1063- // escape_default turns this into '\"' which is unnecessary.
1064+ // escape_debug turns this into '\"' which is unnecessary.
1065 text.push(t);
1066 } else {
1067- text.extend(t.escape_default());
1068+ text.extend(t.escape_debug());
1069 }
1070 text.push('\'');
1071 Literal::_new(text)
1072 }
1073
1074 pub fn byte_string(bytes: &[u8]) -> Literal {
1075 let mut escaped = "b\"".to_string();
1076 for b in bytes {
1077+ #[allow(clippy::match_overlapping_arm)]
1078 match *b {
1079 b'\0' => escaped.push_str(r"\0"),
1080 b'\t' => escaped.push_str(r"\t"),
1081 b'\n' => escaped.push_str(r"\n"),
1082 b'\r' => escaped.push_str(r"\r"),
1083 b'"' => escaped.push_str("\\\""),
1084 b'\\' => escaped.push_str("\\\\"),
1085 b'\x20'..=b'\x7E' => escaped.push(*b as char),
1086@@ -779,656 +873,22 @@ impl Literal {
1087 self.span = span;
1088 }
1089
1090 pub fn subspan<R: RangeBounds<usize>>(&self, _range: R) -> Option<Span> {
1091 None
1092 }
1093 }
1094
1095-impl fmt::Display for Literal {
1096+impl Display for Literal {
1097 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1098- self.text.fmt(f)
1099- }
1100-}
1101-
1102-impl fmt::Debug for Literal {
1103- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
1104- let mut debug = fmt.debug_struct("Literal");
1105- debug.field("lit", &format_args!("{}", self.text));
1106- #[cfg(procmacro2_semver_exempt)]
1107- debug.field("span", &self.span);
1108- debug.finish()
1109- }
1110-}
1111-
1112-fn token_stream(mut input: Cursor) -> PResult<TokenStream> {
1113- let mut trees = Vec::new();
1114- loop {
1115- let input_no_ws = skip_whitespace(input);
1116- if input_no_ws.rest.len() == 0 {
1117- break;
1118- }
1119- if let Ok((a, tokens)) = doc_comment(input_no_ws) {
1120- input = a;
1121- trees.extend(tokens);
1122- continue;
1123- }
1124-
1125- let (a, tt) = match token_tree(input_no_ws) {
1126- Ok(p) => p,
1127- Err(_) => break,
1128- };
1129- trees.push(tt);
1130- input = a;
1131- }
1132- Ok((input, TokenStream { inner: trees }))
1133-}
1134-
1135-#[cfg(not(span_locations))]
1136-fn spanned<'a, T>(
1137- input: Cursor<'a>,
1138- f: fn(Cursor<'a>) -> PResult<'a, T>,
1139-) -> PResult<'a, (T, crate::Span)> {
1140- let (a, b) = f(skip_whitespace(input))?;
1141- Ok((a, ((b, crate::Span::_new_stable(Span::call_site())))))
1142-}
1143-
1144-#[cfg(span_locations)]
1145-fn spanned<'a, T>(
1146- input: Cursor<'a>,
1147- f: fn(Cursor<'a>) -> PResult<'a, T>,
1148-) -> PResult<'a, (T, crate::Span)> {
1149- let input = skip_whitespace(input);
1150- let lo = input.off;
1151- let (a, b) = f(input)?;
1152- let hi = a.off;
1153- let span = crate::Span::_new_stable(Span { lo, hi });
1154- Ok((a, (b, span)))
1155-}
1156-
1157-fn token_tree(input: Cursor) -> PResult<TokenTree> {
1158- let (rest, (mut tt, span)) = spanned(input, token_kind)?;
1159- tt.set_span(span);
1160- Ok((rest, tt))
1161-}
1162-
1163-named!(token_kind -> TokenTree, alt!(
1164- map!(group, |g| TokenTree::Group(crate::Group::_new_stable(g)))
1165- |
1166- map!(literal, |l| TokenTree::Literal(crate::Literal::_new_stable(l))) // must be before symbol
1167- |
1168- map!(op, TokenTree::Punct)
1169- |
1170- symbol_leading_ws
1171-));
1172-
1173-named!(group -> Group, alt!(
1174- delimited!(
1175- punct!("("),
1176- token_stream,
1177- punct!(")")
1178- ) => { |ts| Group::new(Delimiter::Parenthesis, ts) }
1179- |
1180- delimited!(
1181- punct!("["),
1182- token_stream,
1183- punct!("]")
1184- ) => { |ts| Group::new(Delimiter::Bracket, ts) }
1185- |
1186- delimited!(
1187- punct!("{"),
1188- token_stream,
1189- punct!("}")
1190- ) => { |ts| Group::new(Delimiter::Brace, ts) }
1191-));
1192-
1193-fn symbol_leading_ws(input: Cursor) -> PResult<TokenTree> {
1194- symbol(skip_whitespace(input))
1195-}
1196-
1197-fn symbol(input: Cursor) -> PResult<TokenTree> {
1198- let raw = input.starts_with("r#");
1199- let rest = input.advance((raw as usize) << 1);
1200-
1201- let (rest, sym) = symbol_not_raw(rest)?;
1202-
1203- if !raw {
1204- let ident = crate::Ident::new(sym, crate::Span::call_site());
1205- return Ok((rest, ident.into()));
1206- }
1207-
1208- if sym == "_" {
1209- return Err(LexError);
1210- }
1211-
1212- let ident = crate::Ident::_new_raw(sym, crate::Span::call_site());
1213- Ok((rest, ident.into()))
1214-}
1215-
1216-fn symbol_not_raw(input: Cursor) -> PResult<&str> {
1217- let mut chars = input.char_indices();
1218-
1219- match chars.next() {
1220- Some((_, ch)) if is_ident_start(ch) => {}
1221- _ => return Err(LexError),
1222- }
1223-
1224- let mut end = input.len();
1225- for (i, ch) in chars {
1226- if !is_ident_continue(ch) {
1227- end = i;
1228- break;
1229- }
1230- }
1231-
1232- Ok((input.advance(end), &input.rest[..end]))
1233-}
1234-
1235-fn literal(input: Cursor) -> PResult<Literal> {
1236- let input_no_ws = skip_whitespace(input);
1237-
1238- match literal_nocapture(input_no_ws) {
1239- Ok((a, ())) => {
1240- let start = input.len() - input_no_ws.len();
1241- let len = input_no_ws.len() - a.len();
1242- let end = start + len;
1243- Ok((a, Literal::_new(input.rest[start..end].to_string())))
1244- }
1245- Err(LexError) => Err(LexError),
1246+ Display::fmt(&self.text, f)
1247 }
1248 }
1249
1250-named!(literal_nocapture -> (), alt!(
1251- string
1252- |
1253- byte_string
1254- |
1255- byte
1256- |
1257- character
1258- |
1259- float
1260- |
1261- int
1262-));
1263-
1264-named!(string -> (), alt!(
1265- quoted_string
1266- |
1267- preceded!(
1268- punct!("r"),
1269- raw_string
1270- ) => { |_| () }
1271-));
1272-
1273-named!(quoted_string -> (), do_parse!(
1274- punct!("\"") >>
1275- cooked_string >>
1276- tag!("\"") >>
1277- option!(symbol_not_raw) >>
1278- (())
1279-));
1280-
1281-fn cooked_string(input: Cursor) -> PResult<()> {
1282- let mut chars = input.char_indices().peekable();
1283- while let Some((byte_offset, ch)) = chars.next() {
1284- match ch {
1285- '"' => {
1286- return Ok((input.advance(byte_offset), ()));
1287- }
1288- '\r' => {
1289- if let Some((_, '\n')) = chars.next() {
1290- // ...
1291- } else {
1292- break;
1293- }
1294- }
1295- '\\' => match chars.next() {
1296- Some((_, 'x')) => {
1297- if !backslash_x_char(&mut chars) {
1298- break;
1299- }
1300- }
1301- Some((_, 'n')) | Some((_, 'r')) | Some((_, 't')) | Some((_, '\\'))
1302- | Some((_, '\'')) | Some((_, '"')) | Some((_, '0')) => {}
1303- Some((_, 'u')) => {
1304- if !backslash_u(&mut chars) {
1305- break;
1306- }
1307- }
1308- Some((_, '\n')) | Some((_, '\r')) => {
1309- while let Some(&(_, ch)) = chars.peek() {
1310- if ch.is_whitespace() {
1311- chars.next();
1312- } else {
1313- break;
1314- }
1315- }
1316- }
1317- _ => break,
1318- },
1319- _ch => {}
1320- }
1321- }
1322- Err(LexError)
1323-}
1324-
1325-named!(byte_string -> (), alt!(
1326- delimited!(
1327- punct!("b\""),
1328- cooked_byte_string,
1329- tag!("\"")
1330- ) => { |_| () }
1331- |
1332- preceded!(
1333- punct!("br"),
1334- raw_string
1335- ) => { |_| () }
1336-));
1337-
1338-fn cooked_byte_string(mut input: Cursor) -> PResult<()> {
1339- let mut bytes = input.bytes().enumerate();
1340- 'outer: while let Some((offset, b)) = bytes.next() {
1341- match b {
1342- b'"' => {
1343- return Ok((input.advance(offset), ()));
1344- }
1345- b'\r' => {
1346- if let Some((_, b'\n')) = bytes.next() {
1347- // ...
1348- } else {
1349- break;
1350- }
1351- }
1352- b'\\' => match bytes.next() {
1353- Some((_, b'x')) => {
1354- if !backslash_x_byte(&mut bytes) {
1355- break;
1356- }
1357- }
1358- Some((_, b'n')) | Some((_, b'r')) | Some((_, b't')) | Some((_, b'\\'))
1359- | Some((_, b'0')) | Some((_, b'\'')) | Some((_, b'"')) => {}
1360- Some((newline, b'\n')) | Some((newline, b'\r')) => {
1361- let rest = input.advance(newline + 1);
1362- for (offset, ch) in rest.char_indices() {
1363- if !ch.is_whitespace() {
1364- input = rest.advance(offset);
1365- bytes = input.bytes().enumerate();
1366- continue 'outer;
1367- }
1368- }
1369- break;
1370- }
1371- _ => break,
1372- },
1373- b if b < 0x80 => {}
1374- _ => break,
1375- }
1376- }
1377- Err(LexError)
1378-}
1379-
1380-fn raw_string(input: Cursor) -> PResult<()> {
1381- let mut chars = input.char_indices();
1382- let mut n = 0;
1383- while let Some((byte_offset, ch)) = chars.next() {
1384- match ch {
1385- '"' => {
1386- n = byte_offset;
1387- break;
1388- }
1389- '#' => {}
1390- _ => return Err(LexError),
1391- }
1392- }
1393- for (byte_offset, ch) in chars {
1394- match ch {
1395- '"' if input.advance(byte_offset + 1).starts_with(&input.rest[..n]) => {
1396- let rest = input.advance(byte_offset + 1 + n);
1397- return Ok((rest, ()));
1398- }
1399- '\r' => {}
1400- _ => {}
1401- }
1402- }
1403- Err(LexError)
1404-}
1405-
1406-named!(byte -> (), do_parse!(
1407- punct!("b") >>
1408- tag!("'") >>
1409- cooked_byte >>
1410- tag!("'") >>
1411- (())
1412-));
1413-
1414-fn cooked_byte(input: Cursor) -> PResult<()> {
1415- let mut bytes = input.bytes().enumerate();
1416- let ok = match bytes.next().map(|(_, b)| b) {
1417- Some(b'\\') => match bytes.next().map(|(_, b)| b) {
1418- Some(b'x') => backslash_x_byte(&mut bytes),
1419- Some(b'n') | Some(b'r') | Some(b't') | Some(b'\\') | Some(b'0') | Some(b'\'')
1420- | Some(b'"') => true,
1421- _ => false,
1422- },
1423- b => b.is_some(),
1424- };
1425- if ok {
1426- match bytes.next() {
1427- Some((offset, _)) => {
1428- if input.chars().as_str().is_char_boundary(offset) {
1429- Ok((input.advance(offset), ()))
1430- } else {
1431- Err(LexError)
1432- }
1433- }
1434- None => Ok((input.advance(input.len()), ())),
1435- }
1436- } else {
1437- Err(LexError)
1438- }
1439-}
1440-
1441-named!(character -> (), do_parse!(
1442- punct!("'") >>
1443- cooked_char >>
1444- tag!("'") >>
1445- (())
1446-));
1447-
1448-fn cooked_char(input: Cursor) -> PResult<()> {
1449- let mut chars = input.char_indices();
1450- let ok = match chars.next().map(|(_, ch)| ch) {
1451- Some('\\') => match chars.next().map(|(_, ch)| ch) {
1452- Some('x') => backslash_x_char(&mut chars),
1453- Some('u') => backslash_u(&mut chars),
1454- Some('n') | Some('r') | Some('t') | Some('\\') | Some('0') | Some('\'') | Some('"') => {
1455- true
1456- }
1457- _ => false,
1458- },
1459- ch => ch.is_some(),
1460- };
1461- if ok {
1462- match chars.next() {
1463- Some((idx, _)) => Ok((input.advance(idx), ())),
1464- None => Ok((input.advance(input.len()), ())),
1465- }
1466- } else {
1467- Err(LexError)
1468+impl Debug for Literal {
1469+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
1470+ let mut debug = fmt.debug_struct("Literal");
1471+ debug.field("lit", &format_args!("{}", self.text));
1472+ debug_span_field_if_nontrivial(&mut debug, self.span);
1473+ debug.finish()
1474 }
1475 }
1476-
1477-macro_rules! next_ch {
1478- ($chars:ident @ $pat:pat $(| $rest:pat)*) => {
1479- match $chars.next() {
1480- Some((_, ch)) => match ch {
1481- $pat $(| $rest)* => ch,
1482- _ => return false,
1483- },
1484- None => return false
1485- }
1486- };
1487-}
1488-
1489-fn backslash_x_char<I>(chars: &mut I) -> bool
1490-where
1491- I: Iterator<Item = (usize, char)>,
1492-{
1493- next_ch!(chars @ '0'..='7');
1494- next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
1495- true
1496-}
1497-
1498-fn backslash_x_byte<I>(chars: &mut I) -> bool
1499-where
1500- I: Iterator<Item = (usize, u8)>,
1501-{
1502- next_ch!(chars @ b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F');
1503- next_ch!(chars @ b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F');
1504- true
1505-}
1506-
1507-fn backslash_u<I>(chars: &mut I) -> bool
1508-where
1509- I: Iterator<Item = (usize, char)>,
1510-{
1511- next_ch!(chars @ '{');
1512- next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
1513- loop {
1514- let c = next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F' | '_' | '}');
1515- if c == '}' {
1516- return true;
1517- }
1518- }
1519-}
1520-
1521-fn float(input: Cursor) -> PResult<()> {
1522- let (mut rest, ()) = float_digits(input)?;
1523- if let Some(ch) = rest.chars().next() {
1524- if is_ident_start(ch) {
1525- rest = symbol_not_raw(rest)?.0;
1526- }
1527- }
1528- word_break(rest)
1529-}
1530-
1531-fn float_digits(input: Cursor) -> PResult<()> {
1532- let mut chars = input.chars().peekable();
1533- match chars.next() {
1534- Some(ch) if ch >= '0' && ch <= '9' => {}
1535- _ => return Err(LexError),
1536- }
1537-
1538- let mut len = 1;
1539- let mut has_dot = false;
1540- let mut has_exp = false;
1541- while let Some(&ch) = chars.peek() {
1542- match ch {
1543- '0'..='9' | '_' => {
1544- chars.next();
1545- len += 1;
1546- }
1547- '.' => {
1548- if has_dot {
1549- break;
1550- }
1551- chars.next();
1552- if chars
1553- .peek()
1554- .map(|&ch| ch == '.' || is_ident_start(ch))
1555- .unwrap_or(false)
1556- {
1557- return Err(LexError);
1558- }
1559- len += 1;
1560- has_dot = true;
1561- }
1562- 'e' | 'E' => {
1563- chars.next();
1564- len += 1;
1565- has_exp = true;
1566- break;
1567- }
1568- _ => break,
1569- }
1570- }
1571-
1572- let rest = input.advance(len);
1573- if !(has_dot || has_exp || rest.starts_with("f32") || rest.starts_with("f64")) {
1574- return Err(LexError);
1575- }
1576-
1577- if has_exp {
1578- let mut has_exp_value = false;
1579- while let Some(&ch) = chars.peek() {
1580- match ch {
1581- '+' | '-' => {
1582- if has_exp_value {
1583- break;
1584- }
1585- chars.next();
1586- len += 1;
1587- }
1588- '0'..='9' => {
1589- chars.next();
1590- len += 1;
1591- has_exp_value = true;
1592- }
1593- '_' => {
1594- chars.next();
1595- len += 1;
1596- }
1597- _ => break,
1598- }
1599- }
1600- if !has_exp_value {
1601- return Err(LexError);
1602- }
1603- }
1604-
1605- Ok((input.advance(len), ()))
1606-}
1607-
1608-fn int(input: Cursor) -> PResult<()> {
1609- let (mut rest, ()) = digits(input)?;
1610- if let Some(ch) = rest.chars().next() {
1611- if is_ident_start(ch) {
1612- rest = symbol_not_raw(rest)?.0;
1613- }
1614- }
1615- word_break(rest)
1616-}
1617-
1618-fn digits(mut input: Cursor) -> PResult<()> {
1619- let base = if input.starts_with("0x") {
1620- input = input.advance(2);
1621- 16
1622- } else if input.starts_with("0o") {
1623- input = input.advance(2);
1624- 8
1625- } else if input.starts_with("0b") {
1626- input = input.advance(2);
1627- 2
1628- } else {
1629- 10
1630- };
1631-
1632- let mut len = 0;
1633- let mut empty = true;
1634- for b in input.bytes() {
1635- let digit = match b {
1636- b'0'..=b'9' => (b - b'0') as u64,
1637- b'a'..=b'f' => 10 + (b - b'a') as u64,
1638- b'A'..=b'F' => 10 + (b - b'A') as u64,
1639- b'_' => {
1640- if empty && base == 10 {
1641- return Err(LexError);
1642- }
1643- len += 1;
1644- continue;
1645- }
1646- _ => break,
1647- };
1648- if digit >= base {
1649- return Err(LexError);
1650- }
1651- len += 1;
1652- empty = false;
1653- }
1654- if empty {
1655- Err(LexError)
1656- } else {
1657- Ok((input.advance(len), ()))
1658- }
1659-}
1660-
1661-fn op(input: Cursor) -> PResult<Punct> {
1662- let input = skip_whitespace(input);
1663- match op_char(input) {
1664- Ok((rest, '\'')) => {
1665- symbol(rest)?;
1666- Ok((rest, Punct::new('\'', Spacing::Joint)))
1667- }
1668- Ok((rest, ch)) => {
1669- let kind = match op_char(rest) {
1670- Ok(_) => Spacing::Joint,
1671- Err(LexError) => Spacing::Alone,
1672- };
1673- Ok((rest, Punct::new(ch, kind)))
1674- }
1675- Err(LexError) => Err(LexError),
1676- }
1677-}
1678-
1679-fn op_char(input: Cursor) -> PResult<char> {
1680- if input.starts_with("//") || input.starts_with("/*") {
1681- // Do not accept `/` of a comment as an op.
1682- return Err(LexError);
1683- }
1684-
1685- let mut chars = input.chars();
1686- let first = match chars.next() {
1687- Some(ch) => ch,
1688- None => {
1689- return Err(LexError);
1690- }
1691- };
1692- let recognized = "~!@#$%^&*-=+|;:,<.>/?'";
1693- if recognized.contains(first) {
1694- Ok((input.advance(first.len_utf8()), first))
1695- } else {
1696- Err(LexError)
1697- }
1698-}
1699-
1700-fn doc_comment(input: Cursor) -> PResult<Vec<TokenTree>> {
1701- let mut trees = Vec::new();
1702- let (rest, ((comment, inner), span)) = spanned(input, doc_comment_contents)?;
1703- trees.push(TokenTree::Punct(Punct::new('#', Spacing::Alone)));
1704- if inner {
1705- trees.push(Punct::new('!', Spacing::Alone).into());
1706- }
1707- let mut stream = vec![
1708- TokenTree::Ident(crate::Ident::new("doc", span)),
1709- TokenTree::Punct(Punct::new('=', Spacing::Alone)),
1710- TokenTree::Literal(crate::Literal::string(comment)),
1711- ];
1712- for tt in stream.iter_mut() {
1713- tt.set_span(span);
1714- }
1715- let group = Group::new(Delimiter::Bracket, stream.into_iter().collect());
1716- trees.push(crate::Group::_new_stable(group).into());
1717- for tt in trees.iter_mut() {
1718- tt.set_span(span);
1719- }
1720- Ok((rest, trees))
1721-}
1722-
1723-named!(doc_comment_contents -> (&str, bool), alt!(
1724- do_parse!(
1725- punct!("//!") >>
1726- s: take_until_newline_or_eof!() >>
1727- ((s, true))
1728- )
1729- |
1730- do_parse!(
1731- option!(whitespace) >>
1732- peek!(tag!("/*!")) >>
1733- s: block_comment >>
1734- ((s, true))
1735- )
1736- |
1737- do_parse!(
1738- punct!("///") >>
1739- not!(tag!("/")) >>
1740- s: take_until_newline_or_eof!() >>
1741- ((s, false))
1742- )
1743- |
1744- do_parse!(
1745- option!(whitespace) >>
1746- peek!(tuple!(tag!("/**"), not!(tag!("*")))) >>
1747- s: block_comment >>
1748- ((s, false))
1749- )
1750-));
1751diff --git a/third_party/rust/proc-macro2/src/lib.rs b/third_party/rust/proc-macro2/src/lib.rs
1752--- a/third_party/rust/proc-macro2/src/lib.rs
1753+++ b/third_party/rust/proc-macro2/src/lib.rs
1754@@ -73,37 +73,44 @@
1755 //!
1756 //! # Thread-Safety
1757 //!
1758 //! Most types in this crate are `!Sync` because the underlying compiler
1759 //! types make use of thread-local memory, meaning they cannot be accessed from
1760 //! a different thread.
1761
1762 // Proc-macro2 types in rustdoc of other crates get linked to here.
1763-#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.5")]
1764+#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.20")]
1765 #![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))]
1766 #![cfg_attr(super_unstable, feature(proc_macro_raw_ident, proc_macro_def_site))]
1767+#![allow(clippy::needless_doctest_main)]
1768
1769 #[cfg(use_proc_macro)]
1770 extern crate proc_macro;
1771
1772 use std::cmp::Ordering;
1773-use std::fmt;
1774+use std::fmt::{self, Debug, Display};
1775 use std::hash::{Hash, Hasher};
1776 use std::iter::FromIterator;
1777 use std::marker;
1778 use std::ops::RangeBounds;
1779 #[cfg(procmacro2_semver_exempt)]
1780 use std::path::PathBuf;
1781 use std::rc::Rc;
1782 use std::str::FromStr;
1783
1784-#[macro_use]
1785-mod strnom;
1786-mod fallback;
1787+mod parse;
1788+
1789+#[cfg(wrap_proc_macro)]
1790+mod detection;
1791+
1792+// Public for proc_macro2::fallback::force() and unforce(), but those are quite
1793+// a niche use case so we omit it from rustdoc.
1794+#[doc(hidden)]
1795+pub mod fallback;
1796
1797 #[cfg(not(wrap_proc_macro))]
1798 use crate::fallback as imp;
1799 #[path = "wrapper.rs"]
1800 #[cfg(wrap_proc_macro)]
1801 mod imp;
1802
1803 /// An abstract stream of tokens, or more concretely a sequence of token trees.
1804@@ -223,32 +230,32 @@ impl FromIterator<TokenStream> for Token
1805 TokenStream::_new(streams.into_iter().map(|i| i.inner).collect())
1806 }
1807 }
1808
1809 /// Prints the token stream as a string that is supposed to be losslessly
1810 /// convertible back into the same token stream (modulo spans), except for
1811 /// possibly `TokenTree::Group`s with `Delimiter::None` delimiters and negative
1812 /// numeric literals.
1813-impl fmt::Display for TokenStream {
1814+impl Display for TokenStream {
1815 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1816- self.inner.fmt(f)
1817+ Display::fmt(&self.inner, f)
1818 }
1819 }
1820
1821 /// Prints token in a form convenient for debugging.
1822-impl fmt::Debug for TokenStream {
1823+impl Debug for TokenStream {
1824 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1825- self.inner.fmt(f)
1826+ Debug::fmt(&self.inner, f)
1827 }
1828 }
1829
1830-impl fmt::Debug for LexError {
1831+impl Debug for LexError {
1832 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1833- self.inner.fmt(f)
1834+ Debug::fmt(&self.inner, f)
1835 }
1836 }
1837
1838 /// The source file of a given `Span`.
1839 ///
1840 /// This type is semver exempt and not exposed by default.
1841 #[cfg(procmacro2_semver_exempt)]
1842 #[derive(Clone, PartialEq, Eq)]
1843@@ -286,19 +293,19 @@ impl SourceFile {
1844 /// Returns `true` if this source file is a real source file, and not
1845 /// generated by an external macro's expansion.
1846 pub fn is_real(&self) -> bool {
1847 self.inner.is_real()
1848 }
1849 }
1850
1851 #[cfg(procmacro2_semver_exempt)]
1852-impl fmt::Debug for SourceFile {
1853+impl Debug for SourceFile {
1854 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1855- self.inner.fmt(f)
1856+ Debug::fmt(&self.inner, f)
1857 }
1858 }
1859
1860 /// A line-column pair representing the start or end of a `Span`.
1861 ///
1862 /// This type is semver exempt and not exposed by default.
1863 #[cfg(span_locations)]
1864 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
1865@@ -306,16 +313,32 @@ pub struct LineColumn {
1866 /// The 1-indexed line in the source file on which the span starts or ends
1867 /// (inclusive).
1868 pub line: usize,
1869 /// The 0-indexed column (in UTF-8 characters) in the source file on which
1870 /// the span starts or ends (inclusive).
1871 pub column: usize,
1872 }
1873
1874+#[cfg(span_locations)]
1875+impl Ord for LineColumn {
1876+ fn cmp(&self, other: &Self) -> Ordering {
1877+ self.line
1878+ .cmp(&other.line)
1879+ .then(self.column.cmp(&other.column))
1880+ }
1881+}
1882+
1883+#[cfg(span_locations)]
1884+impl PartialOrd for LineColumn {
1885+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
1886+ Some(self.cmp(other))
1887+ }
1888+}
1889+
1890 /// A region of source code, along with macro expansion information.
1891 #[derive(Copy, Clone)]
1892 pub struct Span {
1893 inner: imp::Span,
1894 _marker: marker::PhantomData<Rc<()>>,
1895 }
1896
1897 impl Span {
1898@@ -337,38 +360,42 @@ impl Span {
1899 ///
1900 /// Identifiers created with this span will be resolved as if they were
1901 /// written directly at the macro call location (call-site hygiene) and
1902 /// other code at the macro call site will be able to refer to them as well.
1903 pub fn call_site() -> Span {
1904 Span::_new(imp::Span::call_site())
1905 }
1906
1907+ /// The span located at the invocation of the procedural macro, but with
1908+ /// local variables, labels, and `$crate` resolved at the definition site
1909+ /// of the macro. This is the same hygiene behavior as `macro_rules`.
1910+ ///
1911+ /// This function requires Rust 1.45 or later.
1912+ #[cfg(hygiene)]
1913+ pub fn mixed_site() -> Span {
1914+ Span::_new(imp::Span::mixed_site())
1915+ }
1916+
1917 /// A span that resolves at the macro definition site.
1918 ///
1919 /// This method is semver exempt and not exposed by default.
1920 #[cfg(procmacro2_semver_exempt)]
1921 pub fn def_site() -> Span {
1922 Span::_new(imp::Span::def_site())
1923 }
1924
1925 /// Creates a new span with the same line/column information as `self` but
1926 /// that resolves symbols as though it were at `other`.
1927- ///
1928- /// This method is semver exempt and not exposed by default.
1929- #[cfg(procmacro2_semver_exempt)]
1930 pub fn resolved_at(&self, other: Span) -> Span {
1931 Span::_new(self.inner.resolved_at(other.inner))
1932 }
1933
1934 /// Creates a new span with the same name resolution behavior as `self` but
1935 /// with the line/column information of `other`.
1936- ///
1937- /// This method is semver exempt and not exposed by default.
1938- #[cfg(procmacro2_semver_exempt)]
1939 pub fn located_at(&self, other: Span) -> Span {
1940 Span::_new(self.inner.located_at(other.inner))
1941 }
1942
1943 /// Convert `proc_macro2::Span` to `proc_macro::Span`.
1944 ///
1945 /// This method is available when building with a nightly compiler, or when
1946 /// building with rustc 1.29+ *without* semver exempt features.
1947@@ -434,19 +461,19 @@ impl Span {
1948 /// This method is semver exempt and not exposed by default.
1949 #[cfg(procmacro2_semver_exempt)]
1950 pub fn eq(&self, other: &Span) -> bool {
1951 self.inner.eq(&other.inner)
1952 }
1953 }
1954
1955 /// Prints a span in a form convenient for debugging.
1956-impl fmt::Debug for Span {
1957+impl Debug for Span {
1958 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1959- self.inner.fmt(f)
1960+ Debug::fmt(&self.inner, f)
1961 }
1962 }
1963
1964 /// A single token or a delimited sequence of token trees (e.g. `[1, (), ..]`).
1965 #[derive(Clone)]
1966 pub enum TokenTree {
1967 /// A token stream surrounded by bracket delimiters.
1968 Group(Group),
1969@@ -457,35 +484,35 @@ pub enum TokenTree {
1970 /// A literal character (`'a'`), string (`"hello"`), number (`2.3`), etc.
1971 Literal(Literal),
1972 }
1973
1974 impl TokenTree {
1975 /// Returns the span of this tree, delegating to the `span` method of
1976 /// the contained token or a delimited stream.
1977 pub fn span(&self) -> Span {
1978- match *self {
1979- TokenTree::Group(ref t) => t.span(),
1980- TokenTree::Ident(ref t) => t.span(),
1981- TokenTree::Punct(ref t) => t.span(),
1982- TokenTree::Literal(ref t) => t.span(),
1983+ match self {
1984+ TokenTree::Group(t) => t.span(),
1985+ TokenTree::Ident(t) => t.span(),
1986+ TokenTree::Punct(t) => t.span(),
1987+ TokenTree::Literal(t) => t.span(),
1988 }
1989 }
1990
1991 /// Configures the span for *only this token*.
1992 ///
1993 /// Note that if this token is a `Group` then this method will not configure
1994 /// the span of each of the internal tokens, this will simply delegate to
1995 /// the `set_span` method of each variant.
1996 pub fn set_span(&mut self, span: Span) {
1997- match *self {
1998- TokenTree::Group(ref mut t) => t.set_span(span),
1999- TokenTree::Ident(ref mut t) => t.set_span(span),
2000- TokenTree::Punct(ref mut t) => t.set_span(span),
2001- TokenTree::Literal(ref mut t) => t.set_span(span),
2002+ match self {
2003+ TokenTree::Group(t) => t.set_span(span),
2004+ TokenTree::Ident(t) => t.set_span(span),
2005+ TokenTree::Punct(t) => t.set_span(span),
2006+ TokenTree::Literal(t) => t.set_span(span),
2007 }
2008 }
2009 }
2010
2011 impl From<Group> for TokenTree {
2012 fn from(g: Group) -> TokenTree {
2013 TokenTree::Group(g)
2014 }
2015@@ -508,42 +535,42 @@ impl From<Literal> for TokenTree {
2016 TokenTree::Literal(g)
2017 }
2018 }
2019
2020 /// Prints the token tree as a string that is supposed to be losslessly
2021 /// convertible back into the same token tree (modulo spans), except for
2022 /// possibly `TokenTree::Group`s with `Delimiter::None` delimiters and negative
2023 /// numeric literals.
2024-impl fmt::Display for TokenTree {
2025+impl Display for TokenTree {
2026 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2027- match *self {
2028- TokenTree::Group(ref t) => t.fmt(f),
2029- TokenTree::Ident(ref t) => t.fmt(f),
2030- TokenTree::Punct(ref t) => t.fmt(f),
2031- TokenTree::Literal(ref t) => t.fmt(f),
2032+ match self {
2033+ TokenTree::Group(t) => Display::fmt(t, f),
2034+ TokenTree::Ident(t) => Display::fmt(t, f),
2035+ TokenTree::Punct(t) => Display::fmt(t, f),
2036+ TokenTree::Literal(t) => Display::fmt(t, f),
2037 }
2038 }
2039 }
2040
2041 /// Prints token tree in a form convenient for debugging.
2042-impl fmt::Debug for TokenTree {
2043+impl Debug for TokenTree {
2044 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2045 // Each of these has the name in the struct type in the derived debug,
2046 // so don't bother with an extra layer of indirection
2047- match *self {
2048- TokenTree::Group(ref t) => t.fmt(f),
2049- TokenTree::Ident(ref t) => {
2050+ match self {
2051+ TokenTree::Group(t) => Debug::fmt(t, f),
2052+ TokenTree::Ident(t) => {
2053 let mut debug = f.debug_struct("Ident");
2054 debug.field("sym", &format_args!("{}", t));
2055 imp::debug_span_field_if_nontrivial(&mut debug, t.span().inner);
2056 debug.finish()
2057 }
2058- TokenTree::Punct(ref t) => t.fmt(f),
2059- TokenTree::Literal(ref t) => t.fmt(f),
2060+ TokenTree::Punct(t) => Debug::fmt(t, f),
2061+ TokenTree::Literal(t) => Debug::fmt(t, f),
2062 }
2063 }
2064 }
2065
2066 /// A delimited token stream.
2067 ///
2068 /// A `Group` internally contains a `TokenStream` which is surrounded by
2069 /// `Delimiter`s.
2070@@ -646,25 +673,25 @@ impl Group {
2071 pub fn set_span(&mut self, span: Span) {
2072 self.inner.set_span(span.inner)
2073 }
2074 }
2075
2076 /// Prints the group as a string that should be losslessly convertible back
2077 /// into the same group (modulo spans), except for possibly `TokenTree::Group`s
2078 /// with `Delimiter::None` delimiters.
2079-impl fmt::Display for Group {
2080+impl Display for Group {
2081 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2082- fmt::Display::fmt(&self.inner, formatter)
2083+ Display::fmt(&self.inner, formatter)
2084 }
2085 }
2086
2087-impl fmt::Debug for Group {
2088+impl Debug for Group {
2089 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2090- fmt::Debug::fmt(&self.inner, formatter)
2091+ Debug::fmt(&self.inner, formatter)
2092 }
2093 }
2094
2095 /// An `Punct` is an single punctuation character like `+`, `-` or `#`.
2096 ///
2097 /// Multicharacter operators like `+=` are represented as two instances of
2098 /// `Punct` with different forms of `Spacing` returned.
2099 #[derive(Clone)]
2100@@ -725,23 +752,23 @@ impl Punct {
2101 /// Configure the span for this punctuation character.
2102 pub fn set_span(&mut self, span: Span) {
2103 self.span = span;
2104 }
2105 }
2106
2107 /// Prints the punctuation character as a string that should be losslessly
2108 /// convertible back into the same character.
2109-impl fmt::Display for Punct {
2110+impl Display for Punct {
2111 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2112- self.op.fmt(f)
2113+ Display::fmt(&self.op, f)
2114 }
2115 }
2116
2117-impl fmt::Debug for Punct {
2118+impl Debug for Punct {
2119 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
2120 let mut debug = fmt.debug_struct("Punct");
2121 debug.field("op", &self.op);
2122 debug.field("spacing", &self.spacing);
2123 imp::debug_span_field_if_nontrivial(&mut debug, self.span.inner);
2124 debug.finish()
2125 }
2126 }
2127@@ -915,25 +942,25 @@ impl Ord for Ident {
2128 impl Hash for Ident {
2129 fn hash<H: Hasher>(&self, hasher: &mut H) {
2130 self.to_string().hash(hasher)
2131 }
2132 }
2133
2134 /// Prints the identifier as a string that should be losslessly convertible back
2135 /// into the same identifier.
2136-impl fmt::Display for Ident {
2137+impl Display for Ident {
2138 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2139- self.inner.fmt(f)
2140+ Display::fmt(&self.inner, f)
2141 }
2142 }
2143
2144-impl fmt::Debug for Ident {
2145+impl Debug for Ident {
2146 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2147- self.inner.fmt(f)
2148+ Debug::fmt(&self.inner, f)
2149 }
2150 }
2151
2152 /// A literal string (`"hello"`), byte string (`b"hello"`), character (`'a'`),
2153 /// byte character (`b'a'`), an integer or floating point number with or without
2154 /// a suffix (`1`, `1u8`, `2.3`, `2.3f32`).
2155 ///
2156 /// Boolean literals like `true` and `false` do not belong here, they are
2157@@ -1135,36 +1162,36 @@ impl Literal {
2158 /// nightly compiler, this method will always return `None`.
2159 ///
2160 /// [`proc_macro::Literal::subspan`]: https://doc.rust-lang.org/proc_macro/struct.Literal.html#method.subspan
2161 pub fn subspan<R: RangeBounds<usize>>(&self, range: R) -> Option<Span> {
2162 self.inner.subspan(range).map(Span::_new)
2163 }
2164 }
2165
2166-impl fmt::Debug for Literal {
2167+impl Debug for Literal {
2168 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2169- self.inner.fmt(f)
2170+ Debug::fmt(&self.inner, f)
2171 }
2172 }
2173
2174-impl fmt::Display for Literal {
2175+impl Display for Literal {
2176 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2177- self.inner.fmt(f)
2178+ Display::fmt(&self.inner, f)
2179 }
2180 }
2181
2182 /// Public implementation details for the `TokenStream` type, such as iterators.
2183 pub mod token_stream {
2184- use std::fmt;
2185+ use crate::{imp, TokenTree};
2186+ use std::fmt::{self, Debug};
2187 use std::marker;
2188 use std::rc::Rc;
2189
2190 pub use crate::TokenStream;
2191- use crate::{imp, TokenTree};
2192
2193 /// An iterator over `TokenStream`'s `TokenTree`s.
2194 ///
2195 /// The iteration is "shallow", e.g. the iterator doesn't recurse into
2196 /// delimited groups, and returns whole groups as token trees.
2197 #[derive(Clone)]
2198 pub struct IntoIter {
2199 inner: imp::TokenTreeIter,
2200@@ -1174,19 +1201,19 @@ pub mod token_stream {
2201 impl Iterator for IntoIter {
2202 type Item = TokenTree;
2203
2204 fn next(&mut self) -> Option<TokenTree> {
2205 self.inner.next()
2206 }
2207 }
2208
2209- impl fmt::Debug for IntoIter {
2210+ impl Debug for IntoIter {
2211 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2212- self.inner.fmt(f)
2213+ Debug::fmt(&self.inner, f)
2214 }
2215 }
2216
2217 impl IntoIterator for TokenStream {
2218 type Item = TokenTree;
2219 type IntoIter = IntoIter;
2220
2221 fn into_iter(self) -> IntoIter {
2222diff --git a/third_party/rust/proc-macro2/src/parse.rs b/third_party/rust/proc-macro2/src/parse.rs
2223new file mode 100644
2224--- /dev/null
2225+++ b/third_party/rust/proc-macro2/src/parse.rs
2226@@ -0,0 +1,791 @@
2227+use crate::fallback::{
2228+ is_ident_continue, is_ident_start, Group, LexError, Literal, Span, TokenStream,
2229+};
2230+use crate::{Delimiter, Punct, Spacing, TokenTree};
2231+use std::str::{Bytes, CharIndices, Chars};
2232+use unicode_xid::UnicodeXID;
2233+
2234+#[derive(Copy, Clone, Eq, PartialEq)]
2235+pub(crate) struct Cursor<'a> {
2236+ pub rest: &'a str,
2237+ #[cfg(span_locations)]
2238+ pub off: u32,
2239+}
2240+
2241+impl<'a> Cursor<'a> {
2242+ fn advance(&self, bytes: usize) -> Cursor<'a> {
2243+ let (_front, rest) = self.rest.split_at(bytes);
2244+ Cursor {
2245+ rest,
2246+ #[cfg(span_locations)]
2247+ off: self.off + _front.chars().count() as u32,
2248+ }
2249+ }
2250+
2251+ fn starts_with(&self, s: &str) -> bool {
2252+ self.rest.starts_with(s)
2253+ }
2254+
2255+ pub(crate) fn is_empty(&self) -> bool {
2256+ self.rest.is_empty()
2257+ }
2258+
2259+ fn len(&self) -> usize {
2260+ self.rest.len()
2261+ }
2262+
2263+ fn as_bytes(&self) -> &'a [u8] {
2264+ self.rest.as_bytes()
2265+ }
2266+
2267+ fn bytes(&self) -> Bytes<'a> {
2268+ self.rest.bytes()
2269+ }
2270+
2271+ fn chars(&self) -> Chars<'a> {
2272+ self.rest.chars()
2273+ }
2274+
2275+ fn char_indices(&self) -> CharIndices<'a> {
2276+ self.rest.char_indices()
2277+ }
2278+
2279+ fn parse(&self, tag: &str) -> Result<Cursor<'a>, LexError> {
2280+ if self.starts_with(tag) {
2281+ Ok(self.advance(tag.len()))
2282+ } else {
2283+ Err(LexError)
2284+ }
2285+ }
2286+}
2287+
2288+type PResult<'a, O> = Result<(Cursor<'a>, O), LexError>;
2289+
2290+fn skip_whitespace(input: Cursor) -> Cursor {
2291+ let mut s = input;
2292+
2293+ while !s.is_empty() {
2294+ let byte = s.as_bytes()[0];
2295+ if byte == b'/' {
2296+ if s.starts_with("//")
2297+ && (!s.starts_with("///") || s.starts_with("////"))
2298+ && !s.starts_with("//!")
2299+ {
2300+ let (cursor, _) = take_until_newline_or_eof(s);
2301+ s = cursor;
2302+ continue;
2303+ } else if s.starts_with("/**/") {
2304+ s = s.advance(4);
2305+ continue;
2306+ } else if s.starts_with("/*")
2307+ && (!s.starts_with("/**") || s.starts_with("/***"))
2308+ && !s.starts_with("/*!")
2309+ {
2310+ match block_comment(s) {
2311+ Ok((rest, _)) => {
2312+ s = rest;
2313+ continue;
2314+ }
2315+ Err(LexError) => return s,
2316+ }
2317+ }
2318+ }
2319+ match byte {
2320+ b' ' | 0x09..=0x0d => {
2321+ s = s.advance(1);
2322+ continue;
2323+ }
2324+ b if b <= 0x7f => {}
2325+ _ => {
2326+ let ch = s.chars().next().unwrap();
2327+ if is_whitespace(ch) {
2328+ s = s.advance(ch.len_utf8());
2329+ continue;
2330+ }
2331+ }
2332+ }
2333+ return s;
2334+ }
2335+ s
2336+}
2337+
2338+fn block_comment(input: Cursor) -> PResult<&str> {
2339+ if !input.starts_with("/*") {
2340+ return Err(LexError);
2341+ }
2342+
2343+ let mut depth = 0;
2344+ let bytes = input.as_bytes();
2345+ let mut i = 0;
2346+ let upper = bytes.len() - 1;
2347+
2348+ while i < upper {
2349+ if bytes[i] == b'/' && bytes[i + 1] == b'*' {
2350+ depth += 1;
2351+ i += 1; // eat '*'
2352+ } else if bytes[i] == b'*' && bytes[i + 1] == b'/' {
2353+ depth -= 1;
2354+ if depth == 0 {
2355+ return Ok((input.advance(i + 2), &input.rest[..i + 2]));
2356+ }
2357+ i += 1; // eat '/'
2358+ }
2359+ i += 1;
2360+ }
2361+
2362+ Err(LexError)
2363+}
2364+
2365+fn is_whitespace(ch: char) -> bool {
2366+ // Rust treats left-to-right mark and right-to-left mark as whitespace
2367+ ch.is_whitespace() || ch == '\u{200e}' || ch == '\u{200f}'
2368+}
2369+
2370+fn word_break(input: Cursor) -> Result<Cursor, LexError> {
2371+ match input.chars().next() {
2372+ Some(ch) if UnicodeXID::is_xid_continue(ch) => Err(LexError),
2373+ Some(_) | None => Ok(input),
2374+ }
2375+}
2376+
2377+pub(crate) fn token_stream(mut input: Cursor) -> PResult<TokenStream> {
2378+ let mut trees = Vec::new();
2379+ let mut stack = Vec::new();
2380+
2381+ loop {
2382+ input = skip_whitespace(input);
2383+
2384+ if let Ok((rest, tt)) = doc_comment(input) {
2385+ trees.extend(tt);
2386+ input = rest;
2387+ continue;
2388+ }
2389+
2390+ #[cfg(span_locations)]
2391+ let lo = input.off;
2392+
2393+ let first = match input.bytes().next() {
2394+ Some(first) => first,
2395+ None => break,
2396+ };
2397+
2398+ if let Some(open_delimiter) = match first {
2399+ b'(' => Some(Delimiter::Parenthesis),
2400+ b'[' => Some(Delimiter::Bracket),
2401+ b'{' => Some(Delimiter::Brace),
2402+ _ => None,
2403+ } {
2404+ input = input.advance(1);
2405+ let frame = (open_delimiter, trees);
2406+ #[cfg(span_locations)]
2407+ let frame = (lo, frame);
2408+ stack.push(frame);
2409+ trees = Vec::new();
2410+ } else if let Some(close_delimiter) = match first {
2411+ b')' => Some(Delimiter::Parenthesis),
2412+ b']' => Some(Delimiter::Bracket),
2413+ b'}' => Some(Delimiter::Brace),
2414+ _ => None,
2415+ } {
2416+ input = input.advance(1);
2417+ let frame = stack.pop().ok_or(LexError)?;
2418+ #[cfg(span_locations)]
2419+ let (lo, frame) = frame;
2420+ let (open_delimiter, outer) = frame;
2421+ if open_delimiter != close_delimiter {
2422+ return Err(LexError);
2423+ }
2424+ let mut g = Group::new(open_delimiter, TokenStream { inner: trees });
2425+ g.set_span(Span {
2426+ #[cfg(span_locations)]
2427+ lo,
2428+ #[cfg(span_locations)]
2429+ hi: input.off,
2430+ });
2431+ trees = outer;
2432+ trees.push(TokenTree::Group(crate::Group::_new_stable(g)));
2433+ } else {
2434+ let (rest, mut tt) = leaf_token(input)?;
2435+ tt.set_span(crate::Span::_new_stable(Span {
2436+ #[cfg(span_locations)]
2437+ lo,
2438+ #[cfg(span_locations)]
2439+ hi: rest.off,
2440+ }));
2441+ trees.push(tt);
2442+ input = rest;
2443+ }
2444+ }
2445+
2446+ if stack.is_empty() {
2447+ Ok((input, TokenStream { inner: trees }))
2448+ } else {
2449+ Err(LexError)
2450+ }
2451+}
2452+
2453+fn leaf_token(input: Cursor) -> PResult<TokenTree> {
2454+ if let Ok((input, l)) = literal(input) {
2455+ // must be parsed before ident
2456+ Ok((input, TokenTree::Literal(crate::Literal::_new_stable(l))))
2457+ } else if let Ok((input, p)) = op(input) {
2458+ Ok((input, TokenTree::Punct(p)))
2459+ } else if let Ok((input, i)) = ident(input) {
2460+ Ok((input, TokenTree::Ident(i)))
2461+ } else {
2462+ Err(LexError)
2463+ }
2464+}
2465+
2466+fn ident(input: Cursor) -> PResult<crate::Ident> {
2467+ let raw = input.starts_with("r#");
2468+ let rest = input.advance((raw as usize) << 1);
2469+
2470+ let (rest, sym) = ident_not_raw(rest)?;
2471+
2472+ if !raw {
2473+ let ident = crate::Ident::new(sym, crate::Span::call_site());
2474+ return Ok((rest, ident));
2475+ }
2476+
2477+ if sym == "_" {
2478+ return Err(LexError);
2479+ }
2480+
2481+ let ident = crate::Ident::_new_raw(sym, crate::Span::call_site());
2482+ Ok((rest, ident))
2483+}
2484+
2485+fn ident_not_raw(input: Cursor) -> PResult<&str> {
2486+ let mut chars = input.char_indices();
2487+
2488+ match chars.next() {
2489+ Some((_, ch)) if is_ident_start(ch) => {}
2490+ _ => return Err(LexError),
2491+ }
2492+
2493+ let mut end = input.len();
2494+ for (i, ch) in chars {
2495+ if !is_ident_continue(ch) {
2496+ end = i;
2497+ break;
2498+ }
2499+ }
2500+
2501+ Ok((input.advance(end), &input.rest[..end]))
2502+}
2503+
2504+fn literal(input: Cursor) -> PResult<Literal> {
2505+ match literal_nocapture(input) {
2506+ Ok(a) => {
2507+ let end = input.len() - a.len();
2508+ Ok((a, Literal::_new(input.rest[..end].to_string())))
2509+ }
2510+ Err(LexError) => Err(LexError),
2511+ }
2512+}
2513+
2514+fn literal_nocapture(input: Cursor) -> Result<Cursor, LexError> {
2515+ if let Ok(ok) = string(input) {
2516+ Ok(ok)
2517+ } else if let Ok(ok) = byte_string(input) {
2518+ Ok(ok)
2519+ } else if let Ok(ok) = byte(input) {
2520+ Ok(ok)
2521+ } else if let Ok(ok) = character(input) {
2522+ Ok(ok)
2523+ } else if let Ok(ok) = float(input) {
2524+ Ok(ok)
2525+ } else if let Ok(ok) = int(input) {
2526+ Ok(ok)
2527+ } else {
2528+ Err(LexError)
2529+ }
2530+}
2531+
2532+fn literal_suffix(input: Cursor) -> Cursor {
2533+ match ident_not_raw(input) {
2534+ Ok((input, _)) => input,
2535+ Err(LexError) => input,
2536+ }
2537+}
2538+
2539+fn string(input: Cursor) -> Result<Cursor, LexError> {
2540+ if let Ok(input) = input.parse("\"") {
2541+ cooked_string(input)
2542+ } else if let Ok(input) = input.parse("r") {
2543+ raw_string(input)
2544+ } else {
2545+ Err(LexError)
2546+ }
2547+}
2548+
2549+fn cooked_string(input: Cursor) -> Result<Cursor, LexError> {
2550+ let mut chars = input.char_indices().peekable();
2551+
2552+ while let Some((i, ch)) = chars.next() {
2553+ match ch {
2554+ '"' => {
2555+ let input = input.advance(i + 1);
2556+ return Ok(literal_suffix(input));
2557+ }
2558+ '\r' => {
2559+ if let Some((_, '\n')) = chars.next() {
2560+ // ...
2561+ } else {
2562+ break;
2563+ }
2564+ }
2565+ '\\' => match chars.next() {
2566+ Some((_, 'x')) => {
2567+ if !backslash_x_char(&mut chars) {
2568+ break;
2569+ }
2570+ }
2571+ Some((_, 'n')) | Some((_, 'r')) | Some((_, 't')) | Some((_, '\\'))
2572+ | Some((_, '\'')) | Some((_, '"')) | Some((_, '0')) => {}
2573+ Some((_, 'u')) => {
2574+ if !backslash_u(&mut chars) {
2575+ break;
2576+ }
2577+ }
2578+ Some((_, '\n')) | Some((_, '\r')) => {
2579+ while let Some(&(_, ch)) = chars.peek() {
2580+ if ch.is_whitespace() {
2581+ chars.next();
2582+ } else {
2583+ break;
2584+ }
2585+ }
2586+ }
2587+ _ => break,
2588+ },
2589+ _ch => {}
2590+ }
2591+ }
2592+ Err(LexError)
2593+}
2594+
2595+fn byte_string(input: Cursor) -> Result<Cursor, LexError> {
2596+ if let Ok(input) = input.parse("b\"") {
2597+ cooked_byte_string(input)
2598+ } else if let Ok(input) = input.parse("br") {
2599+ raw_string(input)
2600+ } else {
2601+ Err(LexError)
2602+ }
2603+}
2604+
2605+fn cooked_byte_string(mut input: Cursor) -> Result<Cursor, LexError> {
2606+ let mut bytes = input.bytes().enumerate();
2607+ 'outer: while let Some((offset, b)) = bytes.next() {
2608+ match b {
2609+ b'"' => {
2610+ let input = input.advance(offset + 1);
2611+ return Ok(literal_suffix(input));
2612+ }
2613+ b'\r' => {
2614+ if let Some((_, b'\n')) = bytes.next() {
2615+ // ...
2616+ } else {
2617+ break;
2618+ }
2619+ }
2620+ b'\\' => match bytes.next() {
2621+ Some((_, b'x')) => {
2622+ if !backslash_x_byte(&mut bytes) {
2623+ break;
2624+ }
2625+ }
2626+ Some((_, b'n')) | Some((_, b'r')) | Some((_, b't')) | Some((_, b'\\'))
2627+ | Some((_, b'0')) | Some((_, b'\'')) | Some((_, b'"')) => {}
2628+ Some((newline, b'\n')) | Some((newline, b'\r')) => {
2629+ let rest = input.advance(newline + 1);
2630+ for (offset, ch) in rest.char_indices() {
2631+ if !ch.is_whitespace() {
2632+ input = rest.advance(offset);
2633+ bytes = input.bytes().enumerate();
2634+ continue 'outer;
2635+ }
2636+ }
2637+ break;
2638+ }
2639+ _ => break,
2640+ },
2641+ b if b < 0x80 => {}
2642+ _ => break,
2643+ }
2644+ }
2645+ Err(LexError)
2646+}
2647+
2648+fn raw_string(input: Cursor) -> Result<Cursor, LexError> {
2649+ let mut chars = input.char_indices();
2650+ let mut n = 0;
2651+ while let Some((i, ch)) = chars.next() {
2652+ match ch {
2653+ '"' => {
2654+ n = i;
2655+ break;
2656+ }
2657+ '#' => {}
2658+ _ => return Err(LexError),
2659+ }
2660+ }
2661+ for (i, ch) in chars {
2662+ match ch {
2663+ '"' if input.rest[i + 1..].starts_with(&input.rest[..n]) => {
2664+ let rest = input.advance(i + 1 + n);
2665+ return Ok(literal_suffix(rest));
2666+ }
2667+ '\r' => {}
2668+ _ => {}
2669+ }
2670+ }
2671+ Err(LexError)
2672+}
2673+
2674+fn byte(input: Cursor) -> Result<Cursor, LexError> {
2675+ let input = input.parse("b'")?;
2676+ let mut bytes = input.bytes().enumerate();
2677+ let ok = match bytes.next().map(|(_, b)| b) {
2678+ Some(b'\\') => match bytes.next().map(|(_, b)| b) {
2679+ Some(b'x') => backslash_x_byte(&mut bytes),
2680+ Some(b'n') | Some(b'r') | Some(b't') | Some(b'\\') | Some(b'0') | Some(b'\'')
2681+ | Some(b'"') => true,
2682+ _ => false,
2683+ },
2684+ b => b.is_some(),
2685+ };
2686+ if !ok {
2687+ return Err(LexError);
2688+ }
2689+ let (offset, _) = bytes.next().ok_or(LexError)?;
2690+ if !input.chars().as_str().is_char_boundary(offset) {
2691+ return Err(LexError);
2692+ }
2693+ let input = input.advance(offset).parse("'")?;
2694+ Ok(literal_suffix(input))
2695+}
2696+
2697+fn character(input: Cursor) -> Result<Cursor, LexError> {
2698+ let input = input.parse("'")?;
2699+ let mut chars = input.char_indices();
2700+ let ok = match chars.next().map(|(_, ch)| ch) {
2701+ Some('\\') => match chars.next().map(|(_, ch)| ch) {
2702+ Some('x') => backslash_x_char(&mut chars),
2703+ Some('u') => backslash_u(&mut chars),
2704+ Some('n') | Some('r') | Some('t') | Some('\\') | Some('0') | Some('\'') | Some('"') => {
2705+ true
2706+ }
2707+ _ => false,
2708+ },
2709+ ch => ch.is_some(),
2710+ };
2711+ if !ok {
2712+ return Err(LexError);
2713+ }
2714+ let (idx, _) = chars.next().ok_or(LexError)?;
2715+ let input = input.advance(idx).parse("'")?;
2716+ Ok(literal_suffix(input))
2717+}
2718+
2719+macro_rules! next_ch {
2720+ ($chars:ident @ $pat:pat $(| $rest:pat)*) => {
2721+ match $chars.next() {
2722+ Some((_, ch)) => match ch {
2723+ $pat $(| $rest)* => ch,
2724+ _ => return false,
2725+ },
2726+ None => return false,
2727+ }
2728+ };
2729+}
2730+
2731+fn backslash_x_char<I>(chars: &mut I) -> bool
2732+where
2733+ I: Iterator<Item = (usize, char)>,
2734+{
2735+ next_ch!(chars @ '0'..='7');
2736+ next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
2737+ true
2738+}
2739+
2740+fn backslash_x_byte<I>(chars: &mut I) -> bool
2741+where
2742+ I: Iterator<Item = (usize, u8)>,
2743+{
2744+ next_ch!(chars @ b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F');
2745+ next_ch!(chars @ b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F');
2746+ true
2747+}
2748+
2749+fn backslash_u<I>(chars: &mut I) -> bool
2750+where
2751+ I: Iterator<Item = (usize, char)>,
2752+{
2753+ next_ch!(chars @ '{');
2754+ next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
2755+ loop {
2756+ let c = next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F' | '_' | '}');
2757+ if c == '}' {
2758+ return true;
2759+ }
2760+ }
2761+}
2762+
2763+fn float(input: Cursor) -> Result<Cursor, LexError> {
2764+ let mut rest = float_digits(input)?;
2765+ if let Some(ch) = rest.chars().next() {
2766+ if is_ident_start(ch) {
2767+ rest = ident_not_raw(rest)?.0;
2768+ }
2769+ }
2770+ word_break(rest)
2771+}
2772+
2773+fn float_digits(input: Cursor) -> Result<Cursor, LexError> {
2774+ let mut chars = input.chars().peekable();
2775+ match chars.next() {
2776+ Some(ch) if ch >= '0' && ch <= '9' => {}
2777+ _ => return Err(LexError),
2778+ }
2779+
2780+ let mut len = 1;
2781+ let mut has_dot = false;
2782+ let mut has_exp = false;
2783+ while let Some(&ch) = chars.peek() {
2784+ match ch {
2785+ '0'..='9' | '_' => {
2786+ chars.next();
2787+ len += 1;
2788+ }
2789+ '.' => {
2790+ if has_dot {
2791+ break;
2792+ }
2793+ chars.next();
2794+ if chars
2795+ .peek()
2796+ .map(|&ch| ch == '.' || is_ident_start(ch))
2797+ .unwrap_or(false)
2798+ {
2799+ return Err(LexError);
2800+ }
2801+ len += 1;
2802+ has_dot = true;
2803+ }
2804+ 'e' | 'E' => {
2805+ chars.next();
2806+ len += 1;
2807+ has_exp = true;
2808+ break;
2809+ }
2810+ _ => break,
2811+ }
2812+ }
2813+
2814+ let rest = input.advance(len);
2815+ if !(has_dot || has_exp || rest.starts_with("f32") || rest.starts_with("f64")) {
2816+ return Err(LexError);
2817+ }
2818+
2819+ if has_exp {
2820+ let mut has_exp_value = false;
2821+ while let Some(&ch) = chars.peek() {
2822+ match ch {
2823+ '+' | '-' => {
2824+ if has_exp_value {
2825+ break;
2826+ }
2827+ chars.next();
2828+ len += 1;
2829+ }
2830+ '0'..='9' => {
2831+ chars.next();
2832+ len += 1;
2833+ has_exp_value = true;
2834+ }
2835+ '_' => {
2836+ chars.next();
2837+ len += 1;
2838+ }
2839+ _ => break,
2840+ }
2841+ }
2842+ if !has_exp_value {
2843+ return Err(LexError);
2844+ }
2845+ }
2846+
2847+ Ok(input.advance(len))
2848+}
2849+
2850+fn int(input: Cursor) -> Result<Cursor, LexError> {
2851+ let mut rest = digits(input)?;
2852+ if let Some(ch) = rest.chars().next() {
2853+ if is_ident_start(ch) {
2854+ rest = ident_not_raw(rest)?.0;
2855+ }
2856+ }
2857+ word_break(rest)
2858+}
2859+
2860+fn digits(mut input: Cursor) -> Result<Cursor, LexError> {
2861+ let base = if input.starts_with("0x") {
2862+ input = input.advance(2);
2863+ 16
2864+ } else if input.starts_with("0o") {
2865+ input = input.advance(2);
2866+ 8
2867+ } else if input.starts_with("0b") {
2868+ input = input.advance(2);
2869+ 2
2870+ } else {
2871+ 10
2872+ };
2873+
2874+ let mut len = 0;
2875+ let mut empty = true;
2876+ for b in input.bytes() {
2877+ let digit = match b {
2878+ b'0'..=b'9' => (b - b'0') as u64,
2879+ b'a'..=b'f' => 10 + (b - b'a') as u64,
2880+ b'A'..=b'F' => 10 + (b - b'A') as u64,
2881+ b'_' => {
2882+ if empty && base == 10 {
2883+ return Err(LexError);
2884+ }
2885+ len += 1;
2886+ continue;
2887+ }
2888+ _ => break,
2889+ };
2890+ if digit >= base {
2891+ return Err(LexError);
2892+ }
2893+ len += 1;
2894+ empty = false;
2895+ }
2896+ if empty {
2897+ Err(LexError)
2898+ } else {
2899+ Ok(input.advance(len))
2900+ }
2901+}
2902+
2903+fn op(input: Cursor) -> PResult<Punct> {
2904+ match op_char(input) {
2905+ Ok((rest, '\'')) => {
2906+ ident(rest)?;
2907+ Ok((rest, Punct::new('\'', Spacing::Joint)))
2908+ }
2909+ Ok((rest, ch)) => {
2910+ let kind = match op_char(rest) {
2911+ Ok(_) => Spacing::Joint,
2912+ Err(LexError) => Spacing::Alone,
2913+ };
2914+ Ok((rest, Punct::new(ch, kind)))
2915+ }
2916+ Err(LexError) => Err(LexError),
2917+ }
2918+}
2919+
2920+fn op_char(input: Cursor) -> PResult<char> {
2921+ if input.starts_with("//") || input.starts_with("/*") {
2922+ // Do not accept `/` of a comment as an op.
2923+ return Err(LexError);
2924+ }
2925+
2926+ let mut chars = input.chars();
2927+ let first = match chars.next() {
2928+ Some(ch) => ch,
2929+ None => {
2930+ return Err(LexError);
2931+ }
2932+ };
2933+ let recognized = "~!@#$%^&*-=+|;:,<.>/?'";
2934+ if recognized.contains(first) {
2935+ Ok((input.advance(first.len_utf8()), first))
2936+ } else {
2937+ Err(LexError)
2938+ }
2939+}
2940+
2941+fn doc_comment(input: Cursor) -> PResult<Vec<TokenTree>> {
2942+ #[cfg(span_locations)]
2943+ let lo = input.off;
2944+ let (rest, (comment, inner)) = doc_comment_contents(input)?;
2945+ let span = crate::Span::_new_stable(Span {
2946+ #[cfg(span_locations)]
2947+ lo,
2948+ #[cfg(span_locations)]
2949+ hi: rest.off,
2950+ });
2951+
2952+ let mut scan_for_bare_cr = comment;
2953+ while let Some(cr) = scan_for_bare_cr.find('\r') {
2954+ let rest = &scan_for_bare_cr[cr + 1..];
2955+ if !rest.starts_with('\n') {
2956+ return Err(LexError);
2957+ }
2958+ scan_for_bare_cr = rest;
2959+ }
2960+
2961+ let mut trees = Vec::new();
2962+ trees.push(TokenTree::Punct(Punct::new('#', Spacing::Alone)));
2963+ if inner {
2964+ trees.push(Punct::new('!', Spacing::Alone).into());
2965+ }
2966+ let mut stream = vec![
2967+ TokenTree::Ident(crate::Ident::new("doc", span)),
2968+ TokenTree::Punct(Punct::new('=', Spacing::Alone)),
2969+ TokenTree::Literal(crate::Literal::string(comment)),
2970+ ];
2971+ for tt in stream.iter_mut() {
2972+ tt.set_span(span);
2973+ }
2974+ let group = Group::new(Delimiter::Bracket, stream.into_iter().collect());
2975+ trees.push(crate::Group::_new_stable(group).into());
2976+ for tt in trees.iter_mut() {
2977+ tt.set_span(span);
2978+ }
2979+ Ok((rest, trees))
2980+}
2981+
2982+fn doc_comment_contents(input: Cursor) -> PResult<(&str, bool)> {
2983+ if input.starts_with("//!") {
2984+ let input = input.advance(3);
2985+ let (input, s) = take_until_newline_or_eof(input);
2986+ Ok((input, (s, true)))
2987+ } else if input.starts_with("/*!") {
2988+ let (input, s) = block_comment(input)?;
2989+ Ok((input, (&s[3..s.len() - 2], true)))
2990+ } else if input.starts_with("///") {
2991+ let input = input.advance(3);
2992+ if input.starts_with("/") {
2993+ return Err(LexError);
2994+ }
2995+ let (input, s) = take_until_newline_or_eof(input);
2996+ Ok((input, (s, false)))
2997+ } else if input.starts_with("/**") && !input.rest[3..].starts_with('*') {
2998+ let (input, s) = block_comment(input)?;
2999+ Ok((input, (&s[3..s.len() - 2], false)))
3000+ } else {
3001+ Err(LexError)
3002+ }
3003+}
3004+
3005+fn take_until_newline_or_eof(input: Cursor) -> (Cursor, &str) {
3006+ let chars = input.char_indices();
3007+
3008+ for (i, ch) in chars {
3009+ if ch == '\n' {
3010+ return (input.advance(i), &input.rest[..i]);
3011+ } else if ch == '\r' && input.rest[i + 1..].starts_with('\n') {
3012+ return (input.advance(i + 1), &input.rest[..i]);
3013+ }
3014+ }
3015+
3016+ (input.advance(input.len()), input.rest)
3017+}
3018diff --git a/third_party/rust/proc-macro2/src/strnom.rs b/third_party/rust/proc-macro2/src/strnom.rs
3019deleted file mode 100644
3020--- a/third_party/rust/proc-macro2/src/strnom.rs
3021+++ /dev/null
3022@@ -1,391 +0,0 @@
3023-//! Adapted from [`nom`](https://github.com/Geal/nom).
3024-
3025-use crate::fallback::LexError;
3026-use std::str::{Bytes, CharIndices, Chars};
3027-use unicode_xid::UnicodeXID;
3028-
3029-#[derive(Copy, Clone, Eq, PartialEq)]
3030-pub struct Cursor<'a> {
3031- pub rest: &'a str,
3032- #[cfg(span_locations)]
3033- pub off: u32,
3034-}
3035-
3036-impl<'a> Cursor<'a> {
3037- #[cfg(not(span_locations))]
3038- pub fn advance(&self, amt: usize) -> Cursor<'a> {
3039- Cursor {
3040- rest: &self.rest[amt..],
3041- }
3042- }
3043- #[cfg(span_locations)]
3044- pub fn advance(&self, amt: usize) -> Cursor<'a> {
3045- Cursor {
3046- rest: &self.rest[amt..],
3047- off: self.off + (amt as u32),
3048- }
3049- }
3050-
3051- pub fn find(&self, p: char) -> Option<usize> {
3052- self.rest.find(p)
3053- }
3054-
3055- pub fn starts_with(&self, s: &str) -> bool {
3056- self.rest.starts_with(s)
3057- }
3058-
3059- pub fn is_empty(&self) -> bool {
3060- self.rest.is_empty()
3061- }
3062-
3063- pub fn len(&self) -> usize {
3064- self.rest.len()
3065- }
3066-
3067- pub fn as_bytes(&self) -> &'a [u8] {
3068- self.rest.as_bytes()
3069- }
3070-
3071- pub fn bytes(&self) -> Bytes<'a> {
3072- self.rest.bytes()
3073- }
3074-
3075- pub fn chars(&self) -> Chars<'a> {
3076- self.rest.chars()
3077- }
3078-
3079- pub fn char_indices(&self) -> CharIndices<'a> {
3080- self.rest.char_indices()
3081- }
3082-}
3083-
3084-pub type PResult<'a, O> = Result<(Cursor<'a>, O), LexError>;
3085-
3086-pub fn whitespace(input: Cursor) -> PResult<()> {
3087- if input.is_empty() {
3088- return Err(LexError);
3089- }
3090-
3091- let bytes = input.as_bytes();
3092- let mut i = 0;
3093- while i < bytes.len() {
3094- let s = input.advance(i);
3095- if bytes[i] == b'/' {
3096- if s.starts_with("//")
3097- && (!s.starts_with("///") || s.starts_with("////"))
3098- && !s.starts_with("//!")
3099- {
3100- if let Some(len) = s.find('\n') {
3101- i += len + 1;
3102- continue;
3103- }
3104- break;
3105- } else if s.starts_with("/**/") {
3106- i += 4;
3107- continue;
3108- } else if s.starts_with("/*")
3109- && (!s.starts_with("/**") || s.starts_with("/***"))
3110- && !s.starts_with("/*!")
3111- {
3112- let (_, com) = block_comment(s)?;
3113- i += com.len();
3114- continue;
3115- }
3116- }
3117- match bytes[i] {
3118- b' ' | 0x09..=0x0d => {
3119- i += 1;
3120- continue;
3121- }
3122- b if b <= 0x7f => {}
3123- _ => {
3124- let ch = s.chars().next().unwrap();
3125- if is_whitespace(ch) {
3126- i += ch.len_utf8();
3127- continue;
3128- }
3129- }
3130- }
3131- return if i > 0 { Ok((s, ())) } else { Err(LexError) };
3132- }
3133- Ok((input.advance(input.len()), ()))
3134-}
3135-
3136-pub fn block_comment(input: Cursor) -> PResult<&str> {
3137- if !input.starts_with("/*") {
3138- return Err(LexError);
3139- }
3140-
3141- let mut depth = 0;
3142- let bytes = input.as_bytes();
3143- let mut i = 0;
3144- let upper = bytes.len() - 1;
3145- while i < upper {
3146- if bytes[i] == b'/' && bytes[i + 1] == b'*' {
3147- depth += 1;
3148- i += 1; // eat '*'
3149- } else if bytes[i] == b'*' && bytes[i + 1] == b'/' {
3150- depth -= 1;
3151- if depth == 0 {
3152- return Ok((input.advance(i + 2), &input.rest[..i + 2]));
3153- }
3154- i += 1; // eat '/'
3155- }
3156- i += 1;
3157- }
3158- Err(LexError)
3159-}
3160-
3161-pub fn skip_whitespace(input: Cursor) -> Cursor {
3162- match whitespace(input) {
3163- Ok((rest, _)) => rest,
3164- Err(LexError) => input,
3165- }
3166-}
3167-
3168-fn is_whitespace(ch: char) -> bool {
3169- // Rust treats left-to-right mark and right-to-left mark as whitespace
3170- ch.is_whitespace() || ch == '\u{200e}' || ch == '\u{200f}'
3171-}
3172-
3173-pub fn word_break(input: Cursor) -> PResult<()> {
3174- match input.chars().next() {
3175- Some(ch) if UnicodeXID::is_xid_continue(ch) => Err(LexError),
3176- Some(_) | None => Ok((input, ())),
3177- }
3178-}
3179-
3180-macro_rules! named {
3181- ($name:ident -> $o:ty, $submac:ident!( $($args:tt)* )) => {
3182- fn $name<'a>(i: Cursor<'a>) -> $crate::strnom::PResult<'a, $o> {
3183- $submac!(i, $($args)*)
3184- }
3185- };
3186-}
3187-
3188-macro_rules! alt {
3189- ($i:expr, $e:ident | $($rest:tt)*) => {
3190- alt!($i, call!($e) | $($rest)*)
3191- };
3192-
3193- ($i:expr, $subrule:ident!( $($args:tt)*) | $($rest:tt)*) => {
3194- match $subrule!($i, $($args)*) {
3195- res @ Ok(_) => res,
3196- _ => alt!($i, $($rest)*)
3197- }
3198- };
3199-
3200- ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr } | $($rest:tt)+) => {
3201- match $subrule!($i, $($args)*) {
3202- Ok((i, o)) => Ok((i, $gen(o))),
3203- Err(LexError) => alt!($i, $($rest)*)
3204- }
3205- };
3206-
3207- ($i:expr, $e:ident => { $gen:expr } | $($rest:tt)*) => {
3208- alt!($i, call!($e) => { $gen } | $($rest)*)
3209- };
3210-
3211- ($i:expr, $e:ident => { $gen:expr }) => {
3212- alt!($i, call!($e) => { $gen })
3213- };
3214-
3215- ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr }) => {
3216- match $subrule!($i, $($args)*) {
3217- Ok((i, o)) => Ok((i, $gen(o))),
3218- Err(LexError) => Err(LexError),
3219- }
3220- };
3221-
3222- ($i:expr, $e:ident) => {
3223- alt!($i, call!($e))
3224- };
3225-
3226- ($i:expr, $subrule:ident!( $($args:tt)*)) => {
3227- $subrule!($i, $($args)*)
3228- };
3229-}
3230-
3231-macro_rules! do_parse {
3232- ($i:expr, ( $($rest:expr),* )) => {
3233- Ok(($i, ( $($rest),* )))
3234- };
3235-
3236- ($i:expr, $e:ident >> $($rest:tt)*) => {
3237- do_parse!($i, call!($e) >> $($rest)*)
3238- };
3239-
3240- ($i:expr, $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => {
3241- match $submac!($i, $($args)*) {
3242- Err(LexError) => Err(LexError),
3243- Ok((i, _)) => do_parse!(i, $($rest)*),
3244- }
3245- };
3246-
3247- ($i:expr, $field:ident : $e:ident >> $($rest:tt)*) => {
3248- do_parse!($i, $field: call!($e) >> $($rest)*)
3249- };
3250-
3251- ($i:expr, $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => {
3252- match $submac!($i, $($args)*) {
3253- Err(LexError) => Err(LexError),
3254- Ok((i, o)) => {
3255- let $field = o;
3256- do_parse!(i, $($rest)*)
3257- },
3258- }
3259- };
3260-}
3261-
3262-macro_rules! peek {
3263- ($i:expr, $submac:ident!( $($args:tt)* )) => {
3264- match $submac!($i, $($args)*) {
3265- Ok((_, o)) => Ok(($i, o)),
3266- Err(LexError) => Err(LexError),
3267- }
3268- };
3269-}
3270-
3271-macro_rules! call {
3272- ($i:expr, $fun:expr $(, $args:expr)*) => {
3273- $fun($i $(, $args)*)
3274- };
3275-}
3276-
3277-macro_rules! option {
3278- ($i:expr, $f:expr) => {
3279- match $f($i) {
3280- Ok((i, o)) => Ok((i, Some(o))),
3281- Err(LexError) => Ok(($i, None)),
3282- }
3283- };
3284-}
3285-
3286-macro_rules! take_until_newline_or_eof {
3287- ($i:expr,) => {{
3288- if $i.len() == 0 {
3289- Ok(($i, ""))
3290- } else {
3291- match $i.find('\n') {
3292- Some(i) => Ok(($i.advance(i), &$i.rest[..i])),
3293- None => Ok(($i.advance($i.len()), &$i.rest[..$i.len()])),
3294- }
3295- }
3296- }};
3297-}
3298-
3299-macro_rules! tuple {
3300- ($i:expr, $($rest:tt)*) => {
3301- tuple_parser!($i, (), $($rest)*)
3302- };
3303-}
3304-
3305-/// Do not use directly. Use `tuple!`.
3306-macro_rules! tuple_parser {
3307- ($i:expr, ($($parsed:tt),*), $e:ident, $($rest:tt)*) => {
3308- tuple_parser!($i, ($($parsed),*), call!($e), $($rest)*)
3309- };
3310-
3311- ($i:expr, (), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => {
3312- match $submac!($i, $($args)*) {
3313- Err(LexError) => Err(LexError),
3314- Ok((i, o)) => tuple_parser!(i, (o), $($rest)*),
3315- }
3316- };
3317-
3318- ($i:expr, ($($parsed:tt)*), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => {
3319- match $submac!($i, $($args)*) {
3320- Err(LexError) => Err(LexError),
3321- Ok((i, o)) => tuple_parser!(i, ($($parsed)* , o), $($rest)*),
3322- }
3323- };
3324-
3325- ($i:expr, ($($parsed:tt),*), $e:ident) => {
3326- tuple_parser!($i, ($($parsed),*), call!($e))
3327- };
3328-
3329- ($i:expr, (), $submac:ident!( $($args:tt)* )) => {
3330- $submac!($i, $($args)*)
3331- };
3332-
3333- ($i:expr, ($($parsed:expr),*), $submac:ident!( $($args:tt)* )) => {
3334- match $submac!($i, $($args)*) {
3335- Err(LexError) => Err(LexError),
3336- Ok((i, o)) => Ok((i, ($($parsed),*, o)))
3337- }
3338- };
3339-
3340- ($i:expr, ($($parsed:expr),*)) => {
3341- Ok(($i, ($($parsed),*)))
3342- };
3343-}
3344-
3345-macro_rules! not {
3346- ($i:expr, $submac:ident!( $($args:tt)* )) => {
3347- match $submac!($i, $($args)*) {
3348- Ok((_, _)) => Err(LexError),
3349- Err(LexError) => Ok(($i, ())),
3350- }
3351- };
3352-}
3353-
3354-macro_rules! tag {
3355- ($i:expr, $tag:expr) => {
3356- if $i.starts_with($tag) {
3357- Ok(($i.advance($tag.len()), &$i.rest[..$tag.len()]))
3358- } else {
3359- Err(LexError)
3360- }
3361- };
3362-}
3363-
3364-macro_rules! punct {
3365- ($i:expr, $punct:expr) => {
3366- $crate::strnom::punct($i, $punct)
3367- };
3368-}
3369-
3370-/// Do not use directly. Use `punct!`.
3371-pub fn punct<'a>(input: Cursor<'a>, token: &'static str) -> PResult<'a, &'a str> {
3372- let input = skip_whitespace(input);
3373- if input.starts_with(token) {
3374- Ok((input.advance(token.len()), token))
3375- } else {
3376- Err(LexError)
3377- }
3378-}
3379-
3380-macro_rules! preceded {
3381- ($i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => {
3382- match tuple!($i, $submac!($($args)*), $submac2!($($args2)*)) {
3383- Ok((remaining, (_, o))) => Ok((remaining, o)),
3384- Err(LexError) => Err(LexError),
3385- }
3386- };
3387-
3388- ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => {
3389- preceded!($i, $submac!($($args)*), call!($g))
3390- };
3391-}
3392-
3393-macro_rules! delimited {
3394- ($i:expr, $submac:ident!( $($args:tt)* ), $($rest:tt)+) => {
3395- match tuple_parser!($i, (), $submac!($($args)*), $($rest)*) {
3396- Err(LexError) => Err(LexError),
3397- Ok((i1, (_, o, _))) => Ok((i1, o))
3398- }
3399- };
3400-}
3401-
3402-macro_rules! map {
3403- ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => {
3404- match $submac!($i, $($args)*) {
3405- Err(LexError) => Err(LexError),
3406- Ok((i, o)) => Ok((i, call!(o, $g)))
3407- }
3408- };
3409-
3410- ($i:expr, $f:expr, $g:expr) => {
3411- map!($i, call!($f), $g)
3412- };
3413-}
3414diff --git a/third_party/rust/proc-macro2/src/wrapper.rs b/third_party/rust/proc-macro2/src/wrapper.rs
3415--- a/third_party/rust/proc-macro2/src/wrapper.rs
3416+++ b/third_party/rust/proc-macro2/src/wrapper.rs
3417@@ -1,96 +1,39 @@
3418-use std::fmt;
3419-use std::iter;
3420+use crate::detection::inside_proc_macro;
3421+use crate::{fallback, Delimiter, Punct, Spacing, TokenTree};
3422+use std::fmt::{self, Debug, Display};
3423+use std::iter::FromIterator;
3424 use std::ops::RangeBounds;
3425-use std::panic::{self, PanicInfo};
3426+use std::panic;
3427 #[cfg(super_unstable)]
3428 use std::path::PathBuf;
3429 use std::str::FromStr;
3430
3431-use crate::{fallback, Delimiter, Punct, Spacing, TokenTree};
3432-
3433 #[derive(Clone)]
3434-pub enum TokenStream {
3435+pub(crate) enum TokenStream {
3436 Compiler(DeferredTokenStream),
3437 Fallback(fallback::TokenStream),
3438 }
3439
3440 // Work around https://github.com/rust-lang/rust/issues/65080.
3441 // In `impl Extend<TokenTree> for TokenStream` which is used heavily by quote,
3442 // we hold on to the appended tokens and do proc_macro::TokenStream::extend as
3443 // late as possible to batch together consecutive uses of the Extend impl.
3444 #[derive(Clone)]
3445-pub struct DeferredTokenStream {
3446+pub(crate) struct DeferredTokenStream {
3447 stream: proc_macro::TokenStream,
3448 extra: Vec<proc_macro::TokenTree>,
3449 }
3450
3451-pub enum LexError {
3452+pub(crate) enum LexError {
3453 Compiler(proc_macro::LexError),
3454 Fallback(fallback::LexError),
3455 }
3456
3457-fn nightly_works() -> bool {
3458- use std::sync::atomic::*;
3459- use std::sync::Once;
3460-
3461- static WORKS: AtomicUsize = AtomicUsize::new(0);
3462- static INIT: Once = Once::new();
3463-
3464- match WORKS.load(Ordering::SeqCst) {
3465- 1 => return false,
3466- 2 => return true,
3467- _ => {}
3468- }
3469-
3470- // Swap in a null panic hook to avoid printing "thread panicked" to stderr,
3471- // then use catch_unwind to determine whether the compiler's proc_macro is
3472- // working. When proc-macro2 is used from outside of a procedural macro all
3473- // of the proc_macro crate's APIs currently panic.
3474- //
3475- // The Once is to prevent the possibility of this ordering:
3476- //
3477- // thread 1 calls take_hook, gets the user's original hook
3478- // thread 1 calls set_hook with the null hook
3479- // thread 2 calls take_hook, thinks null hook is the original hook
3480- // thread 2 calls set_hook with the null hook
3481- // thread 1 calls set_hook with the actual original hook
3482- // thread 2 calls set_hook with what it thinks is the original hook
3483- //
3484- // in which the user's hook has been lost.
3485- //
3486- // There is still a race condition where a panic in a different thread can
3487- // happen during the interval that the user's original panic hook is
3488- // unregistered such that their hook is incorrectly not called. This is
3489- // sufficiently unlikely and less bad than printing panic messages to stderr
3490- // on correct use of this crate. Maybe there is a libstd feature request
3491- // here. For now, if a user needs to guarantee that this failure mode does
3492- // not occur, they need to call e.g. `proc_macro2::Span::call_site()` from
3493- // the main thread before launching any other threads.
3494- INIT.call_once(|| {
3495- type PanicHook = dyn Fn(&PanicInfo) + Sync + Send + 'static;
3496-
3497- let null_hook: Box<PanicHook> = Box::new(|_panic_info| { /* ignore */ });
3498- let sanity_check = &*null_hook as *const PanicHook;
3499- let original_hook = panic::take_hook();
3500- panic::set_hook(null_hook);
3501-
3502- let works = panic::catch_unwind(|| proc_macro::Span::call_site()).is_ok();
3503- WORKS.store(works as usize + 1, Ordering::SeqCst);
3504-
3505- let hopefully_null_hook = panic::take_hook();
3506- panic::set_hook(original_hook);
3507- if sanity_check != &*hopefully_null_hook {
3508- panic!("observed race condition in proc_macro2::nightly_works");
3509- }
3510- });
3511- nightly_works()
3512-}
3513-
3514 fn mismatch() -> ! {
3515 panic!("stable/nightly mismatch")
3516 }
3517
3518 impl DeferredTokenStream {
3519 fn new(stream: proc_macro::TokenStream) -> Self {
3520 DeferredTokenStream {
3521 stream,
3522@@ -98,28 +41,33 @@ impl DeferredTokenStream {
3523 }
3524 }
3525
3526 fn is_empty(&self) -> bool {
3527 self.stream.is_empty() && self.extra.is_empty()
3528 }
3529
3530 fn evaluate_now(&mut self) {
3531- self.stream.extend(self.extra.drain(..));
3532+ // If-check provides a fast short circuit for the common case of `extra`
3533+ // being empty, which saves a round trip over the proc macro bridge.
3534+ // Improves macro expansion time in winrt by 6% in debug mode.
3535+ if !self.extra.is_empty() {
3536+ self.stream.extend(self.extra.drain(..));
3537+ }
3538 }
3539
3540 fn into_token_stream(mut self) -> proc_macro::TokenStream {
3541 self.evaluate_now();
3542 self.stream
3543 }
3544 }
3545
3546 impl TokenStream {
3547 pub fn new() -> TokenStream {
3548- if nightly_works() {
3549+ if inside_proc_macro() {
3550 TokenStream::Compiler(DeferredTokenStream::new(proc_macro::TokenStream::new()))
3551 } else {
3552 TokenStream::Fallback(fallback::TokenStream::new())
3553 }
3554 }
3555
3556 pub fn is_empty(&self) -> bool {
3557 match self {
3558@@ -142,31 +90,37 @@ impl TokenStream {
3559 }
3560 }
3561 }
3562
3563 impl FromStr for TokenStream {
3564 type Err = LexError;
3565
3566 fn from_str(src: &str) -> Result<TokenStream, LexError> {
3567- if nightly_works() {
3568+ if inside_proc_macro() {
3569 Ok(TokenStream::Compiler(DeferredTokenStream::new(
3570- src.parse()?,
3571+ proc_macro_parse(src)?,
3572 )))
3573 } else {
3574 Ok(TokenStream::Fallback(src.parse()?))
3575 }
3576 }
3577 }
3578
3579-impl fmt::Display for TokenStream {
3580+// Work around https://github.com/rust-lang/rust/issues/58736.
3581+fn proc_macro_parse(src: &str) -> Result<proc_macro::TokenStream, LexError> {
3582+ panic::catch_unwind(|| src.parse().map_err(LexError::Compiler))
3583+ .unwrap_or(Err(LexError::Fallback(fallback::LexError)))
3584+}
3585+
3586+impl Display for TokenStream {
3587 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3588 match self {
3589- TokenStream::Compiler(tts) => tts.clone().into_token_stream().fmt(f),
3590- TokenStream::Fallback(tts) => tts.fmt(f),
3591+ TokenStream::Compiler(tts) => Display::fmt(&tts.clone().into_token_stream(), f),
3592+ TokenStream::Fallback(tts) => Display::fmt(tts, f),
3593 }
3594 }
3595 }
3596
3597 impl From<proc_macro::TokenStream> for TokenStream {
3598 fn from(inner: proc_macro::TokenStream) -> TokenStream {
3599 TokenStream::Compiler(DeferredTokenStream::new(inner))
3600 }
3601@@ -182,17 +136,17 @@ impl From<TokenStream> for proc_macro::T
3602 }
3603
3604 impl From<fallback::TokenStream> for TokenStream {
3605 fn from(inner: fallback::TokenStream) -> TokenStream {
3606 TokenStream::Fallback(inner)
3607 }
3608 }
3609
3610-// Assumes nightly_works().
3611+// Assumes inside_proc_macro().
3612 fn into_compiler_token(token: TokenTree) -> proc_macro::TokenTree {
3613 match token {
3614 TokenTree::Group(tt) => tt.inner.unwrap_nightly().into(),
3615 TokenTree::Punct(tt) => {
3616 let spacing = match tt.spacing() {
3617 Spacing::Joint => proc_macro::Spacing::Joint,
3618 Spacing::Alone => proc_macro::Spacing::Alone,
3619 };
3620@@ -202,37 +156,37 @@ fn into_compiler_token(token: TokenTree)
3621 }
3622 TokenTree::Ident(tt) => tt.inner.unwrap_nightly().into(),
3623 TokenTree::Literal(tt) => tt.inner.unwrap_nightly().into(),
3624 }
3625 }
3626
3627 impl From<TokenTree> for TokenStream {
3628 fn from(token: TokenTree) -> TokenStream {
3629- if nightly_works() {
3630+ if inside_proc_macro() {
3631 TokenStream::Compiler(DeferredTokenStream::new(into_compiler_token(token).into()))
3632 } else {
3633 TokenStream::Fallback(token.into())
3634 }
3635 }
3636 }
3637
3638-impl iter::FromIterator<TokenTree> for TokenStream {
3639+impl FromIterator<TokenTree> for TokenStream {
3640 fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self {
3641- if nightly_works() {
3642+ if inside_proc_macro() {
3643 TokenStream::Compiler(DeferredTokenStream::new(
3644 trees.into_iter().map(into_compiler_token).collect(),
3645 ))
3646 } else {
3647 TokenStream::Fallback(trees.into_iter().collect())
3648 }
3649 }
3650 }
3651
3652-impl iter::FromIterator<TokenStream> for TokenStream {
3653+impl FromIterator<TokenStream> for TokenStream {
3654 fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self {
3655 let mut streams = streams.into_iter();
3656 match streams.next() {
3657 Some(TokenStream::Compiler(mut first)) => {
3658 first.evaluate_now();
3659 first.stream.extend(streams.map(|s| match s {
3660 TokenStream::Compiler(s) => s.into_token_stream(),
3661 TokenStream::Fallback(_) => mismatch(),
3662@@ -247,75 +201,76 @@ impl iter::FromIterator<TokenStream> for
3663 TokenStream::Fallback(first)
3664 }
3665 None => TokenStream::new(),
3666 }
3667 }
3668 }
3669
3670 impl Extend<TokenTree> for TokenStream {
3671- fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, streams: I) {
3672+ fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, stream: I) {
3673 match self {
3674 TokenStream::Compiler(tts) => {
3675 // Here is the reason for DeferredTokenStream.
3676- tts.extra
3677- .extend(streams.into_iter().map(into_compiler_token));
3678+ for token in stream {
3679+ tts.extra.push(into_compiler_token(token));
3680+ }
3681 }
3682- TokenStream::Fallback(tts) => tts.extend(streams),
3683+ TokenStream::Fallback(tts) => tts.extend(stream),
3684 }
3685 }
3686 }
3687
3688 impl Extend<TokenStream> for TokenStream {
3689 fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I) {
3690 match self {
3691 TokenStream::Compiler(tts) => {
3692 tts.evaluate_now();
3693 tts.stream
3694- .extend(streams.into_iter().map(|stream| stream.unwrap_nightly()));
3695+ .extend(streams.into_iter().map(TokenStream::unwrap_nightly));
3696 }
3697 TokenStream::Fallback(tts) => {
3698- tts.extend(streams.into_iter().map(|stream| stream.unwrap_stable()));
3699+ tts.extend(streams.into_iter().map(TokenStream::unwrap_stable));
3700 }
3701 }
3702 }
3703 }
3704
3705-impl fmt::Debug for TokenStream {
3706+impl Debug for TokenStream {
3707 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3708 match self {
3709- TokenStream::Compiler(tts) => tts.clone().into_token_stream().fmt(f),
3710- TokenStream::Fallback(tts) => tts.fmt(f),
3711+ TokenStream::Compiler(tts) => Debug::fmt(&tts.clone().into_token_stream(), f),
3712+ TokenStream::Fallback(tts) => Debug::fmt(tts, f),
3713 }
3714 }
3715 }
3716
3717 impl From<proc_macro::LexError> for LexError {
3718 fn from(e: proc_macro::LexError) -> LexError {
3719 LexError::Compiler(e)
3720 }
3721 }
3722
3723 impl From<fallback::LexError> for LexError {
3724 fn from(e: fallback::LexError) -> LexError {
3725 LexError::Fallback(e)
3726 }
3727 }
3728
3729-impl fmt::Debug for LexError {
3730+impl Debug for LexError {
3731 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3732 match self {
3733- LexError::Compiler(e) => e.fmt(f),
3734- LexError::Fallback(e) => e.fmt(f),
3735+ LexError::Compiler(e) => Debug::fmt(e, f),
3736+ LexError::Fallback(e) => Debug::fmt(e, f),
3737 }
3738 }
3739 }
3740
3741 #[derive(Clone)]
3742-pub enum TokenTreeIter {
3743+pub(crate) enum TokenTreeIter {
3744 Compiler(proc_macro::token_stream::IntoIter),
3745 Fallback(fallback::TokenTreeIter),
3746 }
3747
3748 impl IntoIterator for TokenStream {
3749 type Item = TokenTree;
3750 type IntoIter = TokenTreeIter;
3751
3752@@ -356,25 +311,25 @@ impl Iterator for TokenTreeIter {
3753 fn size_hint(&self) -> (usize, Option<usize>) {
3754 match self {
3755 TokenTreeIter::Compiler(tts) => tts.size_hint(),
3756 TokenTreeIter::Fallback(tts) => tts.size_hint(),
3757 }
3758 }
3759 }
3760
3761-impl fmt::Debug for TokenTreeIter {
3762+impl Debug for TokenTreeIter {
3763 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3764 f.debug_struct("TokenTreeIter").finish()
3765 }
3766 }
3767
3768 #[derive(Clone, PartialEq, Eq)]
3769 #[cfg(super_unstable)]
3770-pub enum SourceFile {
3771+pub(crate) enum SourceFile {
3772 Compiler(proc_macro::SourceFile),
3773 Fallback(fallback::SourceFile),
3774 }
3775
3776 #[cfg(super_unstable)]
3777 impl SourceFile {
3778 fn nightly(sf: proc_macro::SourceFile) -> Self {
3779 SourceFile::Compiler(sf)
3780@@ -392,68 +347,87 @@ impl SourceFile {
3781 match self {
3782 SourceFile::Compiler(a) => a.is_real(),
3783 SourceFile::Fallback(a) => a.is_real(),
3784 }
3785 }
3786 }
3787
3788 #[cfg(super_unstable)]
3789-impl fmt::Debug for SourceFile {
3790+impl Debug for SourceFile {
3791 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3792 match self {
3793- SourceFile::Compiler(a) => a.fmt(f),
3794- SourceFile::Fallback(a) => a.fmt(f),
3795+ SourceFile::Compiler(a) => Debug::fmt(a, f),
3796+ SourceFile::Fallback(a) => Debug::fmt(a, f),
3797 }
3798 }
3799 }
3800
3801 #[cfg(any(super_unstable, feature = "span-locations"))]
3802-pub struct LineColumn {
3803+pub(crate) struct LineColumn {
3804 pub line: usize,
3805 pub column: usize,
3806 }
3807
3808 #[derive(Copy, Clone)]
3809-pub enum Span {
3810+pub(crate) enum Span {
3811 Compiler(proc_macro::Span),
3812 Fallback(fallback::Span),
3813 }
3814
3815 impl Span {
3816 pub fn call_site() -> Span {
3817- if nightly_works() {
3818+ if inside_proc_macro() {
3819 Span::Compiler(proc_macro::Span::call_site())
3820 } else {
3821 Span::Fallback(fallback::Span::call_site())
3822 }
3823 }
3824
3825+ #[cfg(hygiene)]
3826+ pub fn mixed_site() -> Span {
3827+ if inside_proc_macro() {
3828+ Span::Compiler(proc_macro::Span::mixed_site())
3829+ } else {
3830+ Span::Fallback(fallback::Span::mixed_site())
3831+ }
3832+ }
3833+
3834 #[cfg(super_unstable)]
3835 pub fn def_site() -> Span {
3836- if nightly_works() {
3837+ if inside_proc_macro() {
3838 Span::Compiler(proc_macro::Span::def_site())
3839 } else {
3840 Span::Fallback(fallback::Span::def_site())
3841 }
3842 }
3843
3844- #[cfg(super_unstable)]
3845 pub fn resolved_at(&self, other: Span) -> Span {
3846 match (self, other) {
3847+ #[cfg(hygiene)]
3848 (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.resolved_at(b)),
3849+
3850+ // Name resolution affects semantics, but location is only cosmetic
3851+ #[cfg(not(hygiene))]
3852+ (Span::Compiler(_), Span::Compiler(_)) => other,
3853+
3854 (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.resolved_at(b)),
3855 _ => mismatch(),
3856 }
3857 }
3858
3859- #[cfg(super_unstable)]
3860 pub fn located_at(&self, other: Span) -> Span {
3861 match (self, other) {
3862+ #[cfg(hygiene)]
3863 (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.located_at(b)),
3864+
3865+ // Name resolution affects semantics, but location is only cosmetic
3866+ #[cfg(not(hygiene))]
3867+ (Span::Compiler(_), Span::Compiler(_)) => *self,
3868+
3869 (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.located_at(b)),
3870 _ => mismatch(),
3871 }
3872 }
3873
3874 pub fn unwrap(self) -> proc_macro::Span {
3875 match self {
3876 Span::Compiler(s) => s,
3877@@ -537,36 +511,36 @@ impl From<proc_macro::Span> for crate::S
3878 }
3879
3880 impl From<fallback::Span> for Span {
3881 fn from(inner: fallback::Span) -> Span {
3882 Span::Fallback(inner)
3883 }
3884 }
3885
3886-impl fmt::Debug for Span {
3887+impl Debug for Span {
3888 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3889 match self {
3890- Span::Compiler(s) => s.fmt(f),
3891- Span::Fallback(s) => s.fmt(f),
3892+ Span::Compiler(s) => Debug::fmt(s, f),
3893+ Span::Fallback(s) => Debug::fmt(s, f),
3894 }
3895 }
3896 }
3897
3898-pub fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) {
3899+pub(crate) fn debug_span_field_if_nontrivial(debug: &mut fmt::DebugStruct, span: Span) {
3900 match span {
3901 Span::Compiler(s) => {
3902 debug.field("span", &s);
3903 }
3904 Span::Fallback(s) => fallback::debug_span_field_if_nontrivial(debug, s),
3905 }
3906 }
3907
3908 #[derive(Clone)]
3909-pub enum Group {
3910+pub(crate) enum Group {
3911 Compiler(proc_macro::Group),
3912 Fallback(fallback::Group),
3913 }
3914
3915 impl Group {
3916 pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group {
3917 match stream {
3918 TokenStream::Compiler(tts) => {
3919@@ -647,36 +621,36 @@ impl Group {
3920 }
3921
3922 impl From<fallback::Group> for Group {
3923 fn from(g: fallback::Group) -> Self {
3924 Group::Fallback(g)
3925 }
3926 }
3927
3928-impl fmt::Display for Group {
3929+impl Display for Group {
3930 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3931 match self {
3932- Group::Compiler(group) => group.fmt(formatter),
3933- Group::Fallback(group) => group.fmt(formatter),
3934+ Group::Compiler(group) => Display::fmt(group, formatter),
3935+ Group::Fallback(group) => Display::fmt(group, formatter),
3936 }
3937 }
3938 }
3939
3940-impl fmt::Debug for Group {
3941+impl Debug for Group {
3942 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3943 match self {
3944- Group::Compiler(group) => group.fmt(formatter),
3945- Group::Fallback(group) => group.fmt(formatter),
3946+ Group::Compiler(group) => Debug::fmt(group, formatter),
3947+ Group::Fallback(group) => Debug::fmt(group, formatter),
3948 }
3949 }
3950 }
3951
3952 #[derive(Clone)]
3953-pub enum Ident {
3954+pub(crate) enum Ident {
3955 Compiler(proc_macro::Ident),
3956 Fallback(fallback::Ident),
3957 }
3958
3959 impl Ident {
3960 pub fn new(string: &str, span: Span) -> Ident {
3961 match span {
3962 Span::Compiler(s) => Ident::Compiler(proc_macro::Ident::new(string, s)),
3963@@ -742,56 +716,56 @@ where
3964 let other = other.as_ref();
3965 match self {
3966 Ident::Compiler(t) => t.to_string() == other,
3967 Ident::Fallback(t) => t == other,
3968 }
3969 }
3970 }
3971
3972-impl fmt::Display for Ident {
3973+impl Display for Ident {
3974 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3975 match self {
3976- Ident::Compiler(t) => t.fmt(f),
3977- Ident::Fallback(t) => t.fmt(f),
3978+ Ident::Compiler(t) => Display::fmt(t, f),
3979+ Ident::Fallback(t) => Display::fmt(t, f),
3980 }
3981 }
3982 }
3983
3984-impl fmt::Debug for Ident {
3985+impl Debug for Ident {
3986 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3987 match self {
3988- Ident::Compiler(t) => t.fmt(f),
3989- Ident::Fallback(t) => t.fmt(f),
3990+ Ident::Compiler(t) => Debug::fmt(t, f),
3991+ Ident::Fallback(t) => Debug::fmt(t, f),
3992 }
3993 }
3994 }
3995
3996 #[derive(Clone)]
3997-pub enum Literal {
3998+pub(crate) enum Literal {
3999 Compiler(proc_macro::Literal),
4000 Fallback(fallback::Literal),
4001 }
4002
4003 macro_rules! suffixed_numbers {
4004 ($($name:ident => $kind:ident,)*) => ($(
4005 pub fn $name(n: $kind) -> Literal {
4006- if nightly_works() {
4007+ if inside_proc_macro() {
4008 Literal::Compiler(proc_macro::Literal::$name(n))
4009 } else {
4010 Literal::Fallback(fallback::Literal::$name(n))
4011 }
4012 }
4013 )*)
4014 }
4015
4016 macro_rules! unsuffixed_integers {
4017 ($($name:ident => $kind:ident,)*) => ($(
4018 pub fn $name(n: $kind) -> Literal {
4019- if nightly_works() {
4020+ if inside_proc_macro() {
4021 Literal::Compiler(proc_macro::Literal::$name(n))
4022 } else {
4023 Literal::Fallback(fallback::Literal::$name(n))
4024 }
4025 }
4026 )*)
4027 }
4028
4029@@ -825,49 +799,49 @@ impl Literal {
4030 i16_unsuffixed => i16,
4031 i32_unsuffixed => i32,
4032 i64_unsuffixed => i64,
4033 i128_unsuffixed => i128,
4034 isize_unsuffixed => isize,
4035 }
4036
4037 pub fn f32_unsuffixed(f: f32) -> Literal {
4038- if nightly_works() {
4039+ if inside_proc_macro() {
4040 Literal::Compiler(proc_macro::Literal::f32_unsuffixed(f))
4041 } else {
4042 Literal::Fallback(fallback::Literal::f32_unsuffixed(f))
4043 }
4044 }
4045
4046 pub fn f64_unsuffixed(f: f64) -> Literal {
4047- if nightly_works() {
4048+ if inside_proc_macro() {
4049 Literal::Compiler(proc_macro::Literal::f64_unsuffixed(f))
4050 } else {
4051 Literal::Fallback(fallback::Literal::f64_unsuffixed(f))
4052 }
4053 }
4054
4055 pub fn string(t: &str) -> Literal {
4056- if nightly_works() {
4057+ if inside_proc_macro() {
4058 Literal::Compiler(proc_macro::Literal::string(t))
4059 } else {
4060 Literal::Fallback(fallback::Literal::string(t))
4061 }
4062 }
4063
4064 pub fn character(t: char) -> Literal {
4065- if nightly_works() {
4066+ if inside_proc_macro() {
4067 Literal::Compiler(proc_macro::Literal::character(t))
4068 } else {
4069 Literal::Fallback(fallback::Literal::character(t))
4070 }
4071 }
4072
4073 pub fn byte_string(bytes: &[u8]) -> Literal {
4074- if nightly_works() {
4075+ if inside_proc_macro() {
4076 Literal::Compiler(proc_macro::Literal::byte_string(bytes))
4077 } else {
4078 Literal::Fallback(fallback::Literal::byte_string(bytes))
4079 }
4080 }
4081
4082 pub fn span(&self) -> Span {
4083 match self {
4084@@ -903,25 +877,25 @@ impl Literal {
4085 }
4086
4087 impl From<fallback::Literal> for Literal {
4088 fn from(s: fallback::Literal) -> Literal {
4089 Literal::Fallback(s)
4090 }
4091 }
4092
4093-impl fmt::Display for Literal {
4094+impl Display for Literal {
4095 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4096 match self {
4097- Literal::Compiler(t) => t.fmt(f),
4098- Literal::Fallback(t) => t.fmt(f),
4099+ Literal::Compiler(t) => Display::fmt(t, f),
4100+ Literal::Fallback(t) => Display::fmt(t, f),
4101 }
4102 }
4103 }
4104
4105-impl fmt::Debug for Literal {
4106+impl Debug for Literal {
4107 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4108 match self {
4109- Literal::Compiler(t) => t.fmt(f),
4110- Literal::Fallback(t) => t.fmt(f),
4111+ Literal::Compiler(t) => Debug::fmt(t, f),
4112+ Literal::Fallback(t) => Debug::fmt(t, f),
4113 }
4114 }
4115 }
4116diff --git a/third_party/rust/proc-macro2/tests/comments.rs b/third_party/rust/proc-macro2/tests/comments.rs
4117new file mode 100644
4118--- /dev/null
4119+++ b/third_party/rust/proc-macro2/tests/comments.rs
4120@@ -0,0 +1,103 @@
4121+use proc_macro2::{Delimiter, Literal, Spacing, TokenStream, TokenTree};
4122+
4123+// #[doc = "..."] -> "..."
4124+fn lit_of_outer_doc_comment(tokens: TokenStream) -> Literal {
4125+ lit_of_doc_comment(tokens, false)
4126+}
4127+
4128+// #![doc = "..."] -> "..."
4129+fn lit_of_inner_doc_comment(tokens: TokenStream) -> Literal {
4130+ lit_of_doc_comment(tokens, true)
4131+}
4132+
4133+fn lit_of_doc_comment(tokens: TokenStream, inner: bool) -> Literal {
4134+ let mut iter = tokens.clone().into_iter();
4135+ match iter.next().unwrap() {
4136+ TokenTree::Punct(punct) => {
4137+ assert_eq!(punct.as_char(), '#');
4138+ assert_eq!(punct.spacing(), Spacing::Alone);
4139+ }
4140+ _ => panic!("wrong token {:?}", tokens),
4141+ }
4142+ if inner {
4143+ match iter.next().unwrap() {
4144+ TokenTree::Punct(punct) => {
4145+ assert_eq!(punct.as_char(), '!');
4146+ assert_eq!(punct.spacing(), Spacing::Alone);
4147+ }
4148+ _ => panic!("wrong token {:?}", tokens),
4149+ }
4150+ }
4151+ iter = match iter.next().unwrap() {
4152+ TokenTree::Group(group) => {
4153+ assert_eq!(group.delimiter(), Delimiter::Bracket);
4154+ assert!(iter.next().is_none(), "unexpected token {:?}", tokens);
4155+ group.stream().into_iter()
4156+ }
4157+ _ => panic!("wrong token {:?}", tokens),
4158+ };
4159+ match iter.next().unwrap() {
4160+ TokenTree::Ident(ident) => assert_eq!(ident.to_string(), "doc"),
4161+ _ => panic!("wrong token {:?}", tokens),
4162+ }
4163+ match iter.next().unwrap() {
4164+ TokenTree::Punct(punct) => {
4165+ assert_eq!(punct.as_char(), '=');
4166+ assert_eq!(punct.spacing(), Spacing::Alone);
4167+ }
4168+ _ => panic!("wrong token {:?}", tokens),
4169+ }
4170+ match iter.next().unwrap() {
4171+ TokenTree::Literal(literal) => {
4172+ assert!(iter.next().is_none(), "unexpected token {:?}", tokens);
4173+ literal
4174+ }
4175+ _ => panic!("wrong token {:?}", tokens),
4176+ }
4177+}
4178+
4179+#[test]
4180+fn closed_immediately() {
4181+ let stream = "/**/".parse::<TokenStream>().unwrap();
4182+ let tokens = stream.into_iter().collect::<Vec<_>>();
4183+ assert!(tokens.is_empty(), "not empty -- {:?}", tokens);
4184+}
4185+
4186+#[test]
4187+fn incomplete() {
4188+ assert!("/*/".parse::<TokenStream>().is_err());
4189+}
4190+
4191+#[test]
4192+fn lit() {
4193+ let stream = "/// doc".parse::<TokenStream>().unwrap();
4194+ let lit = lit_of_outer_doc_comment(stream);
4195+ assert_eq!(lit.to_string(), "\" doc\"");
4196+
4197+ let stream = "//! doc".parse::<TokenStream>().unwrap();
4198+ let lit = lit_of_inner_doc_comment(stream);
4199+ assert_eq!(lit.to_string(), "\" doc\"");
4200+
4201+ let stream = "/** doc */".parse::<TokenStream>().unwrap();
4202+ let lit = lit_of_outer_doc_comment(stream);
4203+ assert_eq!(lit.to_string(), "\" doc \"");
4204+
4205+ let stream = "/*! doc */".parse::<TokenStream>().unwrap();
4206+ let lit = lit_of_inner_doc_comment(stream);
4207+ assert_eq!(lit.to_string(), "\" doc \"");
4208+}
4209+
4210+#[test]
4211+fn carriage_return() {
4212+ let stream = "///\r\n".parse::<TokenStream>().unwrap();
4213+ let lit = lit_of_outer_doc_comment(stream);
4214+ assert_eq!(lit.to_string(), "\"\"");
4215+
4216+ let stream = "/**\r\n*/".parse::<TokenStream>().unwrap();
4217+ let lit = lit_of_outer_doc_comment(stream);
4218+ assert_eq!(lit.to_string(), "\"\\r\\n\"");
4219+
4220+ "///\r".parse::<TokenStream>().unwrap_err();
4221+ "///\r \n".parse::<TokenStream>().unwrap_err();
4222+ "/**\r \n*/".parse::<TokenStream>().unwrap_err();
4223+}
4224diff --git a/third_party/rust/proc-macro2/tests/test.rs b/third_party/rust/proc-macro2/tests/test.rs
4225--- a/third_party/rust/proc-macro2/tests/test.rs
4226+++ b/third_party/rust/proc-macro2/tests/test.rs
4227@@ -1,12 +1,11 @@
4228+use proc_macro2::{Ident, Literal, Spacing, Span, TokenStream, TokenTree};
4229 use std::str::{self, FromStr};
4230
4231-use proc_macro2::{Ident, Literal, Spacing, Span, TokenStream, TokenTree};
4232-
4233 #[test]
4234 fn idents() {
4235 assert_eq!(
4236 Ident::new("String", Span::call_site()).to_string(),
4237 "String"
4238 );
4239 assert_eq!(Ident::new("fn", Span::call_site()).to_string(), "fn");
4240 assert_eq!(Ident::new("_", Span::call_site()).to_string(), "_");
4241@@ -105,16 +104,43 @@ fn literal_suffix() {
4242 assert_eq!(token_count("999u256"), 1);
4243 assert_eq!(token_count("999r#u256"), 3);
4244 assert_eq!(token_count("1."), 1);
4245 assert_eq!(token_count("1.f32"), 3);
4246 assert_eq!(token_count("1.0_0"), 1);
4247 assert_eq!(token_count("1._0"), 3);
4248 assert_eq!(token_count("1._m"), 3);
4249 assert_eq!(token_count("\"\"s"), 1);
4250+ assert_eq!(token_count("r\"\"r"), 1);
4251+ assert_eq!(token_count("b\"\"b"), 1);
4252+ assert_eq!(token_count("br\"\"br"), 1);
4253+ assert_eq!(token_count("r#\"\"#r"), 1);
4254+ assert_eq!(token_count("'c'c"), 1);
4255+ assert_eq!(token_count("b'b'b"), 1);
4256+}
4257+
4258+#[test]
4259+fn literal_iter_negative() {
4260+ let negative_literal = Literal::i32_suffixed(-3);
4261+ let tokens = TokenStream::from(TokenTree::Literal(negative_literal));
4262+ let mut iter = tokens.into_iter();
4263+ match iter.next().unwrap() {
4264+ TokenTree::Punct(punct) => {
4265+ assert_eq!(punct.as_char(), '-');
4266+ assert_eq!(punct.spacing(), Spacing::Alone);
4267+ }
4268+ unexpected => panic!("unexpected token {:?}", unexpected),
4269+ }
4270+ match iter.next().unwrap() {
4271+ TokenTree::Literal(literal) => {
4272+ assert_eq!(literal.to_string(), "3i32");
4273+ }
4274+ unexpected => panic!("unexpected token {:?}", unexpected),
4275+ }
4276+ assert!(iter.next().is_none());
4277 }
4278
4279 #[test]
4280 fn roundtrip() {
4281 fn roundtrip(p: &str) {
4282 println!("parse: {}", p);
4283 let s = p.parse::<TokenStream>().unwrap().to_string();
4284 println!("first: {}", s);
4285@@ -161,46 +187,16 @@ fn fail() {
4286 fail("' static");
4287 fail("r#1");
4288 fail("r#_");
4289 }
4290
4291 #[cfg(span_locations)]
4292 #[test]
4293 fn span_test() {
4294- use proc_macro2::TokenTree;
4295-
4296- fn check_spans(p: &str, mut lines: &[(usize, usize, usize, usize)]) {
4297- let ts = p.parse::<TokenStream>().unwrap();
4298- check_spans_internal(ts, &mut lines);
4299- }
4300-
4301- fn check_spans_internal(ts: TokenStream, lines: &mut &[(usize, usize, usize, usize)]) {
4302- for i in ts {
4303- if let Some((&(sline, scol, eline, ecol), rest)) = lines.split_first() {
4304- *lines = rest;
4305-
4306- let start = i.span().start();
4307- assert_eq!(start.line, sline, "sline did not match for {}", i);
4308- assert_eq!(start.column, scol, "scol did not match for {}", i);
4309-
4310- let end = i.span().end();
4311- assert_eq!(end.line, eline, "eline did not match for {}", i);
4312- assert_eq!(end.column, ecol, "ecol did not match for {}", i);
4313-
4314- match i {
4315- TokenTree::Group(ref g) => {
4316- check_spans_internal(g.stream().clone(), lines);
4317- }
4318- _ => {}
4319- }
4320- }
4321- }
4322- }
4323-
4324 check_spans(
4325 "\
4326 /// This is a document comment
4327 testing 123
4328 {
4329 testing 234
4330 }",
4331 &[
4332@@ -269,59 +265,17 @@ fn span_join() {
4333 joined1.unwrap().source_file(),
4334 source1[0].span().source_file()
4335 );
4336 }
4337
4338 #[test]
4339 fn no_panic() {
4340 let s = str::from_utf8(b"b\'\xc2\x86 \x00\x00\x00^\"").unwrap();
4341- assert!(s.parse::<proc_macro2::TokenStream>().is_err());
4342-}
4343-
4344-#[test]
4345-fn tricky_doc_comment() {
4346- let stream = "/**/".parse::<proc_macro2::TokenStream>().unwrap();
4347- let tokens = stream.into_iter().collect::<Vec<_>>();
4348- assert!(tokens.is_empty(), "not empty -- {:?}", tokens);
4349-
4350- let stream = "/// doc".parse::<proc_macro2::TokenStream>().unwrap();
4351- let tokens = stream.into_iter().collect::<Vec<_>>();
4352- assert!(tokens.len() == 2, "not length 2 -- {:?}", tokens);
4353- match tokens[0] {
4354- proc_macro2::TokenTree::Punct(ref tt) => assert_eq!(tt.as_char(), '#'),
4355- _ => panic!("wrong token {:?}", tokens[0]),
4356- }
4357- let mut tokens = match tokens[1] {
4358- proc_macro2::TokenTree::Group(ref tt) => {
4359- assert_eq!(tt.delimiter(), proc_macro2::Delimiter::Bracket);
4360- tt.stream().into_iter()
4361- }
4362- _ => panic!("wrong token {:?}", tokens[0]),
4363- };
4364-
4365- match tokens.next().unwrap() {
4366- proc_macro2::TokenTree::Ident(ref tt) => assert_eq!(tt.to_string(), "doc"),
4367- t => panic!("wrong token {:?}", t),
4368- }
4369- match tokens.next().unwrap() {
4370- proc_macro2::TokenTree::Punct(ref tt) => assert_eq!(tt.as_char(), '='),
4371- t => panic!("wrong token {:?}", t),
4372- }
4373- match tokens.next().unwrap() {
4374- proc_macro2::TokenTree::Literal(ref tt) => {
4375- assert_eq!(tt.to_string(), "\" doc\"");
4376- }
4377- t => panic!("wrong token {:?}", t),
4378- }
4379- assert!(tokens.next().is_none());
4380-
4381- let stream = "//! doc".parse::<proc_macro2::TokenStream>().unwrap();
4382- let tokens = stream.into_iter().collect::<Vec<_>>();
4383- assert!(tokens.len() == 3, "not length 3 -- {:?}", tokens);
4384+ assert!(s.parse::<TokenStream>().is_err());
4385 }
4386
4387 #[test]
4388 fn op_before_comment() {
4389 let mut tts = TokenStream::from_str("~// comment").unwrap().into_iter();
4390 match tts.next().unwrap() {
4391 TokenTree::Punct(tt) => {
4392 assert_eq!(tt.as_char(), '~');
4393@@ -340,30 +294,30 @@ fn raw_identifier() {
4394 }
4395 assert!(tts.next().is_none());
4396 }
4397
4398 #[test]
4399 fn test_debug_ident() {
4400 let ident = Ident::new("proc_macro", Span::call_site());
4401
4402- #[cfg(not(procmacro2_semver_exempt))]
4403+ #[cfg(not(span_locations))]
4404 let expected = "Ident(proc_macro)";
4405
4406- #[cfg(procmacro2_semver_exempt)]
4407- let expected = "Ident { sym: proc_macro, span: bytes(0..0) }";
4408+ #[cfg(span_locations)]
4409+ let expected = "Ident { sym: proc_macro }";
4410
4411 assert_eq!(expected, format!("{:?}", ident));
4412 }
4413
4414 #[test]
4415 fn test_debug_tokenstream() {
4416 let tts = TokenStream::from_str("[a + 1]").unwrap();
4417
4418- #[cfg(not(procmacro2_semver_exempt))]
4419+ #[cfg(not(span_locations))]
4420 let expected = "\
4421 TokenStream [
4422 Group {
4423 delimiter: Bracket,
4424 stream: TokenStream [
4425 Ident {
4426 sym: a,
4427 },
4428@@ -374,17 +328,17 @@ TokenStream [
4429 Literal {
4430 lit: 1,
4431 },
4432 ],
4433 },
4434 ]\
4435 ";
4436
4437- #[cfg(not(procmacro2_semver_exempt))]
4438+ #[cfg(not(span_locations))]
4439 let expected_before_trailing_commas = "\
4440 TokenStream [
4441 Group {
4442 delimiter: Bracket,
4443 stream: TokenStream [
4444 Ident {
4445 sym: a
4446 },
4447@@ -395,17 +349,17 @@ TokenStream [
4448 Literal {
4449 lit: 1
4450 }
4451 ]
4452 }
4453 ]\
4454 ";
4455
4456- #[cfg(procmacro2_semver_exempt)]
4457+ #[cfg(span_locations)]
4458 let expected = "\
4459 TokenStream [
4460 Group {
4461 delimiter: Bracket,
4462 stream: TokenStream [
4463 Ident {
4464 sym: a,
4465 span: bytes(2..3),
4466@@ -420,17 +374,17 @@ TokenStream [
4467 span: bytes(6..7),
4468 },
4469 ],
4470 span: bytes(1..8),
4471 },
4472 ]\
4473 ";
4474
4475- #[cfg(procmacro2_semver_exempt)]
4476+ #[cfg(span_locations)]
4477 let expected_before_trailing_commas = "\
4478 TokenStream [
4479 Group {
4480 delimiter: Bracket,
4481 stream: TokenStream [
4482 Ident {
4483 sym: a,
4484 span: bytes(2..3)
4485@@ -459,8 +413,85 @@ TokenStream [
4486 }
4487
4488 #[test]
4489 fn default_tokenstream_is_empty() {
4490 let default_token_stream: TokenStream = Default::default();
4491
4492 assert!(default_token_stream.is_empty());
4493 }
4494+
4495+#[test]
4496+fn tuple_indexing() {
4497+ // This behavior may change depending on https://github.com/rust-lang/rust/pull/71322
4498+ let mut tokens = "tuple.0.0".parse::<TokenStream>().unwrap().into_iter();
4499+ assert_eq!("tuple", tokens.next().unwrap().to_string());
4500+ assert_eq!(".", tokens.next().unwrap().to_string());
4501+ assert_eq!("0.0", tokens.next().unwrap().to_string());
4502+ assert!(tokens.next().is_none());
4503+}
4504+
4505+#[cfg(span_locations)]
4506+#[test]
4507+fn non_ascii_tokens() {
4508+ check_spans("// abc", &[]);
4509+ check_spans("// ábc", &[]);
4510+ check_spans("// abc x", &[]);
4511+ check_spans("// ábc x", &[]);
4512+ check_spans("/* abc */ x", &[(1, 10, 1, 11)]);
4513+ check_spans("/* ábc */ x", &[(1, 10, 1, 11)]);
4514+ check_spans("/* ab\nc */ x", &[(2, 5, 2, 6)]);
4515+ check_spans("/* áb\nc */ x", &[(2, 5, 2, 6)]);
4516+ check_spans("/*** abc */ x", &[(1, 12, 1, 13)]);
4517+ check_spans("/*** ábc */ x", &[(1, 12, 1, 13)]);
4518+ check_spans(r#""abc""#, &[(1, 0, 1, 5)]);
4519+ check_spans(r#""ábc""#, &[(1, 0, 1, 5)]);
4520+ check_spans(r###"r#"abc"#"###, &[(1, 0, 1, 8)]);
4521+ check_spans(r###"r#"ábc"#"###, &[(1, 0, 1, 8)]);
4522+ check_spans("r#\"a\nc\"#", &[(1, 0, 2, 3)]);
4523+ check_spans("r#\"á\nc\"#", &[(1, 0, 2, 3)]);
4524+ check_spans("'a'", &[(1, 0, 1, 3)]);
4525+ check_spans("'á'", &[(1, 0, 1, 3)]);
4526+ check_spans("//! abc", &[(1, 0, 1, 7), (1, 0, 1, 7), (1, 0, 1, 7)]);
4527+ check_spans("//! ábc", &[(1, 0, 1, 7), (1, 0, 1, 7), (1, 0, 1, 7)]);
4528+ check_spans("//! abc\n", &[(1, 0, 1, 7), (1, 0, 1, 7), (1, 0, 1, 7)]);
4529+ check_spans("//! ábc\n", &[(1, 0, 1, 7), (1, 0, 1, 7), (1, 0, 1, 7)]);
4530+ check_spans("/*! abc */", &[(1, 0, 1, 10), (1, 0, 1, 10), (1, 0, 1, 10)]);
4531+ check_spans("/*! ábc */", &[(1, 0, 1, 10), (1, 0, 1, 10), (1, 0, 1, 10)]);
4532+ check_spans("/*! a\nc */", &[(1, 0, 2, 4), (1, 0, 2, 4), (1, 0, 2, 4)]);
4533+ check_spans("/*! á\nc */", &[(1, 0, 2, 4), (1, 0, 2, 4), (1, 0, 2, 4)]);
4534+ check_spans("abc", &[(1, 0, 1, 3)]);
4535+ check_spans("ábc", &[(1, 0, 1, 3)]);
4536+ check_spans("ábć", &[(1, 0, 1, 3)]);
4537+ check_spans("abc// foo", &[(1, 0, 1, 3)]);
4538+ check_spans("ábc// foo", &[(1, 0, 1, 3)]);
4539+ check_spans("ábć// foo", &[(1, 0, 1, 3)]);
4540+ check_spans("b\"a\\\n c\"", &[(1, 0, 2, 3)]);
4541+ check_spans("b\"a\\\n\u{00a0}c\"", &[(1, 0, 2, 3)]);
4542+}
4543+
4544+#[cfg(span_locations)]
4545+fn check_spans(p: &str, mut lines: &[(usize, usize, usize, usize)]) {
4546+ let ts = p.parse::<TokenStream>().unwrap();
4547+ check_spans_internal(ts, &mut lines);
4548+ assert!(lines.is_empty(), "leftover ranges: {:?}", lines);
4549+}
4550+
4551+#[cfg(span_locations)]
4552+fn check_spans_internal(ts: TokenStream, lines: &mut &[(usize, usize, usize, usize)]) {
4553+ for i in ts {
4554+ if let Some((&(sline, scol, eline, ecol), rest)) = lines.split_first() {
4555+ *lines = rest;
4556+
4557+ let start = i.span().start();
4558+ assert_eq!(start.line, sline, "sline did not match for {}", i);
4559+ assert_eq!(start.column, scol, "scol did not match for {}", i);
4560+
4561+ let end = i.span().end();
4562+ assert_eq!(end.line, eline, "eline did not match for {}", i);
4563+ assert_eq!(end.column, ecol, "ecol did not match for {}", i);
4564+
4565+ if let TokenTree::Group(g) = i {
4566+ check_spans_internal(g.stream().clone(), lines);
4567+ }
4568+ }
4569+ }
4570+}
4571diff --git a/third_party/rust/proc-macro2/tests/test_fmt.rs b/third_party/rust/proc-macro2/tests/test_fmt.rs
4572new file mode 100644
4573--- /dev/null
4574+++ b/third_party/rust/proc-macro2/tests/test_fmt.rs
4575@@ -0,0 +1,26 @@
4576+use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
4577+use std::iter::{self, FromIterator};
4578+
4579+#[test]
4580+fn test_fmt_group() {
4581+ let ident = Ident::new("x", Span::call_site());
4582+ let inner = TokenStream::from_iter(iter::once(TokenTree::Ident(ident)));
4583+ let parens_empty = Group::new(Delimiter::Parenthesis, TokenStream::new());
4584+ let parens_nonempty = Group::new(Delimiter::Parenthesis, inner.clone());
4585+ let brackets_empty = Group::new(Delimiter::Bracket, TokenStream::new());
4586+ let brackets_nonempty = Group::new(Delimiter::Bracket, inner.clone());
4587+ let braces_empty = Group::new(Delimiter::Brace, TokenStream::new());
4588+ let braces_nonempty = Group::new(Delimiter::Brace, inner.clone());
4589+ let none_empty = Group::new(Delimiter::None, TokenStream::new());
4590+ let none_nonempty = Group::new(Delimiter::None, inner.clone());
4591+
4592+ // Matches libproc_macro.
4593+ assert_eq!("()", parens_empty.to_string());
4594+ assert_eq!("(x)", parens_nonempty.to_string());
4595+ assert_eq!("[]", brackets_empty.to_string());
4596+ assert_eq!("[x]", brackets_nonempty.to_string());
4597+ assert_eq!("{ }", braces_empty.to_string());
4598+ assert_eq!("{ x }", braces_nonempty.to_string());
4599+ assert_eq!("", none_empty.to_string());
4600+ assert_eq!("x", none_nonempty.to_string());
4601+}
4602diff --git a/third_party/rust/syn/.cargo-checksum.json b/third_party/rust/syn/.cargo-checksum.json
4603--- a/third_party/rust/syn/.cargo-checksum.json
4604+++ b/third_party/rust/syn/.cargo-checksum.json
4605@@ -1,1 +1,1 @@
4606-{"files":{"Cargo.toml":"484d29864d333a361652fa4e24e1dcfab9efa47705ffd8c106d802eb03b78da7","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"ca605417b6db8c995458f8407afaad6c177aedcc2274004283600f5638fa1b0c","benches/file.rs":"b45211cc4a0296a77aac2b4de16dbc6b5cb66adfb5afac00a77bccea87f43968","benches/rust.rs":"9cc0f62e944f1583d05c43a395a1556731501cf5976ef67a081f4f6387f883ba","build.rs":"7423ab199728d55c7d64c44b7c6729cfd93bd8273366a77707353003e27565d7","src/attr.rs":"cf81add298f0e75c35a9980a59bc3c2fd3fe933635830d1591374eeb2487c225","src/await.rs":"18f0b2ecb319991f891e300011424985e3cf33d166ea9f29f22d575fc8c83a76","src/bigint.rs":"efc7f64959980653d73fe4f8bc2a3a2904dc05f45b02c6dc15cd316fa3d7c338","src/buffer.rs":"2a432c11a3da67a21d46c2272bf9ce60a0bb20893b5750027bbd8ca3e843ab35","src/custom_keyword.rs":"589e46ec1be9a04d6de12c0b8cadf87cc1c05606ed46ddea62e9869cbca4a191","src/custom_punctuation.rs":"2ba2e294e15a0fce7ede3686c42b2891797079a724dd1193b66e7d305624c891","src/data.rs":"cc9b250d084e444782d3ff5e63c1ba387cbde8f7f2e977eab9846d920b4b8c3f","src/derive.rs":"c18878f14be5d5ab11fd7dda2d2ff1ff75c9662daf11eed033de62e4d0670a89","src/discouraged.rs":"50e10915695c4d14f64a78e20ecbef90a2cd53a7c26ee3426a2524a8ee5c9cbf","src/error.rs":"2c17a402f83ed5ae4ad96e753216771bef620235c2ff1ccc23f4bbafc7266fe1","src/export.rs":"dcae67456278c0339acfbcbb4737b8d37cfba5a150ae789f31f4be79abf7e726","src/expr.rs":"871d8eeb43cef02ef88de3bea7477b79b4eabc096a0899dde0e5750edf482f49","src/ext.rs":"b97ed549490b9248b5b5df31b3d5b08ba8791e23e6c5d3a1157a0363eb683ff3","src/file.rs":"3cc2bf5c709238d515a557f721f231c8c725b196400de051f945b549299d38a7","src/gen/fold.rs":"10b3ae33d0ce410d6bbe8b93be9d5f9e856c7dc8212133cc46b703f97d548190","src/gen/visit.rs":"e0f5798552d186024696b7bfc7219d4ff53b0e45f735a83e77cbb6b6578c5fa4","src/gen/visit_mut.rs":"9f7dda83907969971dba84d545aaa563b0728e54db97ffab5050fdf43a79c731","src/gen_helper.rs":"ea6c66388365971db6a2fc86cbb208f7eacde77e245bc8623f27a3642a3d7741","src/generics.rs":"d845d7a828863123a5187fd0fe59c9dae3636f63bad302bd035792eed3dcb1ba","src/group.rs":"119b62d8481b4b1c327639bed40e114bf1969765250b68186628247fd4144b3b","src/ident.rs":"503156ce51a7ef0420892e8dbf2ecf8fe51f42a84d52cc2c05654e1a83020cbf","src/item.rs":"213f2f58c65ee1aa222f111bc9b1be681f8fb069caed04ca56586839979318d0","src/keyword.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","src/lib.rs":"24778e9f15e8025e75aca114c712716ada586b471adb3b3b69278f4d39b8a21b","src/lifetime.rs":"905359708f772ec858954badde69ee016d29e6eeba1dd205b268445b1aff6f3a","src/lit.rs":"5bb0bddb94cbd256e50e92dc091a0baa09f1be40a77058b897507f3b17191e5d","src/lookahead.rs":"5cce8b4cb345a85c24a452ea6d78eadb76f01ca0a789cbf5ce35108334904173","src/mac.rs":"6b468244cc07e3f2f10419f833d9e2ed23edbcd6dc34cf21c5947633699db964","src/macros.rs":"0d8c3bab47539aa2d00bec64e92c901ea2c9c0af74c868051c0905b82650f970","src/op.rs":"93cd44770bb110deadf807a01d9a666efe644b6e3010f4b51cae77ee7438cfbb","src/parse.rs":"5017123c249ebc65866af113a0ad671814b9873f47568180e6539a305eb0317d","src/parse_macro_input.rs":"f799aadb7216c2d333b579f48ed2fedfe07b5e96f004b25b569649ffbaa958d2","src/parse_quote.rs":"81575bf60b18b0d8624d7025a5bcc8dcd6633ad70c454dee2a06e4c391700b6c","src/pat.rs":"db0f2263b9813de1f4e3e3e0396fe0080b1e11c8090c6b4fb6fca3cfbe22bc96","src/path.rs":"32e685ac7fd2d4b9989802de8f326a8d47fa710f86ec3e45fd9d3ff8fdfe97ef","src/print.rs":"da6529c1d9d21aaf6c835f66b4e67eacb7cf91a10eb5e9a2143b49bf99b3b5e1","src/punctuated.rs":"384e7b317b26f24118eb4b0c39e949ee9f4f3e700a4c80e462342c83b2cc3282","src/sealed.rs":"896a495a5340eec898527f18bd4ddca408ea03ea0ee3af30074ff48deace778d","src/span.rs":"748c51c6feb223c26d3b1701f5bb98aee823666c775c98106cfa24fe29d8cec1","src/spanned.rs":"adddb6acae14a0fa340df302b932c31e34b259706ce56fd82ab597ec424500e1","src/stmt.rs":"fbccf2b4da7980fe6ea8d99457d291577c0f225b370c1dd97da41abf2a18fcf7","src/thread.rs":"815eca6bd64f4eef7c447f0809e84108f5428ff50225224b373efd8fbb696874","src/token.rs":"761d8d1793560eb2b631c36ddfdbb14ac65178405f095453aa0e75e8816bdbb9","src/tt.rs":"1e32ae216d14d895ff621bf32bc611f138aa00108b0090be2cbaa0affebe8e2a","src/ty.rs":"ce052e0079b65b66bea4e9502d2ff2c90ad4b867904bf7eb892eb60aa3ef219a","tests/clone.sh":"961243d42540d9992090efbbd5478b7aa395671db64a6c28cdadb6edc610ebdf","tests/common/eq.rs":"a42d339808fd32dd4bfd440c254add8c56d5e2cde3a6bf0c88621b618ce5eaa7","tests/common/mod.rs":"20a3300016351fa210a193fbb0db059ef5125fa7909585ded64790004d4977ed","tests/common/parse.rs":"17ba6d1e74aaa3f8096c6d379d803221f12d95cca69927be047d6ddf8367647f","tests/debug/gen.rs":"57bd5cf585e0b86ad00f29f09ff3db3390c4a756d503514a9b28407500dcea3c","tests/debug/mod.rs":"462d6fe34ee75c3ca1207d4db2ff3bdee5b430b9f9ca632e5671d1588d3f76b3","tests/features/error.rs":"e0581a2869cbd237c2bc18a0a85272296e1577bb5f7317a67fa85e28e04eea6f","tests/features/mod.rs":"66a2605ec54ede29208da350f2bed536dfa763b58408d64d3fca3b13de64b64f","tests/macros/mod.rs":"3f2d758c0ba76b93f54b0c1fc22ad50edff8ef42629ba4d47ac7d7f823da8359","tests/repo/mod.rs":"e851a68972c9194a9a8d7b68538b16ed79ae81cba55e1a2ce210d1b759fb1a21","tests/test_asyncness.rs":"b6c46118b036e6807d24eb0e1779244b4fca23dac0d8031e9843b3edec484ce8","tests/test_attribute.rs":"2d8f18a98c989d3f7adaaeb1aeebd4f8413365ace63feecb37cb3f9db9db4d8f","tests/test_derive_input.rs":"477d80f914c54b526f8ff229788dc0e7798d118f6dcfa348f4c99755edb347b9","tests/test_expr.rs":"f35ca80566849a36e6ba6403d9663519eff37e4224360c468fedff8b561a643e","tests/test_generics.rs":"83a5dc07f5c5701c12625399262f7120b66f01a742523f3eda28da2cf2c87eb3","tests/test_grouping.rs":"aadd75215addd9e5a8fa2f9472117d4cb80f1e8b84e07f4c0845675c9014164f","tests/test_ident.rs":"236c239dd66f543f084f44ff747d7bc3962cf11a019a279777fe972f6e17aa4c","tests/test_iterators.rs":"718938da14778dcba06324d36a99d9317c9d45d81a34c6a44c47e1fa38085e9f","tests/test_lit.rs":"7dff2661a5ac586d6ed2fe27501cb8ff62f4cf3f6c91f596bff6057c67ad7857","tests/test_meta.rs":"8444dee084882243b107dfc8a6aac27f9382f9774162d1ac8ed8ec30d60c048e","tests/test_parse_buffer.rs":"b244bb4bc41ff06d21f239e60a3d663fdec5aa4af33f2a354afef36d34f0aefc","tests/test_pat.rs":"41776b878efae9b8e340f21ffe6296e921cf309f618482efd98609c33e32c28b","tests/test_precedence.rs":"71f3ea52cda8b40166bb7416fb98774e6a653542497b521f8e183e283dcf579d","tests/test_round_trip.rs":"e0de37f45fa223b488d25a41beab185eb92abb7bf765a9f13fe5d870ff31f5f1","tests/test_should_parse.rs":"4da4e25ee2baa7e75135c375042a7f958de136c5698dab03f99ff7a774dcd463","tests/test_size.rs":"970150b9d49ef91ab4c8f8c6a59b83f9a68a02acb779f0280733a5efaec6487a","tests/test_token_trees.rs":"a07ea657bf03b9c667c821b2db2af49b176ca737e3e01217a73cca78b7f11380","tests/zzz_stable.rs":"961d4940a926db4ca523d834b060c62de988e6a8e01c9f5efaa7bb4c86745b47"},"package":"66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf"}
4607\ No newline at end of file
4608+{"files":{"Cargo.toml":"28ddb678a5ccac4423435384c8b7116f804e896eabc5aae9d5c2bc666aaebbb4","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"03f3b53cf858536a0883aa5b5882ee61dcd0f1e71c0930c9106fcfa1d6aad2df","benches/file.rs":"b4724fc7c0f48b8f488e2632a1064f6c0bf16ded3969680fc3f4a2369536269b","benches/rust.rs":"ea6291ef2d2a83d94a3312fe179d48259f8ec0b04c961993ddd181d0a4ab740e","build.rs":"aeca2312f05aec658eaa66980a0ef3d578837db107a55702b39419ea0422eb4a","src/attr.rs":"7d79482634d6544eb4a4825405407b53660d0f5f8b929f7e1671e005b9d92038","src/await.rs":"18f0b2ecb319991f891e300011424985e3cf33d166ea9f29f22d575fc8c83a76","src/bigint.rs":"efc7f64959980653d73fe4f8bc2a3a2904dc05f45b02c6dc15cd316fa3d7c338","src/buffer.rs":"cf2a4b3bdc247b80c85ff5625a1dfb7a5f517fd835f6e1518a7b924990e4c293","src/custom_keyword.rs":"9627467063e41776315a6a14b2aaea3875592d8e0ebd2dc6df1fc2f12c06f146","src/custom_punctuation.rs":"b00e7bee96eb473507527e39db65e74e71592dc06421d2cfe45ed899c17d4847","src/data.rs":"7aec9a745cd53ec95688afa353f6efb9576e7fc0143757b51d28bc3d900b1d2a","src/derive.rs":"fa71866df6e383673dd3329f455a9f953585b83f9739050be3bf1f8c6d526b96","src/discouraged.rs":"a1f3d85e20dedf50b1b7b4571d970a3a6e9b2de4afde7dd0c986fe240df2ba46","src/error.rs":"c3005b50e3132026250c5356d0d391bf96db8087f0f5f744de98e360d8a20a3e","src/export.rs":"dcae67456278c0339acfbcbb4737b8d37cfba5a150ae789f31f4be79abf7e726","src/expr.rs":"54455fd20041996653ca5379b03cdf3c2fc1b3dd2e1149b5bc6b1dd492545d55","src/ext.rs":"870086d9021e6a6fcefa2f00cd91b55c4b74dcee8f0f6a07e76d96fb44707d61","src/file.rs":"75167ebc77e7870122078eabde1b872c337142d4b0962c20cedffcaaa2a5b7c6","src/gen/clone.rs":"0845c1bf8624c3f235cd247b4eb748e7e16b4c240097cb0ff16751f688c079ae","src/gen/debug.rs":"d24fe37f4ce1dd74f2dc54136e893782d3c4d0908323c036c97599551a56960c","src/gen/eq.rs":"1e6ef09b17ca7f36861ef23ce2a6991b231ed5f087f046469b5f23da40f5b419","src/gen/fold.rs":"3f59e59ed8ad2ab5dd347bfbe41bbc785c2aabd8ae902087a584a6daed597182","src/gen/hash.rs":"e5b2a52587173076777233a9e57e2b3c8e0dd6d6f41d16fa7c9fde68b05c2bfc","src/gen/visit.rs":"23008c170d4dd3975232876a0a654921d9b6af57372cb9fcc133ca740588d666","src/gen/visit_mut.rs":"42886c3ee02ded72d9c3eec006e20431eaee0c6b90ddefc1a36ec7bf50c6a24a","src/gen_helper.rs":"ea6c66388365971db6a2fc86cbb208f7eacde77e245bc8623f27a3642a3d7741","src/generics.rs":"d1c175284ca21e777ef0414c28383929b170ccb00aaf7a929eb18d3b05e18da8","src/group.rs":"119b62d8481b4b1c327639bed40e114bf1969765250b68186628247fd4144b3b","src/ident.rs":"503156ce51a7ef0420892e8dbf2ecf8fe51f42a84d52cc2c05654e1a83020cbf","src/item.rs":"c9ad9881e8cda8ee3f157f0c7602fc53d08a7e3288b9afc388c393689eac5aea","src/lib.rs":"558ad13779233b27bebc4b2fc8025eb1c7e57b32130dc1dd911391e27b427500","src/lifetime.rs":"f390fe06692fc51fbf3eb490bb9f795da70e4452f51c5b0df3bbaa899084ddf1","src/lit.rs":"9fab84e38756b092fbb055dcdf01e31d42d916c49e3eaae8c9019043b0ee4301","src/lookahead.rs":"5cce8b4cb345a85c24a452ea6d78eadb76f01ca0a789cbf5ce35108334904173","src/mac.rs":"e5cecea397fd01a44958162781d8d94343fe2a1b9b9754a5666c3d2ab4d7ef64","src/macros.rs":"2ce05b553f14da4ee550bb681cb0733b7186ad94719cd36f96d53e15fd02cf2b","src/op.rs":"449514e146deab0ab020bc6f764544c294dbc780941c9802bf60cf1b2839d550","src/parse.rs":"bde888c98ee259f2a73489a693515ed4875432b0d79486ac83aea19f441992a3","src/parse_macro_input.rs":"653a020f023cac0eccbc1fcc34aa7bf80567b43e5475deab4ad3e487a5363201","src/parse_quote.rs":"642f21e5fa54df4b7c373fb158289ee1005d49e1a49b1d194df5438faee71c46","src/pat.rs":"1473b258162cc822f1ee0c0869f521053ed345a140c39ed83b9b4dfb6f9f2aca","src/path.rs":"f119f0c2af12fabd360eac9a2312e0f6e6c28c633c9671bde6ef0bece7c5ba3c","src/print.rs":"da6529c1d9d21aaf6c835f66b4e67eacb7cf91a10eb5e9a2143b49bf99b3b5e1","src/punctuated.rs":"212f5a601d6c2eb8b8fa679be1167b455b595bee964d2775b0101ebb16c3eaa5","src/reserved.rs":"3625eb2a64589a4992ab79a1674e9679f465bea613ab139a671df5337e88cee6","src/sealed.rs":"896a495a5340eec898527f18bd4ddca408ea03ea0ee3af30074ff48deace778d","src/span.rs":"748c51c6feb223c26d3b1701f5bb98aee823666c775c98106cfa24fe29d8cec1","src/spanned.rs":"7d77714d585e6f42397091ffb3a799fd7b20c05c5442c737683c429ea7d409a5","src/stmt.rs":"3917fbc897f80efe838267833c55650ff8d636cb49a6d1084e28eff65d0e3ccd","src/thread.rs":"815eca6bd64f4eef7c447f0809e84108f5428ff50225224b373efd8fbb696874","src/token.rs":"a1ca6298bf6592cb80cbab1db4eac2fa4e3fa56729bb807bfb0f08ab0f229ca5","src/tt.rs":"1cc9e200624288322f800f32e3d6e2e53da946467bb312dd40a52c02cdcc4730","src/ty.rs":"cb167cbb16240c59a31b44adec175172caaf75ffef9a0bb168584b51bf105795","src/verbatim.rs":"802a97df997432f18cac6e6200ff6ea29fb2474986005e0fcdbc2b65197f87f7","src/whitespace.rs":"e63dd0aa3d34029f17766a8b09c1a6e4479e36c552c8b7023d710a399333aace","tests/.gitignore":"22e782449a3c216db3f7215d5fb8882e316768e40beeec3833aae419ad8941db","tests/common/eq.rs":"4b190a3833bdfd20a4cb1e3dff25a698751dec71d6f30249cf09426e061a4fb1","tests/common/mod.rs":"25ef6d7daa09bad3198a0e9e91b2812425f92db7c585c1e34a03a84d7362ccd8","tests/common/parse.rs":"8b7ba32f4988c30758c108536c4877dc5a039a237bf9b0687220ef2295797bbd","tests/debug/gen.rs":"d6e2abf2a7bb58a7895a60c2f094a98a4f85c9189d02011d0dcef6ef053f26e3","tests/debug/mod.rs":"868763d0ef1609a3ad5e05e9f1bfa0f813e91e7e9a36653414a188bb2fdaa425","tests/macros/mod.rs":"c0eafa4e3845fc08f6efe6021bac37822c0ac325eb7b51194a5f35236f648d92","tests/repo/mod.rs":"9e316b88d57ae213e81950c35e45443078ec90e702798353bc3528cb8a2810b6","tests/repo/progress.rs":"c08d0314a7f3ecf760d471f27da3cd2a500aeb9f1c8331bffb2aa648f9fabf3f","tests/test_asyncness.rs":"cff01db49d28ab23b0b258bc6c0a5cc4071be4fe7248eef344a5d79d2fb649b7","tests/test_attribute.rs":"0ffd99384e1a52ae17d9fed5c4053e411e8f9018decef07ffa621d1faa7329d8","tests/test_derive_input.rs":"610444351e3bf99366976bbf1da109c334a70ac9500caef366bcf9b68819829f","tests/test_expr.rs":"0ee83f6f6de950018c043efcc3e85776b4227dae3068309998a8d9709f2fc66c","tests/test_generics.rs":"9d713f90a79d6145efc89fb6f946029ca03486c632219950889da39940152ba0","tests/test_grouping.rs":"46c27baec4daaaf1e891892f0b0515ea8a44619071c7d0cc9192580916f1569f","tests/test_ident.rs":"9eb53d1e21edf23e7c9e14dc74dcc2b2538e9221e19dbcc0a44e3acc2e90f3f6","tests/test_item.rs":"461ed0c8648afffcea3217f52c9a88298182b4d39d73a11803b1281d99c98c25","tests/test_iterators.rs":"53ed6078d37550bd6765d2411e3660be401aef8a31a407350cc064a7d08c7c33","tests/test_lit.rs":"2a46c5f2f2ad1dcbb7e9b0cd11b55861c5ff818c2c4c51351d07e2daa7c74674","tests/test_meta.rs":"1fc98af3279cadc3d8db3c7e8d4d7f9e9dbd4d17548cf6a2f6f4536ed65367f6","tests/test_parse_buffer.rs":"8bbe2d24ca8a3788f72c6908fc96c26d546f11c69687bf8d72727f851d5e2d27","tests/test_parse_stream.rs":"2f449a2c41a3dee6fd14bee24e1666a453cb808eda17332fd91afd127fcdd2a6","tests/test_pat.rs":"2cb331fe404496d51e7cc7e283ae13c519a2265ca82e1c88e113296f860c2cba","tests/test_path.rs":"fcd5591e639fc787acc9763d828a811c8114525c9341282eefda8f331e082a51","tests/test_precedence.rs":"8d03656741b01e577d7501ce24332d1a4febec3e31a043e47c61062b8c527ed2","tests/test_receiver.rs":"084eca59984b9a18651da52f2c4407355da3de1335916a12477652999e2d01cc","tests/test_round_trip.rs":"ba01bf4ec04cd2d6f9e4800c343563925ae960c5f16752dc0797fda4451b6cc2","tests/test_shebang.rs":"f5772cadad5b56e3112cb16308b779f92bce1c3a48091fc9933deb2276a69331","tests/test_should_parse.rs":"1d3535698a446e2755bfc360676bdb161841a1f454cdef6e7556c6d06a95c89d","tests/test_size.rs":"5fae772bab66809d6708232f35cfb4a287882486763b0f763feec2ad79fbb68b","tests/test_stmt.rs":"17e4355843ee2982b51faba2721a18966f8c2b9422e16b052a123b8ee8b80752","tests/test_token_trees.rs":"43e56a701817e3c3bfd0cae54a457dd7a38ccb3ca19da41e2b995fdf20e6ed18","tests/test_ty.rs":"5b7c0bfc4963d41920dd0b39fdea419e34f00409ba86ad4211d6c3c7e8bbe1c0","tests/test_visibility.rs":"3f958e2b3b5908005e756a80eea326a91eac97cc4ab60599bebde8d4b942d65c","tests/zzz_stable.rs":"2a862e59cb446235ed99aec0e6ada8e16d3ecc30229b29d825b7c0bbc2602989"},"package":"963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350"}
4609\ No newline at end of file
4610diff --git a/third_party/rust/syn/Cargo.toml b/third_party/rust/syn/Cargo.toml
4611--- a/third_party/rust/syn/Cargo.toml
4612+++ b/third_party/rust/syn/Cargo.toml
4613@@ -8,79 +8,90 @@
4614 # If you believe there's an error in this file please file an
4615 # issue against the rust-lang/cargo repository. If you're
4616 # editing this file be aware that the upstream Cargo.toml
4617 # will likely look very different (and much more reasonable)
4618
4619 [package]
4620 edition = "2018"
4621 name = "syn"
4622-version = "1.0.5"
4623+version = "1.0.40"
4624 authors = ["David Tolnay <dtolnay@gmail.com>"]
4625 include = ["/benches/**", "/build.rs", "/Cargo.toml", "/LICENSE-APACHE", "/LICENSE-MIT", "/README.md", "/src/**", "/tests/**"]
4626 description = "Parser for Rust source code"
4627 documentation = "https://docs.rs/syn"
4628 readme = "README.md"
4629 categories = ["development-tools::procedural-macro-helpers"]
4630 license = "MIT OR Apache-2.0"
4631 repository = "https://github.com/dtolnay/syn"
4632 [package.metadata.docs.rs]
4633 all-features = true
4634+targets = ["x86_64-unknown-linux-gnu"]
4635
4636 [package.metadata.playground]
4637-all-features = true
4638-
4639-[lib]
4640-name = "syn"
4641+features = ["full", "visit", "visit-mut", "fold", "extra-traits"]
4642
4643 [[bench]]
4644 name = "rust"
4645 harness = false
4646 required-features = ["full", "parsing"]
4647-edition = "2018"
4648
4649 [[bench]]
4650 name = "file"
4651 required-features = ["full", "parsing"]
4652-edition = "2018"
4653 [dependencies.proc-macro2]
4654-version = "1.0"
4655+version = "1.0.13"
4656 default-features = false
4657
4658 [dependencies.quote]
4659 version = "1.0"
4660 optional = true
4661 default-features = false
4662
4663 [dependencies.unicode-xid]
4664 version = "0.2"
4665+[dev-dependencies.anyhow]
4666+version = "1.0"
4667+
4668+[dev-dependencies.flate2]
4669+version = "1.0"
4670+
4671 [dev-dependencies.insta]
4672-version = "0.9"
4673+version = "0.16"
4674
4675 [dev-dependencies.rayon]
4676 version = "1.0"
4677
4678 [dev-dependencies.ref-cast]
4679-version = "0.2"
4680+version = "1.0"
4681
4682 [dev-dependencies.regex]
4683 version = "1.0"
4684
4685+[dev-dependencies.reqwest]
4686+version = "0.10"
4687+features = ["blocking"]
4688+
4689+[dev-dependencies.syn-test-suite]
4690+version = "0"
4691+
4692+[dev-dependencies.tar]
4693+version = "0.4"
4694+
4695 [dev-dependencies.termcolor]
4696 version = "1.0"
4697
4698 [dev-dependencies.walkdir]
4699 version = "2.1"
4700
4701 [features]
4702 clone-impls = []
4703 default = ["derive", "parsing", "printing", "clone-impls", "proc-macro"]
4704 derive = []
4705 extra-traits = []
4706 fold = []
4707 full = []
4708 parsing = []
4709 printing = ["quote"]
4710 proc-macro = ["proc-macro2/proc-macro", "quote/proc-macro"]
4711+test = ["syn-test-suite/all-features"]
4712 visit = []
4713 visit-mut = []
4714-[badges.travis-ci]
4715-repository = "dtolnay/syn"
4716diff --git a/third_party/rust/syn/README.md b/third_party/rust/syn/README.md
4717--- a/third_party/rust/syn/README.md
4718+++ b/third_party/rust/syn/README.md
4719@@ -1,15 +1,15 @@
4720 Parser for Rust source code
4721 ===========================
4722
4723-[![Build Status](https://api.travis-ci.org/dtolnay/syn.svg?branch=master)](https://travis-ci.org/dtolnay/syn)
4724-[![Latest Version](https://img.shields.io/crates/v/syn.svg)](https://crates.io/crates/syn)
4725-[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/syn/1.0/syn/)
4726-[![Rustc Version 1.31+](https://img.shields.io/badge/rustc-1.31+-lightgray.svg)](https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html)
4727+[<img alt="github" src="https://img.shields.io/badge/github-dtolnay/syn-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/dtolnay/syn)
4728+[<img alt="crates.io" src="https://img.shields.io/crates/v/syn.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/syn)
4729+[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-syn-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20">](https://docs.rs/syn)
4730+[<img alt="build status" src="https://img.shields.io/github/workflow/status/dtolnay/syn/CI/master?style=for-the-badge" height="20">](https://github.com/dtolnay/syn/actions?query=branch%3Amaster)
4731
4732 Syn is a parsing library for parsing a stream of Rust tokens into a syntax tree
4733 of Rust source code.
4734
4735 Currently this library is geared toward use in Rust procedural macros, but
4736 contains some APIs that may be useful more generally.
4737
4738 - **Data structures** — Syn provides a complete syntax tree that can represent
4739@@ -41,20 +41,16 @@ contains some APIs that may be useful mo
4740
4741 [`syn::File`]: https://docs.rs/syn/1.0/syn/struct.File.html
4742 [`syn::Item`]: https://docs.rs/syn/1.0/syn/enum.Item.html
4743 [`syn::Expr`]: https://docs.rs/syn/1.0/syn/enum.Expr.html
4744 [`syn::Type`]: https://docs.rs/syn/1.0/syn/enum.Type.html
4745 [`syn::DeriveInput`]: https://docs.rs/syn/1.0/syn/struct.DeriveInput.html
4746 [parser functions]: https://docs.rs/syn/1.0/syn/parse/index.html
4747
4748-If you get stuck with anything involving procedural macros in Rust I am happy to
4749-provide help even if the issue is not related to Syn. Please file a ticket in
4750-this repo.
4751-
4752 *Version requirement: Syn supports rustc 1.31 and up.*
4753
4754 [*Release notes*](https://github.com/dtolnay/syn/releases)
4755
4756 <br>
4757
4758 ## Resources
4759
4760@@ -83,18 +79,16 @@ tokens back to the compiler to compile i
4761 syn = "1.0"
4762 quote = "1.0"
4763
4764 [lib]
4765 proc-macro = true
4766 ```
4767
4768 ```rust
4769-extern crate proc_macro;
4770-
4771 use proc_macro::TokenStream;
4772 use quote::quote;
4773 use syn::{parse_macro_input, DeriveInput};
4774
4775 #[proc_macro_derive(MyMacro)]
4776 pub fn my_macro(input: TokenStream) -> TokenStream {
4777 // Parse the input tokens into a syntax tree
4778 let input = parse_macro_input!(input as DeriveInput);
4779@@ -266,17 +260,17 @@ incompatible ecosystems for proc macros
4780
4781 In general all of your code should be written against proc-macro2 rather than
4782 proc-macro. The one exception is in the signatures of procedural macro entry
4783 points, which are required by the language to use `proc_macro::TokenStream`.
4784
4785 The proc-macro2 crate will automatically detect and use the compiler's data
4786 structures when a procedural macro is active.
4787
4788-[proc-macro2]: https://docs.rs/proc-macro2/1.0.0/proc_macro2/
4789+[proc-macro2]: https://docs.rs/proc-macro2/1.0/proc_macro2/
4790
4791 <br>
4792
4793 #### License
4794
4795 <sup>
4796 Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
4797 2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
4798diff --git a/third_party/rust/syn/benches/file.rs b/third_party/rust/syn/benches/file.rs
4799--- a/third_party/rust/syn/benches/file.rs
4800+++ b/third_party/rust/syn/benches/file.rs
4801@@ -1,14 +1,21 @@
4802 // $ cargo bench --features full --bench file
4803
4804 #![feature(rustc_private, test)]
4805+#![recursion_limit = "1024"]
4806
4807 extern crate test;
4808
4809+#[macro_use]
4810+#[path = "../tests/macros/mod.rs"]
4811+mod macros;
4812+
4813+#[path = "../tests/common/mod.rs"]
4814+mod common;
4815 #[path = "../tests/repo/mod.rs"]
4816 pub mod repo;
4817
4818 use proc_macro2::TokenStream;
4819 use std::fs;
4820 use std::str::FromStr;
4821 use test::Bencher;
4822
4823diff --git a/third_party/rust/syn/benches/rust.rs b/third_party/rust/syn/benches/rust.rs
4824--- a/third_party/rust/syn/benches/rust.rs
4825+++ b/third_party/rust/syn/benches/rust.rs
4826@@ -1,15 +1,22 @@
4827 // $ cargo bench --features full --bench rust
4828 //
4829 // Syn only, useful for profiling:
4830 // $ RUSTFLAGS='--cfg syn_only' cargo build --release --features full --bench rust
4831
4832 #![cfg_attr(not(syn_only), feature(rustc_private))]
4833+#![recursion_limit = "1024"]
4834
4835+#[macro_use]
4836+#[path = "../tests/macros/mod.rs"]
4837+mod macros;
4838+
4839+#[path = "../tests/common/mod.rs"]
4840+mod common;
4841 #[path = "../tests/repo/mod.rs"]
4842 mod repo;
4843
4844 use std::fs;
4845 use std::time::{Duration, Instant};
4846
4847 #[cfg(not(syn_only))]
4848 mod tokenstream_parse {
4849@@ -23,41 +30,45 @@ mod tokenstream_parse {
4850
4851 mod syn_parse {
4852 pub fn bench(content: &str) -> Result<(), ()> {
4853 syn::parse_file(content).map(drop).map_err(drop)
4854 }
4855 }
4856
4857 #[cfg(not(syn_only))]
4858-mod libsyntax_parse {
4859+mod librustc_parse {
4860 extern crate rustc_data_structures;
4861- extern crate syntax;
4862- extern crate syntax_pos;
4863+ extern crate rustc_errors;
4864+ extern crate rustc_parse;
4865+ extern crate rustc_session;
4866+ extern crate rustc_span;
4867
4868 use rustc_data_structures::sync::Lrc;
4869- use syntax::edition::Edition;
4870- use syntax::errors::{emitter::Emitter, DiagnosticBuilder, Handler};
4871- use syntax::parse::ParseSess;
4872- use syntax::source_map::{FilePathMapping, SourceMap};
4873- use syntax_pos::FileName;
4874+ use rustc_errors::{emitter::Emitter, Diagnostic, Handler};
4875+ use rustc_session::parse::ParseSess;
4876+ use rustc_span::source_map::{FilePathMapping, SourceMap};
4877+ use rustc_span::{edition::Edition, FileName};
4878
4879 pub fn bench(content: &str) -> Result<(), ()> {
4880 struct SilentEmitter;
4881
4882 impl Emitter for SilentEmitter {
4883- fn emit_diagnostic(&mut self, _db: &DiagnosticBuilder) {}
4884+ fn emit_diagnostic(&mut self, _diag: &Diagnostic) {}
4885+ fn source_map(&self) -> Option<&Lrc<SourceMap>> {
4886+ None
4887+ }
4888 }
4889
4890- syntax::with_globals(Edition::Edition2018, || {
4891+ rustc_span::with_session_globals(Edition::Edition2018, || {
4892 let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
4893 let emitter = Box::new(SilentEmitter);
4894 let handler = Handler::with_emitter(false, None, emitter);
4895 let sess = ParseSess::with_span_handler(handler, cm);
4896- if let Err(mut diagnostic) = syntax::parse::parse_crate_from_source_str(
4897+ if let Err(mut diagnostic) = rustc_parse::parse_crate_from_source_str(
4898 FileName::Custom("bench".to_owned()),
4899 content.to_owned(),
4900 &sess,
4901 ) {
4902 diagnostic.cancel();
4903 return Err(());
4904 };
4905 Ok(())
4906@@ -99,21 +110,21 @@ fn exec(mut codepath: impl FnMut(&str) -
4907 assert_eq!(success, total);
4908 begin.elapsed()
4909 }
4910
4911 fn main() {
4912 repo::clone_rust();
4913
4914 macro_rules! testcases {
4915- ($($(#[$cfg:meta])* $name:path,)*) => {
4916+ ($($(#[$cfg:meta])* $name:ident,)*) => {
4917 vec![
4918 $(
4919 $(#[$cfg])*
4920- (stringify!($name), $name as fn(&str) -> Result<(), ()>),
4921+ (stringify!($name), $name::bench as fn(&str) -> Result<(), ()>),
4922 )*
4923 ]
4924 };
4925 }
4926
4927 #[cfg(not(syn_only))]
4928 {
4929 let mut lines = 0;
4930@@ -123,22 +134,22 @@ fn main() {
4931 files += 1;
4932 Ok(())
4933 });
4934 eprintln!("\n{} lines in {} files", lines, files);
4935 }
4936
4937 for (name, f) in testcases!(
4938 #[cfg(not(syn_only))]
4939- read_from_disk::bench,
4940+ read_from_disk,
4941 #[cfg(not(syn_only))]
4942- tokenstream_parse::bench,
4943- syn_parse::bench,
4944+ tokenstream_parse,
4945+ syn_parse,
4946 #[cfg(not(syn_only))]
4947- libsyntax_parse::bench,
4948+ librustc_parse,
4949 ) {
4950 eprint!("{:20}", format!("{}:", name));
4951 let elapsed = exec(f);
4952 eprintln!(
4953 "elapsed={}.{:03}s",
4954 elapsed.as_secs(),
4955 elapsed.subsec_millis(),
4956 );
4957diff --git a/third_party/rust/syn/build.rs b/third_party/rust/syn/build.rs
4958--- a/third_party/rust/syn/build.rs
4959+++ b/third_party/rust/syn/build.rs
4960@@ -1,11 +1,11 @@
4961 use std::env;
4962 use std::process::Command;
4963-use std::str::{self, FromStr};
4964+use std::str;
4965
4966 // The rustc-cfg strings below are *not* public API. Please let us know by
4967 // opening a GitHub issue if your build environment requires some way to enable
4968 // these cfgs other than by executing our build script.
4969 fn main() {
4970 let compiler = match rustc_version() {
4971 Some(compiler) => compiler,
4972 None => return,
4973@@ -21,43 +21,19 @@ fn main() {
4974 }
4975
4976 struct Compiler {
4977 minor: u32,
4978 nightly: bool,
4979 }
4980
4981 fn rustc_version() -> Option<Compiler> {
4982- let rustc = match env::var_os("RUSTC") {
4983- Some(rustc) => rustc,
4984- None => return None,
4985- };
4986-
4987- let output = match Command::new(rustc).arg("--version").output() {
4988- Ok(output) => output,
4989- Err(_) => return None,
4990- };
4991-
4992- let version = match str::from_utf8(&output.stdout) {
4993- Ok(version) => version,
4994- Err(_) => return None,
4995- };
4996-
4997+ let rustc = env::var_os("RUSTC")?;
4998+ let output = Command::new(rustc).arg("--version").output().ok()?;
4999+ let version = str::from_utf8(&output.stdout).ok()?;
5000 let mut pieces = version.split('.');
5001 if pieces.next() != Some("rustc 1") {
5002 return None;
5003 }
5004-
5005- let next = match pieces.next() {
5006- Some(next) => next,
5007- None => return None,
5008- };
5009-
5010- let minor = match u32::from_str(next) {
5011- Ok(minor) => minor,
5012- Err(_) => return None,
5013- };
5014-
5015- Some(Compiler {
5016- minor: minor,
5017- nightly: version.contains("nightly"),
5018- })
5019+ let minor = pieces.next()?.parse().ok()?;
5020+ let nightly = version.contains("nightly");
5021+ Some(Compiler { minor, nightly })
5022 }
5023diff --git a/third_party/rust/syn/src/attr.rs b/third_party/rust/syn/src/attr.rs
5024--- a/third_party/rust/syn/src/attr.rs
5025+++ b/third_party/rust/syn/src/attr.rs
5026@@ -4,25 +4,21 @@ use crate::punctuated::Punctuated;
5027 use std::iter;
5028
5029 use proc_macro2::TokenStream;
5030
5031 #[cfg(feature = "parsing")]
5032 use crate::parse::{Parse, ParseBuffer, ParseStream, Parser, Result};
5033 #[cfg(feature = "parsing")]
5034 use crate::punctuated::Pair;
5035-#[cfg(feature = "extra-traits")]
5036-use crate::tt::TokenStreamHelper;
5037-#[cfg(feature = "extra-traits")]
5038-use std::hash::{Hash, Hasher};
5039
5040 ast_struct! {
5041 /// An attribute like `#[repr(transparent)]`.
5042 ///
5043- /// *This type is available if Syn is built with the `"derive"` or `"full"`
5044+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
5045 /// feature.*
5046 ///
5047 /// <br>
5048 ///
5049 /// # Syntax
5050 ///
5051 /// Rust has six types of attributes.
5052 ///
5053@@ -106,58 +102,69 @@ ast_struct! {
5054 /// If the attribute you are parsing is expected to conform to the
5055 /// conventional structured form of attribute, use [`parse_meta()`] to
5056 /// obtain that structured representation. If the attribute follows some
5057 /// other grammar of its own, use [`parse_args()`] to parse that into the
5058 /// expected data structure.
5059 ///
5060 /// [`parse_meta()`]: Attribute::parse_meta
5061 /// [`parse_args()`]: Attribute::parse_args
5062- pub struct Attribute #manual_extra_traits {
5063+ ///
5064+ /// <p><br></p>
5065+ ///
5066+ /// # Doc comments
5067+ ///
5068+ /// The compiler transforms doc comments, such as `/// comment` and `/*!
5069+ /// comment */`, into attributes before macros are expanded. Each comment is
5070+ /// expanded into an attribute of the form `#[doc = r"comment"]`.
5071+ ///
5072+ /// As an example, the following `mod` items are expanded identically:
5073+ ///
5074+ /// ```
5075+ /// # use syn::{ItemMod, parse_quote};
5076+ /// let doc: ItemMod = parse_quote! {
5077+ /// /// Single line doc comments
5078+ /// /// We write so many!
5079+ /// /**
5080+ /// * Multi-line comments...
5081+ /// * May span many lines
5082+ /// */
5083+ /// mod example {
5084+ /// //! Of course, they can be inner too
5085+ /// /*! And fit in a single line */
5086+ /// }
5087+ /// };
5088+ /// let attr: ItemMod = parse_quote! {
5089+ /// #[doc = r" Single line doc comments"]
5090+ /// #[doc = r" We write so many!"]
5091+ /// #[doc = r"
5092+ /// * Multi-line comments...
5093+ /// * May span many lines
5094+ /// "]
5095+ /// mod example {
5096+ /// #![doc = r" Of course, they can be inner too"]
5097+ /// #![doc = r" And fit in a single line "]
5098+ /// }
5099+ /// };
5100+ /// assert_eq!(doc, attr);
5101+ /// ```
5102+ pub struct Attribute {
5103 pub pound_token: Token![#],
5104 pub style: AttrStyle,
5105 pub bracket_token: token::Bracket,
5106 pub path: Path,
5107 pub tokens: TokenStream,
5108 }
5109 }
5110
5111-#[cfg(feature = "extra-traits")]
5112-impl Eq for Attribute {}
5113-
5114-#[cfg(feature = "extra-traits")]
5115-impl PartialEq for Attribute {
5116- fn eq(&self, other: &Self) -> bool {
5117- self.style == other.style
5118- && self.pound_token == other.pound_token
5119- && self.bracket_token == other.bracket_token
5120- && self.path == other.path
5121- && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens)
5122- }
5123-}
5124-
5125-#[cfg(feature = "extra-traits")]
5126-impl Hash for Attribute {
5127- fn hash<H>(&self, state: &mut H)
5128- where
5129- H: Hasher,
5130- {
5131- self.style.hash(state);
5132- self.pound_token.hash(state);
5133- self.bracket_token.hash(state);
5134- self.path.hash(state);
5135- TokenStreamHelper(&self.tokens).hash(state);
5136- }
5137-}
5138-
5139 impl Attribute {
5140 /// Parses the content of the attribute, consisting of the path and tokens,
5141 /// as a [`Meta`] if possible.
5142 ///
5143- /// *This function is available if Syn is built with the `"parsing"`
5144+ /// *This function is available only if Syn is built with the `"parsing"`
5145 /// feature.*
5146 #[cfg(feature = "parsing")]
5147 pub fn parse_meta(&self) -> Result<Meta> {
5148 fn clone_ident_segment(segment: &PathSegment) -> PathSegment {
5149 PathSegment {
5150 ident: segment.ident.clone(),
5151 arguments: PathArguments::None,
5152 }
5153@@ -194,91 +201,95 @@ impl Attribute {
5154 /// parser; and
5155 /// - the error message has a more useful span when `tokens` is empty.
5156 ///
5157 /// ```text
5158 /// #[my_attr(value < 5)]
5159 /// ^^^^^^^^^ what gets parsed
5160 /// ```
5161 ///
5162- /// *This function is available if Syn is built with the `"parsing"`
5163+ /// *This function is available only if Syn is built with the `"parsing"`
5164 /// feature.*
5165 #[cfg(feature = "parsing")]
5166 pub fn parse_args<T: Parse>(&self) -> Result<T> {
5167 self.parse_args_with(T::parse)
5168 }
5169
5170 /// Parse the arguments to the attribute using the given parser.
5171 ///
5172- /// *This function is available if Syn is built with the `"parsing"`
5173+ /// *This function is available only if Syn is built with the `"parsing"`
5174 /// feature.*
5175 #[cfg(feature = "parsing")]
5176 pub fn parse_args_with<F: Parser>(&self, parser: F) -> Result<F::Output> {
5177 let parser = |input: ParseStream| {
5178 let args = enter_args(self, input)?;
5179 parse::parse_stream(parser, &args)
5180 };
5181 parser.parse2(self.tokens.clone())
5182 }
5183
5184 /// Parses zero or more outer attributes from the stream.
5185 ///
5186- /// *This function is available if Syn is built with the `"parsing"`
5187+ /// *This function is available only if Syn is built with the `"parsing"`
5188 /// feature.*
5189 #[cfg(feature = "parsing")]
5190 pub fn parse_outer(input: ParseStream) -> Result<Vec<Self>> {
5191 let mut attrs = Vec::new();
5192 while input.peek(Token![#]) {
5193 attrs.push(input.call(parsing::single_parse_outer)?);
5194 }
5195 Ok(attrs)
5196 }
5197
5198 /// Parses zero or more inner attributes from the stream.
5199 ///
5200- /// *This function is available if Syn is built with the `"parsing"`
5201+ /// *This function is available only if Syn is built with the `"parsing"`
5202 /// feature.*
5203 #[cfg(feature = "parsing")]
5204 pub fn parse_inner(input: ParseStream) -> Result<Vec<Self>> {
5205 let mut attrs = Vec::new();
5206 while input.peek(Token![#]) && input.peek2(Token![!]) {
5207 attrs.push(input.call(parsing::single_parse_inner)?);
5208 }
5209 Ok(attrs)
5210 }
5211 }
5212
5213 #[cfg(feature = "parsing")]
5214-fn error_expected_args(attr: &Attribute) -> Error {
5215+fn expected_parentheses(attr: &Attribute) -> String {
5216 let style = match attr.style {
5217 AttrStyle::Outer => "#",
5218 AttrStyle::Inner(_) => "#!",
5219 };
5220
5221 let mut path = String::new();
5222 for segment in &attr.path.segments {
5223 if !path.is_empty() || attr.path.leading_colon.is_some() {
5224 path += "::";
5225 }
5226 path += &segment.ident.to_string();
5227 }
5228
5229- let msg = format!("expected attribute arguments: {}[{}(...)]", style, path);
5230-
5231- #[cfg(feature = "printing")]
5232- return Error::new_spanned(attr, msg);
5233-
5234- #[cfg(not(feature = "printing"))]
5235- return Error::new(attr.bracket_token.span, msg);
5236+ format!("{}[{}(...)]", style, path)
5237 }
5238
5239 #[cfg(feature = "parsing")]
5240 fn enter_args<'a>(attr: &Attribute, input: ParseStream<'a>) -> Result<ParseBuffer<'a>> {
5241 if input.is_empty() {
5242- return Err(error_expected_args(attr));
5243+ let expected = expected_parentheses(attr);
5244+ let msg = format!("expected attribute arguments in parentheses: {}", expected);
5245+ return Err(crate::error::new2(
5246+ attr.pound_token.span,
5247+ attr.bracket_token.span,
5248+ msg,
5249+ ));
5250+ } else if input.peek(Token![=]) {
5251+ let expected = expected_parentheses(attr);
5252+ let msg = format!("expected parentheses: {}", expected);
5253+ return Err(input.error(msg));
5254 };
5255
5256 let content;
5257 if input.peek(token::Paren) {
5258 parenthesized!(content in input);
5259 } else if input.peek(token::Bracket) {
5260 bracketed!(content in input);
5261 } else if input.peek(token::Brace) {
5262@@ -293,41 +304,40 @@ fn enter_args<'a>(attr: &Attribute, inpu
5263 Err(input.error("unexpected token in attribute arguments"))
5264 }
5265 }
5266
5267 ast_enum! {
5268 /// Distinguishes between attributes that decorate an item and attributes
5269 /// that are contained within an item.
5270 ///
5271- /// *This type is available if Syn is built with the `"derive"` or `"full"`
5272+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
5273 /// feature.*
5274 ///
5275 /// # Outer attributes
5276 ///
5277 /// - `#[repr(transparent)]`
5278 /// - `/// # Example`
5279 /// - `/** Please file an issue */`
5280 ///
5281 /// # Inner attributes
5282 ///
5283 /// - `#![feature(proc_macro)]`
5284 /// - `//! # Example`
5285 /// - `/*! Please file an issue */`
5286- #[cfg_attr(feature = "clone-impls", derive(Copy))]
5287 pub enum AttrStyle {
5288 Outer,
5289 Inner(Token![!]),
5290 }
5291 }
5292
5293 ast_enum_of_structs! {
5294 /// Content of a compile-time structured attribute.
5295 ///
5296- /// *This type is available if Syn is built with the `"derive"` or `"full"`
5297+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
5298 /// feature.*
5299 ///
5300 /// ## Path
5301 ///
5302 /// A meta path is like the `test` in `#[test]`.
5303 ///
5304 /// ## List
5305 ///
5306@@ -355,29 +365,29 @@ ast_enum_of_structs! {
5307 /// A name-value pair within an attribute, like `feature = "nightly"`.
5308 NameValue(MetaNameValue),
5309 }
5310 }
5311
5312 ast_struct! {
5313 /// A structured list within an attribute, like `derive(Copy, Clone)`.
5314 ///
5315- /// *This type is available if Syn is built with the `"derive"` or
5316+ /// *This type is available only if Syn is built with the `"derive"` or
5317 /// `"full"` feature.*
5318 pub struct MetaList {
5319 pub path: Path,
5320 pub paren_token: token::Paren,
5321 pub nested: Punctuated<NestedMeta, Token![,]>,
5322 }
5323 }
5324
5325 ast_struct! {
5326 /// A name-value pair within an attribute, like `feature = "nightly"`.
5327 ///
5328- /// *This type is available if Syn is built with the `"derive"` or
5329+ /// *This type is available only if Syn is built with the `"derive"` or
5330 /// `"full"` feature.*
5331 pub struct MetaNameValue {
5332 pub path: Path,
5333 pub eq_token: Token![=],
5334 pub lit: Lit,
5335 }
5336 }
5337
5338@@ -393,17 +403,17 @@ impl Meta {
5339 Meta::NameValue(meta) => &meta.path,
5340 }
5341 }
5342 }
5343
5344 ast_enum_of_structs! {
5345 /// Element of a compile-time attribute list.
5346 ///
5347- /// *This type is available if Syn is built with the `"derive"` or `"full"`
5348+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
5349 /// feature.*
5350 pub enum NestedMeta {
5351 /// A structured meta item, like the `Copy` in `#[derive(Copy)]` which
5352 /// would be a nested `Meta::Path`.
5353 Meta(Meta),
5354
5355 /// A Rust literal, like the `"new_name"` in `#[rename("new_name")]`.
5356 Lit(Lit),
5357@@ -424,18 +434,18 @@ ast_enum_of_structs! {
5358 /// /* ... */
5359 /// }
5360 /// ```
5361 ///
5362 /// The implementation of this macro would want to parse its attribute arguments
5363 /// as type `AttributeArgs`.
5364 ///
5365 /// ```
5366-/// extern crate proc_macro;
5367-///
5368+/// # extern crate proc_macro;
5369+/// #
5370 /// use proc_macro::TokenStream;
5371 /// use syn::{parse_macro_input, AttributeArgs, ItemFn};
5372 ///
5373 /// # const IGNORE: &str = stringify! {
5374 /// #[proc_macro_attribute]
5375 /// # };
5376 /// pub fn my_attribute(args: TokenStream, input: TokenStream) -> TokenStream {
5377 /// let args = parse_macro_input!(args as AttributeArgs);
5378@@ -459,27 +469,27 @@ where
5379 T: IntoIterator<Item = &'a Attribute>,
5380 {
5381 type Ret = iter::Filter<T::IntoIter, fn(&&Attribute) -> bool>;
5382
5383 fn outer(self) -> Self::Ret {
5384 fn is_outer(attr: &&Attribute) -> bool {
5385 match attr.style {
5386 AttrStyle::Outer => true,
5387- _ => false,
5388+ AttrStyle::Inner(_) => false,
5389 }
5390 }
5391 self.into_iter().filter(is_outer)
5392 }
5393
5394 fn inner(self) -> Self::Ret {
5395 fn is_inner(attr: &&Attribute) -> bool {
5396 match attr.style {
5397 AttrStyle::Inner(_) => true,
5398- _ => false,
5399+ AttrStyle::Outer => false,
5400 }
5401 }
5402 self.into_iter().filter(is_inner)
5403 }
5404 }
5405
5406 #[cfg(feature = "parsing")]
5407 pub mod parsing {
5408diff --git a/third_party/rust/syn/src/buffer.rs b/third_party/rust/syn/src/buffer.rs
5409--- a/third_party/rust/syn/src/buffer.rs
5410+++ b/third_party/rust/syn/src/buffer.rs
5411@@ -1,12 +1,12 @@
5412 //! A stably addressed token buffer supporting efficient traversal based on a
5413 //! cheaply copyable cursor.
5414 //!
5415-//! *This module is available if Syn is built with the `"parsing"` feature.*
5416+//! *This module is available only if Syn is built with the `"parsing"` feature.*
5417
5418 // This module is heavily commented as it contains most of the unsafe code in
5419 // Syn, and caution should be used when editing it. The public-facing interface
5420 // is 100% safe but the implementation is fragile internally.
5421
5422 #[cfg(all(
5423 not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
5424 feature = "proc-macro"
5425@@ -31,17 +31,17 @@ enum Entry {
5426 // token tree, or null if this is the outermost level.
5427 End(*const Entry),
5428 }
5429
5430 /// A buffer that can be efficiently traversed multiple times, unlike
5431 /// `TokenStream` which requires a deep copy in order to traverse more than
5432 /// once.
5433 ///
5434-/// *This type is available if Syn is built with the `"parsing"` feature.*
5435+/// *This type is available only if Syn is built with the `"parsing"` feature.*
5436 pub struct TokenBuffer {
5437 // NOTE: Do not derive clone on this - there are raw pointers inside which
5438 // will be messed up. Moving the `TokenBuffer` itself is safe as the actual
5439 // backing slices won't be moved.
5440 data: Box<[Entry]>,
5441 }
5442
5443 impl TokenBuffer {
5444@@ -93,17 +93,17 @@ impl TokenBuffer {
5445 }
5446
5447 TokenBuffer { data: entries }
5448 }
5449
5450 /// Creates a `TokenBuffer` containing all the tokens from the input
5451 /// `TokenStream`.
5452 ///
5453- /// *This method is available if Syn is built with both the `"parsing"` and
5454+ /// *This method is available only if Syn is built with both the `"parsing"` and
5455 /// `"proc-macro"` features.*
5456 #[cfg(all(
5457 not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
5458 feature = "proc-macro"
5459 ))]
5460 pub fn new(stream: pm::TokenStream) -> TokenBuffer {
5461 Self::new2(stream.into())
5462 }
5463@@ -128,18 +128,17 @@ impl TokenBuffer {
5464 /// and copied around.
5465 ///
5466 /// An empty `Cursor` can be created directly, or one may create a `TokenBuffer`
5467 /// object and get a cursor to its first token with `begin()`.
5468 ///
5469 /// Two cursors are equal if they have the same location in the same input
5470 /// stream, and have the same scope.
5471 ///
5472-/// *This type is available if Syn is built with the `"parsing"` feature.*
5473-#[derive(Copy, Clone, Eq, PartialEq)]
5474+/// *This type is available only if Syn is built with the `"parsing"` feature.*
5475 pub struct Cursor<'a> {
5476 // The current entry which the `Cursor` is pointing at.
5477 ptr: *const Entry,
5478 // This is the only `Entry::End(..)` object which this cursor is allowed to
5479 // point at. All other `End` objects are skipped over in `Cursor::create`.
5480 scope: *const Entry,
5481 // Cursor is covariant in 'a. This field ensures that our pointers are still
5482 // valid.
5483@@ -196,37 +195,38 @@ impl<'a> Cursor<'a> {
5484
5485 /// Bump the cursor to point at the next token after the current one. This
5486 /// is undefined behavior if the cursor is currently looking at an
5487 /// `Entry::End`.
5488 unsafe fn bump(self) -> Cursor<'a> {
5489 Cursor::create(self.ptr.offset(1), self.scope)
5490 }
5491
5492- /// If the cursor is looking at a `None`-delimited group, move it to look at
5493- /// the first token inside instead. If the group is empty, this will move
5494+ /// While the cursor is looking at a `None`-delimited group, move it to look
5495+ /// at the first token inside instead. If the group is empty, this will move
5496 /// the cursor past the `None`-delimited group.
5497 ///
5498 /// WARNING: This mutates its argument.
5499 fn ignore_none(&mut self) {
5500- if let Entry::Group(group, buf) = self.entry() {
5501+ while let Entry::Group(group, buf) = self.entry() {
5502 if group.delimiter() == Delimiter::None {
5503 // NOTE: We call `Cursor::create` here to make sure that
5504 // situations where we should immediately exit the span after
5505 // entering it are handled correctly.
5506 unsafe {
5507 *self = Cursor::create(&buf.data[0], self.scope);
5508 }
5509+ } else {
5510+ break;
5511 }
5512 }
5513 }
5514
5515 /// Checks whether the cursor is currently pointing at the end of its valid
5516 /// scope.
5517- #[inline]
5518 pub fn eof(self) -> bool {
5519 // We're at eof if we're at the end of our scope.
5520 self.ptr == self.scope
5521 }
5522
5523 /// If the cursor is pointing at a `Group` with the given delimiter, returns
5524 /// a cursor into that group and one pointing to the next `TokenTree`.
5525 pub fn group(mut self, delim: Delimiter) -> Option<(Cursor<'a>, Span, Cursor<'a>)> {
5526@@ -337,16 +337,54 @@ impl<'a> Cursor<'a> {
5527 match self.entry() {
5528 Entry::Group(group, _) => group.span(),
5529 Entry::Literal(l) => l.span(),
5530 Entry::Ident(t) => t.span(),
5531 Entry::Punct(o) => o.span(),
5532 Entry::End(..) => Span::call_site(),
5533 }
5534 }
5535+
5536+ /// Skip over the next token without cloning it. Returns `None` if this
5537+ /// cursor points to eof.
5538+ ///
5539+ /// This method treats `'lifetimes` as a single token.
5540+ pub(crate) fn skip(self) -> Option<Cursor<'a>> {
5541+ match self.entry() {
5542+ Entry::End(..) => None,
5543+
5544+ // Treat lifetimes as a single tt for the purposes of 'skip'.
5545+ Entry::Punct(op) if op.as_char() == '\'' && op.spacing() == Spacing::Joint => {
5546+ let next = unsafe { self.bump() };
5547+ match next.entry() {
5548+ Entry::Ident(_) => Some(unsafe { next.bump() }),
5549+ _ => Some(next),
5550+ }
5551+ }
5552+ _ => Some(unsafe { self.bump() }),
5553+ }
5554+ }
5555+}
5556+
5557+impl<'a> Copy for Cursor<'a> {}
5558+
5559+impl<'a> Clone for Cursor<'a> {
5560+ fn clone(&self) -> Self {
5561+ *self
5562+ }
5563+}
5564+
5565+impl<'a> Eq for Cursor<'a> {}
5566+
5567+impl<'a> PartialEq for Cursor<'a> {
5568+ fn eq(&self, other: &Self) -> bool {
5569+ let Cursor { ptr, scope, marker } = self;
5570+ let _ = marker;
5571+ *ptr == other.ptr && *scope == other.scope
5572+ }
5573 }
5574
5575 pub(crate) fn same_scope(a: Cursor, b: Cursor) -> bool {
5576 a.scope == b.scope
5577 }
5578
5579 pub(crate) fn open_span_of_group(cursor: Cursor) -> Span {
5580 match cursor.entry() {
5581diff --git a/third_party/rust/syn/src/custom_keyword.rs b/third_party/rust/syn/src/custom_keyword.rs
5582--- a/third_party/rust/syn/src/custom_keyword.rs
5583+++ b/third_party/rust/syn/src/custom_keyword.rs
5584@@ -81,46 +81,46 @@
5585 /// value: input.parse()?,
5586 /// })
5587 /// } else {
5588 /// Err(lookahead.error())
5589 /// }
5590 /// }
5591 /// }
5592 /// ```
5593-#[macro_export(local_inner_macros)]
5594+#[macro_export]
5595 macro_rules! custom_keyword {
5596 ($ident:ident) => {
5597 #[allow(non_camel_case_types)]
5598 pub struct $ident {
5599 pub span: $crate::export::Span,
5600 }
5601
5602 #[doc(hidden)]
5603- #[allow(non_snake_case)]
5604+ #[allow(dead_code, non_snake_case)]
5605 pub fn $ident<__S: $crate::export::IntoSpans<[$crate::export::Span; 1]>>(
5606 span: __S,
5607 ) -> $ident {
5608 $ident {
5609 span: $crate::export::IntoSpans::into_spans(span)[0],
5610 }
5611 }
5612
5613 impl $crate::export::Default for $ident {
5614 fn default() -> Self {
5615 $ident {
5616 span: $crate::export::Span::call_site(),
5617 }
5618 }
5619 }
5620
5621- impl_parse_for_custom_keyword!($ident);
5622- impl_to_tokens_for_custom_keyword!($ident);
5623- impl_clone_for_custom_keyword!($ident);
5624- impl_extra_traits_for_custom_keyword!($ident);
5625+ $crate::impl_parse_for_custom_keyword!($ident);
5626+ $crate::impl_to_tokens_for_custom_keyword!($ident);
5627+ $crate::impl_clone_for_custom_keyword!($ident);
5628+ $crate::impl_extra_traits_for_custom_keyword!($ident);
5629 };
5630 }
5631
5632 // Not public API.
5633 #[cfg(feature = "parsing")]
5634 #[doc(hidden)]
5635 #[macro_export]
5636 macro_rules! impl_parse_for_custom_keyword {
5637diff --git a/third_party/rust/syn/src/custom_punctuation.rs b/third_party/rust/syn/src/custom_punctuation.rs
5638--- a/third_party/rust/syn/src/custom_punctuation.rs
5639+++ b/third_party/rust/syn/src/custom_punctuation.rs
5640@@ -69,67 +69,67 @@
5641 /// Ok(tokens)
5642 /// }
5643 ///
5644 /// fn main() {
5645 /// let input = r#" a::b </> c::d::e "#;
5646 /// let _: PathSegments = syn::parse_str(input).unwrap();
5647 /// }
5648 /// ```
5649-#[macro_export(local_inner_macros)]
5650+#[macro_export]
5651 macro_rules! custom_punctuation {
5652 ($ident:ident, $($tt:tt)+) => {
5653 pub struct $ident {
5654- pub spans: custom_punctuation_repr!($($tt)+),
5655+ pub spans: $crate::custom_punctuation_repr!($($tt)+),
5656 }
5657
5658 #[doc(hidden)]
5659- #[allow(non_snake_case)]
5660- pub fn $ident<__S: $crate::export::IntoSpans<custom_punctuation_repr!($($tt)+)>>(
5661+ #[allow(dead_code, non_snake_case)]
5662+ pub fn $ident<__S: $crate::export::IntoSpans<$crate::custom_punctuation_repr!($($tt)+)>>(
5663 spans: __S,
5664 ) -> $ident {
5665- let _validate_len = 0 $(+ custom_punctuation_len!(strict, $tt))*;
5666+ let _validate_len = 0 $(+ $crate::custom_punctuation_len!(strict, $tt))*;
5667 $ident {
5668 spans: $crate::export::IntoSpans::into_spans(spans)
5669 }
5670 }
5671
5672 impl $crate::export::Default for $ident {
5673 fn default() -> Self {
5674 $ident($crate::export::Span::call_site())
5675 }
5676 }
5677
5678- impl_parse_for_custom_punctuation!($ident, $($tt)+);
5679- impl_to_tokens_for_custom_punctuation!($ident, $($tt)+);
5680- impl_clone_for_custom_punctuation!($ident, $($tt)+);
5681- impl_extra_traits_for_custom_punctuation!($ident, $($tt)+);
5682+ $crate::impl_parse_for_custom_punctuation!($ident, $($tt)+);
5683+ $crate::impl_to_tokens_for_custom_punctuation!($ident, $($tt)+);
5684+ $crate::impl_clone_for_custom_punctuation!($ident, $($tt)+);
5685+ $crate::impl_extra_traits_for_custom_punctuation!($ident, $($tt)+);
5686 };
5687 }
5688
5689 // Not public API.
5690 #[cfg(feature = "parsing")]
5691 #[doc(hidden)]
5692-#[macro_export(local_inner_macros)]
5693+#[macro_export]
5694 macro_rules! impl_parse_for_custom_punctuation {
5695 ($ident:ident, $($tt:tt)+) => {
5696 impl $crate::token::CustomToken for $ident {
5697 fn peek(cursor: $crate::buffer::Cursor) -> bool {
5698- $crate::token::parsing::peek_punct(cursor, stringify_punct!($($tt)+))
5699+ $crate::token::parsing::peek_punct(cursor, $crate::stringify_punct!($($tt)+))
5700 }
5701
5702 fn display() -> &'static $crate::export::str {
5703- custom_punctuation_concat!("`", stringify_punct!($($tt)+), "`")
5704+ concat!("`", $crate::stringify_punct!($($tt)+), "`")
5705 }
5706 }
5707
5708 impl $crate::parse::Parse for $ident {
5709 fn parse(input: $crate::parse::ParseStream) -> $crate::parse::Result<$ident> {
5710- let spans: custom_punctuation_repr!($($tt)+) =
5711- $crate::token::parsing::punct(input, stringify_punct!($($tt)+))?;
5712+ let spans: $crate::custom_punctuation_repr!($($tt)+) =
5713+ $crate::token::parsing::punct(input, $crate::stringify_punct!($($tt)+))?;
5714 Ok($ident(spans))
5715 }
5716 }
5717 };
5718 }
5719
5720 // Not public API.
5721 #[cfg(not(feature = "parsing"))]
5722@@ -137,22 +137,22 @@ macro_rules! impl_parse_for_custom_punct
5723 #[macro_export]
5724 macro_rules! impl_parse_for_custom_punctuation {
5725 ($ident:ident, $($tt:tt)+) => {};
5726 }
5727
5728 // Not public API.
5729 #[cfg(feature = "printing")]
5730 #[doc(hidden)]
5731-#[macro_export(local_inner_macros)]
5732+#[macro_export]
5733 macro_rules! impl_to_tokens_for_custom_punctuation {
5734 ($ident:ident, $($tt:tt)+) => {
5735 impl $crate::export::ToTokens for $ident {
5736 fn to_tokens(&self, tokens: &mut $crate::export::TokenStream2) {
5737- $crate::token::printing::punct(stringify_punct!($($tt)+), &self.spans, tokens)
5738+ $crate::token::printing::punct($crate::stringify_punct!($($tt)+), &self.spans, tokens)
5739 }
5740 }
5741 };
5742 }
5743
5744 // Not public API.
5745 #[cfg(not(feature = "printing"))]
5746 #[doc(hidden)]
5747@@ -216,26 +216,26 @@ macro_rules! impl_extra_traits_for_custo
5748 #[doc(hidden)]
5749 #[macro_export]
5750 macro_rules! impl_extra_traits_for_custom_punctuation {
5751 ($ident:ident, $($tt:tt)+) => {};
5752 }
5753
5754 // Not public API.
5755 #[doc(hidden)]
5756-#[macro_export(local_inner_macros)]
5757+#[macro_export]
5758 macro_rules! custom_punctuation_repr {
5759 ($($tt:tt)+) => {
5760- [$crate::export::Span; 0 $(+ custom_punctuation_len!(lenient, $tt))+]
5761+ [$crate::export::Span; 0 $(+ $crate::custom_punctuation_len!(lenient, $tt))+]
5762 };
5763 }
5764
5765 // Not public API.
5766 #[doc(hidden)]
5767-#[macro_export(local_inner_macros)]
5768+#[macro_export]
5769 #[rustfmt::skip]
5770 macro_rules! custom_punctuation_len {
5771 ($mode:ident, +) => { 1 };
5772 ($mode:ident, +=) => { 2 };
5773 ($mode:ident, &) => { 1 };
5774 ($mode:ident, &&) => { 2 };
5775 ($mode:ident, &=) => { 2 };
5776 ($mode:ident, @) => { 1 };
5777@@ -274,17 +274,17 @@ macro_rules! custom_punctuation_len {
5778 ($mode:ident, <<=) => { 3 };
5779 ($mode:ident, >>) => { 2 };
5780 ($mode:ident, >>=) => { 3 };
5781 ($mode:ident, *) => { 1 };
5782 ($mode:ident, -) => { 1 };
5783 ($mode:ident, -=) => { 2 };
5784 ($mode:ident, ~) => { 1 };
5785 (lenient, $tt:tt) => { 0 };
5786- (strict, $tt:tt) => {{ custom_punctuation_unexpected!($tt); 0 }};
5787+ (strict, $tt:tt) => {{ $crate::custom_punctuation_unexpected!($tt); 0 }};
5788 }
5789
5790 // Not public API.
5791 #[doc(hidden)]
5792 #[macro_export]
5793 macro_rules! custom_punctuation_unexpected {
5794 () => {};
5795 }
5796@@ -292,18 +292,8 @@ macro_rules! custom_punctuation_unexpect
5797 // Not public API.
5798 #[doc(hidden)]
5799 #[macro_export]
5800 macro_rules! stringify_punct {
5801 ($($tt:tt)+) => {
5802 concat!($(stringify!($tt)),+)
5803 };
5804 }
5805-
5806-// Not public API.
5807-// Without this, local_inner_macros breaks when looking for concat!
5808-#[doc(hidden)]
5809-#[macro_export]
5810-macro_rules! custom_punctuation_concat {
5811- ($($tt:tt)*) => {
5812- concat!($($tt)*)
5813- };
5814-}
5815diff --git a/third_party/rust/syn/src/data.rs b/third_party/rust/syn/src/data.rs
5816--- a/third_party/rust/syn/src/data.rs
5817+++ b/third_party/rust/syn/src/data.rs
5818@@ -1,15 +1,15 @@
5819 use super::*;
5820 use crate::punctuated::Punctuated;
5821
5822 ast_struct! {
5823 /// An enum variant.
5824 ///
5825- /// *This type is available if Syn is built with the `"derive"` or `"full"`
5826+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
5827 /// feature.*
5828 pub struct Variant {
5829 /// Attributes tagged on the variant.
5830 pub attrs: Vec<Attribute>,
5831
5832 /// Name of the variant.
5833 pub ident: Ident,
5834
5835@@ -19,17 +19,17 @@ ast_struct! {
5836 /// Explicit discriminant: `Variant = 1`
5837 pub discriminant: Option<(Token![=], Expr)>,
5838 }
5839 }
5840
5841 ast_enum_of_structs! {
5842 /// Data stored within an enum variant or struct.
5843 ///
5844- /// *This type is available if Syn is built with the `"derive"` or `"full"`
5845+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
5846 /// feature.*
5847 ///
5848 /// # Syntax tree enum
5849 ///
5850 /// This type is a [syntax tree enum].
5851 ///
5852 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
5853 //
5854@@ -47,28 +47,28 @@ ast_enum_of_structs! {
5855 Unit,
5856 }
5857 }
5858
5859 ast_struct! {
5860 /// Named fields of a struct or struct variant such as `Point { x: f64,
5861 /// y: f64 }`.
5862 ///
5863- /// *This type is available if Syn is built with the `"derive"` or
5864+ /// *This type is available only if Syn is built with the `"derive"` or
5865 /// `"full"` feature.*
5866 pub struct FieldsNamed {
5867 pub brace_token: token::Brace,
5868 pub named: Punctuated<Field, Token![,]>,
5869 }
5870 }
5871
5872 ast_struct! {
5873 /// Unnamed fields of a tuple struct or tuple variant such as `Some(T)`.
5874 ///
5875- /// *This type is available if Syn is built with the `"derive"` or
5876+ /// *This type is available only if Syn is built with the `"derive"` or
5877 /// `"full"` feature.*
5878 pub struct FieldsUnnamed {
5879 pub paren_token: token::Paren,
5880 pub unnamed: Punctuated<Field, Token![,]>,
5881 }
5882 }
5883
5884 impl Fields {
5885@@ -88,16 +88,34 @@ impl Fields {
5886 /// struct or variant's fields uniformly.
5887 pub fn iter_mut(&mut self) -> punctuated::IterMut<Field> {
5888 match self {
5889 Fields::Unit => crate::punctuated::empty_punctuated_iter_mut(),
5890 Fields::Named(f) => f.named.iter_mut(),
5891 Fields::Unnamed(f) => f.unnamed.iter_mut(),
5892 }
5893 }
5894+
5895+ /// Returns the number of fields.
5896+ pub fn len(&self) -> usize {
5897+ match self {
5898+ Fields::Unit => 0,
5899+ Fields::Named(f) => f.named.len(),
5900+ Fields::Unnamed(f) => f.unnamed.len(),
5901+ }
5902+ }
5903+
5904+ /// Returns `true` if there are zero fields.
5905+ pub fn is_empty(&self) -> bool {
5906+ match self {
5907+ Fields::Unit => true,
5908+ Fields::Named(f) => f.named.is_empty(),
5909+ Fields::Unnamed(f) => f.unnamed.is_empty(),
5910+ }
5911+ }
5912 }
5913
5914 impl IntoIterator for Fields {
5915 type Item = Field;
5916 type IntoIter = punctuated::IntoIter<Field>;
5917
5918 fn into_iter(self) -> Self::IntoIter {
5919 match self {
5920@@ -124,17 +142,17 @@ impl<'a> IntoIterator for &'a mut Fields
5921 fn into_iter(self) -> Self::IntoIter {
5922 self.iter_mut()
5923 }
5924 }
5925
5926 ast_struct! {
5927 /// A field of a struct or enum variant.
5928 ///
5929- /// *This type is available if Syn is built with the `"derive"` or `"full"`
5930+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
5931 /// feature.*
5932 pub struct Field {
5933 /// Attributes tagged on the field.
5934 pub attrs: Vec<Attribute>,
5935
5936 /// Visibility of the field.
5937 pub vis: Visibility,
5938
5939@@ -149,17 +167,17 @@ ast_struct! {
5940 pub ty: Type,
5941 }
5942 }
5943
5944 ast_enum_of_structs! {
5945 /// The visibility level of an item: inherited or `pub` or
5946 /// `pub(restricted)`.
5947 ///
5948- /// *This type is available if Syn is built with the `"derive"` or `"full"`
5949+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
5950 /// feature.*
5951 ///
5952 /// # Syntax tree enum
5953 ///
5954 /// This type is a [syntax tree enum].
5955 ///
5956 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
5957 //
5958@@ -179,58 +197,61 @@ ast_enum_of_structs! {
5959 /// An inherited visibility, which usually means private.
5960 Inherited,
5961 }
5962 }
5963
5964 ast_struct! {
5965 /// A public visibility level: `pub`.
5966 ///
5967- /// *This type is available if Syn is built with the `"derive"` or
5968+ /// *This type is available only if Syn is built with the `"derive"` or
5969 /// `"full"` feature.*
5970 pub struct VisPublic {
5971 pub pub_token: Token![pub],
5972 }
5973 }
5974
5975 ast_struct! {
5976 /// A crate-level visibility: `crate`.
5977 ///
5978- /// *This type is available if Syn is built with the `"derive"` or
5979+ /// *This type is available only if Syn is built with the `"derive"` or
5980 /// `"full"` feature.*
5981 pub struct VisCrate {
5982 pub crate_token: Token![crate],
5983 }
5984 }
5985
5986 ast_struct! {
5987 /// A visibility level restricted to some path: `pub(self)` or
5988 /// `pub(super)` or `pub(crate)` or `pub(in some::module)`.
5989 ///
5990- /// *This type is available if Syn is built with the `"derive"` or
5991+ /// *This type is available only if Syn is built with the `"derive"` or
5992 /// `"full"` feature.*
5993 pub struct VisRestricted {
5994 pub pub_token: Token![pub],
5995 pub paren_token: token::Paren,
5996 pub in_token: Option<Token![in]>,
5997 pub path: Box<Path>,
5998 }
5999 }
6000
6001 #[cfg(feature = "parsing")]
6002 pub mod parsing {
6003 use super::*;
6004
6005 use crate::ext::IdentExt;
6006+ use crate::parse::discouraged::Speculative;
6007 use crate::parse::{Parse, ParseStream, Result};
6008
6009 impl Parse for Variant {
6010 fn parse(input: ParseStream) -> Result<Self> {
6011+ let attrs = input.call(Attribute::parse_outer)?;
6012+ let _visibility: Visibility = input.parse()?;
6013 Ok(Variant {
6014- attrs: input.call(Attribute::parse_outer)?,
6015+ attrs,
6016 ident: input.parse()?,
6017 fields: {
6018 if input.peek(token::Brace) {
6019 Fields::Named(input.parse()?)
6020 } else if input.peek(token::Paren) {
6021 Fields::Unnamed(input.parse()?)
6022 } else {
6023 Fields::Unit
6024@@ -290,68 +311,99 @@ pub mod parsing {
6025 colon_token: None,
6026 ty: input.parse()?,
6027 })
6028 }
6029 }
6030
6031 impl Parse for Visibility {
6032 fn parse(input: ParseStream) -> Result<Self> {
6033+ // Recognize an empty None-delimited group, as produced by a $:vis
6034+ // matcher that matched no tokens.
6035+ if input.peek(token::Group) {
6036+ let ahead = input.fork();
6037+ let group = crate::group::parse_group(&ahead)?;
6038+ if group.content.is_empty() {
6039+ input.advance_to(&ahead);
6040+ return Ok(Visibility::Inherited);
6041+ }
6042+ }
6043+
6044 if input.peek(Token![pub]) {
6045 Self::parse_pub(input)
6046 } else if input.peek(Token![crate]) {
6047 Self::parse_crate(input)
6048 } else {
6049 Ok(Visibility::Inherited)
6050 }
6051 }
6052 }
6053
6054 impl Visibility {
6055 fn parse_pub(input: ParseStream) -> Result<Self> {
6056 let pub_token = input.parse::<Token![pub]>()?;
6057
6058 if input.peek(token::Paren) {
6059- // TODO: optimize using advance_to
6060 let ahead = input.fork();
6061- let mut content;
6062- parenthesized!(content in ahead);
6063
6064+ let content;
6065+ let paren_token = parenthesized!(content in ahead);
6066 if content.peek(Token![crate])
6067 || content.peek(Token![self])
6068 || content.peek(Token![super])
6069 {
6070+ let path = content.call(Ident::parse_any)?;
6071+
6072+ // Ensure there are no additional tokens within `content`.
6073+ // Without explicitly checking, we may misinterpret a tuple
6074+ // field as a restricted visibility, causing a parse error.
6075+ // e.g. `pub (crate::A, crate::B)` (Issue #720).
6076+ if content.is_empty() {
6077+ input.advance_to(&ahead);
6078+ return Ok(Visibility::Restricted(VisRestricted {
6079+ pub_token,
6080+ paren_token,
6081+ in_token: None,
6082+ path: Box::new(Path::from(path)),
6083+ }));
6084+ }
6085+ } else if content.peek(Token![in]) {
6086+ let in_token: Token![in] = content.parse()?;
6087+ let path = content.call(Path::parse_mod_style)?;
6088+
6089+ input.advance_to(&ahead);
6090 return Ok(Visibility::Restricted(VisRestricted {
6091 pub_token,
6092- paren_token: parenthesized!(content in input),
6093- in_token: None,
6094- path: Box::new(Path::from(content.call(Ident::parse_any)?)),
6095- }));
6096- } else if content.peek(Token![in]) {
6097- return Ok(Visibility::Restricted(VisRestricted {
6098- pub_token,
6099- paren_token: parenthesized!(content in input),
6100- in_token: Some(content.parse()?),
6101- path: Box::new(content.call(Path::parse_mod_style)?),
6102+ paren_token,
6103+ in_token: Some(in_token),
6104+ path: Box::new(path),
6105 }));
6106 }
6107 }
6108
6109 Ok(Visibility::Public(VisPublic { pub_token }))
6110 }
6111
6112 fn parse_crate(input: ParseStream) -> Result<Self> {
6113 if input.peek2(Token![::]) {
6114 Ok(Visibility::Inherited)
6115 } else {
6116 Ok(Visibility::Crate(VisCrate {
6117 crate_token: input.parse()?,
6118 }))
6119 }
6120 }
6121+
6122+ #[cfg(feature = "full")]
6123+ pub(crate) fn is_some(&self) -> bool {
6124+ match self {
6125+ Visibility::Inherited => false,
6126+ _ => true,
6127+ }
6128+ }
6129 }
6130 }
6131
6132 #[cfg(feature = "printing")]
6133 mod printing {
6134 use super::*;
6135
6136 use proc_macro2::TokenStream;
6137diff --git a/third_party/rust/syn/src/derive.rs b/third_party/rust/syn/src/derive.rs
6138--- a/third_party/rust/syn/src/derive.rs
6139+++ b/third_party/rust/syn/src/derive.rs
6140@@ -1,15 +1,15 @@
6141 use super::*;
6142 use crate::punctuated::Punctuated;
6143
6144 ast_struct! {
6145 /// Data structure sent to a `proc_macro_derive` macro.
6146 ///
6147- /// *This type is available if Syn is built with the `"derive"` feature.*
6148+ /// *This type is available only if Syn is built with the `"derive"` feature.*
6149 pub struct DeriveInput {
6150 /// Attributes tagged on the whole struct or enum.
6151 pub attrs: Vec<Attribute>,
6152
6153 /// Visibility of the struct or enum.
6154 pub vis: Visibility,
6155
6156 /// Name of the struct or enum.
6157@@ -21,17 +21,17 @@ ast_struct! {
6158 /// Data within the struct or enum.
6159 pub data: Data,
6160 }
6161 }
6162
6163 ast_enum_of_structs! {
6164 /// The storage of a struct, enum or union data structure.
6165 ///
6166- /// *This type is available if Syn is built with the `"derive"` feature.*
6167+ /// *This type is available only if Syn is built with the `"derive"` feature.*
6168 ///
6169 /// # Syntax tree enum
6170 ///
6171 /// This type is a [syntax tree enum].
6172 ///
6173 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
6174 //
6175 // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
6176@@ -48,41 +48,41 @@ ast_enum_of_structs! {
6177 }
6178
6179 do_not_generate_to_tokens
6180 }
6181
6182 ast_struct! {
6183 /// A struct input to a `proc_macro_derive` macro.
6184 ///
6185- /// *This type is available if Syn is built with the `"derive"`
6186+ /// *This type is available only if Syn is built with the `"derive"`
6187 /// feature.*
6188 pub struct DataStruct {
6189 pub struct_token: Token![struct],
6190 pub fields: Fields,
6191 pub semi_token: Option<Token![;]>,
6192 }
6193 }
6194
6195 ast_struct! {
6196 /// An enum input to a `proc_macro_derive` macro.
6197 ///
6198- /// *This type is available if Syn is built with the `"derive"`
6199+ /// *This type is available only if Syn is built with the `"derive"`
6200 /// feature.*
6201 pub struct DataEnum {
6202 pub enum_token: Token![enum],
6203 pub brace_token: token::Brace,
6204 pub variants: Punctuated<Variant, Token![,]>,
6205 }
6206 }
6207
6208 ast_struct! {
6209 /// An untagged union input to a `proc_macro_derive` macro.
6210 ///
6211- /// *This type is available if Syn is built with the `"derive"`
6212+ /// *This type is available only if Syn is built with the `"derive"`
6213 /// feature.*
6214 pub struct DataUnion {
6215 pub union_token: Token![union],
6216 pub fields: FieldsNamed,
6217 }
6218 }
6219
6220 #[cfg(feature = "parsing")]
6221diff --git a/third_party/rust/syn/src/discouraged.rs b/third_party/rust/syn/src/discouraged.rs
6222--- a/third_party/rust/syn/src/discouraged.rs
6223+++ b/third_party/rust/syn/src/discouraged.rs
6224@@ -11,17 +11,17 @@ pub trait Speculative {
6225 /// stream to the fork to "commit" the parsing from the fork to the main
6226 /// stream.
6227 ///
6228 /// If you can avoid doing this, you should, as it limits the ability to
6229 /// generate useful errors. That said, it is often the only way to parse
6230 /// syntax of the form `A* B*` for arbitrary syntax `A` and `B`. The problem
6231 /// is that when the fork fails to parse an `A`, it's impossible to tell
6232 /// whether that was because of a syntax error and the user meant to provide
6233- /// an `A`, or that the `A`s are finished and its time to start parsing
6234+ /// an `A`, or that the `A`s are finished and it's time to start parsing
6235 /// `B`s. Use with care.
6236 ///
6237 /// Also note that if `A` is a subset of `B`, `A* B*` can be parsed by
6238 /// parsing `B*` and removing the leading members of `A` from the
6239 /// repetition, bypassing the need to involve the downsides associated with
6240 /// speculative parsing.
6241 ///
6242 /// [`ParseStream::fork`]: ParseBuffer::fork
6243@@ -67,17 +67,16 @@ pub trait Speculative {
6244 /// # }
6245 ///
6246 /// impl Parse for PathSegment {
6247 /// fn parse(input: ParseStream) -> Result<Self> {
6248 /// if input.peek(Token![super])
6249 /// || input.peek(Token![self])
6250 /// || input.peek(Token![Self])
6251 /// || input.peek(Token![crate])
6252- /// || input.peek(Token![extern])
6253 /// {
6254 /// let ident = input.call(Ident::parse_any)?;
6255 /// return Ok(PathSegment::from(ident));
6256 /// }
6257 ///
6258 /// let ident = input.parse()?;
6259 /// if input.peek(Token![::]) && input.peek3(Token![<]) {
6260 /// return Ok(PathSegment {
6261@@ -159,13 +158,37 @@ pub trait Speculative {
6262 }
6263
6264 impl<'a> Speculative for ParseBuffer<'a> {
6265 fn advance_to(&self, fork: &Self) {
6266 if !crate::buffer::same_scope(self.cursor(), fork.cursor()) {
6267 panic!("Fork was not derived from the advancing parse stream");
6268 }
6269
6270+ let (self_unexp, self_sp) = inner_unexpected(self);
6271+ let (fork_unexp, fork_sp) = inner_unexpected(fork);
6272+ if !Rc::ptr_eq(&self_unexp, &fork_unexp) {
6273+ match (fork_sp, self_sp) {
6274+ // Unexpected set on the fork, but not on `self`, copy it over.
6275+ (Some(span), None) => {
6276+ self_unexp.set(Unexpected::Some(span));
6277+ }
6278+ // Unexpected unset. Use chain to propagate errors from fork.
6279+ (None, None) => {
6280+ fork_unexp.set(Unexpected::Chain(self_unexp));
6281+
6282+ // Ensure toplevel 'unexpected' tokens from the fork don't
6283+ // bubble up the chain by replacing the root `unexpected`
6284+ // pointer, only 'unexpected' tokens from existing group
6285+ // parsers should bubble.
6286+ fork.unexpected
6287+ .set(Some(Rc::new(Cell::new(Unexpected::None))));
6288+ }
6289+ // Unexpected has been set on `self`. No changes needed.
6290+ (_, Some(_)) => {}
6291+ }
6292+ }
6293+
6294 // See comment on `cell` in the struct definition.
6295 self.cell
6296 .set(unsafe { mem::transmute::<Cursor, Cursor<'static>>(fork.cursor()) })
6297 }
6298 }
6299diff --git a/third_party/rust/syn/src/error.rs b/third_party/rust/syn/src/error.rs
6300--- a/third_party/rust/syn/src/error.rs
6301+++ b/third_party/rust/syn/src/error.rs
6302@@ -1,9 +1,8 @@
6303-use std;
6304 use std::fmt::{self, Debug, Display};
6305 use std::iter::FromIterator;
6306 use std::slice;
6307 use std::vec;
6308
6309 use proc_macro2::{
6310 Delimiter, Group, Ident, LexError, Literal, Punct, Spacing, Span, TokenStream, TokenTree,
6311 };
6312@@ -27,18 +26,18 @@ pub type Result<T> = std::result::Result
6313 /// message than simply panicking the macro.
6314 ///
6315 /// [`compile_error!`]: https://doc.rust-lang.org/std/macro.compile_error.html
6316 ///
6317 /// When parsing macro input, the [`parse_macro_input!`] macro handles the
6318 /// conversion to `compile_error!` automatically.
6319 ///
6320 /// ```
6321-/// extern crate proc_macro;
6322-///
6323+/// # extern crate proc_macro;
6324+/// #
6325 /// use proc_macro::TokenStream;
6326 /// use syn::{parse_macro_input, AttributeArgs, ItemFn};
6327 ///
6328 /// # const IGNORE: &str = stringify! {
6329 /// #[proc_macro_attribute]
6330 /// # };
6331 /// pub fn my_attr(args: TokenStream, input: TokenStream) -> TokenStream {
6332 /// let args = parse_macro_input!(args as AttributeArgs);
6333@@ -77,17 +76,16 @@ pub type Result<T> = std::result::Result
6334 /// # use proc_macro2::TokenStream;
6335 /// # use syn::{DeriveInput, Result};
6336 /// #
6337 /// # pub fn my_derive(input: DeriveInput) -> Result<TokenStream> {
6338 /// # unimplemented!()
6339 /// # }
6340 /// # }
6341 /// ```
6342-#[derive(Clone)]
6343 pub struct Error {
6344 messages: Vec<ErrorMessage>,
6345 }
6346
6347 struct ErrorMessage {
6348 // Span is implemented as an index into a thread-local interner to keep the
6349 // size small. It is not safe to access from a different thread. We want
6350 // errors to be Send and Sync to play nicely with the Failure crate, so pin
6351@@ -245,16 +243,27 @@ pub fn new_at<T: Display>(scope: Span, c
6352 if cursor.eof() {
6353 Error::new(scope, format!("unexpected end of input, {}", message))
6354 } else {
6355 let span = crate::buffer::open_span_of_group(cursor);
6356 Error::new(span, message)
6357 }
6358 }
6359
6360+#[cfg(all(feature = "parsing", any(feature = "full", feature = "derive")))]
6361+pub fn new2<T: Display>(start: Span, end: Span, message: T) -> Error {
6362+ Error {
6363+ messages: vec![ErrorMessage {
6364+ start_span: ThreadBound::new(start),
6365+ end_span: ThreadBound::new(end),
6366+ message: message.to_string(),
6367+ }],
6368+ }
6369+}
6370+
6371 impl Debug for Error {
6372 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
6373 if self.messages.len() == 1 {
6374 formatter
6375 .debug_tuple("Error")
6376 .field(&self.messages[0])
6377 .finish()
6378 } else {
6379@@ -273,16 +282,24 @@ impl Debug for ErrorMessage {
6380 }
6381
6382 impl Display for Error {
6383 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
6384 formatter.write_str(&self.messages[0].message)
6385 }
6386 }
6387
6388+impl Clone for Error {
6389+ fn clone(&self) -> Self {
6390+ Error {
6391+ messages: self.messages.clone(),
6392+ }
6393+ }
6394+}
6395+
6396 impl Clone for ErrorMessage {
6397 fn clone(&self) -> Self {
6398 let start = self
6399 .start_span
6400 .get()
6401 .cloned()
6402 .unwrap_or_else(Span::call_site);
6403 let end = self.end_span.get().cloned().unwrap_or_else(Span::call_site);
6404@@ -350,8 +367,16 @@ impl<'a> Iterator for Iter<'a> {
6405 type Item = Error;
6406
6407 fn next(&mut self) -> Option<Self::Item> {
6408 Some(Error {
6409 messages: vec![self.messages.next()?.clone()],
6410 })
6411 }
6412 }
6413+
6414+impl Extend<Error> for Error {
6415+ fn extend<T: IntoIterator<Item = Error>>(&mut self, iter: T) {
6416+ for err in iter {
6417+ self.combine(err);
6418+ }
6419+ }
6420+}
6421diff --git a/third_party/rust/syn/src/expr.rs b/third_party/rust/syn/src/expr.rs
6422--- a/third_party/rust/syn/src/expr.rs
6423+++ b/third_party/rust/syn/src/expr.rs
6424@@ -1,23 +1,26 @@
6425 use super::*;
6426 use crate::punctuated::Punctuated;
6427-#[cfg(feature = "extra-traits")]
6428-use crate::tt::TokenStreamHelper;
6429+#[cfg(feature = "full")]
6430+use crate::reserved::Reserved;
6431 use proc_macro2::{Span, TokenStream};
6432-#[cfg(feature = "extra-traits")]
6433+#[cfg(feature = "printing")]
6434+use quote::IdentFragment;
6435+#[cfg(feature = "printing")]
6436+use std::fmt::{self, Display};
6437 use std::hash::{Hash, Hasher};
6438-#[cfg(all(feature = "parsing", feature = "full"))]
6439+#[cfg(feature = "parsing")]
6440 use std::mem;
6441
6442 ast_enum_of_structs! {
6443 /// A Rust expression.
6444 ///
6445- /// *This type is available if Syn is built with the `"derive"` or `"full"`
6446- /// feature.*
6447+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
6448+ /// feature, but most of the variants are not available unless "full" is enabled.*
6449 ///
6450 /// # Syntax tree enums
6451 ///
6452 /// This type is a syntax tree enum. In Syn this and other syntax tree enums
6453 /// are designed to be traversed using the following rebinding idiom.
6454 ///
6455 /// ```
6456 /// # use syn::Expr;
6457@@ -78,17 +81,17 @@ ast_enum_of_structs! {
6458 /// if let Expr::Tuple(base) = *discriminant.base {
6459 /// # }
6460 /// # }
6461 /// ```
6462 ///
6463 /// A sign that you may not be choosing the right variable names is if you
6464 /// see names getting repeated in your code, like accessing
6465 /// `receiver.receiver` or `pat.pat` or `cond.cond`.
6466- pub enum Expr #manual_extra_traits {
6467+ pub enum Expr {
6468 /// A slice literal expression: `[a, b, c, d]`.
6469 Array(ExprArray),
6470
6471 /// An assignment expression: `a = compute()`.
6472 Assign(ExprAssign),
6473
6474 /// A compound assignment expression: `counter += 1`.
6475 AssignOp(ExprAssignOp),
6476@@ -223,191 +226,191 @@ ast_enum_of_structs! {
6477 #[doc(hidden)]
6478 __Nonexhaustive,
6479 }
6480 }
6481
6482 ast_struct! {
6483 /// A slice literal expression: `[a, b, c, d]`.
6484 ///
6485- /// *This type is available if Syn is built with the `"full"` feature.*
6486+ /// *This type is available only if Syn is built with the `"full"` feature.*
6487 pub struct ExprArray #full {
6488 pub attrs: Vec<Attribute>,
6489 pub bracket_token: token::Bracket,
6490 pub elems: Punctuated<Expr, Token![,]>,
6491 }
6492 }
6493
6494 ast_struct! {
6495 /// An assignment expression: `a = compute()`.
6496 ///
6497- /// *This type is available if Syn is built with the `"full"` feature.*
6498+ /// *This type is available only if Syn is built with the `"full"` feature.*
6499 pub struct ExprAssign #full {
6500 pub attrs: Vec<Attribute>,
6501 pub left: Box<Expr>,
6502 pub eq_token: Token![=],
6503 pub right: Box<Expr>,
6504 }
6505 }
6506
6507 ast_struct! {
6508 /// A compound assignment expression: `counter += 1`.
6509 ///
6510- /// *This type is available if Syn is built with the `"full"` feature.*
6511+ /// *This type is available only if Syn is built with the `"full"` feature.*
6512 pub struct ExprAssignOp #full {
6513 pub attrs: Vec<Attribute>,
6514 pub left: Box<Expr>,
6515 pub op: BinOp,
6516 pub right: Box<Expr>,
6517 }
6518 }
6519
6520 ast_struct! {
6521 /// An async block: `async { ... }`.
6522 ///
6523- /// *This type is available if Syn is built with the `"full"` feature.*
6524+ /// *This type is available only if Syn is built with the `"full"` feature.*
6525 pub struct ExprAsync #full {
6526 pub attrs: Vec<Attribute>,
6527 pub async_token: Token![async],
6528 pub capture: Option<Token![move]>,
6529 pub block: Block,
6530 }
6531 }
6532
6533 ast_struct! {
6534 /// An await expression: `fut.await`.
6535 ///
6536- /// *This type is available if Syn is built with the `"full"` feature.*
6537+ /// *This type is available only if Syn is built with the `"full"` feature.*
6538 pub struct ExprAwait #full {
6539 pub attrs: Vec<Attribute>,
6540 pub base: Box<Expr>,
6541 pub dot_token: Token![.],
6542 pub await_token: token::Await,
6543 }
6544 }
6545
6546 ast_struct! {
6547 /// A binary operation: `a + b`, `a * b`.
6548 ///
6549- /// *This type is available if Syn is built with the `"derive"` or
6550+ /// *This type is available only if Syn is built with the `"derive"` or
6551 /// `"full"` feature.*
6552 pub struct ExprBinary {
6553 pub attrs: Vec<Attribute>,
6554 pub left: Box<Expr>,
6555 pub op: BinOp,
6556 pub right: Box<Expr>,
6557 }
6558 }
6559
6560 ast_struct! {
6561 /// A blocked scope: `{ ... }`.
6562 ///
6563- /// *This type is available if Syn is built with the `"full"` feature.*
6564+ /// *This type is available only if Syn is built with the `"full"` feature.*
6565 pub struct ExprBlock #full {
6566 pub attrs: Vec<Attribute>,
6567 pub label: Option<Label>,
6568 pub block: Block,
6569 }
6570 }
6571
6572 ast_struct! {
6573 /// A box expression: `box f`.
6574 ///
6575- /// *This type is available if Syn is built with the `"full"` feature.*
6576+ /// *This type is available only if Syn is built with the `"full"` feature.*
6577 pub struct ExprBox #full {
6578 pub attrs: Vec<Attribute>,
6579 pub box_token: Token![box],
6580 pub expr: Box<Expr>,
6581 }
6582 }
6583
6584 ast_struct! {
6585 /// A `break`, with an optional label to break and an optional
6586 /// expression.
6587 ///
6588- /// *This type is available if Syn is built with the `"full"` feature.*
6589+ /// *This type is available only if Syn is built with the `"full"` feature.*
6590 pub struct ExprBreak #full {
6591 pub attrs: Vec<Attribute>,
6592 pub break_token: Token![break],
6593 pub label: Option<Lifetime>,
6594 pub expr: Option<Box<Expr>>,
6595 }
6596 }
6597
6598 ast_struct! {
6599 /// A function call expression: `invoke(a, b)`.
6600 ///
6601- /// *This type is available if Syn is built with the `"derive"` or
6602+ /// *This type is available only if Syn is built with the `"derive"` or
6603 /// `"full"` feature.*
6604 pub struct ExprCall {
6605 pub attrs: Vec<Attribute>,
6606 pub func: Box<Expr>,
6607 pub paren_token: token::Paren,
6608 pub args: Punctuated<Expr, Token![,]>,
6609 }
6610 }
6611
6612 ast_struct! {
6613 /// A cast expression: `foo as f64`.
6614 ///
6615- /// *This type is available if Syn is built with the `"derive"` or
6616+ /// *This type is available only if Syn is built with the `"derive"` or
6617 /// `"full"` feature.*
6618 pub struct ExprCast {
6619 pub attrs: Vec<Attribute>,
6620 pub expr: Box<Expr>,
6621 pub as_token: Token![as],
6622 pub ty: Box<Type>,
6623 }
6624 }
6625
6626 ast_struct! {
6627 /// A closure expression: `|a, b| a + b`.
6628 ///
6629- /// *This type is available if Syn is built with the `"full"` feature.*
6630+ /// *This type is available only if Syn is built with the `"full"` feature.*
6631 pub struct ExprClosure #full {
6632 pub attrs: Vec<Attribute>,
6633 pub asyncness: Option<Token![async]>,
6634 pub movability: Option<Token![static]>,
6635 pub capture: Option<Token![move]>,
6636 pub or1_token: Token![|],
6637 pub inputs: Punctuated<Pat, Token![,]>,
6638 pub or2_token: Token![|],
6639 pub output: ReturnType,
6640 pub body: Box<Expr>,
6641 }
6642 }
6643
6644 ast_struct! {
6645 /// A `continue`, with an optional label.
6646 ///
6647- /// *This type is available if Syn is built with the `"full"` feature.*
6648+ /// *This type is available only if Syn is built with the `"full"` feature.*
6649 pub struct ExprContinue #full {
6650 pub attrs: Vec<Attribute>,
6651 pub continue_token: Token![continue],
6652 pub label: Option<Lifetime>,
6653 }
6654 }
6655
6656 ast_struct! {
6657 /// Access of a named struct field (`obj.k`) or unnamed tuple struct
6658 /// field (`obj.0`).
6659 ///
6660- /// *This type is available if Syn is built with the `"full"` feature.*
6661+ /// *This type is available only if Syn is built with the `"full"` feature.*
6662 pub struct ExprField {
6663 pub attrs: Vec<Attribute>,
6664 pub base: Box<Expr>,
6665 pub dot_token: Token![.],
6666 pub member: Member,
6667 }
6668 }
6669
6670 ast_struct! {
6671 /// A for loop: `for pat in expr { ... }`.
6672 ///
6673- /// *This type is available if Syn is built with the `"full"` feature.*
6674+ /// *This type is available only if Syn is built with the `"full"` feature.*
6675 pub struct ExprForLoop #full {
6676 pub attrs: Vec<Attribute>,
6677 pub label: Option<Label>,
6678 pub for_token: Token![for],
6679 pub pat: Pat,
6680 pub in_token: Token![in],
6681 pub expr: Box<Expr>,
6682 pub body: Block,
6683@@ -416,538 +419,312 @@ ast_struct! {
6684
6685 ast_struct! {
6686 /// An expression contained within invisible delimiters.
6687 ///
6688 /// This variant is important for faithfully representing the precedence
6689 /// of expressions and is related to `None`-delimited spans in a
6690 /// `TokenStream`.
6691 ///
6692- /// *This type is available if Syn is built with the `"full"` feature.*
6693+ /// *This type is available only if Syn is built with the `"full"` feature.*
6694 pub struct ExprGroup #full {
6695 pub attrs: Vec<Attribute>,
6696 pub group_token: token::Group,
6697 pub expr: Box<Expr>,
6698 }
6699 }
6700
6701 ast_struct! {
6702 /// An `if` expression with an optional `else` block: `if expr { ... }
6703 /// else { ... }`.
6704 ///
6705 /// The `else` branch expression may only be an `If` or `Block`
6706 /// expression, not any of the other types of expression.
6707 ///
6708- /// *This type is available if Syn is built with the `"full"` feature.*
6709+ /// *This type is available only if Syn is built with the `"full"` feature.*
6710 pub struct ExprIf #full {
6711 pub attrs: Vec<Attribute>,
6712 pub if_token: Token![if],
6713 pub cond: Box<Expr>,
6714 pub then_branch: Block,
6715 pub else_branch: Option<(Token![else], Box<Expr>)>,
6716 }
6717 }
6718
6719 ast_struct! {
6720 /// A square bracketed indexing expression: `vector[2]`.
6721 ///
6722- /// *This type is available if Syn is built with the `"derive"` or
6723+ /// *This type is available only if Syn is built with the `"derive"` or
6724 /// `"full"` feature.*
6725 pub struct ExprIndex {
6726 pub attrs: Vec<Attribute>,
6727 pub expr: Box<Expr>,
6728 pub bracket_token: token::Bracket,
6729 pub index: Box<Expr>,
6730 }
6731 }
6732
6733 ast_struct! {
6734 /// A `let` guard: `let Some(x) = opt`.
6735 ///
6736- /// *This type is available if Syn is built with the `"full"` feature.*
6737+ /// *This type is available only if Syn is built with the `"full"` feature.*
6738 pub struct ExprLet #full {
6739 pub attrs: Vec<Attribute>,
6740 pub let_token: Token![let],
6741 pub pat: Pat,
6742 pub eq_token: Token![=],
6743 pub expr: Box<Expr>,
6744 }
6745 }
6746
6747 ast_struct! {
6748 /// A literal in place of an expression: `1`, `"foo"`.
6749 ///
6750- /// *This type is available if Syn is built with the `"derive"` or
6751+ /// *This type is available only if Syn is built with the `"derive"` or
6752 /// `"full"` feature.*
6753 pub struct ExprLit {
6754 pub attrs: Vec<Attribute>,
6755 pub lit: Lit,
6756 }
6757 }
6758
6759 ast_struct! {
6760 /// Conditionless loop: `loop { ... }`.
6761 ///
6762- /// *This type is available if Syn is built with the `"full"` feature.*
6763+ /// *This type is available only if Syn is built with the `"full"` feature.*
6764 pub struct ExprLoop #full {
6765 pub attrs: Vec<Attribute>,
6766 pub label: Option<Label>,
6767 pub loop_token: Token![loop],
6768 pub body: Block,
6769 }
6770 }
6771
6772 ast_struct! {
6773 /// A macro invocation expression: `format!("{}", q)`.
6774 ///
6775- /// *This type is available if Syn is built with the `"full"` feature.*
6776+ /// *This type is available only if Syn is built with the `"full"` feature.*
6777 pub struct ExprMacro #full {
6778 pub attrs: Vec<Attribute>,
6779 pub mac: Macro,
6780 }
6781 }
6782
6783 ast_struct! {
6784 /// A `match` expression: `match n { Some(n) => {}, None => {} }`.
6785 ///
6786- /// *This type is available if Syn is built with the `"full"` feature.*
6787+ /// *This type is available only if Syn is built with the `"full"` feature.*
6788 pub struct ExprMatch #full {
6789 pub attrs: Vec<Attribute>,
6790 pub match_token: Token![match],
6791 pub expr: Box<Expr>,
6792 pub brace_token: token::Brace,
6793 pub arms: Vec<Arm>,
6794 }
6795 }
6796
6797 ast_struct! {
6798 /// A method call expression: `x.foo::<T>(a, b)`.
6799 ///
6800- /// *This type is available if Syn is built with the `"full"` feature.*
6801+ /// *This type is available only if Syn is built with the `"full"` feature.*
6802 pub struct ExprMethodCall #full {
6803 pub attrs: Vec<Attribute>,
6804 pub receiver: Box<Expr>,
6805 pub dot_token: Token![.],
6806 pub method: Ident,
6807 pub turbofish: Option<MethodTurbofish>,
6808 pub paren_token: token::Paren,
6809 pub args: Punctuated<Expr, Token![,]>,
6810 }
6811 }
6812
6813 ast_struct! {
6814 /// A parenthesized expression: `(a + b)`.
6815 ///
6816- /// *This type is available if Syn is built with the `"full"` feature.*
6817+ /// *This type is available only if Syn is built with the `"full"` feature.*
6818 pub struct ExprParen {
6819 pub attrs: Vec<Attribute>,
6820 pub paren_token: token::Paren,
6821 pub expr: Box<Expr>,
6822 }
6823 }
6824
6825 ast_struct! {
6826 /// A path like `std::mem::replace` possibly containing generic
6827 /// parameters and a qualified self-type.
6828 ///
6829 /// A plain identifier like `x` is a path of length 1.
6830 ///
6831- /// *This type is available if Syn is built with the `"derive"` or
6832+ /// *This type is available only if Syn is built with the `"derive"` or
6833 /// `"full"` feature.*
6834 pub struct ExprPath {
6835 pub attrs: Vec<Attribute>,
6836 pub qself: Option<QSelf>,
6837 pub path: Path,
6838 }
6839 }
6840
6841 ast_struct! {
6842 /// A range expression: `1..2`, `1..`, `..2`, `1..=2`, `..=2`.
6843 ///
6844- /// *This type is available if Syn is built with the `"full"` feature.*
6845+ /// *This type is available only if Syn is built with the `"full"` feature.*
6846 pub struct ExprRange #full {
6847 pub attrs: Vec<Attribute>,
6848 pub from: Option<Box<Expr>>,
6849 pub limits: RangeLimits,
6850 pub to: Option<Box<Expr>>,
6851 }
6852 }
6853
6854 ast_struct! {
6855 /// A referencing operation: `&a` or `&mut a`.
6856 ///
6857- /// *This type is available if Syn is built with the `"full"` feature.*
6858+ /// *This type is available only if Syn is built with the `"full"` feature.*
6859 pub struct ExprReference #full {
6860 pub attrs: Vec<Attribute>,
6861 pub and_token: Token![&],
6862 pub raw: Reserved,
6863 pub mutability: Option<Token![mut]>,
6864 pub expr: Box<Expr>,
6865 }
6866 }
6867
6868 ast_struct! {
6869 /// An array literal constructed from one repeated element: `[0u8; N]`.
6870 ///
6871- /// *This type is available if Syn is built with the `"full"` feature.*
6872+ /// *This type is available only if Syn is built with the `"full"` feature.*
6873 pub struct ExprRepeat #full {
6874 pub attrs: Vec<Attribute>,
6875 pub bracket_token: token::Bracket,
6876 pub expr: Box<Expr>,
6877 pub semi_token: Token![;],
6878 pub len: Box<Expr>,
6879 }
6880 }
6881
6882 ast_struct! {
6883 /// A `return`, with an optional value to be returned.
6884 ///
6885- /// *This type is available if Syn is built with the `"full"` feature.*
6886+ /// *This type is available only if Syn is built with the `"full"` feature.*
6887 pub struct ExprReturn #full {
6888 pub attrs: Vec<Attribute>,
6889 pub return_token: Token![return],
6890 pub expr: Option<Box<Expr>>,
6891 }
6892 }
6893
6894 ast_struct! {
6895 /// A struct literal expression: `Point { x: 1, y: 1 }`.
6896 ///
6897 /// The `rest` provides the value of the remaining fields as in `S { a:
6898 /// 1, b: 1, ..rest }`.
6899 ///
6900- /// *This type is available if Syn is built with the `"full"` feature.*
6901+ /// *This type is available only if Syn is built with the `"full"` feature.*
6902 pub struct ExprStruct #full {
6903 pub attrs: Vec<Attribute>,
6904 pub path: Path,
6905 pub brace_token: token::Brace,
6906 pub fields: Punctuated<FieldValue, Token![,]>,
6907 pub dot2_token: Option<Token![..]>,
6908 pub rest: Option<Box<Expr>>,
6909 }
6910 }
6911
6912 ast_struct! {
6913 /// A try-expression: `expr?`.
6914 ///
6915- /// *This type is available if Syn is built with the `"full"` feature.*
6916+ /// *This type is available only if Syn is built with the `"full"` feature.*
6917 pub struct ExprTry #full {
6918 pub attrs: Vec<Attribute>,
6919 pub expr: Box<Expr>,
6920 pub question_token: Token![?],
6921 }
6922 }
6923
6924 ast_struct! {
6925 /// A try block: `try { ... }`.
6926 ///
6927- /// *This type is available if Syn is built with the `"full"` feature.*
6928+ /// *This type is available only if Syn is built with the `"full"` feature.*
6929 pub struct ExprTryBlock #full {
6930 pub attrs: Vec<Attribute>,
6931 pub try_token: Token![try],
6932 pub block: Block,
6933 }
6934 }
6935
6936 ast_struct! {
6937 /// A tuple expression: `(a, b, c, d)`.
6938 ///
6939- /// *This type is available if Syn is built with the `"full"` feature.*
6940+ /// *This type is available only if Syn is built with the `"full"` feature.*
6941 pub struct ExprTuple #full {
6942 pub attrs: Vec<Attribute>,
6943 pub paren_token: token::Paren,
6944 pub elems: Punctuated<Expr, Token![,]>,
6945 }
6946 }
6947
6948 ast_struct! {
6949 /// A type ascription expression: `foo: f64`.
6950 ///
6951- /// *This type is available if Syn is built with the `"full"` feature.*
6952+ /// *This type is available only if Syn is built with the `"full"` feature.*
6953 pub struct ExprType #full {
6954 pub attrs: Vec<Attribute>,
6955 pub expr: Box<Expr>,
6956 pub colon_token: Token![:],
6957 pub ty: Box<Type>,
6958 }
6959 }
6960
6961 ast_struct! {
6962 /// A unary operation: `!x`, `*x`.
6963 ///
6964- /// *This type is available if Syn is built with the `"derive"` or
6965+ /// *This type is available only if Syn is built with the `"derive"` or
6966 /// `"full"` feature.*
6967 pub struct ExprUnary {
6968 pub attrs: Vec<Attribute>,
6969 pub op: UnOp,
6970 pub expr: Box<Expr>,
6971 }
6972 }
6973
6974 ast_struct! {
6975 /// An unsafe block: `unsafe { ... }`.
6976 ///
6977- /// *This type is available if Syn is built with the `"full"` feature.*
6978+ /// *This type is available only if Syn is built with the `"full"` feature.*
6979 pub struct ExprUnsafe #full {
6980 pub attrs: Vec<Attribute>,
6981 pub unsafe_token: Token![unsafe],
6982 pub block: Block,
6983 }
6984 }
6985
6986 ast_struct! {
6987 /// A while loop: `while expr { ... }`.
6988 ///
6989- /// *This type is available if Syn is built with the `"full"` feature.*
6990+ /// *This type is available only if Syn is built with the `"full"` feature.*
6991 pub struct ExprWhile #full {
6992 pub attrs: Vec<Attribute>,
6993 pub label: Option<Label>,
6994 pub while_token: Token![while],
6995 pub cond: Box<Expr>,
6996 pub body: Block,
6997 }
6998 }
6999
7000 ast_struct! {
7001 /// A yield expression: `yield expr`.
7002 ///
7003- /// *This type is available if Syn is built with the `"full"` feature.*
7004+ /// *This type is available only if Syn is built with the `"full"` feature.*
7005 pub struct ExprYield #full {
7006 pub attrs: Vec<Attribute>,
7007 pub yield_token: Token![yield],
7008 pub expr: Option<Box<Expr>>,
7009 }
7010 }
7011
7012-#[cfg(feature = "extra-traits")]
7013-impl Eq for Expr {}
7014-
7015-#[cfg(feature = "extra-traits")]
7016-impl PartialEq for Expr {
7017- fn eq(&self, other: &Self) -> bool {
7018- match (self, other) {
7019- (Expr::Array(this), Expr::Array(other)) => this == other,
7020- (Expr::Assign(this), Expr::Assign(other)) => this == other,
7021- (Expr::AssignOp(this), Expr::AssignOp(other)) => this == other,
7022- (Expr::Async(this), Expr::Async(other)) => this == other,
7023- (Expr::Await(this), Expr::Await(other)) => this == other,
7024- (Expr::Binary(this), Expr::Binary(other)) => this == other,
7025- (Expr::Block(this), Expr::Block(other)) => this == other,
7026- (Expr::Box(this), Expr::Box(other)) => this == other,
7027- (Expr::Break(this), Expr::Break(other)) => this == other,
7028- (Expr::Call(this), Expr::Call(other)) => this == other,
7029- (Expr::Cast(this), Expr::Cast(other)) => this == other,
7030- (Expr::Closure(this), Expr::Closure(other)) => this == other,
7031- (Expr::Continue(this), Expr::Continue(other)) => this == other,
7032- (Expr::Field(this), Expr::Field(other)) => this == other,
7033- (Expr::ForLoop(this), Expr::ForLoop(other)) => this == other,
7034- (Expr::Group(this), Expr::Group(other)) => this == other,
7035- (Expr::If(this), Expr::If(other)) => this == other,
7036- (Expr::Index(this), Expr::Index(other)) => this == other,
7037- (Expr::Let(this), Expr::Let(other)) => this == other,
7038- (Expr::Lit(this), Expr::Lit(other)) => this == other,
7039- (Expr::Loop(this), Expr::Loop(other)) => this == other,
7040- (Expr::Macro(this), Expr::Macro(other)) => this == other,
7041- (Expr::Match(this), Expr::Match(other)) => this == other,
7042- (Expr::MethodCall(this), Expr::MethodCall(other)) => this == other,
7043- (Expr::Paren(this), Expr::Paren(other)) => this == other,
7044- (Expr::Path(this), Expr::Path(other)) => this == other,
7045- (Expr::Range(this), Expr::Range(other)) => this == other,
7046- (Expr::Reference(this), Expr::Reference(other)) => this == other,
7047- (Expr::Repeat(this), Expr::Repeat(other)) => this == other,
7048- (Expr::Return(this), Expr::Return(other)) => this == other,
7049- (Expr::Struct(this), Expr::Struct(other)) => this == other,
7050- (Expr::Try(this), Expr::Try(other)) => this == other,
7051- (Expr::TryBlock(this), Expr::TryBlock(other)) => this == other,
7052- (Expr::Tuple(this), Expr::Tuple(other)) => this == other,
7053- (Expr::Type(this), Expr::Type(other)) => this == other,
7054- (Expr::Unary(this), Expr::Unary(other)) => this == other,
7055- (Expr::Unsafe(this), Expr::Unsafe(other)) => this == other,
7056- (Expr::Verbatim(this), Expr::Verbatim(other)) => {
7057- TokenStreamHelper(this) == TokenStreamHelper(other)
7058- }
7059- (Expr::While(this), Expr::While(other)) => this == other,
7060- (Expr::Yield(this), Expr::Yield(other)) => this == other,
7061- _ => false,
7062- }
7063- }
7064-}
7065-
7066-#[cfg(feature = "extra-traits")]
7067-impl Hash for Expr {
7068- fn hash<H>(&self, hash: &mut H)
7069- where
7070- H: Hasher,
7071- {
7072- match self {
7073- Expr::Array(expr) => {
7074- hash.write_u8(0);
7075- expr.hash(hash);
7076- }
7077- Expr::Assign(expr) => {
7078- hash.write_u8(1);
7079- expr.hash(hash);
7080- }
7081- Expr::AssignOp(expr) => {
7082- hash.write_u8(2);
7083- expr.hash(hash);
7084- }
7085- Expr::Async(expr) => {
7086- hash.write_u8(3);
7087- expr.hash(hash);
7088- }
7089- Expr::Await(expr) => {
7090- hash.write_u8(4);
7091- expr.hash(hash);
7092- }
7093- Expr::Binary(expr) => {
7094- hash.write_u8(5);
7095- expr.hash(hash);
7096- }
7097- Expr::Block(expr) => {
7098- hash.write_u8(6);
7099- expr.hash(hash);
7100- }
7101- Expr::Box(expr) => {
7102- hash.write_u8(7);
7103- expr.hash(hash);
7104- }
7105- Expr::Break(expr) => {
7106- hash.write_u8(8);
7107- expr.hash(hash);
7108- }
7109- Expr::Call(expr) => {
7110- hash.write_u8(9);
7111- expr.hash(hash);
7112- }
7113- Expr::Cast(expr) => {
7114- hash.write_u8(10);
7115- expr.hash(hash);
7116- }
7117- Expr::Closure(expr) => {
7118- hash.write_u8(11);
7119- expr.hash(hash);
7120- }
7121- Expr::Continue(expr) => {
7122- hash.write_u8(12);
7123- expr.hash(hash);
7124- }
7125- Expr::Field(expr) => {
7126- hash.write_u8(13);
7127- expr.hash(hash);
7128- }
7129- Expr::ForLoop(expr) => {
7130- hash.write_u8(14);
7131- expr.hash(hash);
7132- }
7133- Expr::Group(expr) => {
7134- hash.write_u8(15);
7135- expr.hash(hash);
7136- }
7137- Expr::If(expr) => {
7138- hash.write_u8(16);
7139- expr.hash(hash);
7140- }
7141- Expr::Index(expr) => {
7142- hash.write_u8(17);
7143- expr.hash(hash);
7144- }
7145- Expr::Let(expr) => {
7146- hash.write_u8(18);
7147- expr.hash(hash);
7148- }
7149- Expr::Lit(expr) => {
7150- hash.write_u8(19);
7151- expr.hash(hash);
7152- }
7153- Expr::Loop(expr) => {
7154- hash.write_u8(20);
7155- expr.hash(hash);
7156- }
7157- Expr::Macro(expr) => {
7158- hash.write_u8(21);
7159- expr.hash(hash);
7160- }
7161- Expr::Match(expr) => {
7162- hash.write_u8(22);
7163- expr.hash(hash);
7164- }
7165- Expr::MethodCall(expr) => {
7166- hash.write_u8(23);
7167- expr.hash(hash);
7168- }
7169- Expr::Paren(expr) => {
7170- hash.write_u8(24);
7171- expr.hash(hash);
7172- }
7173- Expr::Path(expr) => {
7174- hash.write_u8(25);
7175- expr.hash(hash);
7176- }
7177- Expr::Range(expr) => {
7178- hash.write_u8(26);
7179- expr.hash(hash);
7180- }
7181- Expr::Reference(expr) => {
7182- hash.write_u8(27);
7183- expr.hash(hash);
7184- }
7185- Expr::Repeat(expr) => {
7186- hash.write_u8(28);
7187- expr.hash(hash);
7188- }
7189- Expr::Return(expr) => {
7190- hash.write_u8(29);
7191- expr.hash(hash);
7192- }
7193- Expr::Struct(expr) => {
7194- hash.write_u8(30);
7195- expr.hash(hash);
7196- }
7197- Expr::Try(expr) => {
7198- hash.write_u8(31);
7199- expr.hash(hash);
7200- }
7201- Expr::TryBlock(expr) => {
7202- hash.write_u8(32);
7203- expr.hash(hash);
7204- }
7205- Expr::Tuple(expr) => {
7206- hash.write_u8(33);
7207- expr.hash(hash);
7208- }
7209- Expr::Type(expr) => {
7210- hash.write_u8(34);
7211- expr.hash(hash);
7212- }
7213- Expr::Unary(expr) => {
7214- hash.write_u8(35);
7215- expr.hash(hash);
7216- }
7217- Expr::Unsafe(expr) => {
7218- hash.write_u8(36);
7219- expr.hash(hash);
7220- }
7221- Expr::Verbatim(expr) => {
7222- hash.write_u8(37);
7223- TokenStreamHelper(expr).hash(hash);
7224- }
7225- Expr::While(expr) => {
7226- hash.write_u8(38);
7227- expr.hash(hash);
7228- }
7229- Expr::Yield(expr) => {
7230- hash.write_u8(39);
7231- expr.hash(hash);
7232- }
7233- Expr::__Nonexhaustive => unreachable!(),
7234- }
7235- }
7236-}
7237-
7238 impl Expr {
7239 #[cfg(all(feature = "parsing", feature = "full"))]
7240 pub(crate) fn replace_attrs(&mut self, new: Vec<Attribute>) -> Vec<Attribute> {
7241 match self {
7242 Expr::Box(ExprBox { attrs, .. })
7243 | Expr::Array(ExprArray { attrs, .. })
7244 | Expr::Call(ExprCall { attrs, .. })
7245 | Expr::MethodCall(ExprMethodCall { attrs, .. })
7246@@ -991,107 +768,145 @@ impl Expr {
7247 }
7248 }
7249 }
7250
7251 ast_enum! {
7252 /// A struct or tuple struct field accessed in a struct literal or field
7253 /// expression.
7254 ///
7255- /// *This type is available if Syn is built with the `"derive"` or `"full"`
7256+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
7257 /// feature.*
7258 pub enum Member {
7259 /// A named field like `self.x`.
7260 Named(Ident),
7261 /// An unnamed field like `self.0`.
7262 Unnamed(Index),
7263 }
7264 }
7265
7266+impl Eq for Member {}
7267+
7268+impl PartialEq for Member {
7269+ fn eq(&self, other: &Self) -> bool {
7270+ match (self, other) {
7271+ (Member::Named(this), Member::Named(other)) => this == other,
7272+ (Member::Unnamed(this), Member::Unnamed(other)) => this == other,
7273+ _ => false,
7274+ }
7275+ }
7276+}
7277+
7278+impl Hash for Member {
7279+ fn hash<H: Hasher>(&self, state: &mut H) {
7280+ match self {
7281+ Member::Named(m) => m.hash(state),
7282+ Member::Unnamed(m) => m.hash(state),
7283+ }
7284+ }
7285+}
7286+
7287+#[cfg(feature = "printing")]
7288+impl IdentFragment for Member {
7289+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
7290+ match self {
7291+ Member::Named(m) => Display::fmt(m, formatter),
7292+ Member::Unnamed(m) => Display::fmt(&m.index, formatter),
7293+ }
7294+ }
7295+
7296+ fn span(&self) -> Option<Span> {
7297+ match self {
7298+ Member::Named(m) => Some(m.span()),
7299+ Member::Unnamed(m) => Some(m.span),
7300+ }
7301+ }
7302+}
7303+
7304 ast_struct! {
7305 /// The index of an unnamed tuple struct field.
7306 ///
7307- /// *This type is available if Syn is built with the `"derive"` or `"full"`
7308+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
7309 /// feature.*
7310- pub struct Index #manual_extra_traits {
7311+ pub struct Index {
7312 pub index: u32,
7313 pub span: Span,
7314 }
7315 }
7316
7317 impl From<usize> for Index {
7318 fn from(index: usize) -> Index {
7319 assert!(index < u32::max_value() as usize);
7320 Index {
7321 index: index as u32,
7322 span: Span::call_site(),
7323 }
7324 }
7325 }
7326
7327-#[cfg(feature = "extra-traits")]
7328 impl Eq for Index {}
7329
7330-#[cfg(feature = "extra-traits")]
7331 impl PartialEq for Index {
7332 fn eq(&self, other: &Self) -> bool {
7333 self.index == other.index
7334 }
7335 }
7336
7337-#[cfg(feature = "extra-traits")]
7338 impl Hash for Index {
7339 fn hash<H: Hasher>(&self, state: &mut H) {
7340 self.index.hash(state);
7341 }
7342 }
7343
7344-#[cfg(feature = "full")]
7345-ast_struct! {
7346- #[derive(Default)]
7347- pub struct Reserved {
7348- private: (),
7349+#[cfg(feature = "printing")]
7350+impl IdentFragment for Index {
7351+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
7352+ Display::fmt(&self.index, formatter)
7353+ }
7354+
7355+ fn span(&self) -> Option<Span> {
7356+ Some(self.span)
7357 }
7358 }
7359
7360 #[cfg(feature = "full")]
7361 ast_struct! {
7362 /// The `::<>` explicit type parameters passed to a method call:
7363 /// `parse::<u64>()`.
7364 ///
7365- /// *This type is available if Syn is built with the `"full"` feature.*
7366+ /// *This type is available only if Syn is built with the `"full"` feature.*
7367 pub struct MethodTurbofish {
7368 pub colon2_token: Token![::],
7369 pub lt_token: Token![<],
7370 pub args: Punctuated<GenericMethodArgument, Token![,]>,
7371 pub gt_token: Token![>],
7372 }
7373 }
7374
7375 #[cfg(feature = "full")]
7376 ast_enum! {
7377 /// An individual generic argument to a method, like `T`.
7378 ///
7379- /// *This type is available if Syn is built with the `"full"` feature.*
7380+ /// *This type is available only if Syn is built with the `"full"` feature.*
7381 pub enum GenericMethodArgument {
7382 /// A type argument.
7383 Type(Type),
7384 /// A const expression. Must be inside of a block.
7385 ///
7386 /// NOTE: Identity expressions are represented as Type arguments, as
7387 /// they are indistinguishable syntactically.
7388 Const(Expr),
7389 }
7390 }
7391
7392 #[cfg(feature = "full")]
7393 ast_struct! {
7394 /// A field-value pair in a struct literal.
7395 ///
7396- /// *This type is available if Syn is built with the `"full"` feature.*
7397+ /// *This type is available only if Syn is built with the `"full"` feature.*
7398 pub struct FieldValue {
7399 /// Attributes tagged on the field.
7400 pub attrs: Vec<Attribute>,
7401
7402 /// Name or index of the field.
7403 pub member: Member,
7404
7405 /// The colon in `Struct { x: x }`. If written in shorthand like
7406@@ -1102,17 +917,17 @@ ast_struct! {
7407 pub expr: Expr,
7408 }
7409 }
7410
7411 #[cfg(feature = "full")]
7412 ast_struct! {
7413 /// A lifetime labeling a `for`, `while`, or `loop`.
7414 ///
7415- /// *This type is available if Syn is built with the `"full"` feature.*
7416+ /// *This type is available only if Syn is built with the `"full"` feature.*
7417 pub struct Label {
7418 pub name: Lifetime,
7419 pub colon_token: Token![:],
7420 }
7421 }
7422
7423 #[cfg(feature = "full")]
7424 ast_struct! {
7425@@ -1129,45 +944,44 @@ ast_struct! {
7426 /// }
7427 /// // ...
7428 /// # _ => {}
7429 /// }
7430 /// # false
7431 /// # }
7432 /// ```
7433 ///
7434- /// *This type is available if Syn is built with the `"full"` feature.*
7435+ /// *This type is available only if Syn is built with the `"full"` feature.*
7436 pub struct Arm {
7437 pub attrs: Vec<Attribute>,
7438 pub pat: Pat,
7439 pub guard: Option<(Token![if], Box<Expr>)>,
7440 pub fat_arrow_token: Token![=>],
7441 pub body: Box<Expr>,
7442 pub comma: Option<Token![,]>,
7443 }
7444 }
7445
7446 #[cfg(feature = "full")]
7447 ast_enum! {
7448 /// Limit types of a range, inclusive or exclusive.
7449 ///
7450- /// *This type is available if Syn is built with the `"full"` feature.*
7451- #[cfg_attr(feature = "clone-impls", derive(Copy))]
7452+ /// *This type is available only if Syn is built with the `"full"` feature.*
7453 pub enum RangeLimits {
7454 /// Inclusive at the beginning, exclusive at the end.
7455 HalfOpen(Token![..]),
7456 /// Inclusive at the beginning and end.
7457 Closed(Token![..=]),
7458 }
7459 }
7460
7461 #[cfg(any(feature = "parsing", feature = "printing"))]
7462 #[cfg(feature = "full")]
7463 pub(crate) fn requires_terminator(expr: &Expr) -> bool {
7464- // see https://github.com/rust-lang/rust/blob/eb8f2586e/src/libsyntax/parse/classify.rs#L17-L37
7465+ // see https://github.com/rust-lang/rust/blob/2679c38fc/src/librustc_ast/util/classify.rs#L7-L25
7466 match *expr {
7467 Expr::Unsafe(..)
7468 | Expr::Block(..)
7469 | Expr::If(..)
7470 | Expr::Match(..)
7471 | Expr::While(..)
7472 | Expr::Loop(..)
7473 | Expr::ForLoop(..)
7474@@ -1178,26 +992,27 @@ pub(crate) fn requires_terminator(expr:
7475 }
7476
7477 #[cfg(feature = "parsing")]
7478 pub(crate) mod parsing {
7479 use super::*;
7480
7481 use crate::parse::{Parse, ParseStream, Result};
7482 use crate::path;
7483+ use std::cmp::Ordering;
7484+
7485+ crate::custom_keyword!(raw);
7486
7487 // When we're parsing expressions which occur before blocks, like in an if
7488 // statement's condition, we cannot parse a struct literal.
7489 //
7490 // Struct literals are ambiguous in certain positions
7491 // https://github.com/rust-lang/rfcs/pull/92
7492- #[derive(Copy, Clone)]
7493 pub struct AllowStruct(bool);
7494
7495- #[derive(Copy, Clone, PartialEq, PartialOrd)]
7496 enum Precedence {
7497 Any,
7498 Assign,
7499 Range,
7500 Or,
7501 And,
7502 Compare,
7503 BitOr,
7504@@ -1241,19 +1056,131 @@ pub(crate) mod parsing {
7505 }
7506
7507 impl Parse for Expr {
7508 fn parse(input: ParseStream) -> Result<Self> {
7509 ambiguous_expr(input, AllowStruct(true))
7510 }
7511 }
7512
7513- #[cfg(feature = "full")]
7514- fn expr_no_struct(input: ParseStream) -> Result<Expr> {
7515- ambiguous_expr(input, AllowStruct(false))
7516+ impl Expr {
7517+ /// An alternative to the primary `Expr::parse` parser (from the
7518+ /// [`Parse`] trait) for ambiguous syntactic positions in which a
7519+ /// trailing brace should not be taken as part of the expression.
7520+ ///
7521+ /// Rust grammar has an ambiguity where braces sometimes turn a path
7522+ /// expression into a struct initialization and sometimes do not. In the
7523+ /// following code, the expression `S {}` is one expression. Presumably
7524+ /// there is an empty struct `struct S {}` defined somewhere which it is
7525+ /// instantiating.
7526+ ///
7527+ /// ```
7528+ /// # struct S;
7529+ /// # impl std::ops::Deref for S {
7530+ /// # type Target = bool;
7531+ /// # fn deref(&self) -> &Self::Target {
7532+ /// # &true
7533+ /// # }
7534+ /// # }
7535+ /// let _ = *S {};
7536+ ///
7537+ /// // parsed by rustc as: `*(S {})`
7538+ /// ```
7539+ ///
7540+ /// We would want to parse the above using `Expr::parse` after the `=`
7541+ /// token.
7542+ ///
7543+ /// But in the following, `S {}` is *not* a struct init expression.
7544+ ///
7545+ /// ```
7546+ /// # const S: &bool = &true;
7547+ /// if *S {} {}
7548+ ///
7549+ /// // parsed by rustc as:
7550+ /// //
7551+ /// // if (*S) {
7552+ /// // /* empty block */
7553+ /// // }
7554+ /// // {
7555+ /// // /* another empty block */
7556+ /// // }
7557+ /// ```
7558+ ///
7559+ /// For that reason we would want to parse if-conditions using
7560+ /// `Expr::parse_without_eager_brace` after the `if` token. Same for
7561+ /// similar syntactic positions such as the condition expr after a
7562+ /// `while` token or the expr at the top of a `match`.
7563+ ///
7564+ /// The Rust grammar's choices around which way this ambiguity is
7565+ /// resolved at various syntactic positions is fairly arbitrary. Really
7566+ /// either parse behavior could work in most positions, and language
7567+ /// designers just decide each case based on which is more likely to be
7568+ /// what the programmer had in mind most of the time.
7569+ ///
7570+ /// ```
7571+ /// # struct S;
7572+ /// # fn doc() -> S {
7573+ /// if return S {} {}
7574+ /// # unreachable!()
7575+ /// # }
7576+ ///
7577+ /// // parsed by rustc as:
7578+ /// //
7579+ /// // if (return (S {})) {
7580+ /// // }
7581+ /// //
7582+ /// // but could equally well have been this other arbitrary choice:
7583+ /// //
7584+ /// // if (return S) {
7585+ /// // }
7586+ /// // {}
7587+ /// ```
7588+ ///
7589+ /// Note the grammar ambiguity on trailing braces is distinct from
7590+ /// precedence and is not captured by assigning a precedence level to
7591+ /// the braced struct init expr in relation to other operators. This can
7592+ /// be illustrated by `return 0..S {}` vs `match 0..S {}`. The former
7593+ /// parses as `return (0..(S {}))` implying tighter precedence for
7594+ /// struct init than `..`, while the latter parses as `match (0..S) {}`
7595+ /// implying tighter precedence for `..` than struct init, a
7596+ /// contradiction.
7597+ #[cfg(feature = "full")]
7598+ pub fn parse_without_eager_brace(input: ParseStream) -> Result<Expr> {
7599+ ambiguous_expr(input, AllowStruct(false))
7600+ }
7601+ }
7602+
7603+ impl Copy for AllowStruct {}
7604+
7605+ impl Clone for AllowStruct {
7606+ fn clone(&self) -> Self {
7607+ *self
7608+ }
7609+ }
7610+
7611+ impl Copy for Precedence {}
7612+
7613+ impl Clone for Precedence {
7614+ fn clone(&self) -> Self {
7615+ *self
7616+ }
7617+ }
7618+
7619+ impl PartialEq for Precedence {
7620+ fn eq(&self, other: &Self) -> bool {
7621+ *self as u8 == *other as u8
7622+ }
7623+ }
7624+
7625+ impl PartialOrd for Precedence {
7626+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
7627+ let this = *self as u8;
7628+ let other = *other as u8;
7629+ Some(this.cmp(&other))
7630+ }
7631 }
7632
7633 #[cfg(feature = "full")]
7634 fn parse_expr(
7635 input: ParseStream,
7636 mut lhs: Expr,
7637 allow_struct: AllowStruct,
7638 base: Precedence,
7639@@ -1425,88 +1352,114 @@ pub(crate) mod parsing {
7640 }
7641
7642 // Parse an arbitrary expression.
7643 fn ambiguous_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
7644 let lhs = unary_expr(input, allow_struct)?;
7645 parse_expr(input, lhs, allow_struct, Precedence::Any)
7646 }
7647
7648+ #[cfg(feature = "full")]
7649+ fn expr_attrs(input: ParseStream) -> Result<Vec<Attribute>> {
7650+ let mut attrs = Vec::new();
7651+ loop {
7652+ if input.peek(token::Group) {
7653+ let ahead = input.fork();
7654+ let group = crate::group::parse_group(&ahead)?;
7655+ if !group.content.peek(Token![#]) || group.content.peek2(Token![!]) {
7656+ break;
7657+ }
7658+ let attr = group.content.call(attr::parsing::single_parse_outer)?;
7659+ if !group.content.is_empty() {
7660+ break;
7661+ }
7662+ attrs.push(attr);
7663+ } else if input.peek(Token![#]) {
7664+ attrs.push(input.call(attr::parsing::single_parse_outer)?);
7665+ } else {
7666+ break;
7667+ }
7668+ }
7669+ Ok(attrs)
7670+ }
7671+
7672 // <UnOp> <trailer>
7673 // & <trailer>
7674 // &mut <trailer>
7675 // box <trailer>
7676 #[cfg(feature = "full")]
7677 fn unary_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
7678- // TODO: optimize using advance_to
7679- let ahead = input.fork();
7680- ahead.call(Attribute::parse_outer)?;
7681- if ahead.peek(Token![&])
7682- || ahead.peek(Token![box])
7683- || ahead.peek(Token![*])
7684- || ahead.peek(Token![!])
7685- || ahead.peek(Token![-])
7686- {
7687- let attrs = input.call(Attribute::parse_outer)?;
7688- if input.peek(Token![&]) {
7689+ let begin = input.fork();
7690+ let attrs = input.call(expr_attrs)?;
7691+ if input.peek(Token![&]) {
7692+ let and_token: Token![&] = input.parse()?;
7693+ let raw: Option<raw> =
7694+ if input.peek(raw) && (input.peek2(Token![mut]) || input.peek2(Token![const])) {
7695+ Some(input.parse()?)
7696+ } else {
7697+ None
7698+ };
7699+ let mutability: Option<Token![mut]> = input.parse()?;
7700+ if raw.is_some() && mutability.is_none() {
7701+ input.parse::<Token![const]>()?;
7702+ }
7703+ let expr = Box::new(unary_expr(input, allow_struct)?);
7704+ if raw.is_some() {
7705+ Ok(Expr::Verbatim(verbatim::between(begin, input)))
7706+ } else {
7707 Ok(Expr::Reference(ExprReference {
7708 attrs,
7709- and_token: input.parse()?,
7710+ and_token,
7711 raw: Reserved::default(),
7712- mutability: input.parse()?,
7713- expr: Box::new(unary_expr(input, allow_struct)?),
7714- }))
7715- } else if input.peek(Token![box]) {
7716- Ok(Expr::Box(ExprBox {
7717- attrs,
7718- box_token: input.parse()?,
7719- expr: Box::new(unary_expr(input, allow_struct)?),
7720- }))
7721- } else {
7722- Ok(Expr::Unary(ExprUnary {
7723- attrs,
7724- op: input.parse()?,
7725- expr: Box::new(unary_expr(input, allow_struct)?),
7726+ mutability,
7727+ expr,
7728 }))
7729 }
7730+ } else if input.peek(Token![box]) {
7731+ Ok(Expr::Box(ExprBox {
7732+ attrs,
7733+ box_token: input.parse()?,
7734+ expr: Box::new(unary_expr(input, allow_struct)?),
7735+ }))
7736+ } else if input.peek(Token![*]) || input.peek(Token![!]) || input.peek(Token![-]) {
7737+ Ok(Expr::Unary(ExprUnary {
7738+ attrs,
7739+ op: input.parse()?,
7740+ expr: Box::new(unary_expr(input, allow_struct)?),
7741+ }))
7742 } else {
7743- trailer_expr(input, allow_struct)
7744+ trailer_expr(attrs, input, allow_struct)
7745 }
7746 }
7747
7748 #[cfg(not(feature = "full"))]
7749 fn unary_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
7750- // TODO: optimize using advance_to
7751- let ahead = input.fork();
7752- ahead.call(Attribute::parse_outer)?;
7753- if ahead.peek(Token![*]) || ahead.peek(Token![!]) || ahead.peek(Token![-]) {
7754+ if input.peek(Token![*]) || input.peek(Token![!]) || input.peek(Token![-]) {
7755 Ok(Expr::Unary(ExprUnary {
7756- attrs: input.call(Attribute::parse_outer)?,
7757+ attrs: Vec::new(),
7758 op: input.parse()?,
7759 expr: Box::new(unary_expr(input, allow_struct)?),
7760 }))
7761 } else {
7762 trailer_expr(input, allow_struct)
7763 }
7764 }
7765
7766 // <atom> (..<args>) ...
7767 // <atom> . <ident> (..<args>) ...
7768 // <atom> . <ident> ...
7769 // <atom> . <lit> ...
7770 // <atom> [ <expr> ] ...
7771 // <atom> ? ...
7772 #[cfg(feature = "full")]
7773- fn trailer_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
7774- if input.peek(token::Group) {
7775- return input.call(expr_group).map(Expr::Group);
7776- }
7777-
7778- let outer_attrs = input.call(Attribute::parse_outer)?;
7779-
7780+ fn trailer_expr(
7781+ outer_attrs: Vec<Attribute>,
7782+ input: ParseStream,
7783+ allow_struct: AllowStruct,
7784+ ) -> Result<Expr> {
7785 let atom = atom_expr(input, allow_struct)?;
7786 let mut e = trailer_helper(input, atom)?;
7787
7788 let inner_attrs = e.replace_attrs(Vec::new());
7789 let attrs = private::attrs(outer_attrs, inner_attrs);
7790 e.replace_attrs(attrs);
7791 Ok(e)
7792 }
7793@@ -1518,28 +1471,36 @@ pub(crate) mod parsing {
7794 let content;
7795 e = Expr::Call(ExprCall {
7796 attrs: Vec::new(),
7797 func: Box::new(e),
7798 paren_token: parenthesized!(content in input),
7799 args: content.parse_terminated(Expr::parse)?,
7800 });
7801 } else if input.peek(Token![.]) && !input.peek(Token![..]) {
7802- let dot_token: Token![.] = input.parse()?;
7803+ let mut dot_token: Token![.] = input.parse()?;
7804
7805- if input.peek(token::Await) {
7806+ let await_token: Option<token::Await> = input.parse()?;
7807+ if let Some(await_token) = await_token {
7808 e = Expr::Await(ExprAwait {
7809 attrs: Vec::new(),
7810 base: Box::new(e),
7811 dot_token,
7812- await_token: input.parse()?,
7813+ await_token,
7814 });
7815 continue;
7816 }
7817
7818+ let float_token: Option<LitFloat> = input.parse()?;
7819+ if let Some(float_token) = float_token {
7820+ if multi_index(&mut e, &mut dot_token, float_token)? {
7821+ continue;
7822+ }
7823+ }
7824+
7825 let member: Member = input.parse()?;
7826 let turbofish = if member.is_named() && input.peek(Token![::]) {
7827 Some(MethodTurbofish {
7828 colon2_token: input.parse()?,
7829 lt_token: input.parse()?,
7830 args: {
7831 let mut args = Punctuated::new();
7832 loop {
7833@@ -1615,20 +1576,27 @@ pub(crate) mod parsing {
7834 e = Expr::Call(ExprCall {
7835 attrs: Vec::new(),
7836 func: Box::new(e),
7837 paren_token: parenthesized!(content in input),
7838 args: content.parse_terminated(Expr::parse)?,
7839 });
7840 } else if input.peek(Token![.]) && !input.peek(Token![..]) && !input.peek2(token::Await)
7841 {
7842+ let mut dot_token: Token![.] = input.parse()?;
7843+ let float_token: Option<LitFloat> = input.parse()?;
7844+ if let Some(float_token) = float_token {
7845+ if multi_index(&mut e, &mut dot_token, float_token)? {
7846+ continue;
7847+ }
7848+ }
7849 e = Expr::Field(ExprField {
7850 attrs: Vec::new(),
7851 base: Box::new(e),
7852- dot_token: input.parse()?,
7853+ dot_token,
7854 member: input.parse()?,
7855 });
7856 } else if input.peek(token::Bracket) {
7857 let content;
7858 e = Expr::Index(ExprIndex {
7859 attrs: Vec::new(),
7860 expr: Box::new(e),
7861 bracket_token: bracketed!(content in input),
7862@@ -1641,17 +1609,21 @@ pub(crate) mod parsing {
7863
7864 Ok(e)
7865 }
7866
7867 // Parse all atomic expressions which don't have to worry about precedence
7868 // interactions, as they are fully contained.
7869 #[cfg(feature = "full")]
7870 fn atom_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> {
7871- if input.peek(token::Group) {
7872+ if input.peek(token::Group)
7873+ && !input.peek2(Token![::])
7874+ && !input.peek2(Token![!])
7875+ && !input.peek2(token::Brace)
7876+ {
7877 input.call(expr_group).map(Expr::Group)
7878 } else if input.peek(Lit) {
7879 input.parse().map(Expr::Lit)
7880 } else if input.peek(Token![async])
7881 && (input.peek2(token::Brace) || input.peek2(Token![move]) && input.peek3(token::Brace))
7882 {
7883 input.call(expr_async).map(Expr::Async)
7884 } else if input.peek(Token![try]) && input.peek2(token::Brace) {
7885@@ -1663,17 +1635,16 @@ pub(crate) mod parsing {
7886 {
7887 expr_closure(input, allow_struct).map(Expr::Closure)
7888 } else if input.peek(Ident)
7889 || input.peek(Token![::])
7890 || input.peek(Token![<])
7891 || input.peek(Token![self])
7892 || input.peek(Token![Self])
7893 || input.peek(Token![super])
7894- || input.peek(Token![extern])
7895 || input.peek(Token![crate])
7896 {
7897 path_or_macro_or_struct(input, allow_struct)
7898 } else if input.peek(token::Paren) {
7899 paren_or_tuple(input)
7900 } else if input.peek(Token![break]) {
7901 expr_break(input, allow_struct).map(Expr::Break)
7902 } else if input.peek(Token![continue]) {
7903@@ -1735,17 +1706,16 @@ pub(crate) mod parsing {
7904 } else if input.peek(token::Paren) {
7905 input.call(expr_paren).map(Expr::Paren)
7906 } else if input.peek(Ident)
7907 || input.peek(Token![::])
7908 || input.peek(Token![<])
7909 || input.peek(Token![self])
7910 || input.peek(Token![Self])
7911 || input.peek(Token![super])
7912- || input.peek(Token![extern])
7913 || input.peek(Token![crate])
7914 {
7915 input.parse().map(Expr::Path)
7916 } else {
7917 Err(input.error("unsupported expression; enable syn's features=[\"full\"]"))
7918 }
7919 }
7920
7921@@ -1873,17 +1843,17 @@ pub(crate) mod parsing {
7922 }))
7923 } else {
7924 Err(content.error("expected `,` or `;`"))
7925 }
7926 }
7927
7928 #[cfg(feature = "full")]
7929 pub(crate) fn expr_early(input: ParseStream) -> Result<Expr> {
7930- let mut attrs = input.call(Attribute::parse_outer)?;
7931+ let mut attrs = input.call(expr_attrs)?;
7932 let mut expr = if input.peek(Token![if]) {
7933 Expr::If(input.parse()?)
7934 } else if input.peek(Token![while]) {
7935 Expr::While(input.parse()?)
7936 } else if input.peek(Token![for]) {
7937 Expr::ForLoop(input.parse()?)
7938 } else if input.peek(Token![loop]) {
7939 Expr::Loop(input.parse()?)
7940@@ -1900,17 +1870,17 @@ pub(crate) mod parsing {
7941 let mut expr = unary_expr(input, allow_struct)?;
7942
7943 attrs.extend(expr.replace_attrs(Vec::new()));
7944 expr.replace_attrs(attrs);
7945
7946 return parse_expr(input, expr, allow_struct, Precedence::Any);
7947 };
7948
7949- if input.peek(Token![.]) || input.peek(Token![?]) {
7950+ if input.peek(Token![.]) && !input.peek(Token![..]) || input.peek(Token![?]) {
7951 expr = trailer_helper(input, expr)?;
7952
7953 attrs.extend(expr.replace_attrs(Vec::new()));
7954 expr.replace_attrs(attrs);
7955
7956 let allow_struct = AllowStruct(true);
7957 return parse_expr(input, expr, allow_struct, Precedence::Any);
7958 }
7959@@ -1946,63 +1916,48 @@ pub(crate) mod parsing {
7960 attrs: Vec::new(),
7961 paren_token: parenthesized!(content in input),
7962 expr: content.parse()?,
7963 })
7964 }
7965
7966 #[cfg(feature = "full")]
7967 fn generic_method_argument(input: ParseStream) -> Result<GenericMethodArgument> {
7968- // TODO parse const generics as well
7969+ if input.peek(Lit) {
7970+ let lit = input.parse()?;
7971+ return Ok(GenericMethodArgument::Const(Expr::Lit(lit)));
7972+ }
7973+
7974+ if input.peek(token::Brace) {
7975+ let block = input.call(expr::parsing::expr_block)?;
7976+ return Ok(GenericMethodArgument::Const(Expr::Block(block)));
7977+ }
7978+
7979 input.parse().map(GenericMethodArgument::Type)
7980 }
7981
7982 #[cfg(feature = "full")]
7983 fn expr_let(input: ParseStream) -> Result<ExprLet> {
7984 Ok(ExprLet {
7985 attrs: Vec::new(),
7986 let_token: input.parse()?,
7987- pat: {
7988- let leading_vert: Option<Token![|]> = input.parse()?;
7989- let pat: Pat = input.parse()?;
7990- if leading_vert.is_some()
7991- || input.peek(Token![|]) && !input.peek(Token![||]) && !input.peek(Token![|=])
7992- {
7993- let mut cases = Punctuated::new();
7994- cases.push_value(pat);
7995- while input.peek(Token![|])
7996- && !input.peek(Token![||])
7997- && !input.peek(Token![|=])
7998- {
7999- let punct = input.parse()?;
8000- cases.push_punct(punct);
8001- let pat: Pat = input.parse()?;
8002- cases.push_value(pat);
8003- }
8004- Pat::Or(PatOr {
8005- attrs: Vec::new(),
8006- leading_vert,
8007- cases,
8008- })
8009- } else {
8010- pat
8011- }
8012- },
8013+ pat: pat::parsing::multi_pat_with_leading_vert(input)?,
8014 eq_token: input.parse()?,
8015- expr: Box::new(input.call(expr_no_struct)?),
8016+ expr: Box::new(input.call(Expr::parse_without_eager_brace)?),
8017 })
8018 }
8019
8020 #[cfg(feature = "full")]
8021 impl Parse for ExprIf {
8022 fn parse(input: ParseStream) -> Result<Self> {
8023+ let attrs = input.call(Attribute::parse_outer)?;
8024 Ok(ExprIf {
8025- attrs: Vec::new(),
8026+ attrs,
8027 if_token: input.parse()?,
8028- cond: Box::new(input.call(expr_no_struct)?),
8029+ cond: Box::new(input.call(Expr::parse_without_eager_brace)?),
8030 then_branch: input.parse()?,
8031 else_branch: {
8032 if input.peek(Token![else]) {
8033 Some(input.call(else_block)?)
8034 } else {
8035 None
8036 }
8037 },
8038@@ -2028,94 +1983,81 @@ pub(crate) mod parsing {
8039 };
8040
8041 Ok((else_token, Box::new(else_branch)))
8042 }
8043
8044 #[cfg(feature = "full")]
8045 impl Parse for ExprForLoop {
8046 fn parse(input: ParseStream) -> Result<Self> {
8047+ let outer_attrs = input.call(Attribute::parse_outer)?;
8048 let label: Option<Label> = input.parse()?;
8049 let for_token: Token![for] = input.parse()?;
8050
8051- let leading_vert: Option<Token![|]> = input.parse()?;
8052- let mut pat: Pat = input.parse()?;
8053- if leading_vert.is_some() || input.peek(Token![|]) {
8054- let mut cases = Punctuated::new();
8055- cases.push_value(pat);
8056- while input.peek(Token![|]) {
8057- let punct = input.parse()?;
8058- cases.push_punct(punct);
8059- let pat: Pat = input.parse()?;
8060- cases.push_value(pat);
8061- }
8062- pat = Pat::Or(PatOr {
8063- attrs: Vec::new(),
8064- leading_vert,
8065- cases,
8066- });
8067- }
8068+ let pat = pat::parsing::multi_pat_with_leading_vert(input)?;
8069
8070 let in_token: Token![in] = input.parse()?;
8071- let expr: Expr = input.call(expr_no_struct)?;
8072+ let expr: Expr = input.call(Expr::parse_without_eager_brace)?;
8073
8074 let content;
8075 let brace_token = braced!(content in input);
8076 let inner_attrs = content.call(Attribute::parse_inner)?;
8077 let stmts = content.call(Block::parse_within)?;
8078
8079 Ok(ExprForLoop {
8080- attrs: inner_attrs,
8081+ attrs: private::attrs(outer_attrs, inner_attrs),
8082 label,
8083 for_token,
8084 pat,
8085 in_token,
8086 expr: Box::new(expr),
8087 body: Block { brace_token, stmts },
8088 })
8089 }
8090 }
8091
8092 #[cfg(feature = "full")]
8093 impl Parse for ExprLoop {
8094 fn parse(input: ParseStream) -> Result<Self> {
8095+ let outer_attrs = input.call(Attribute::parse_outer)?;
8096 let label: Option<Label> = input.parse()?;
8097 let loop_token: Token![loop] = input.parse()?;
8098
8099 let content;
8100 let brace_token = braced!(content in input);
8101 let inner_attrs = content.call(Attribute::parse_inner)?;
8102 let stmts = content.call(Block::parse_within)?;
8103
8104 Ok(ExprLoop {
8105- attrs: inner_attrs,
8106+ attrs: private::attrs(outer_attrs, inner_attrs),
8107 label,
8108 loop_token,
8109 body: Block { brace_token, stmts },
8110 })
8111 }
8112 }
8113
8114 #[cfg(feature = "full")]
8115 impl Parse for ExprMatch {
8116 fn parse(input: ParseStream) -> Result<Self> {
8117+ let outer_attrs = input.call(Attribute::parse_outer)?;
8118 let match_token: Token![match] = input.parse()?;
8119- let expr = expr_no_struct(input)?;
8120+ let expr = Expr::parse_without_eager_brace(input)?;
8121
8122 let content;
8123 let brace_token = braced!(content in input);
8124 let inner_attrs = content.call(Attribute::parse_inner)?;
8125
8126 let mut arms = Vec::new();
8127 while !content.is_empty() {
8128 arms.push(content.call(Arm::parse)?);
8129 }
8130
8131 Ok(ExprMatch {
8132- attrs: inner_attrs,
8133+ attrs: private::attrs(outer_attrs, inner_attrs),
8134 match_token,
8135 expr: Box::new(expr),
8136 brace_token,
8137 arms,
8138 })
8139 }
8140 }
8141
8142@@ -2300,27 +2242,28 @@ pub(crate) mod parsing {
8143 }
8144 Ok(pat)
8145 }
8146 }
8147
8148 #[cfg(feature = "full")]
8149 impl Parse for ExprWhile {
8150 fn parse(input: ParseStream) -> Result<Self> {
8151+ let outer_attrs = input.call(Attribute::parse_outer)?;
8152 let label: Option<Label> = input.parse()?;
8153 let while_token: Token![while] = input.parse()?;
8154- let cond = expr_no_struct(input)?;
8155+ let cond = Expr::parse_without_eager_brace(input)?;
8156
8157 let content;
8158 let brace_token = braced!(content in input);
8159 let inner_attrs = content.call(Attribute::parse_inner)?;
8160 let stmts = content.call(Block::parse_within)?;
8161
8162 Ok(ExprWhile {
8163- attrs: inner_attrs,
8164+ attrs: private::attrs(outer_attrs, inner_attrs),
8165 label,
8166 while_token,
8167 cond: Box::new(cond),
8168 body: Block { brace_token, stmts },
8169 })
8170 }
8171 }
8172
8173@@ -2394,16 +2337,17 @@ pub(crate) mod parsing {
8174 }
8175 },
8176 })
8177 }
8178
8179 #[cfg(feature = "full")]
8180 impl Parse for FieldValue {
8181 fn parse(input: ParseStream) -> Result<Self> {
8182+ let attrs = input.call(Attribute::parse_outer)?;
8183 let member: Member = input.parse()?;
8184 let (colon_token, value) = if input.peek(Token![:]) || !member.is_named() {
8185 let colon_token: Token![:] = input.parse()?;
8186 let value: Expr = input.parse()?;
8187 (Some(colon_token), value)
8188 } else if let Member::Named(ident) = &member {
8189 let value = Expr::Path(ExprPath {
8190 attrs: Vec::new(),
8191@@ -2411,73 +2355,63 @@ pub(crate) mod parsing {
8192 path: Path::from(ident.clone()),
8193 });
8194 (None, value)
8195 } else {
8196 unreachable!()
8197 };
8198
8199 Ok(FieldValue {
8200- attrs: Vec::new(),
8201+ attrs,
8202 member,
8203 colon_token,
8204 expr: value,
8205 })
8206 }
8207 }
8208
8209 #[cfg(feature = "full")]
8210 fn expr_struct_helper(
8211 input: ParseStream,
8212 outer_attrs: Vec<Attribute>,
8213 path: Path,
8214 ) -> Result<ExprStruct> {
8215 let content;
8216 let brace_token = braced!(content in input);
8217 let inner_attrs = content.call(Attribute::parse_inner)?;
8218+ let attrs = private::attrs(outer_attrs, inner_attrs);
8219
8220 let mut fields = Punctuated::new();
8221- loop {
8222- let attrs = content.call(Attribute::parse_outer)?;
8223- // TODO: optimize using advance_to
8224- if content.fork().parse::<Member>().is_err() {
8225- if attrs.is_empty() {
8226- break;
8227- } else {
8228- return Err(content.error("expected struct field"));
8229- }
8230+ while !content.is_empty() {
8231+ if content.peek(Token![..]) {
8232+ return Ok(ExprStruct {
8233+ attrs,
8234+ brace_token,
8235+ path,
8236+ fields,
8237+ dot2_token: Some(content.parse()?),
8238+ rest: Some(Box::new(content.parse()?)),
8239+ });
8240 }
8241
8242- fields.push(FieldValue {
8243- attrs,
8244- ..content.parse()?
8245- });
8246-
8247- if !content.peek(Token![,]) {
8248+ fields.push(content.parse()?);
8249+ if content.is_empty() {
8250 break;
8251 }
8252 let punct: Token![,] = content.parse()?;
8253 fields.push_punct(punct);
8254 }
8255
8256- let (dot2_token, rest) = if fields.empty_or_trailing() && content.peek(Token![..]) {
8257- let dot2_token: Token![..] = content.parse()?;
8258- let rest: Expr = content.parse()?;
8259- (Some(dot2_token), Some(Box::new(rest)))
8260- } else {
8261- (None, None)
8262- };
8263-
8264 Ok(ExprStruct {
8265- attrs: private::attrs(outer_attrs, inner_attrs),
8266+ attrs,
8267 brace_token,
8268 path,
8269 fields,
8270- dot2_token,
8271- rest,
8272+ dot2_token: None,
8273+ rest: None,
8274 })
8275 }
8276
8277 #[cfg(feature = "full")]
8278 fn expr_unsafe(input: ParseStream) -> Result<ExprUnsafe> {
8279 let unsafe_token: Token![unsafe] = input.parse()?;
8280
8281 let content;
8282@@ -2572,37 +2506,17 @@ pub(crate) mod parsing {
8283 }
8284
8285 #[cfg(feature = "full")]
8286 impl Parse for Arm {
8287 fn parse(input: ParseStream) -> Result<Arm> {
8288 let requires_comma;
8289 Ok(Arm {
8290 attrs: input.call(Attribute::parse_outer)?,
8291- pat: {
8292- let leading_vert: Option<Token![|]> = input.parse()?;
8293- let pat: Pat = input.parse()?;
8294- if leading_vert.is_some() || input.peek(Token![|]) {
8295- let mut cases = Punctuated::new();
8296- cases.push_value(pat);
8297- while input.peek(Token![|]) {
8298- let punct = input.parse()?;
8299- cases.push_punct(punct);
8300- let pat: Pat = input.parse()?;
8301- cases.push_value(pat);
8302- }
8303- Pat::Or(PatOr {
8304- attrs: Vec::new(),
8305- leading_vert,
8306- cases,
8307- })
8308- } else {
8309- pat
8310- }
8311- },
8312+ pat: pat::parsing::multi_pat_with_leading_vert(input)?,
8313 guard: {
8314 if input.peek(Token![if]) {
8315 let if_token: Token![if] = input.parse()?;
8316 let guard: Expr = input.parse()?;
8317 Some((if_token, Box::new(guard)))
8318 } else {
8319 None
8320 }
8321@@ -2636,16 +2550,36 @@ pub(crate) mod parsing {
8322 span: lit.span(),
8323 })
8324 } else {
8325 Err(Error::new(lit.span(), "expected unsuffixed integer"))
8326 }
8327 }
8328 }
8329
8330+ fn multi_index(e: &mut Expr, dot_token: &mut Token![.], float: LitFloat) -> Result<bool> {
8331+ let mut float_repr = float.to_string();
8332+ let trailing_dot = float_repr.ends_with('.');
8333+ if trailing_dot {
8334+ float_repr.truncate(float_repr.len() - 1);
8335+ }
8336+ for part in float_repr.split('.') {
8337+ let index = crate::parse_str(part).map_err(|err| Error::new(float.span(), err))?;
8338+ let base = mem::replace(e, Expr::__Nonexhaustive);
8339+ *e = Expr::Field(ExprField {
8340+ attrs: Vec::new(),
8341+ base: Box::new(base),
8342+ dot_token: Token![.](dot_token.span),
8343+ member: Member::Unnamed(index),
8344+ });
8345+ *dot_token = Token![.](float.span());
8346+ }
8347+ Ok(!trailing_dot)
8348+ }
8349+
8350 #[cfg(feature = "full")]
8351 impl Member {
8352 fn is_named(&self) -> bool {
8353 match *self {
8354 Member::Named(_) => true,
8355 Member::Unnamed(_) => false,
8356 }
8357 }
8358diff --git a/third_party/rust/syn/src/ext.rs b/third_party/rust/syn/src/ext.rs
8359--- a/third_party/rust/syn/src/ext.rs
8360+++ b/third_party/rust/syn/src/ext.rs
8361@@ -1,27 +1,27 @@
8362 //! Extension traits to provide parsing methods on foreign types.
8363 //!
8364-//! *This module is available if Syn is built with the `"parsing"` feature.*
8365+//! *This module is available only if Syn is built with the `"parsing"` feature.*
8366
8367 use proc_macro2::Ident;
8368
8369 use crate::parse::{ParseStream, Result};
8370
8371 use crate::buffer::Cursor;
8372 use crate::parse::Peek;
8373 use crate::sealed::lookahead;
8374 use crate::token::CustomToken;
8375
8376 /// Additional methods for `Ident` not provided by proc-macro2 or libproc_macro.
8377 ///
8378 /// This trait is sealed and cannot be implemented for types outside of Syn. It
8379 /// is implemented only for `proc_macro2::Ident`.
8380 ///
8381-/// *This trait is available if Syn is built with the `"parsing"` feature.*
8382+/// *This trait is available only if Syn is built with the `"parsing"` feature.*
8383 pub trait IdentExt: Sized + private::Sealed {
8384 /// Parses any identifier including keywords.
8385 ///
8386 /// This is useful when parsing macro input which allows Rust keywords as
8387 /// identifiers.
8388 ///
8389 /// # Example
8390 ///
8391@@ -124,12 +124,18 @@ impl lookahead::Sealed for private::Peek
8392
8393 mod private {
8394 use proc_macro2::Ident;
8395
8396 pub trait Sealed {}
8397
8398 impl Sealed for Ident {}
8399
8400- #[derive(Copy, Clone)]
8401 pub struct PeekFn;
8402 pub struct IdentAny;
8403+
8404+ impl Copy for PeekFn {}
8405+ impl Clone for PeekFn {
8406+ fn clone(&self) -> Self {
8407+ *self
8408+ }
8409+ }
8410 }
8411diff --git a/third_party/rust/syn/src/file.rs b/third_party/rust/syn/src/file.rs
8412--- a/third_party/rust/syn/src/file.rs
8413+++ b/third_party/rust/syn/src/file.rs
8414@@ -1,14 +1,14 @@
8415 use super::*;
8416
8417 ast_struct! {
8418 /// A complete file of Rust source code.
8419 ///
8420- /// *This type is available if Syn is built with the `"full"` feature.*
8421+ /// *This type is available only if Syn is built with the `"full"` feature.*
8422 ///
8423 /// # Example
8424 ///
8425 /// Parse a Rust source file into a `syn::File` and print out a debug
8426 /// representation of the syntax tree.
8427 ///
8428 /// ```
8429 /// use std::env;
8430@@ -32,16 +32,18 @@ ast_struct! {
8431 /// };
8432 ///
8433 /// let mut file = File::open(&filename).expect("Unable to open file");
8434 ///
8435 /// let mut src = String::new();
8436 /// file.read_to_string(&mut src).expect("Unable to read file");
8437 ///
8438 /// let syntax = syn::parse_file(&src).expect("Unable to parse file");
8439+ ///
8440+ /// // Debug impl is available if Syn is built with "extra-traits" feature.
8441 /// println!("{:#?}", syntax);
8442 /// }
8443 /// ```
8444 ///
8445 /// Running with its own source code as input, this program prints output
8446 /// that begins with:
8447 ///
8448 /// ```text
8449diff --git a/third_party/rust/syn/src/gen/clone.rs b/third_party/rust/syn/src/gen/clone.rs
8450new file mode 100644
8451--- /dev/null
8452+++ b/third_party/rust/syn/src/gen/clone.rs
8453@@ -0,0 +1,2051 @@
8454+// This file is @generated by syn-internal-codegen.
8455+// It is not intended for manual editing.
8456+
8457+#![allow(clippy::clone_on_copy, clippy::expl_impl_clone_on_copy)]
8458+use crate::*;
8459+#[cfg(any(feature = "derive", feature = "full"))]
8460+impl Clone for Abi {
8461+ fn clone(&self) -> Self {
8462+ Abi {
8463+ extern_token: self.extern_token.clone(),
8464+ name: self.name.clone(),
8465+ }
8466+ }
8467+}
8468+#[cfg(any(feature = "derive", feature = "full"))]
8469+impl Clone for AngleBracketedGenericArguments {
8470+ fn clone(&self) -> Self {
8471+ AngleBracketedGenericArguments {
8472+ colon2_token: self.colon2_token.clone(),
8473+ lt_token: self.lt_token.clone(),
8474+ args: self.args.clone(),
8475+ gt_token: self.gt_token.clone(),
8476+ }
8477+ }
8478+}
8479+#[cfg(feature = "full")]
8480+impl Clone for Arm {
8481+ fn clone(&self) -> Self {
8482+ Arm {
8483+ attrs: self.attrs.clone(),
8484+ pat: self.pat.clone(),
8485+ guard: self.guard.clone(),
8486+ fat_arrow_token: self.fat_arrow_token.clone(),
8487+ body: self.body.clone(),
8488+ comma: self.comma.clone(),
8489+ }
8490+ }
8491+}
8492+#[cfg(any(feature = "derive", feature = "full"))]
8493+impl Copy for AttrStyle {}
8494+#[cfg(any(feature = "derive", feature = "full"))]
8495+impl Clone for AttrStyle {
8496+ fn clone(&self) -> Self {
8497+ *self
8498+ }
8499+}
8500+#[cfg(any(feature = "derive", feature = "full"))]
8501+impl Clone for Attribute {
8502+ fn clone(&self) -> Self {
8503+ Attribute {
8504+ pound_token: self.pound_token.clone(),
8505+ style: self.style.clone(),
8506+ bracket_token: self.bracket_token.clone(),
8507+ path: self.path.clone(),
8508+ tokens: self.tokens.clone(),
8509+ }
8510+ }
8511+}
8512+#[cfg(any(feature = "derive", feature = "full"))]
8513+impl Clone for BareFnArg {
8514+ fn clone(&self) -> Self {
8515+ BareFnArg {
8516+ attrs: self.attrs.clone(),
8517+ name: self.name.clone(),
8518+ ty: self.ty.clone(),
8519+ }
8520+ }
8521+}
8522+#[cfg(any(feature = "derive", feature = "full"))]
8523+impl Copy for BinOp {}
8524+#[cfg(any(feature = "derive", feature = "full"))]
8525+impl Clone for BinOp {
8526+ fn clone(&self) -> Self {
8527+ *self
8528+ }
8529+}
8530+#[cfg(any(feature = "derive", feature = "full"))]
8531+impl Clone for Binding {
8532+ fn clone(&self) -> Self {
8533+ Binding {
8534+ ident: self.ident.clone(),
8535+ eq_token: self.eq_token.clone(),
8536+ ty: self.ty.clone(),
8537+ }
8538+ }
8539+}
8540+#[cfg(feature = "full")]
8541+impl Clone for Block {
8542+ fn clone(&self) -> Self {
8543+ Block {
8544+ brace_token: self.brace_token.clone(),
8545+ stmts: self.stmts.clone(),
8546+ }
8547+ }
8548+}
8549+#[cfg(any(feature = "derive", feature = "full"))]
8550+impl Clone for BoundLifetimes {
8551+ fn clone(&self) -> Self {
8552+ BoundLifetimes {
8553+ for_token: self.for_token.clone(),
8554+ lt_token: self.lt_token.clone(),
8555+ lifetimes: self.lifetimes.clone(),
8556+ gt_token: self.gt_token.clone(),
8557+ }
8558+ }
8559+}
8560+#[cfg(any(feature = "derive", feature = "full"))]
8561+impl Clone for ConstParam {
8562+ fn clone(&self) -> Self {
8563+ ConstParam {
8564+ attrs: self.attrs.clone(),
8565+ const_token: self.const_token.clone(),
8566+ ident: self.ident.clone(),
8567+ colon_token: self.colon_token.clone(),
8568+ ty: self.ty.clone(),
8569+ eq_token: self.eq_token.clone(),
8570+ default: self.default.clone(),
8571+ }
8572+ }
8573+}
8574+#[cfg(any(feature = "derive", feature = "full"))]
8575+impl Clone for Constraint {
8576+ fn clone(&self) -> Self {
8577+ Constraint {
8578+ ident: self.ident.clone(),
8579+ colon_token: self.colon_token.clone(),
8580+ bounds: self.bounds.clone(),
8581+ }
8582+ }
8583+}
8584+#[cfg(feature = "derive")]
8585+impl Clone for Data {
8586+ fn clone(&self) -> Self {
8587+ match self {
8588+ Data::Struct(v0) => Data::Struct(v0.clone()),
8589+ Data::Enum(v0) => Data::Enum(v0.clone()),
8590+ Data::Union(v0) => Data::Union(v0.clone()),
8591+ }
8592+ }
8593+}
8594+#[cfg(feature = "derive")]
8595+impl Clone for DataEnum {
8596+ fn clone(&self) -> Self {
8597+ DataEnum {
8598+ enum_token: self.enum_token.clone(),
8599+ brace_token: self.brace_token.clone(),
8600+ variants: self.variants.clone(),
8601+ }
8602+ }
8603+}
8604+#[cfg(feature = "derive")]
8605+impl Clone for DataStruct {
8606+ fn clone(&self) -> Self {
8607+ DataStruct {
8608+ struct_token: self.struct_token.clone(),
8609+ fields: self.fields.clone(),
8610+ semi_token: self.semi_token.clone(),
8611+ }
8612+ }
8613+}
8614+#[cfg(feature = "derive")]
8615+impl Clone for DataUnion {
8616+ fn clone(&self) -> Self {
8617+ DataUnion {
8618+ union_token: self.union_token.clone(),
8619+ fields: self.fields.clone(),
8620+ }
8621+ }
8622+}
8623+#[cfg(feature = "derive")]
8624+impl Clone for DeriveInput {
8625+ fn clone(&self) -> Self {
8626+ DeriveInput {
8627+ attrs: self.attrs.clone(),
8628+ vis: self.vis.clone(),
8629+ ident: self.ident.clone(),
8630+ generics: self.generics.clone(),
8631+ data: self.data.clone(),
8632+ }
8633+ }
8634+}
8635+#[cfg(any(feature = "derive", feature = "full"))]
8636+impl Clone for Expr {
8637+ fn clone(&self) -> Self {
8638+ match self {
8639+ #[cfg(feature = "full")]
8640+ Expr::Array(v0) => Expr::Array(v0.clone()),
8641+ #[cfg(feature = "full")]
8642+ Expr::Assign(v0) => Expr::Assign(v0.clone()),
8643+ #[cfg(feature = "full")]
8644+ Expr::AssignOp(v0) => Expr::AssignOp(v0.clone()),
8645+ #[cfg(feature = "full")]
8646+ Expr::Async(v0) => Expr::Async(v0.clone()),
8647+ #[cfg(feature = "full")]
8648+ Expr::Await(v0) => Expr::Await(v0.clone()),
8649+ Expr::Binary(v0) => Expr::Binary(v0.clone()),
8650+ #[cfg(feature = "full")]
8651+ Expr::Block(v0) => Expr::Block(v0.clone()),
8652+ #[cfg(feature = "full")]
8653+ Expr::Box(v0) => Expr::Box(v0.clone()),
8654+ #[cfg(feature = "full")]
8655+ Expr::Break(v0) => Expr::Break(v0.clone()),
8656+ Expr::Call(v0) => Expr::Call(v0.clone()),
8657+ Expr::Cast(v0) => Expr::Cast(v0.clone()),
8658+ #[cfg(feature = "full")]
8659+ Expr::Closure(v0) => Expr::Closure(v0.clone()),
8660+ #[cfg(feature = "full")]
8661+ Expr::Continue(v0) => Expr::Continue(v0.clone()),
8662+ Expr::Field(v0) => Expr::Field(v0.clone()),
8663+ #[cfg(feature = "full")]
8664+ Expr::ForLoop(v0) => Expr::ForLoop(v0.clone()),
8665+ #[cfg(feature = "full")]
8666+ Expr::Group(v0) => Expr::Group(v0.clone()),
8667+ #[cfg(feature = "full")]
8668+ Expr::If(v0) => Expr::If(v0.clone()),
8669+ Expr::Index(v0) => Expr::Index(v0.clone()),
8670+ #[cfg(feature = "full")]
8671+ Expr::Let(v0) => Expr::Let(v0.clone()),
8672+ Expr::Lit(v0) => Expr::Lit(v0.clone()),
8673+ #[cfg(feature = "full")]
8674+ Expr::Loop(v0) => Expr::Loop(v0.clone()),
8675+ #[cfg(feature = "full")]
8676+ Expr::Macro(v0) => Expr::Macro(v0.clone()),
8677+ #[cfg(feature = "full")]
8678+ Expr::Match(v0) => Expr::Match(v0.clone()),
8679+ #[cfg(feature = "full")]
8680+ Expr::MethodCall(v0) => Expr::MethodCall(v0.clone()),
8681+ Expr::Paren(v0) => Expr::Paren(v0.clone()),
8682+ Expr::Path(v0) => Expr::Path(v0.clone()),
8683+ #[cfg(feature = "full")]
8684+ Expr::Range(v0) => Expr::Range(v0.clone()),
8685+ #[cfg(feature = "full")]
8686+ Expr::Reference(v0) => Expr::Reference(v0.clone()),
8687+ #[cfg(feature = "full")]
8688+ Expr::Repeat(v0) => Expr::Repeat(v0.clone()),
8689+ #[cfg(feature = "full")]
8690+ Expr::Return(v0) => Expr::Return(v0.clone()),
8691+ #[cfg(feature = "full")]
8692+ Expr::Struct(v0) => Expr::Struct(v0.clone()),
8693+ #[cfg(feature = "full")]
8694+ Expr::Try(v0) => Expr::Try(v0.clone()),
8695+ #[cfg(feature = "full")]
8696+ Expr::TryBlock(v0) => Expr::TryBlock(v0.clone()),
8697+ #[cfg(feature = "full")]
8698+ Expr::Tuple(v0) => Expr::Tuple(v0.clone()),
8699+ #[cfg(feature = "full")]
8700+ Expr::Type(v0) => Expr::Type(v0.clone()),
8701+ Expr::Unary(v0) => Expr::Unary(v0.clone()),
8702+ #[cfg(feature = "full")]
8703+ Expr::Unsafe(v0) => Expr::Unsafe(v0.clone()),
8704+ Expr::Verbatim(v0) => Expr::Verbatim(v0.clone()),
8705+ #[cfg(feature = "full")]
8706+ Expr::While(v0) => Expr::While(v0.clone()),
8707+ #[cfg(feature = "full")]
8708+ Expr::Yield(v0) => Expr::Yield(v0.clone()),
8709+ _ => unreachable!(),
8710+ }
8711+ }
8712+}
8713+#[cfg(feature = "full")]
8714+impl Clone for ExprArray {
8715+ fn clone(&self) -> Self {
8716+ ExprArray {
8717+ attrs: self.attrs.clone(),
8718+ bracket_token: self.bracket_token.clone(),
8719+ elems: self.elems.clone(),
8720+ }
8721+ }
8722+}
8723+#[cfg(feature = "full")]
8724+impl Clone for ExprAssign {
8725+ fn clone(&self) -> Self {
8726+ ExprAssign {
8727+ attrs: self.attrs.clone(),
8728+ left: self.left.clone(),
8729+ eq_token: self.eq_token.clone(),
8730+ right: self.right.clone(),
8731+ }
8732+ }
8733+}
8734+#[cfg(feature = "full")]
8735+impl Clone for ExprAssignOp {
8736+ fn clone(&self) -> Self {
8737+ ExprAssignOp {
8738+ attrs: self.attrs.clone(),
8739+ left: self.left.clone(),
8740+ op: self.op.clone(),
8741+ right: self.right.clone(),
8742+ }
8743+ }
8744+}
8745+#[cfg(feature = "full")]
8746+impl Clone for ExprAsync {
8747+ fn clone(&self) -> Self {
8748+ ExprAsync {
8749+ attrs: self.attrs.clone(),
8750+ async_token: self.async_token.clone(),
8751+ capture: self.capture.clone(),
8752+ block: self.block.clone(),
8753+ }
8754+ }
8755+}
8756+#[cfg(feature = "full")]
8757+impl Clone for ExprAwait {
8758+ fn clone(&self) -> Self {
8759+ ExprAwait {
8760+ attrs: self.attrs.clone(),
8761+ base: self.base.clone(),
8762+ dot_token: self.dot_token.clone(),
8763+ await_token: self.await_token.clone(),
8764+ }
8765+ }
8766+}
8767+#[cfg(any(feature = "derive", feature = "full"))]
8768+impl Clone for ExprBinary {
8769+ fn clone(&self) -> Self {
8770+ ExprBinary {
8771+ attrs: self.attrs.clone(),
8772+ left: self.left.clone(),
8773+ op: self.op.clone(),
8774+ right: self.right.clone(),
8775+ }
8776+ }
8777+}
8778+#[cfg(feature = "full")]
8779+impl Clone for ExprBlock {
8780+ fn clone(&self) -> Self {
8781+ ExprBlock {
8782+ attrs: self.attrs.clone(),
8783+ label: self.label.clone(),
8784+ block: self.block.clone(),
8785+ }
8786+ }
8787+}
8788+#[cfg(feature = "full")]
8789+impl Clone for ExprBox {
8790+ fn clone(&self) -> Self {
8791+ ExprBox {
8792+ attrs: self.attrs.clone(),
8793+ box_token: self.box_token.clone(),
8794+ expr: self.expr.clone(),
8795+ }
8796+ }
8797+}
8798+#[cfg(feature = "full")]
8799+impl Clone for ExprBreak {
8800+ fn clone(&self) -> Self {
8801+ ExprBreak {
8802+ attrs: self.attrs.clone(),
8803+ break_token: self.break_token.clone(),
8804+ label: self.label.clone(),
8805+ expr: self.expr.clone(),
8806+ }
8807+ }
8808+}
8809+#[cfg(any(feature = "derive", feature = "full"))]
8810+impl Clone for ExprCall {
8811+ fn clone(&self) -> Self {
8812+ ExprCall {
8813+ attrs: self.attrs.clone(),
8814+ func: self.func.clone(),
8815+ paren_token: self.paren_token.clone(),
8816+ args: self.args.clone(),
8817+ }
8818+ }
8819+}
8820+#[cfg(any(feature = "derive", feature = "full"))]
8821+impl Clone for ExprCast {
8822+ fn clone(&self) -> Self {
8823+ ExprCast {
8824+ attrs: self.attrs.clone(),
8825+ expr: self.expr.clone(),
8826+ as_token: self.as_token.clone(),
8827+ ty: self.ty.clone(),
8828+ }
8829+ }
8830+}
8831+#[cfg(feature = "full")]
8832+impl Clone for ExprClosure {
8833+ fn clone(&self) -> Self {
8834+ ExprClosure {
8835+ attrs: self.attrs.clone(),
8836+ asyncness: self.asyncness.clone(),
8837+ movability: self.movability.clone(),
8838+ capture: self.capture.clone(),
8839+ or1_token: self.or1_token.clone(),
8840+ inputs: self.inputs.clone(),
8841+ or2_token: self.or2_token.clone(),
8842+ output: self.output.clone(),
8843+ body: self.body.clone(),
8844+ }
8845+ }
8846+}
8847+#[cfg(feature = "full")]
8848+impl Clone for ExprContinue {
8849+ fn clone(&self) -> Self {
8850+ ExprContinue {
8851+ attrs: self.attrs.clone(),
8852+ continue_token: self.continue_token.clone(),
8853+ label: self.label.clone(),
8854+ }
8855+ }
8856+}
8857+#[cfg(any(feature = "derive", feature = "full"))]
8858+impl Clone for ExprField {
8859+ fn clone(&self) -> Self {
8860+ ExprField {
8861+ attrs: self.attrs.clone(),
8862+ base: self.base.clone(),
8863+ dot_token: self.dot_token.clone(),
8864+ member: self.member.clone(),
8865+ }
8866+ }
8867+}
8868+#[cfg(feature = "full")]
8869+impl Clone for ExprForLoop {
8870+ fn clone(&self) -> Self {
8871+ ExprForLoop {
8872+ attrs: self.attrs.clone(),
8873+ label: self.label.clone(),
8874+ for_token: self.for_token.clone(),
8875+ pat: self.pat.clone(),
8876+ in_token: self.in_token.clone(),
8877+ expr: self.expr.clone(),
8878+ body: self.body.clone(),
8879+ }
8880+ }
8881+}
8882+#[cfg(feature = "full")]
8883+impl Clone for ExprGroup {
8884+ fn clone(&self) -> Self {
8885+ ExprGroup {
8886+ attrs: self.attrs.clone(),
8887+ group_token: self.group_token.clone(),
8888+ expr: self.expr.clone(),
8889+ }
8890+ }
8891+}
8892+#[cfg(feature = "full")]
8893+impl Clone for ExprIf {
8894+ fn clone(&self) -> Self {
8895+ ExprIf {
8896+ attrs: self.attrs.clone(),
8897+ if_token: self.if_token.clone(),
8898+ cond: self.cond.clone(),
8899+ then_branch: self.then_branch.clone(),
8900+ else_branch: self.else_branch.clone(),
8901+ }
8902+ }
8903+}
8904+#[cfg(any(feature = "derive", feature = "full"))]
8905+impl Clone for ExprIndex {
8906+ fn clone(&self) -> Self {
8907+ ExprIndex {
8908+ attrs: self.attrs.clone(),
8909+ expr: self.expr.clone(),
8910+ bracket_token: self.bracket_token.clone(),
8911+ index: self.index.clone(),
8912+ }
8913+ }
8914+}
8915+#[cfg(feature = "full")]
8916+impl Clone for ExprLet {
8917+ fn clone(&self) -> Self {
8918+ ExprLet {
8919+ attrs: self.attrs.clone(),
8920+ let_token: self.let_token.clone(),
8921+ pat: self.pat.clone(),
8922+ eq_token: self.eq_token.clone(),
8923+ expr: self.expr.clone(),
8924+ }
8925+ }
8926+}
8927+#[cfg(any(feature = "derive", feature = "full"))]
8928+impl Clone for ExprLit {
8929+ fn clone(&self) -> Self {
8930+ ExprLit {
8931+ attrs: self.attrs.clone(),
8932+ lit: self.lit.clone(),
8933+ }
8934+ }
8935+}
8936+#[cfg(feature = "full")]
8937+impl Clone for ExprLoop {
8938+ fn clone(&self) -> Self {
8939+ ExprLoop {
8940+ attrs: self.attrs.clone(),
8941+ label: self.label.clone(),
8942+ loop_token: self.loop_token.clone(),
8943+ body: self.body.clone(),
8944+ }
8945+ }
8946+}
8947+#[cfg(feature = "full")]
8948+impl Clone for ExprMacro {
8949+ fn clone(&self) -> Self {
8950+ ExprMacro {
8951+ attrs: self.attrs.clone(),
8952+ mac: self.mac.clone(),
8953+ }
8954+ }
8955+}
8956+#[cfg(feature = "full")]
8957+impl Clone for ExprMatch {
8958+ fn clone(&self) -> Self {
8959+ ExprMatch {
8960+ attrs: self.attrs.clone(),
8961+ match_token: self.match_token.clone(),
8962+ expr: self.expr.clone(),
8963+ brace_token: self.brace_token.clone(),
8964+ arms: self.arms.clone(),
8965+ }
8966+ }
8967+}
8968+#[cfg(feature = "full")]
8969+impl Clone for ExprMethodCall {
8970+ fn clone(&self) -> Self {
8971+ ExprMethodCall {
8972+ attrs: self.attrs.clone(),
8973+ receiver: self.receiver.clone(),
8974+ dot_token: self.dot_token.clone(),
8975+ method: self.method.clone(),
8976+ turbofish: self.turbofish.clone(),
8977+ paren_token: self.paren_token.clone(),
8978+ args: self.args.clone(),
8979+ }
8980+ }
8981+}
8982+#[cfg(any(feature = "derive", feature = "full"))]
8983+impl Clone for ExprParen {
8984+ fn clone(&self) -> Self {
8985+ ExprParen {
8986+ attrs: self.attrs.clone(),
8987+ paren_token: self.paren_token.clone(),
8988+ expr: self.expr.clone(),
8989+ }
8990+ }
8991+}
8992+#[cfg(any(feature = "derive", feature = "full"))]
8993+impl Clone for ExprPath {
8994+ fn clone(&self) -> Self {
8995+ ExprPath {
8996+ attrs: self.attrs.clone(),
8997+ qself: self.qself.clone(),
8998+ path: self.path.clone(),
8999+ }
9000+ }
9001+}
9002+#[cfg(feature = "full")]
9003+impl Clone for ExprRange {
9004+ fn clone(&self) -> Self {
9005+ ExprRange {
9006+ attrs: self.attrs.clone(),
9007+ from: self.from.clone(),
9008+ limits: self.limits.clone(),
9009+ to: self.to.clone(),
9010+ }
9011+ }
9012+}
9013+#[cfg(feature = "full")]
9014+impl Clone for ExprReference {
9015+ fn clone(&self) -> Self {
9016+ ExprReference {
9017+ attrs: self.attrs.clone(),
9018+ and_token: self.and_token.clone(),
9019+ raw: self.raw.clone(),
9020+ mutability: self.mutability.clone(),
9021+ expr: self.expr.clone(),
9022+ }
9023+ }
9024+}
9025+#[cfg(feature = "full")]
9026+impl Clone for ExprRepeat {
9027+ fn clone(&self) -> Self {
9028+ ExprRepeat {
9029+ attrs: self.attrs.clone(),
9030+ bracket_token: self.bracket_token.clone(),
9031+ expr: self.expr.clone(),
9032+ semi_token: self.semi_token.clone(),
9033+ len: self.len.clone(),
9034+ }
9035+ }
9036+}
9037+#[cfg(feature = "full")]
9038+impl Clone for ExprReturn {
9039+ fn clone(&self) -> Self {
9040+ ExprReturn {
9041+ attrs: self.attrs.clone(),
9042+ return_token: self.return_token.clone(),
9043+ expr: self.expr.clone(),
9044+ }
9045+ }
9046+}
9047+#[cfg(feature = "full")]
9048+impl Clone for ExprStruct {
9049+ fn clone(&self) -> Self {
9050+ ExprStruct {
9051+ attrs: self.attrs.clone(),
9052+ path: self.path.clone(),
9053+ brace_token: self.brace_token.clone(),
9054+ fields: self.fields.clone(),
9055+ dot2_token: self.dot2_token.clone(),
9056+ rest: self.rest.clone(),
9057+ }
9058+ }
9059+}
9060+#[cfg(feature = "full")]
9061+impl Clone for ExprTry {
9062+ fn clone(&self) -> Self {
9063+ ExprTry {
9064+ attrs: self.attrs.clone(),
9065+ expr: self.expr.clone(),
9066+ question_token: self.question_token.clone(),
9067+ }
9068+ }
9069+}
9070+#[cfg(feature = "full")]
9071+impl Clone for ExprTryBlock {
9072+ fn clone(&self) -> Self {
9073+ ExprTryBlock {
9074+ attrs: self.attrs.clone(),
9075+ try_token: self.try_token.clone(),
9076+ block: self.block.clone(),
9077+ }
9078+ }
9079+}
9080+#[cfg(feature = "full")]
9081+impl Clone for ExprTuple {
9082+ fn clone(&self) -> Self {
9083+ ExprTuple {
9084+ attrs: self.attrs.clone(),
9085+ paren_token: self.paren_token.clone(),
9086+ elems: self.elems.clone(),
9087+ }
9088+ }
9089+}
9090+#[cfg(feature = "full")]
9091+impl Clone for ExprType {
9092+ fn clone(&self) -> Self {
9093+ ExprType {
9094+ attrs: self.attrs.clone(),
9095+ expr: self.expr.clone(),
9096+ colon_token: self.colon_token.clone(),
9097+ ty: self.ty.clone(),
9098+ }
9099+ }
9100+}
9101+#[cfg(any(feature = "derive", feature = "full"))]
9102+impl Clone for ExprUnary {
9103+ fn clone(&self) -> Self {
9104+ ExprUnary {
9105+ attrs: self.attrs.clone(),
9106+ op: self.op.clone(),
9107+ expr: self.expr.clone(),
9108+ }
9109+ }
9110+}
9111+#[cfg(feature = "full")]
9112+impl Clone for ExprUnsafe {
9113+ fn clone(&self) -> Self {
9114+ ExprUnsafe {
9115+ attrs: self.attrs.clone(),
9116+ unsafe_token: self.unsafe_token.clone(),
9117+ block: self.block.clone(),
9118+ }
9119+ }
9120+}
9121+#[cfg(feature = "full")]
9122+impl Clone for ExprWhile {
9123+ fn clone(&self) -> Self {
9124+ ExprWhile {
9125+ attrs: self.attrs.clone(),
9126+ label: self.label.clone(),
9127+ while_token: self.while_token.clone(),
9128+ cond: self.cond.clone(),
9129+ body: self.body.clone(),
9130+ }
9131+ }
9132+}
9133+#[cfg(feature = "full")]
9134+impl Clone for ExprYield {
9135+ fn clone(&self) -> Self {
9136+ ExprYield {
9137+ attrs: self.attrs.clone(),
9138+ yield_token: self.yield_token.clone(),
9139+ expr: self.expr.clone(),
9140+ }
9141+ }
9142+}
9143+#[cfg(any(feature = "derive", feature = "full"))]
9144+impl Clone for Field {
9145+ fn clone(&self) -> Self {
9146+ Field {
9147+ attrs: self.attrs.clone(),
9148+ vis: self.vis.clone(),
9149+ ident: self.ident.clone(),
9150+ colon_token: self.colon_token.clone(),
9151+ ty: self.ty.clone(),
9152+ }
9153+ }
9154+}
9155+#[cfg(feature = "full")]
9156+impl Clone for FieldPat {
9157+ fn clone(&self) -> Self {
9158+ FieldPat {
9159+ attrs: self.attrs.clone(),
9160+ member: self.member.clone(),
9161+ colon_token: self.colon_token.clone(),
9162+ pat: self.pat.clone(),
9163+ }
9164+ }
9165+}
9166+#[cfg(feature = "full")]
9167+impl Clone for FieldValue {
9168+ fn clone(&self) -> Self {
9169+ FieldValue {
9170+ attrs: self.attrs.clone(),
9171+ member: self.member.clone(),
9172+ colon_token: self.colon_token.clone(),
9173+ expr: self.expr.clone(),
9174+ }
9175+ }
9176+}
9177+#[cfg(any(feature = "derive", feature = "full"))]
9178+impl Clone for Fields {
9179+ fn clone(&self) -> Self {
9180+ match self {
9181+ Fields::Named(v0) => Fields::Named(v0.clone()),
9182+ Fields::Unnamed(v0) => Fields::Unnamed(v0.clone()),
9183+ Fields::Unit => Fields::Unit,
9184+ }
9185+ }
9186+}
9187+#[cfg(any(feature = "derive", feature = "full"))]
9188+impl Clone for FieldsNamed {
9189+ fn clone(&self) -> Self {
9190+ FieldsNamed {
9191+ brace_token: self.brace_token.clone(),
9192+ named: self.named.clone(),
9193+ }
9194+ }
9195+}
9196+#[cfg(any(feature = "derive", feature = "full"))]
9197+impl Clone for FieldsUnnamed {
9198+ fn clone(&self) -> Self {
9199+ FieldsUnnamed {
9200+ paren_token: self.paren_token.clone(),
9201+ unnamed: self.unnamed.clone(),
9202+ }
9203+ }
9204+}
9205+#[cfg(feature = "full")]
9206+impl Clone for File {
9207+ fn clone(&self) -> Self {
9208+ File {
9209+ shebang: self.shebang.clone(),
9210+ attrs: self.attrs.clone(),
9211+ items: self.items.clone(),
9212+ }
9213+ }
9214+}
9215+#[cfg(feature = "full")]
9216+impl Clone for FnArg {
9217+ fn clone(&self) -> Self {
9218+ match self {
9219+ FnArg::Receiver(v0) => FnArg::Receiver(v0.clone()),
9220+ FnArg::Typed(v0) => FnArg::Typed(v0.clone()),
9221+ }
9222+ }
9223+}
9224+#[cfg(feature = "full")]
9225+impl Clone for ForeignItem {
9226+ fn clone(&self) -> Self {
9227+ match self {
9228+ ForeignItem::Fn(v0) => ForeignItem::Fn(v0.clone()),
9229+ ForeignItem::Static(v0) => ForeignItem::Static(v0.clone()),
9230+ ForeignItem::Type(v0) => ForeignItem::Type(v0.clone()),
9231+ ForeignItem::Macro(v0) => ForeignItem::Macro(v0.clone()),
9232+ ForeignItem::Verbatim(v0) => ForeignItem::Verbatim(v0.clone()),
9233+ _ => unreachable!(),
9234+ }
9235+ }
9236+}
9237+#[cfg(feature = "full")]
9238+impl Clone for ForeignItemFn {
9239+ fn clone(&self) -> Self {
9240+ ForeignItemFn {
9241+ attrs: self.attrs.clone(),
9242+ vis: self.vis.clone(),
9243+ sig: self.sig.clone(),
9244+ semi_token: self.semi_token.clone(),
9245+ }
9246+ }
9247+}
9248+#[cfg(feature = "full")]
9249+impl Clone for ForeignItemMacro {
9250+ fn clone(&self) -> Self {
9251+ ForeignItemMacro {
9252+ attrs: self.attrs.clone(),
9253+ mac: self.mac.clone(),
9254+ semi_token: self.semi_token.clone(),
9255+ }
9256+ }
9257+}
9258+#[cfg(feature = "full")]
9259+impl Clone for ForeignItemStatic {
9260+ fn clone(&self) -> Self {
9261+ ForeignItemStatic {
9262+ attrs: self.attrs.clone(),
9263+ vis: self.vis.clone(),
9264+ static_token: self.static_token.clone(),
9265+ mutability: self.mutability.clone(),
9266+ ident: self.ident.clone(),
9267+ colon_token: self.colon_token.clone(),
9268+ ty: self.ty.clone(),
9269+ semi_token: self.semi_token.clone(),
9270+ }
9271+ }
9272+}
9273+#[cfg(feature = "full")]
9274+impl Clone for ForeignItemType {
9275+ fn clone(&self) -> Self {
9276+ ForeignItemType {
9277+ attrs: self.attrs.clone(),
9278+ vis: self.vis.clone(),
9279+ type_token: self.type_token.clone(),
9280+ ident: self.ident.clone(),
9281+ semi_token: self.semi_token.clone(),
9282+ }
9283+ }
9284+}
9285+#[cfg(any(feature = "derive", feature = "full"))]
9286+impl Clone for GenericArgument {
9287+ fn clone(&self) -> Self {
9288+ match self {
9289+ GenericArgument::Lifetime(v0) => GenericArgument::Lifetime(v0.clone()),
9290+ GenericArgument::Type(v0) => GenericArgument::Type(v0.clone()),
9291+ GenericArgument::Binding(v0) => GenericArgument::Binding(v0.clone()),
9292+ GenericArgument::Constraint(v0) => GenericArgument::Constraint(v0.clone()),
9293+ GenericArgument::Const(v0) => GenericArgument::Const(v0.clone()),
9294+ }
9295+ }
9296+}
9297+#[cfg(feature = "full")]
9298+impl Clone for GenericMethodArgument {
9299+ fn clone(&self) -> Self {
9300+ match self {
9301+ GenericMethodArgument::Type(v0) => GenericMethodArgument::Type(v0.clone()),
9302+ GenericMethodArgument::Const(v0) => GenericMethodArgument::Const(v0.clone()),
9303+ }
9304+ }
9305+}
9306+#[cfg(any(feature = "derive", feature = "full"))]
9307+impl Clone for GenericParam {
9308+ fn clone(&self) -> Self {
9309+ match self {
9310+ GenericParam::Type(v0) => GenericParam::Type(v0.clone()),
9311+ GenericParam::Lifetime(v0) => GenericParam::Lifetime(v0.clone()),
9312+ GenericParam::Const(v0) => GenericParam::Const(v0.clone()),
9313+ }
9314+ }
9315+}
9316+#[cfg(any(feature = "derive", feature = "full"))]
9317+impl Clone for Generics {
9318+ fn clone(&self) -> Self {
9319+ Generics {
9320+ lt_token: self.lt_token.clone(),
9321+ params: self.params.clone(),
9322+ gt_token: self.gt_token.clone(),
9323+ where_clause: self.where_clause.clone(),
9324+ }
9325+ }
9326+}
9327+#[cfg(feature = "full")]
9328+impl Clone for ImplItem {
9329+ fn clone(&self) -> Self {
9330+ match self {
9331+ ImplItem::Const(v0) => ImplItem::Const(v0.clone()),
9332+ ImplItem::Method(v0) => ImplItem::Method(v0.clone()),
9333+ ImplItem::Type(v0) => ImplItem::Type(v0.clone()),
9334+ ImplItem::Macro(v0) => ImplItem::Macro(v0.clone()),
9335+ ImplItem::Verbatim(v0) => ImplItem::Verbatim(v0.clone()),
9336+ _ => unreachable!(),
9337+ }
9338+ }
9339+}
9340+#[cfg(feature = "full")]
9341+impl Clone for ImplItemConst {
9342+ fn clone(&self) -> Self {
9343+ ImplItemConst {
9344+ attrs: self.attrs.clone(),
9345+ vis: self.vis.clone(),
9346+ defaultness: self.defaultness.clone(),
9347+ const_token: self.const_token.clone(),
9348+ ident: self.ident.clone(),
9349+ colon_token: self.colon_token.clone(),
9350+ ty: self.ty.clone(),
9351+ eq_token: self.eq_token.clone(),
9352+ expr: self.expr.clone(),
9353+ semi_token: self.semi_token.clone(),
9354+ }
9355+ }
9356+}
9357+#[cfg(feature = "full")]
9358+impl Clone for ImplItemMacro {
9359+ fn clone(&self) -> Self {
9360+ ImplItemMacro {
9361+ attrs: self.attrs.clone(),
9362+ mac: self.mac.clone(),
9363+ semi_token: self.semi_token.clone(),
9364+ }
9365+ }
9366+}
9367+#[cfg(feature = "full")]
9368+impl Clone for ImplItemMethod {
9369+ fn clone(&self) -> Self {
9370+ ImplItemMethod {
9371+ attrs: self.attrs.clone(),
9372+ vis: self.vis.clone(),
9373+ defaultness: self.defaultness.clone(),
9374+ sig: self.sig.clone(),
9375+ block: self.block.clone(),
9376+ }
9377+ }
9378+}
9379+#[cfg(feature = "full")]
9380+impl Clone for ImplItemType {
9381+ fn clone(&self) -> Self {
9382+ ImplItemType {
9383+ attrs: self.attrs.clone(),
9384+ vis: self.vis.clone(),
9385+ defaultness: self.defaultness.clone(),
9386+ type_token: self.type_token.clone(),
9387+ ident: self.ident.clone(),
9388+ generics: self.generics.clone(),
9389+ eq_token: self.eq_token.clone(),
9390+ ty: self.ty.clone(),
9391+ semi_token: self.semi_token.clone(),
9392+ }
9393+ }
9394+}
9395+#[cfg(any(feature = "derive", feature = "full"))]
9396+impl Clone for Index {
9397+ fn clone(&self) -> Self {
9398+ Index {
9399+ index: self.index.clone(),
9400+ span: self.span.clone(),
9401+ }
9402+ }
9403+}
9404+#[cfg(feature = "full")]
9405+impl Clone for Item {
9406+ fn clone(&self) -> Self {
9407+ match self {
9408+ Item::Const(v0) => Item::Const(v0.clone()),
9409+ Item::Enum(v0) => Item::Enum(v0.clone()),
9410+ Item::ExternCrate(v0) => Item::ExternCrate(v0.clone()),
9411+ Item::Fn(v0) => Item::Fn(v0.clone()),
9412+ Item::ForeignMod(v0) => Item::ForeignMod(v0.clone()),
9413+ Item::Impl(v0) => Item::Impl(v0.clone()),
9414+ Item::Macro(v0) => Item::Macro(v0.clone()),
9415+ Item::Macro2(v0) => Item::Macro2(v0.clone()),
9416+ Item::Mod(v0) => Item::Mod(v0.clone()),
9417+ Item::Static(v0) => Item::Static(v0.clone()),
9418+ Item::Struct(v0) => Item::Struct(v0.clone()),
9419+ Item::Trait(v0) => Item::Trait(v0.clone()),
9420+ Item::TraitAlias(v0) => Item::TraitAlias(v0.clone()),
9421+ Item::Type(v0) => Item::Type(v0.clone()),
9422+ Item::Union(v0) => Item::Union(v0.clone()),
9423+ Item::Use(v0) => Item::Use(v0.clone()),
9424+ Item::Verbatim(v0) => Item::Verbatim(v0.clone()),
9425+ _ => unreachable!(),
9426+ }
9427+ }
9428+}
9429+#[cfg(feature = "full")]
9430+impl Clone for ItemConst {
9431+ fn clone(&self) -> Self {
9432+ ItemConst {
9433+ attrs: self.attrs.clone(),
9434+ vis: self.vis.clone(),
9435+ const_token: self.const_token.clone(),
9436+ ident: self.ident.clone(),
9437+ colon_token: self.colon_token.clone(),
9438+ ty: self.ty.clone(),
9439+ eq_token: self.eq_token.clone(),
9440+ expr: self.expr.clone(),
9441+ semi_token: self.semi_token.clone(),
9442+ }
9443+ }
9444+}
9445+#[cfg(feature = "full")]
9446+impl Clone for ItemEnum {
9447+ fn clone(&self) -> Self {
9448+ ItemEnum {
9449+ attrs: self.attrs.clone(),
9450+ vis: self.vis.clone(),
9451+ enum_token: self.enum_token.clone(),
9452+ ident: self.ident.clone(),
9453+ generics: self.generics.clone(),
9454+ brace_token: self.brace_token.clone(),
9455+ variants: self.variants.clone(),
9456+ }
9457+ }
9458+}
9459+#[cfg(feature = "full")]
9460+impl Clone for ItemExternCrate {
9461+ fn clone(&self) -> Self {
9462+ ItemExternCrate {
9463+ attrs: self.attrs.clone(),
9464+ vis: self.vis.clone(),
9465+ extern_token: self.extern_token.clone(),
9466+ crate_token: self.crate_token.clone(),
9467+ ident: self.ident.clone(),
9468+ rename: self.rename.clone(),
9469+ semi_token: self.semi_token.clone(),
9470+ }
9471+ }
9472+}
9473+#[cfg(feature = "full")]
9474+impl Clone for ItemFn {
9475+ fn clone(&self) -> Self {
9476+ ItemFn {
9477+ attrs: self.attrs.clone(),
9478+ vis: self.vis.clone(),
9479+ sig: self.sig.clone(),
9480+ block: self.block.clone(),
9481+ }
9482+ }
9483+}
9484+#[cfg(feature = "full")]
9485+impl Clone for ItemForeignMod {
9486+ fn clone(&self) -> Self {
9487+ ItemForeignMod {
9488+ attrs: self.attrs.clone(),
9489+ abi: self.abi.clone(),
9490+ brace_token: self.brace_token.clone(),
9491+ items: self.items.clone(),
9492+ }
9493+ }
9494+}
9495+#[cfg(feature = "full")]
9496+impl Clone for ItemImpl {
9497+ fn clone(&self) -> Self {
9498+ ItemImpl {
9499+ attrs: self.attrs.clone(),
9500+ defaultness: self.defaultness.clone(),
9501+ unsafety: self.unsafety.clone(),
9502+ impl_token: self.impl_token.clone(),
9503+ generics: self.generics.clone(),
9504+ trait_: self.trait_.clone(),
9505+ self_ty: self.self_ty.clone(),
9506+ brace_token: self.brace_token.clone(),
9507+ items: self.items.clone(),
9508+ }
9509+ }
9510+}
9511+#[cfg(feature = "full")]
9512+impl Clone for ItemMacro {
9513+ fn clone(&self) -> Self {
9514+ ItemMacro {
9515+ attrs: self.attrs.clone(),
9516+ ident: self.ident.clone(),
9517+ mac: self.mac.clone(),
9518+ semi_token: self.semi_token.clone(),
9519+ }
9520+ }
9521+}
9522+#[cfg(feature = "full")]
9523+impl Clone for ItemMacro2 {
9524+ fn clone(&self) -> Self {
9525+ ItemMacro2 {
9526+ attrs: self.attrs.clone(),
9527+ vis: self.vis.clone(),
9528+ macro_token: self.macro_token.clone(),
9529+ ident: self.ident.clone(),
9530+ rules: self.rules.clone(),
9531+ }
9532+ }
9533+}
9534+#[cfg(feature = "full")]
9535+impl Clone for ItemMod {
9536+ fn clone(&self) -> Self {
9537+ ItemMod {
9538+ attrs: self.attrs.clone(),
9539+ vis: self.vis.clone(),
9540+ mod_token: self.mod_token.clone(),
9541+ ident: self.ident.clone(),
9542+ content: self.content.clone(),
9543+ semi: self.semi.clone(),
9544+ }
9545+ }
9546+}
9547+#[cfg(feature = "full")]
9548+impl Clone for ItemStatic {
9549+ fn clone(&self) -> Self {
9550+ ItemStatic {
9551+ attrs: self.attrs.clone(),
9552+ vis: self.vis.clone(),
9553+ static_token: self.static_token.clone(),
9554+ mutability: self.mutability.clone(),
9555+ ident: self.ident.clone(),
9556+ colon_token: self.colon_token.clone(),
9557+ ty: self.ty.clone(),
9558+ eq_token: self.eq_token.clone(),
9559+ expr: self.expr.clone(),
9560+ semi_token: self.semi_token.clone(),
9561+ }
9562+ }
9563+}
9564+#[cfg(feature = "full")]
9565+impl Clone for ItemStruct {
9566+ fn clone(&self) -> Self {
9567+ ItemStruct {
9568+ attrs: self.attrs.clone(),
9569+ vis: self.vis.clone(),
9570+ struct_token: self.struct_token.clone(),
9571+ ident: self.ident.clone(),
9572+ generics: self.generics.clone(),
9573+ fields: self.fields.clone(),
9574+ semi_token: self.semi_token.clone(),
9575+ }
9576+ }
9577+}
9578+#[cfg(feature = "full")]
9579+impl Clone for ItemTrait {
9580+ fn clone(&self) -> Self {
9581+ ItemTrait {
9582+ attrs: self.attrs.clone(),
9583+ vis: self.vis.clone(),
9584+ unsafety: self.unsafety.clone(),
9585+ auto_token: self.auto_token.clone(),
9586+ trait_token: self.trait_token.clone(),
9587+ ident: self.ident.clone(),
9588+ generics: self.generics.clone(),
9589+ colon_token: self.colon_token.clone(),
9590+ supertraits: self.supertraits.clone(),
9591+ brace_token: self.brace_token.clone(),
9592+ items: self.items.clone(),
9593+ }
9594+ }
9595+}
9596+#[cfg(feature = "full")]
9597+impl Clone for ItemTraitAlias {
9598+ fn clone(&self) -> Self {
9599+ ItemTraitAlias {
9600+ attrs: self.attrs.clone(),
9601+ vis: self.vis.clone(),
9602+ trait_token: self.trait_token.clone(),
9603+ ident: self.ident.clone(),
9604+ generics: self.generics.clone(),
9605+ eq_token: self.eq_token.clone(),
9606+ bounds: self.bounds.clone(),
9607+ semi_token: self.semi_token.clone(),
9608+ }
9609+ }
9610+}
9611+#[cfg(feature = "full")]
9612+impl Clone for ItemType {
9613+ fn clone(&self) -> Self {
9614+ ItemType {
9615+ attrs: self.attrs.clone(),
9616+ vis: self.vis.clone(),
9617+ type_token: self.type_token.clone(),
9618+ ident: self.ident.clone(),
9619+ generics: self.generics.clone(),
9620+ eq_token: self.eq_token.clone(),
9621+ ty: self.ty.clone(),
9622+ semi_token: self.semi_token.clone(),
9623+ }
9624+ }
9625+}
9626+#[cfg(feature = "full")]
9627+impl Clone for ItemUnion {
9628+ fn clone(&self) -> Self {
9629+ ItemUnion {
9630+ attrs: self.attrs.clone(),
9631+ vis: self.vis.clone(),
9632+ union_token: self.union_token.clone(),
9633+ ident: self.ident.clone(),
9634+ generics: self.generics.clone(),
9635+ fields: self.fields.clone(),
9636+ }
9637+ }
9638+}
9639+#[cfg(feature = "full")]
9640+impl Clone for ItemUse {
9641+ fn clone(&self) -> Self {
9642+ ItemUse {
9643+ attrs: self.attrs.clone(),
9644+ vis: self.vis.clone(),
9645+ use_token: self.use_token.clone(),
9646+ leading_colon: self.leading_colon.clone(),
9647+ tree: self.tree.clone(),
9648+ semi_token: self.semi_token.clone(),
9649+ }
9650+ }
9651+}
9652+#[cfg(feature = "full")]
9653+impl Clone for Label {
9654+ fn clone(&self) -> Self {
9655+ Label {
9656+ name: self.name.clone(),
9657+ colon_token: self.colon_token.clone(),
9658+ }
9659+ }
9660+}
9661+#[cfg(any(feature = "derive", feature = "full"))]
9662+impl Clone for LifetimeDef {
9663+ fn clone(&self) -> Self {
9664+ LifetimeDef {
9665+ attrs: self.attrs.clone(),
9666+ lifetime: self.lifetime.clone(),
9667+ colon_token: self.colon_token.clone(),
9668+ bounds: self.bounds.clone(),
9669+ }
9670+ }
9671+}
9672+impl Clone for Lit {
9673+ fn clone(&self) -> Self {
9674+ match self {
9675+ Lit::Str(v0) => Lit::Str(v0.clone()),
9676+ Lit::ByteStr(v0) => Lit::ByteStr(v0.clone()),
9677+ Lit::Byte(v0) => Lit::Byte(v0.clone()),
9678+ Lit::Char(v0) => Lit::Char(v0.clone()),
9679+ Lit::Int(v0) => Lit::Int(v0.clone()),
9680+ Lit::Float(v0) => Lit::Float(v0.clone()),
9681+ Lit::Bool(v0) => Lit::Bool(v0.clone()),
9682+ Lit::Verbatim(v0) => Lit::Verbatim(v0.clone()),
9683+ }
9684+ }
9685+}
9686+impl Clone for LitBool {
9687+ fn clone(&self) -> Self {
9688+ LitBool {
9689+ value: self.value.clone(),
9690+ span: self.span.clone(),
9691+ }
9692+ }
9693+}
9694+#[cfg(feature = "full")]
9695+impl Clone for Local {
9696+ fn clone(&self) -> Self {
9697+ Local {
9698+ attrs: self.attrs.clone(),
9699+ let_token: self.let_token.clone(),
9700+ pat: self.pat.clone(),
9701+ init: self.init.clone(),
9702+ semi_token: self.semi_token.clone(),
9703+ }
9704+ }
9705+}
9706+#[cfg(any(feature = "derive", feature = "full"))]
9707+impl Clone for Macro {
9708+ fn clone(&self) -> Self {
9709+ Macro {
9710+ path: self.path.clone(),
9711+ bang_token: self.bang_token.clone(),
9712+ delimiter: self.delimiter.clone(),
9713+ tokens: self.tokens.clone(),
9714+ }
9715+ }
9716+}
9717+#[cfg(any(feature = "derive", feature = "full"))]
9718+impl Clone for MacroDelimiter {
9719+ fn clone(&self) -> Self {
9720+ match self {
9721+ MacroDelimiter::Paren(v0) => MacroDelimiter::Paren(v0.clone()),
9722+ MacroDelimiter::Brace(v0) => MacroDelimiter::Brace(v0.clone()),
9723+ MacroDelimiter::Bracket(v0) => MacroDelimiter::Bracket(v0.clone()),
9724+ }
9725+ }
9726+}
9727+#[cfg(any(feature = "derive", feature = "full"))]
9728+impl Clone for Member {
9729+ fn clone(&self) -> Self {
9730+ match self {
9731+ Member::Named(v0) => Member::Named(v0.clone()),
9732+ Member::Unnamed(v0) => Member::Unnamed(v0.clone()),
9733+ }
9734+ }
9735+}
9736+#[cfg(any(feature = "derive", feature = "full"))]
9737+impl Clone for Meta {
9738+ fn clone(&self) -> Self {
9739+ match self {
9740+ Meta::Path(v0) => Meta::Path(v0.clone()),
9741+ Meta::List(v0) => Meta::List(v0.clone()),
9742+ Meta::NameValue(v0) => Meta::NameValue(v0.clone()),
9743+ }
9744+ }
9745+}
9746+#[cfg(any(feature = "derive", feature = "full"))]
9747+impl Clone for MetaList {
9748+ fn clone(&self) -> Self {
9749+ MetaList {
9750+ path: self.path.clone(),
9751+ paren_token: self.paren_token.clone(),
9752+ nested: self.nested.clone(),
9753+ }
9754+ }
9755+}
9756+#[cfg(any(feature = "derive", feature = "full"))]
9757+impl Clone for MetaNameValue {
9758+ fn clone(&self) -> Self {
9759+ MetaNameValue {
9760+ path: self.path.clone(),
9761+ eq_token: self.eq_token.clone(),
9762+ lit: self.lit.clone(),
9763+ }
9764+ }
9765+}
9766+#[cfg(feature = "full")]
9767+impl Clone for MethodTurbofish {
9768+ fn clone(&self) -> Self {
9769+ MethodTurbofish {
9770+ colon2_token: self.colon2_token.clone(),
9771+ lt_token: self.lt_token.clone(),
9772+ args: self.args.clone(),
9773+ gt_token: self.gt_token.clone(),
9774+ }
9775+ }
9776+}
9777+#[cfg(any(feature = "derive", feature = "full"))]
9778+impl Clone for NestedMeta {
9779+ fn clone(&self) -> Self {
9780+ match self {
9781+ NestedMeta::Meta(v0) => NestedMeta::Meta(v0.clone()),
9782+ NestedMeta::Lit(v0) => NestedMeta::Lit(v0.clone()),
9783+ }
9784+ }
9785+}
9786+#[cfg(any(feature = "derive", feature = "full"))]
9787+impl Clone for ParenthesizedGenericArguments {
9788+ fn clone(&self) -> Self {
9789+ ParenthesizedGenericArguments {
9790+ paren_token: self.paren_token.clone(),
9791+ inputs: self.inputs.clone(),
9792+ output: self.output.clone(),
9793+ }
9794+ }
9795+}
9796+#[cfg(feature = "full")]
9797+impl Clone for Pat {
9798+ fn clone(&self) -> Self {
9799+ match self {
9800+ Pat::Box(v0) => Pat::Box(v0.clone()),
9801+ Pat::Ident(v0) => Pat::Ident(v0.clone()),
9802+ Pat::Lit(v0) => Pat::Lit(v0.clone()),
9803+ Pat::Macro(v0) => Pat::Macro(v0.clone()),
9804+ Pat::Or(v0) => Pat::Or(v0.clone()),
9805+ Pat::Path(v0) => Pat::Path(v0.clone()),
9806+ Pat::Range(v0) => Pat::Range(v0.clone()),
9807+ Pat::Reference(v0) => Pat::Reference(v0.clone()),
9808+ Pat::Rest(v0) => Pat::Rest(v0.clone()),
9809+ Pat::Slice(v0) => Pat::Slice(v0.clone()),
9810+ Pat::Struct(v0) => Pat::Struct(v0.clone()),
9811+ Pat::Tuple(v0) => Pat::Tuple(v0.clone()),
9812+ Pat::TupleStruct(v0) => Pat::TupleStruct(v0.clone()),
9813+ Pat::Type(v0) => Pat::Type(v0.clone()),
9814+ Pat::Verbatim(v0) => Pat::Verbatim(v0.clone()),
9815+ Pat::Wild(v0) => Pat::Wild(v0.clone()),
9816+ _ => unreachable!(),
9817+ }
9818+ }
9819+}
9820+#[cfg(feature = "full")]
9821+impl Clone for PatBox {
9822+ fn clone(&self) -> Self {
9823+ PatBox {
9824+ attrs: self.attrs.clone(),
9825+ box_token: self.box_token.clone(),
9826+ pat: self.pat.clone(),
9827+ }
9828+ }
9829+}
9830+#[cfg(feature = "full")]
9831+impl Clone for PatIdent {
9832+ fn clone(&self) -> Self {
9833+ PatIdent {
9834+ attrs: self.attrs.clone(),
9835+ by_ref: self.by_ref.clone(),
9836+ mutability: self.mutability.clone(),
9837+ ident: self.ident.clone(),
9838+ subpat: self.subpat.clone(),
9839+ }
9840+ }
9841+}
9842+#[cfg(feature = "full")]
9843+impl Clone for PatLit {
9844+ fn clone(&self) -> Self {
9845+ PatLit {
9846+ attrs: self.attrs.clone(),
9847+ expr: self.expr.clone(),
9848+ }
9849+ }
9850+}
9851+#[cfg(feature = "full")]
9852+impl Clone for PatMacro {
9853+ fn clone(&self) -> Self {
9854+ PatMacro {
9855+ attrs: self.attrs.clone(),
9856+ mac: self.mac.clone(),
9857+ }
9858+ }
9859+}
9860+#[cfg(feature = "full")]
9861+impl Clone for PatOr {
9862+ fn clone(&self) -> Self {
9863+ PatOr {
9864+ attrs: self.attrs.clone(),
9865+ leading_vert: self.leading_vert.clone(),
9866+ cases: self.cases.clone(),
9867+ }
9868+ }
9869+}
9870+#[cfg(feature = "full")]
9871+impl Clone for PatPath {
9872+ fn clone(&self) -> Self {
9873+ PatPath {
9874+ attrs: self.attrs.clone(),
9875+ qself: self.qself.clone(),
9876+ path: self.path.clone(),
9877+ }
9878+ }
9879+}
9880+#[cfg(feature = "full")]
9881+impl Clone for PatRange {
9882+ fn clone(&self) -> Self {
9883+ PatRange {
9884+ attrs: self.attrs.clone(),
9885+ lo: self.lo.clone(),
9886+ limits: self.limits.clone(),
9887+ hi: self.hi.clone(),
9888+ }
9889+ }
9890+}
9891+#[cfg(feature = "full")]
9892+impl Clone for PatReference {
9893+ fn clone(&self) -> Self {
9894+ PatReference {
9895+ attrs: self.attrs.clone(),
9896+ and_token: self.and_token.clone(),
9897+ mutability: self.mutability.clone(),
9898+ pat: self.pat.clone(),
9899+ }
9900+ }
9901+}
9902+#[cfg(feature = "full")]
9903+impl Clone for PatRest {
9904+ fn clone(&self) -> Self {
9905+ PatRest {
9906+ attrs: self.attrs.clone(),
9907+ dot2_token: self.dot2_token.clone(),
9908+ }
9909+ }
9910+}
9911+#[cfg(feature = "full")]
9912+impl Clone for PatSlice {
9913+ fn clone(&self) -> Self {
9914+ PatSlice {
9915+ attrs: self.attrs.clone(),
9916+ bracket_token: self.bracket_token.clone(),
9917+ elems: self.elems.clone(),
9918+ }
9919+ }
9920+}
9921+#[cfg(feature = "full")]
9922+impl Clone for PatStruct {
9923+ fn clone(&self) -> Self {
9924+ PatStruct {
9925+ attrs: self.attrs.clone(),
9926+ path: self.path.clone(),
9927+ brace_token: self.brace_token.clone(),
9928+ fields: self.fields.clone(),
9929+ dot2_token: self.dot2_token.clone(),
9930+ }
9931+ }
9932+}
9933+#[cfg(feature = "full")]
9934+impl Clone for PatTuple {
9935+ fn clone(&self) -> Self {
9936+ PatTuple {
9937+ attrs: self.attrs.clone(),
9938+ paren_token: self.paren_token.clone(),
9939+ elems: self.elems.clone(),
9940+ }
9941+ }
9942+}
9943+#[cfg(feature = "full")]
9944+impl Clone for PatTupleStruct {
9945+ fn clone(&self) -> Self {
9946+ PatTupleStruct {
9947+ attrs: self.attrs.clone(),
9948+ path: self.path.clone(),
9949+ pat: self.pat.clone(),
9950+ }
9951+ }
9952+}
9953+#[cfg(feature = "full")]
9954+impl Clone for PatType {
9955+ fn clone(&self) -> Self {
9956+ PatType {
9957+ attrs: self.attrs.clone(),
9958+ pat: self.pat.clone(),
9959+ colon_token: self.colon_token.clone(),
9960+ ty: self.ty.clone(),
9961+ }
9962+ }
9963+}
9964+#[cfg(feature = "full")]
9965+impl Clone for PatWild {
9966+ fn clone(&self) -> Self {
9967+ PatWild {
9968+ attrs: self.attrs.clone(),
9969+ underscore_token: self.underscore_token.clone(),
9970+ }
9971+ }
9972+}
9973+#[cfg(any(feature = "derive", feature = "full"))]
9974+impl Clone for Path {
9975+ fn clone(&self) -> Self {
9976+ Path {
9977+ leading_colon: self.leading_colon.clone(),
9978+ segments: self.segments.clone(),
9979+ }
9980+ }
9981+}
9982+#[cfg(any(feature = "derive", feature = "full"))]
9983+impl Clone for PathArguments {
9984+ fn clone(&self) -> Self {
9985+ match self {
9986+ PathArguments::None => PathArguments::None,
9987+ PathArguments::AngleBracketed(v0) => PathArguments::AngleBracketed(v0.clone()),
9988+ PathArguments::Parenthesized(v0) => PathArguments::Parenthesized(v0.clone()),
9989+ }
9990+ }
9991+}
9992+#[cfg(any(feature = "derive", feature = "full"))]
9993+impl Clone for PathSegment {
9994+ fn clone(&self) -> Self {
9995+ PathSegment {
9996+ ident: self.ident.clone(),
9997+ arguments: self.arguments.clone(),
9998+ }
9999+ }
10000+}
10001+#[cfg(any(feature = "derive", feature = "full"))]
10002+impl Clone for PredicateEq {
10003+ fn clone(&self) -> Self {
10004+ PredicateEq {
10005+ lhs_ty: self.lhs_ty.clone(),
10006+ eq_token: self.eq_token.clone(),
10007+ rhs_ty: self.rhs_ty.clone(),
10008+ }
10009+ }
10010+}
10011+#[cfg(any(feature = "derive", feature = "full"))]
10012+impl Clone for PredicateLifetime {
10013+ fn clone(&self) -> Self {
10014+ PredicateLifetime {
10015+ lifetime: self.lifetime.clone(),
10016+ colon_token: self.colon_token.clone(),
10017+ bounds: self.bounds.clone(),
10018+ }
10019+ }
10020+}
10021+#[cfg(any(feature = "derive", feature = "full"))]
10022+impl Clone for PredicateType {
10023+ fn clone(&self) -> Self {
10024+ PredicateType {
10025+ lifetimes: self.lifetimes.clone(),
10026+ bounded_ty: self.bounded_ty.clone(),
10027+ colon_token: self.colon_token.clone(),
10028+ bounds: self.bounds.clone(),
10029+ }
10030+ }
10031+}
10032+#[cfg(any(feature = "derive", feature = "full"))]
10033+impl Clone for QSelf {
10034+ fn clone(&self) -> Self {
10035+ QSelf {
10036+ lt_token: self.lt_token.clone(),
10037+ ty: self.ty.clone(),
10038+ position: self.position.clone(),
10039+ as_token: self.as_token.clone(),
10040+ gt_token: self.gt_token.clone(),
10041+ }
10042+ }
10043+}
10044+#[cfg(feature = "full")]
10045+impl Copy for RangeLimits {}
10046+#[cfg(feature = "full")]
10047+impl Clone for RangeLimits {
10048+ fn clone(&self) -> Self {
10049+ *self
10050+ }
10051+}
10052+#[cfg(feature = "full")]
10053+impl Clone for Receiver {
10054+ fn clone(&self) -> Self {
10055+ Receiver {
10056+ attrs: self.attrs.clone(),
10057+ reference: self.reference.clone(),
10058+ mutability: self.mutability.clone(),
10059+ self_token: self.self_token.clone(),
10060+ }
10061+ }
10062+}
10063+#[cfg(any(feature = "derive", feature = "full"))]
10064+impl Clone for ReturnType {
10065+ fn clone(&self) -> Self {
10066+ match self {
10067+ ReturnType::Default => ReturnType::Default,
10068+ ReturnType::Type(v0, v1) => ReturnType::Type(v0.clone(), v1.clone()),
10069+ }
10070+ }
10071+}
10072+#[cfg(feature = "full")]
10073+impl Clone for Signature {
10074+ fn clone(&self) -> Self {
10075+ Signature {
10076+ constness: self.constness.clone(),
10077+ asyncness: self.asyncness.clone(),
10078+ unsafety: self.unsafety.clone(),
10079+ abi: self.abi.clone(),
10080+ fn_token: self.fn_token.clone(),
10081+ ident: self.ident.clone(),
10082+ generics: self.generics.clone(),
10083+ paren_token: self.paren_token.clone(),
10084+ inputs: self.inputs.clone(),
10085+ variadic: self.variadic.clone(),
10086+ output: self.output.clone(),
10087+ }
10088+ }
10089+}
10090+#[cfg(feature = "full")]
10091+impl Clone for Stmt {
10092+ fn clone(&self) -> Self {
10093+ match self {
10094+ Stmt::Local(v0) => Stmt::Local(v0.clone()),
10095+ Stmt::Item(v0) => Stmt::Item(v0.clone()),
10096+ Stmt::Expr(v0) => Stmt::Expr(v0.clone()),
10097+ Stmt::Semi(v0, v1) => Stmt::Semi(v0.clone(), v1.clone()),
10098+ }
10099+ }
10100+}
10101+#[cfg(any(feature = "derive", feature = "full"))]
10102+impl Clone for TraitBound {
10103+ fn clone(&self) -> Self {
10104+ TraitBound {
10105+ paren_token: self.paren_token.clone(),
10106+ modifier: self.modifier.clone(),
10107+ lifetimes: self.lifetimes.clone(),
10108+ path: self.path.clone(),
10109+ }
10110+ }
10111+}
10112+#[cfg(any(feature = "derive", feature = "full"))]
10113+impl Copy for TraitBoundModifier {}
10114+#[cfg(any(feature = "derive", feature = "full"))]
10115+impl Clone for TraitBoundModifier {
10116+ fn clone(&self) -> Self {
10117+ *self
10118+ }
10119+}
10120+#[cfg(feature = "full")]
10121+impl Clone for TraitItem {
10122+ fn clone(&self) -> Self {
10123+ match self {
10124+ TraitItem::Const(v0) => TraitItem::Const(v0.clone()),
10125+ TraitItem::Method(v0) => TraitItem::Method(v0.clone()),
10126+ TraitItem::Type(v0) => TraitItem::Type(v0.clone()),
10127+ TraitItem::Macro(v0) => TraitItem::Macro(v0.clone()),
10128+ TraitItem::Verbatim(v0) => TraitItem::Verbatim(v0.clone()),
10129+ _ => unreachable!(),
10130+ }
10131+ }
10132+}
10133+#[cfg(feature = "full")]
10134+impl Clone for TraitItemConst {
10135+ fn clone(&self) -> Self {
10136+ TraitItemConst {
10137+ attrs: self.attrs.clone(),
10138+ const_token: self.const_token.clone(),
10139+ ident: self.ident.clone(),
10140+ colon_token: self.colon_token.clone(),
10141+ ty: self.ty.clone(),
10142+ default: self.default.clone(),
10143+ semi_token: self.semi_token.clone(),
10144+ }
10145+ }
10146+}
10147+#[cfg(feature = "full")]
10148+impl Clone for TraitItemMacro {
10149+ fn clone(&self) -> Self {
10150+ TraitItemMacro {
10151+ attrs: self.attrs.clone(),
10152+ mac: self.mac.clone(),
10153+ semi_token: self.semi_token.clone(),
10154+ }
10155+ }
10156+}
10157+#[cfg(feature = "full")]
10158+impl Clone for TraitItemMethod {
10159+ fn clone(&self) -> Self {
10160+ TraitItemMethod {
10161+ attrs: self.attrs.clone(),
10162+ sig: self.sig.clone(),
10163+ default: self.default.clone(),
10164+ semi_token: self.semi_token.clone(),
10165+ }
10166+ }
10167+}
10168+#[cfg(feature = "full")]
10169+impl Clone for TraitItemType {
10170+ fn clone(&self) -> Self {
10171+ TraitItemType {
10172+ attrs: self.attrs.clone(),
10173+ type_token: self.type_token.clone(),
10174+ ident: self.ident.clone(),
10175+ generics: self.generics.clone(),
10176+ colon_token: self.colon_token.clone(),
10177+ bounds: self.bounds.clone(),
10178+ default: self.default.clone(),
10179+ semi_token: self.semi_token.clone(),
10180+ }
10181+ }
10182+}
10183+#[cfg(any(feature = "derive", feature = "full"))]
10184+impl Clone for Type {
10185+ fn clone(&self) -> Self {
10186+ match self {
10187+ Type::Array(v0) => Type::Array(v0.clone()),
10188+ Type::BareFn(v0) => Type::BareFn(v0.clone()),
10189+ Type::Group(v0) => Type::Group(v0.clone()),
10190+ Type::ImplTrait(v0) => Type::ImplTrait(v0.clone()),
10191+ Type::Infer(v0) => Type::Infer(v0.clone()),
10192+ Type::Macro(v0) => Type::Macro(v0.clone()),
10193+ Type::Never(v0) => Type::Never(v0.clone()),
10194+ Type::Paren(v0) => Type::Paren(v0.clone()),
10195+ Type::Path(v0) => Type::Path(v0.clone()),
10196+ Type::Ptr(v0) => Type::Ptr(v0.clone()),
10197+ Type::Reference(v0) => Type::Reference(v0.clone()),
10198+ Type::Slice(v0) => Type::Slice(v0.clone()),
10199+ Type::TraitObject(v0) => Type::TraitObject(v0.clone()),
10200+ Type::Tuple(v0) => Type::Tuple(v0.clone()),
10201+ Type::Verbatim(v0) => Type::Verbatim(v0.clone()),
10202+ _ => unreachable!(),
10203+ }
10204+ }
10205+}
10206+#[cfg(any(feature = "derive", feature = "full"))]
10207+impl Clone for TypeArray {
10208+ fn clone(&self) -> Self {
10209+ TypeArray {
10210+ bracket_token: self.bracket_token.clone(),
10211+ elem: self.elem.clone(),
10212+ semi_token: self.semi_token.clone(),
10213+ len: self.len.clone(),
10214+ }
10215+ }
10216+}
10217+#[cfg(any(feature = "derive", feature = "full"))]
10218+impl Clone for TypeBareFn {
10219+ fn clone(&self) -> Self {
10220+ TypeBareFn {
10221+ lifetimes: self.lifetimes.clone(),
10222+ unsafety: self.unsafety.clone(),
10223+ abi: self.abi.clone(),
10224+ fn_token: self.fn_token.clone(),
10225+ paren_token: self.paren_token.clone(),
10226+ inputs: self.inputs.clone(),
10227+ variadic: self.variadic.clone(),
10228+ output: self.output.clone(),
10229+ }
10230+ }
10231+}
10232+#[cfg(any(feature = "derive", feature = "full"))]
10233+impl Clone for TypeGroup {
10234+ fn clone(&self) -> Self {
10235+ TypeGroup {
10236+ group_token: self.group_token.clone(),
10237+ elem: self.elem.clone(),
10238+ }
10239+ }
10240+}
10241+#[cfg(any(feature = "derive", feature = "full"))]
10242+impl Clone for TypeImplTrait {
10243+ fn clone(&self) -> Self {
10244+ TypeImplTrait {
10245+ impl_token: self.impl_token.clone(),
10246+ bounds: self.bounds.clone(),
10247+ }
10248+ }
10249+}
10250+#[cfg(any(feature = "derive", feature = "full"))]
10251+impl Clone for TypeInfer {
10252+ fn clone(&self) -> Self {
10253+ TypeInfer {
10254+ underscore_token: self.underscore_token.clone(),
10255+ }
10256+ }
10257+}
10258+#[cfg(any(feature = "derive", feature = "full"))]
10259+impl Clone for TypeMacro {
10260+ fn clone(&self) -> Self {
10261+ TypeMacro {
10262+ mac: self.mac.clone(),
10263+ }
10264+ }
10265+}
10266+#[cfg(any(feature = "derive", feature = "full"))]
10267+impl Clone for TypeNever {
10268+ fn clone(&self) -> Self {
10269+ TypeNever {
10270+ bang_token: self.bang_token.clone(),
10271+ }
10272+ }
10273+}
10274+#[cfg(any(feature = "derive", feature = "full"))]
10275+impl Clone for TypeParam {
10276+ fn clone(&self) -> Self {
10277+ TypeParam {
10278+ attrs: self.attrs.clone(),
10279+ ident: self.ident.clone(),
10280+ colon_token: self.colon_token.clone(),
10281+ bounds: self.bounds.clone(),
10282+ eq_token: self.eq_token.clone(),
10283+ default: self.default.clone(),
10284+ }
10285+ }
10286+}
10287+#[cfg(any(feature = "derive", feature = "full"))]
10288+impl Clone for TypeParamBound {
10289+ fn clone(&self) -> Self {
10290+ match self {
10291+ TypeParamBound::Trait(v0) => TypeParamBound::Trait(v0.clone()),
10292+ TypeParamBound::Lifetime(v0) => TypeParamBound::Lifetime(v0.clone()),
10293+ }
10294+ }
10295+}
10296+#[cfg(any(feature = "derive", feature = "full"))]
10297+impl Clone for TypeParen {
10298+ fn clone(&self) -> Self {
10299+ TypeParen {
10300+ paren_token: self.paren_token.clone(),
10301+ elem: self.elem.clone(),
10302+ }
10303+ }
10304+}
10305+#[cfg(any(feature = "derive", feature = "full"))]
10306+impl Clone for TypePath {
10307+ fn clone(&self) -> Self {
10308+ TypePath {
10309+ qself: self.qself.clone(),
10310+ path: self.path.clone(),
10311+ }
10312+ }
10313+}
10314+#[cfg(any(feature = "derive", feature = "full"))]
10315+impl Clone for TypePtr {
10316+ fn clone(&self) -> Self {
10317+ TypePtr {
10318+ star_token: self.star_token.clone(),
10319+ const_token: self.const_token.clone(),
10320+ mutability: self.mutability.clone(),
10321+ elem: self.elem.clone(),
10322+ }
10323+ }
10324+}
10325+#[cfg(any(feature = "derive", feature = "full"))]
10326+impl Clone for TypeReference {
10327+ fn clone(&self) -> Self {
10328+ TypeReference {
10329+ and_token: self.and_token.clone(),
10330+ lifetime: self.lifetime.clone(),
10331+ mutability: self.mutability.clone(),
10332+ elem: self.elem.clone(),
10333+ }
10334+ }
10335+}
10336+#[cfg(any(feature = "derive", feature = "full"))]
10337+impl Clone for TypeSlice {
10338+ fn clone(&self) -> Self {
10339+ TypeSlice {
10340+ bracket_token: self.bracket_token.clone(),
10341+ elem: self.elem.clone(),
10342+ }
10343+ }
10344+}
10345+#[cfg(any(feature = "derive", feature = "full"))]
10346+impl Clone for TypeTraitObject {
10347+ fn clone(&self) -> Self {
10348+ TypeTraitObject {
10349+ dyn_token: self.dyn_token.clone(),
10350+ bounds: self.bounds.clone(),
10351+ }
10352+ }
10353+}
10354+#[cfg(any(feature = "derive", feature = "full"))]
10355+impl Clone for TypeTuple {
10356+ fn clone(&self) -> Self {
10357+ TypeTuple {
10358+ paren_token: self.paren_token.clone(),
10359+ elems: self.elems.clone(),
10360+ }
10361+ }
10362+}
10363+#[cfg(any(feature = "derive", feature = "full"))]
10364+impl Copy for UnOp {}
10365+#[cfg(any(feature = "derive", feature = "full"))]
10366+impl Clone for UnOp {
10367+ fn clone(&self) -> Self {
10368+ *self
10369+ }
10370+}
10371+#[cfg(feature = "full")]
10372+impl Clone for UseGlob {
10373+ fn clone(&self) -> Self {
10374+ UseGlob {
10375+ star_token: self.star_token.clone(),
10376+ }
10377+ }
10378+}
10379+#[cfg(feature = "full")]
10380+impl Clone for UseGroup {
10381+ fn clone(&self) -> Self {
10382+ UseGroup {
10383+ brace_token: self.brace_token.clone(),
10384+ items: self.items.clone(),
10385+ }
10386+ }
10387+}
10388+#[cfg(feature = "full")]
10389+impl Clone for UseName {
10390+ fn clone(&self) -> Self {
10391+ UseName {
10392+ ident: self.ident.clone(),
10393+ }
10394+ }
10395+}
10396+#[cfg(feature = "full")]
10397+impl Clone for UsePath {
10398+ fn clone(&self) -> Self {
10399+ UsePath {
10400+ ident: self.ident.clone(),
10401+ colon2_token: self.colon2_token.clone(),
10402+ tree: self.tree.clone(),
10403+ }
10404+ }
10405+}
10406+#[cfg(feature = "full")]
10407+impl Clone for UseRename {
10408+ fn clone(&self) -> Self {
10409+ UseRename {
10410+ ident: self.ident.clone(),
10411+ as_token: self.as_token.clone(),
10412+ rename: self.rename.clone(),
10413+ }
10414+ }
10415+}
10416+#[cfg(feature = "full")]
10417+impl Clone for UseTree {
10418+ fn clone(&self) -> Self {
10419+ match self {
10420+ UseTree::Path(v0) => UseTree::Path(v0.clone()),
10421+ UseTree::Name(v0) => UseTree::Name(v0.clone()),
10422+ UseTree::Rename(v0) => UseTree::Rename(v0.clone()),
10423+ UseTree::Glob(v0) => UseTree::Glob(v0.clone()),
10424+ UseTree::Group(v0) => UseTree::Group(v0.clone()),
10425+ }
10426+ }
10427+}
10428+#[cfg(any(feature = "derive", feature = "full"))]
10429+impl Clone for Variadic {
10430+ fn clone(&self) -> Self {
10431+ Variadic {
10432+ attrs: self.attrs.clone(),
10433+ dots: self.dots.clone(),
10434+ }
10435+ }
10436+}
10437+#[cfg(any(feature = "derive", feature = "full"))]
10438+impl Clone for Variant {
10439+ fn clone(&self) -> Self {
10440+ Variant {
10441+ attrs: self.attrs.clone(),
10442+ ident: self.ident.clone(),
10443+ fields: self.fields.clone(),
10444+ discriminant: self.discriminant.clone(),
10445+ }
10446+ }
10447+}
10448+#[cfg(any(feature = "derive", feature = "full"))]
10449+impl Clone for VisCrate {
10450+ fn clone(&self) -> Self {
10451+ VisCrate {
10452+ crate_token: self.crate_token.clone(),
10453+ }
10454+ }
10455+}
10456+#[cfg(any(feature = "derive", feature = "full"))]
10457+impl Clone for VisPublic {
10458+ fn clone(&self) -> Self {
10459+ VisPublic {
10460+ pub_token: self.pub_token.clone(),
10461+ }
10462+ }
10463+}
10464+#[cfg(any(feature = "derive", feature = "full"))]
10465+impl Clone for VisRestricted {
10466+ fn clone(&self) -> Self {
10467+ VisRestricted {
10468+ pub_token: self.pub_token.clone(),
10469+ paren_token: self.paren_token.clone(),
10470+ in_token: self.in_token.clone(),
10471+ path: self.path.clone(),
10472+ }
10473+ }
10474+}
10475+#[cfg(any(feature = "derive", feature = "full"))]
10476+impl Clone for Visibility {
10477+ fn clone(&self) -> Self {
10478+ match self {
10479+ Visibility::Public(v0) => Visibility::Public(v0.clone()),
10480+ Visibility::Crate(v0) => Visibility::Crate(v0.clone()),
10481+ Visibility::Restricted(v0) => Visibility::Restricted(v0.clone()),
10482+ Visibility::Inherited => Visibility::Inherited,
10483+ }
10484+ }
10485+}
10486+#[cfg(any(feature = "derive", feature = "full"))]
10487+impl Clone for WhereClause {
10488+ fn clone(&self) -> Self {
10489+ WhereClause {
10490+ where_token: self.where_token.clone(),
10491+ predicates: self.predicates.clone(),
10492+ }
10493+ }
10494+}
10495+#[cfg(any(feature = "derive", feature = "full"))]
10496+impl Clone for WherePredicate {
10497+ fn clone(&self) -> Self {
10498+ match self {
10499+ WherePredicate::Type(v0) => WherePredicate::Type(v0.clone()),
10500+ WherePredicate::Lifetime(v0) => WherePredicate::Lifetime(v0.clone()),
10501+ WherePredicate::Eq(v0) => WherePredicate::Eq(v0.clone()),
10502+ }
10503+ }
10504+}
10505diff --git a/third_party/rust/syn/src/gen/debug.rs b/third_party/rust/syn/src/gen/debug.rs
10506new file mode 100644
10507--- /dev/null
10508+++ b/third_party/rust/syn/src/gen/debug.rs
10509@@ -0,0 +1,2857 @@
10510+// This file is @generated by syn-internal-codegen.
10511+// It is not intended for manual editing.
10512+
10513+use crate::*;
10514+use std::fmt::{self, Debug};
10515+#[cfg(any(feature = "derive", feature = "full"))]
10516+impl Debug for Abi {
10517+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10518+ let mut formatter = formatter.debug_struct("Abi");
10519+ formatter.field("extern_token", &self.extern_token);
10520+ formatter.field("name", &self.name);
10521+ formatter.finish()
10522+ }
10523+}
10524+#[cfg(any(feature = "derive", feature = "full"))]
10525+impl Debug for AngleBracketedGenericArguments {
10526+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10527+ let mut formatter = formatter.debug_struct("AngleBracketedGenericArguments");
10528+ formatter.field("colon2_token", &self.colon2_token);
10529+ formatter.field("lt_token", &self.lt_token);
10530+ formatter.field("args", &self.args);
10531+ formatter.field("gt_token", &self.gt_token);
10532+ formatter.finish()
10533+ }
10534+}
10535+#[cfg(feature = "full")]
10536+impl Debug for Arm {
10537+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10538+ let mut formatter = formatter.debug_struct("Arm");
10539+ formatter.field("attrs", &self.attrs);
10540+ formatter.field("pat", &self.pat);
10541+ formatter.field("guard", &self.guard);
10542+ formatter.field("fat_arrow_token", &self.fat_arrow_token);
10543+ formatter.field("body", &self.body);
10544+ formatter.field("comma", &self.comma);
10545+ formatter.finish()
10546+ }
10547+}
10548+#[cfg(any(feature = "derive", feature = "full"))]
10549+impl Debug for AttrStyle {
10550+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10551+ match self {
10552+ AttrStyle::Outer => formatter.write_str("Outer"),
10553+ AttrStyle::Inner(v0) => {
10554+ let mut formatter = formatter.debug_tuple("Inner");
10555+ formatter.field(v0);
10556+ formatter.finish()
10557+ }
10558+ }
10559+ }
10560+}
10561+#[cfg(any(feature = "derive", feature = "full"))]
10562+impl Debug for Attribute {
10563+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10564+ let mut formatter = formatter.debug_struct("Attribute");
10565+ formatter.field("pound_token", &self.pound_token);
10566+ formatter.field("style", &self.style);
10567+ formatter.field("bracket_token", &self.bracket_token);
10568+ formatter.field("path", &self.path);
10569+ formatter.field("tokens", &self.tokens);
10570+ formatter.finish()
10571+ }
10572+}
10573+#[cfg(any(feature = "derive", feature = "full"))]
10574+impl Debug for BareFnArg {
10575+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10576+ let mut formatter = formatter.debug_struct("BareFnArg");
10577+ formatter.field("attrs", &self.attrs);
10578+ formatter.field("name", &self.name);
10579+ formatter.field("ty", &self.ty);
10580+ formatter.finish()
10581+ }
10582+}
10583+#[cfg(any(feature = "derive", feature = "full"))]
10584+impl Debug for BinOp {
10585+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10586+ match self {
10587+ BinOp::Add(v0) => {
10588+ let mut formatter = formatter.debug_tuple("Add");
10589+ formatter.field(v0);
10590+ formatter.finish()
10591+ }
10592+ BinOp::Sub(v0) => {
10593+ let mut formatter = formatter.debug_tuple("Sub");
10594+ formatter.field(v0);
10595+ formatter.finish()
10596+ }
10597+ BinOp::Mul(v0) => {
10598+ let mut formatter = formatter.debug_tuple("Mul");
10599+ formatter.field(v0);
10600+ formatter.finish()
10601+ }
10602+ BinOp::Div(v0) => {
10603+ let mut formatter = formatter.debug_tuple("Div");
10604+ formatter.field(v0);
10605+ formatter.finish()
10606+ }
10607+ BinOp::Rem(v0) => {
10608+ let mut formatter = formatter.debug_tuple("Rem");
10609+ formatter.field(v0);
10610+ formatter.finish()
10611+ }
10612+ BinOp::And(v0) => {
10613+ let mut formatter = formatter.debug_tuple("And");
10614+ formatter.field(v0);
10615+ formatter.finish()
10616+ }
10617+ BinOp::Or(v0) => {
10618+ let mut formatter = formatter.debug_tuple("Or");
10619+ formatter.field(v0);
10620+ formatter.finish()
10621+ }
10622+ BinOp::BitXor(v0) => {
10623+ let mut formatter = formatter.debug_tuple("BitXor");
10624+ formatter.field(v0);
10625+ formatter.finish()
10626+ }
10627+ BinOp::BitAnd(v0) => {
10628+ let mut formatter = formatter.debug_tuple("BitAnd");
10629+ formatter.field(v0);
10630+ formatter.finish()
10631+ }
10632+ BinOp::BitOr(v0) => {
10633+ let mut formatter = formatter.debug_tuple("BitOr");
10634+ formatter.field(v0);
10635+ formatter.finish()
10636+ }
10637+ BinOp::Shl(v0) => {
10638+ let mut formatter = formatter.debug_tuple("Shl");
10639+ formatter.field(v0);
10640+ formatter.finish()
10641+ }
10642+ BinOp::Shr(v0) => {
10643+ let mut formatter = formatter.debug_tuple("Shr");
10644+ formatter.field(v0);
10645+ formatter.finish()
10646+ }
10647+ BinOp::Eq(v0) => {
10648+ let mut formatter = formatter.debug_tuple("Eq");
10649+ formatter.field(v0);
10650+ formatter.finish()
10651+ }
10652+ BinOp::Lt(v0) => {
10653+ let mut formatter = formatter.debug_tuple("Lt");
10654+ formatter.field(v0);
10655+ formatter.finish()
10656+ }
10657+ BinOp::Le(v0) => {
10658+ let mut formatter = formatter.debug_tuple("Le");
10659+ formatter.field(v0);
10660+ formatter.finish()
10661+ }
10662+ BinOp::Ne(v0) => {
10663+ let mut formatter = formatter.debug_tuple("Ne");
10664+ formatter.field(v0);
10665+ formatter.finish()
10666+ }
10667+ BinOp::Ge(v0) => {
10668+ let mut formatter = formatter.debug_tuple("Ge");
10669+ formatter.field(v0);
10670+ formatter.finish()
10671+ }
10672+ BinOp::Gt(v0) => {
10673+ let mut formatter = formatter.debug_tuple("Gt");
10674+ formatter.field(v0);
10675+ formatter.finish()
10676+ }
10677+ BinOp::AddEq(v0) => {
10678+ let mut formatter = formatter.debug_tuple("AddEq");
10679+ formatter.field(v0);
10680+ formatter.finish()
10681+ }
10682+ BinOp::SubEq(v0) => {
10683+ let mut formatter = formatter.debug_tuple("SubEq");
10684+ formatter.field(v0);
10685+ formatter.finish()
10686+ }
10687+ BinOp::MulEq(v0) => {
10688+ let mut formatter = formatter.debug_tuple("MulEq");
10689+ formatter.field(v0);
10690+ formatter.finish()
10691+ }
10692+ BinOp::DivEq(v0) => {
10693+ let mut formatter = formatter.debug_tuple("DivEq");
10694+ formatter.field(v0);
10695+ formatter.finish()
10696+ }
10697+ BinOp::RemEq(v0) => {
10698+ let mut formatter = formatter.debug_tuple("RemEq");
10699+ formatter.field(v0);
10700+ formatter.finish()
10701+ }
10702+ BinOp::BitXorEq(v0) => {
10703+ let mut formatter = formatter.debug_tuple("BitXorEq");
10704+ formatter.field(v0);
10705+ formatter.finish()
10706+ }
10707+ BinOp::BitAndEq(v0) => {
10708+ let mut formatter = formatter.debug_tuple("BitAndEq");
10709+ formatter.field(v0);
10710+ formatter.finish()
10711+ }
10712+ BinOp::BitOrEq(v0) => {
10713+ let mut formatter = formatter.debug_tuple("BitOrEq");
10714+ formatter.field(v0);
10715+ formatter.finish()
10716+ }
10717+ BinOp::ShlEq(v0) => {
10718+ let mut formatter = formatter.debug_tuple("ShlEq");
10719+ formatter.field(v0);
10720+ formatter.finish()
10721+ }
10722+ BinOp::ShrEq(v0) => {
10723+ let mut formatter = formatter.debug_tuple("ShrEq");
10724+ formatter.field(v0);
10725+ formatter.finish()
10726+ }
10727+ }
10728+ }
10729+}
10730+#[cfg(any(feature = "derive", feature = "full"))]
10731+impl Debug for Binding {
10732+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10733+ let mut formatter = formatter.debug_struct("Binding");
10734+ formatter.field("ident", &self.ident);
10735+ formatter.field("eq_token", &self.eq_token);
10736+ formatter.field("ty", &self.ty);
10737+ formatter.finish()
10738+ }
10739+}
10740+#[cfg(feature = "full")]
10741+impl Debug for Block {
10742+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10743+ let mut formatter = formatter.debug_struct("Block");
10744+ formatter.field("brace_token", &self.brace_token);
10745+ formatter.field("stmts", &self.stmts);
10746+ formatter.finish()
10747+ }
10748+}
10749+#[cfg(any(feature = "derive", feature = "full"))]
10750+impl Debug for BoundLifetimes {
10751+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10752+ let mut formatter = formatter.debug_struct("BoundLifetimes");
10753+ formatter.field("for_token", &self.for_token);
10754+ formatter.field("lt_token", &self.lt_token);
10755+ formatter.field("lifetimes", &self.lifetimes);
10756+ formatter.field("gt_token", &self.gt_token);
10757+ formatter.finish()
10758+ }
10759+}
10760+#[cfg(any(feature = "derive", feature = "full"))]
10761+impl Debug for ConstParam {
10762+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10763+ let mut formatter = formatter.debug_struct("ConstParam");
10764+ formatter.field("attrs", &self.attrs);
10765+ formatter.field("const_token", &self.const_token);
10766+ formatter.field("ident", &self.ident);
10767+ formatter.field("colon_token", &self.colon_token);
10768+ formatter.field("ty", &self.ty);
10769+ formatter.field("eq_token", &self.eq_token);
10770+ formatter.field("default", &self.default);
10771+ formatter.finish()
10772+ }
10773+}
10774+#[cfg(any(feature = "derive", feature = "full"))]
10775+impl Debug for Constraint {
10776+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10777+ let mut formatter = formatter.debug_struct("Constraint");
10778+ formatter.field("ident", &self.ident);
10779+ formatter.field("colon_token", &self.colon_token);
10780+ formatter.field("bounds", &self.bounds);
10781+ formatter.finish()
10782+ }
10783+}
10784+#[cfg(feature = "derive")]
10785+impl Debug for Data {
10786+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10787+ match self {
10788+ Data::Struct(v0) => {
10789+ let mut formatter = formatter.debug_tuple("Struct");
10790+ formatter.field(v0);
10791+ formatter.finish()
10792+ }
10793+ Data::Enum(v0) => {
10794+ let mut formatter = formatter.debug_tuple("Enum");
10795+ formatter.field(v0);
10796+ formatter.finish()
10797+ }
10798+ Data::Union(v0) => {
10799+ let mut formatter = formatter.debug_tuple("Union");
10800+ formatter.field(v0);
10801+ formatter.finish()
10802+ }
10803+ }
10804+ }
10805+}
10806+#[cfg(feature = "derive")]
10807+impl Debug for DataEnum {
10808+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10809+ let mut formatter = formatter.debug_struct("DataEnum");
10810+ formatter.field("enum_token", &self.enum_token);
10811+ formatter.field("brace_token", &self.brace_token);
10812+ formatter.field("variants", &self.variants);
10813+ formatter.finish()
10814+ }
10815+}
10816+#[cfg(feature = "derive")]
10817+impl Debug for DataStruct {
10818+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10819+ let mut formatter = formatter.debug_struct("DataStruct");
10820+ formatter.field("struct_token", &self.struct_token);
10821+ formatter.field("fields", &self.fields);
10822+ formatter.field("semi_token", &self.semi_token);
10823+ formatter.finish()
10824+ }
10825+}
10826+#[cfg(feature = "derive")]
10827+impl Debug for DataUnion {
10828+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10829+ let mut formatter = formatter.debug_struct("DataUnion");
10830+ formatter.field("union_token", &self.union_token);
10831+ formatter.field("fields", &self.fields);
10832+ formatter.finish()
10833+ }
10834+}
10835+#[cfg(feature = "derive")]
10836+impl Debug for DeriveInput {
10837+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10838+ let mut formatter = formatter.debug_struct("DeriveInput");
10839+ formatter.field("attrs", &self.attrs);
10840+ formatter.field("vis", &self.vis);
10841+ formatter.field("ident", &self.ident);
10842+ formatter.field("generics", &self.generics);
10843+ formatter.field("data", &self.data);
10844+ formatter.finish()
10845+ }
10846+}
10847+#[cfg(any(feature = "derive", feature = "full"))]
10848+impl Debug for Expr {
10849+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10850+ match self {
10851+ #[cfg(feature = "full")]
10852+ Expr::Array(v0) => {
10853+ let mut formatter = formatter.debug_tuple("Array");
10854+ formatter.field(v0);
10855+ formatter.finish()
10856+ }
10857+ #[cfg(feature = "full")]
10858+ Expr::Assign(v0) => {
10859+ let mut formatter = formatter.debug_tuple("Assign");
10860+ formatter.field(v0);
10861+ formatter.finish()
10862+ }
10863+ #[cfg(feature = "full")]
10864+ Expr::AssignOp(v0) => {
10865+ let mut formatter = formatter.debug_tuple("AssignOp");
10866+ formatter.field(v0);
10867+ formatter.finish()
10868+ }
10869+ #[cfg(feature = "full")]
10870+ Expr::Async(v0) => {
10871+ let mut formatter = formatter.debug_tuple("Async");
10872+ formatter.field(v0);
10873+ formatter.finish()
10874+ }
10875+ #[cfg(feature = "full")]
10876+ Expr::Await(v0) => {
10877+ let mut formatter = formatter.debug_tuple("Await");
10878+ formatter.field(v0);
10879+ formatter.finish()
10880+ }
10881+ Expr::Binary(v0) => {
10882+ let mut formatter = formatter.debug_tuple("Binary");
10883+ formatter.field(v0);
10884+ formatter.finish()
10885+ }
10886+ #[cfg(feature = "full")]
10887+ Expr::Block(v0) => {
10888+ let mut formatter = formatter.debug_tuple("Block");
10889+ formatter.field(v0);
10890+ formatter.finish()
10891+ }
10892+ #[cfg(feature = "full")]
10893+ Expr::Box(v0) => {
10894+ let mut formatter = formatter.debug_tuple("Box");
10895+ formatter.field(v0);
10896+ formatter.finish()
10897+ }
10898+ #[cfg(feature = "full")]
10899+ Expr::Break(v0) => {
10900+ let mut formatter = formatter.debug_tuple("Break");
10901+ formatter.field(v0);
10902+ formatter.finish()
10903+ }
10904+ Expr::Call(v0) => {
10905+ let mut formatter = formatter.debug_tuple("Call");
10906+ formatter.field(v0);
10907+ formatter.finish()
10908+ }
10909+ Expr::Cast(v0) => {
10910+ let mut formatter = formatter.debug_tuple("Cast");
10911+ formatter.field(v0);
10912+ formatter.finish()
10913+ }
10914+ #[cfg(feature = "full")]
10915+ Expr::Closure(v0) => {
10916+ let mut formatter = formatter.debug_tuple("Closure");
10917+ formatter.field(v0);
10918+ formatter.finish()
10919+ }
10920+ #[cfg(feature = "full")]
10921+ Expr::Continue(v0) => {
10922+ let mut formatter = formatter.debug_tuple("Continue");
10923+ formatter.field(v0);
10924+ formatter.finish()
10925+ }
10926+ Expr::Field(v0) => {
10927+ let mut formatter = formatter.debug_tuple("Field");
10928+ formatter.field(v0);
10929+ formatter.finish()
10930+ }
10931+ #[cfg(feature = "full")]
10932+ Expr::ForLoop(v0) => {
10933+ let mut formatter = formatter.debug_tuple("ForLoop");
10934+ formatter.field(v0);
10935+ formatter.finish()
10936+ }
10937+ #[cfg(feature = "full")]
10938+ Expr::Group(v0) => {
10939+ let mut formatter = formatter.debug_tuple("Group");
10940+ formatter.field(v0);
10941+ formatter.finish()
10942+ }
10943+ #[cfg(feature = "full")]
10944+ Expr::If(v0) => {
10945+ let mut formatter = formatter.debug_tuple("If");
10946+ formatter.field(v0);
10947+ formatter.finish()
10948+ }
10949+ Expr::Index(v0) => {
10950+ let mut formatter = formatter.debug_tuple("Index");
10951+ formatter.field(v0);
10952+ formatter.finish()
10953+ }
10954+ #[cfg(feature = "full")]
10955+ Expr::Let(v0) => {
10956+ let mut formatter = formatter.debug_tuple("Let");
10957+ formatter.field(v0);
10958+ formatter.finish()
10959+ }
10960+ Expr::Lit(v0) => {
10961+ let mut formatter = formatter.debug_tuple("Lit");
10962+ formatter.field(v0);
10963+ formatter.finish()
10964+ }
10965+ #[cfg(feature = "full")]
10966+ Expr::Loop(v0) => {
10967+ let mut formatter = formatter.debug_tuple("Loop");
10968+ formatter.field(v0);
10969+ formatter.finish()
10970+ }
10971+ #[cfg(feature = "full")]
10972+ Expr::Macro(v0) => {
10973+ let mut formatter = formatter.debug_tuple("Macro");
10974+ formatter.field(v0);
10975+ formatter.finish()
10976+ }
10977+ #[cfg(feature = "full")]
10978+ Expr::Match(v0) => {
10979+ let mut formatter = formatter.debug_tuple("Match");
10980+ formatter.field(v0);
10981+ formatter.finish()
10982+ }
10983+ #[cfg(feature = "full")]
10984+ Expr::MethodCall(v0) => {
10985+ let mut formatter = formatter.debug_tuple("MethodCall");
10986+ formatter.field(v0);
10987+ formatter.finish()
10988+ }
10989+ Expr::Paren(v0) => {
10990+ let mut formatter = formatter.debug_tuple("Paren");
10991+ formatter.field(v0);
10992+ formatter.finish()
10993+ }
10994+ Expr::Path(v0) => {
10995+ let mut formatter = formatter.debug_tuple("Path");
10996+ formatter.field(v0);
10997+ formatter.finish()
10998+ }
10999+ #[cfg(feature = "full")]
11000+ Expr::Range(v0) => {
11001+ let mut formatter = formatter.debug_tuple("Range");
11002+ formatter.field(v0);
11003+ formatter.finish()
11004+ }
11005+ #[cfg(feature = "full")]
11006+ Expr::Reference(v0) => {
11007+ let mut formatter = formatter.debug_tuple("Reference");
11008+ formatter.field(v0);
11009+ formatter.finish()
11010+ }
11011+ #[cfg(feature = "full")]
11012+ Expr::Repeat(v0) => {
11013+ let mut formatter = formatter.debug_tuple("Repeat");
11014+ formatter.field(v0);
11015+ formatter.finish()
11016+ }
11017+ #[cfg(feature = "full")]
11018+ Expr::Return(v0) => {
11019+ let mut formatter = formatter.debug_tuple("Return");
11020+ formatter.field(v0);
11021+ formatter.finish()
11022+ }
11023+ #[cfg(feature = "full")]
11024+ Expr::Struct(v0) => {
11025+ let mut formatter = formatter.debug_tuple("Struct");
11026+ formatter.field(v0);
11027+ formatter.finish()
11028+ }
11029+ #[cfg(feature = "full")]
11030+ Expr::Try(v0) => {
11031+ let mut formatter = formatter.debug_tuple("Try");
11032+ formatter.field(v0);
11033+ formatter.finish()
11034+ }
11035+ #[cfg(feature = "full")]
11036+ Expr::TryBlock(v0) => {
11037+ let mut formatter = formatter.debug_tuple("TryBlock");
11038+ formatter.field(v0);
11039+ formatter.finish()
11040+ }
11041+ #[cfg(feature = "full")]
11042+ Expr::Tuple(v0) => {
11043+ let mut formatter = formatter.debug_tuple("Tuple");
11044+ formatter.field(v0);
11045+ formatter.finish()
11046+ }
11047+ #[cfg(feature = "full")]
11048+ Expr::Type(v0) => {
11049+ let mut formatter = formatter.debug_tuple("Type");
11050+ formatter.field(v0);
11051+ formatter.finish()
11052+ }
11053+ Expr::Unary(v0) => {
11054+ let mut formatter = formatter.debug_tuple("Unary");
11055+ formatter.field(v0);
11056+ formatter.finish()
11057+ }
11058+ #[cfg(feature = "full")]
11059+ Expr::Unsafe(v0) => {
11060+ let mut formatter = formatter.debug_tuple("Unsafe");
11061+ formatter.field(v0);
11062+ formatter.finish()
11063+ }
11064+ Expr::Verbatim(v0) => {
11065+ let mut formatter = formatter.debug_tuple("Verbatim");
11066+ formatter.field(v0);
11067+ formatter.finish()
11068+ }
11069+ #[cfg(feature = "full")]
11070+ Expr::While(v0) => {
11071+ let mut formatter = formatter.debug_tuple("While");
11072+ formatter.field(v0);
11073+ formatter.finish()
11074+ }
11075+ #[cfg(feature = "full")]
11076+ Expr::Yield(v0) => {
11077+ let mut formatter = formatter.debug_tuple("Yield");
11078+ formatter.field(v0);
11079+ formatter.finish()
11080+ }
11081+ _ => unreachable!(),
11082+ }
11083+ }
11084+}
11085+#[cfg(feature = "full")]
11086+impl Debug for ExprArray {
11087+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11088+ let mut formatter = formatter.debug_struct("ExprArray");
11089+ formatter.field("attrs", &self.attrs);
11090+ formatter.field("bracket_token", &self.bracket_token);
11091+ formatter.field("elems", &self.elems);
11092+ formatter.finish()
11093+ }
11094+}
11095+#[cfg(feature = "full")]
11096+impl Debug for ExprAssign {
11097+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11098+ let mut formatter = formatter.debug_struct("ExprAssign");
11099+ formatter.field("attrs", &self.attrs);
11100+ formatter.field("left", &self.left);
11101+ formatter.field("eq_token", &self.eq_token);
11102+ formatter.field("right", &self.right);
11103+ formatter.finish()
11104+ }
11105+}
11106+#[cfg(feature = "full")]
11107+impl Debug for ExprAssignOp {
11108+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11109+ let mut formatter = formatter.debug_struct("ExprAssignOp");
11110+ formatter.field("attrs", &self.attrs);
11111+ formatter.field("left", &self.left);
11112+ formatter.field("op", &self.op);
11113+ formatter.field("right", &self.right);
11114+ formatter.finish()
11115+ }
11116+}
11117+#[cfg(feature = "full")]
11118+impl Debug for ExprAsync {
11119+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11120+ let mut formatter = formatter.debug_struct("ExprAsync");
11121+ formatter.field("attrs", &self.attrs);
11122+ formatter.field("async_token", &self.async_token);
11123+ formatter.field("capture", &self.capture);
11124+ formatter.field("block", &self.block);
11125+ formatter.finish()
11126+ }
11127+}
11128+#[cfg(feature = "full")]
11129+impl Debug for ExprAwait {
11130+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11131+ let mut formatter = formatter.debug_struct("ExprAwait");
11132+ formatter.field("attrs", &self.attrs);
11133+ formatter.field("base", &self.base);
11134+ formatter.field("dot_token", &self.dot_token);
11135+ formatter.field("await_token", &self.await_token);
11136+ formatter.finish()
11137+ }
11138+}
11139+#[cfg(any(feature = "derive", feature = "full"))]
11140+impl Debug for ExprBinary {
11141+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11142+ let mut formatter = formatter.debug_struct("ExprBinary");
11143+ formatter.field("attrs", &self.attrs);
11144+ formatter.field("left", &self.left);
11145+ formatter.field("op", &self.op);
11146+ formatter.field("right", &self.right);
11147+ formatter.finish()
11148+ }
11149+}
11150+#[cfg(feature = "full")]
11151+impl Debug for ExprBlock {
11152+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11153+ let mut formatter = formatter.debug_struct("ExprBlock");
11154+ formatter.field("attrs", &self.attrs);
11155+ formatter.field("label", &self.label);
11156+ formatter.field("block", &self.block);
11157+ formatter.finish()
11158+ }
11159+}
11160+#[cfg(feature = "full")]
11161+impl Debug for ExprBox {
11162+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11163+ let mut formatter = formatter.debug_struct("ExprBox");
11164+ formatter.field("attrs", &self.attrs);
11165+ formatter.field("box_token", &self.box_token);
11166+ formatter.field("expr", &self.expr);
11167+ formatter.finish()
11168+ }
11169+}
11170+#[cfg(feature = "full")]
11171+impl Debug for ExprBreak {
11172+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11173+ let mut formatter = formatter.debug_struct("ExprBreak");
11174+ formatter.field("attrs", &self.attrs);
11175+ formatter.field("break_token", &self.break_token);
11176+ formatter.field("label", &self.label);
11177+ formatter.field("expr", &self.expr);
11178+ formatter.finish()
11179+ }
11180+}
11181+#[cfg(any(feature = "derive", feature = "full"))]
11182+impl Debug for ExprCall {
11183+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11184+ let mut formatter = formatter.debug_struct("ExprCall");
11185+ formatter.field("attrs", &self.attrs);
11186+ formatter.field("func", &self.func);
11187+ formatter.field("paren_token", &self.paren_token);
11188+ formatter.field("args", &self.args);
11189+ formatter.finish()
11190+ }
11191+}
11192+#[cfg(any(feature = "derive", feature = "full"))]
11193+impl Debug for ExprCast {
11194+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11195+ let mut formatter = formatter.debug_struct("ExprCast");
11196+ formatter.field("attrs", &self.attrs);
11197+ formatter.field("expr", &self.expr);
11198+ formatter.field("as_token", &self.as_token);
11199+ formatter.field("ty", &self.ty);
11200+ formatter.finish()
11201+ }
11202+}
11203+#[cfg(feature = "full")]
11204+impl Debug for ExprClosure {
11205+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11206+ let mut formatter = formatter.debug_struct("ExprClosure");
11207+ formatter.field("attrs", &self.attrs);
11208+ formatter.field("asyncness", &self.asyncness);
11209+ formatter.field("movability", &self.movability);
11210+ formatter.field("capture", &self.capture);
11211+ formatter.field("or1_token", &self.or1_token);
11212+ formatter.field("inputs", &self.inputs);
11213+ formatter.field("or2_token", &self.or2_token);
11214+ formatter.field("output", &self.output);
11215+ formatter.field("body", &self.body);
11216+ formatter.finish()
11217+ }
11218+}
11219+#[cfg(feature = "full")]
11220+impl Debug for ExprContinue {
11221+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11222+ let mut formatter = formatter.debug_struct("ExprContinue");
11223+ formatter.field("attrs", &self.attrs);
11224+ formatter.field("continue_token", &self.continue_token);
11225+ formatter.field("label", &self.label);
11226+ formatter.finish()
11227+ }
11228+}
11229+#[cfg(any(feature = "derive", feature = "full"))]
11230+impl Debug for ExprField {
11231+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11232+ let mut formatter = formatter.debug_struct("ExprField");
11233+ formatter.field("attrs", &self.attrs);
11234+ formatter.field("base", &self.base);
11235+ formatter.field("dot_token", &self.dot_token);
11236+ formatter.field("member", &self.member);
11237+ formatter.finish()
11238+ }
11239+}
11240+#[cfg(feature = "full")]
11241+impl Debug for ExprForLoop {
11242+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11243+ let mut formatter = formatter.debug_struct("ExprForLoop");
11244+ formatter.field("attrs", &self.attrs);
11245+ formatter.field("label", &self.label);
11246+ formatter.field("for_token", &self.for_token);
11247+ formatter.field("pat", &self.pat);
11248+ formatter.field("in_token", &self.in_token);
11249+ formatter.field("expr", &self.expr);
11250+ formatter.field("body", &self.body);
11251+ formatter.finish()
11252+ }
11253+}
11254+#[cfg(feature = "full")]
11255+impl Debug for ExprGroup {
11256+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11257+ let mut formatter = formatter.debug_struct("ExprGroup");
11258+ formatter.field("attrs", &self.attrs);
11259+ formatter.field("group_token", &self.group_token);
11260+ formatter.field("expr", &self.expr);
11261+ formatter.finish()
11262+ }
11263+}
11264+#[cfg(feature = "full")]
11265+impl Debug for ExprIf {
11266+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11267+ let mut formatter = formatter.debug_struct("ExprIf");
11268+ formatter.field("attrs", &self.attrs);
11269+ formatter.field("if_token", &self.if_token);
11270+ formatter.field("cond", &self.cond);
11271+ formatter.field("then_branch", &self.then_branch);
11272+ formatter.field("else_branch", &self.else_branch);
11273+ formatter.finish()
11274+ }
11275+}
11276+#[cfg(any(feature = "derive", feature = "full"))]
11277+impl Debug for ExprIndex {
11278+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11279+ let mut formatter = formatter.debug_struct("ExprIndex");
11280+ formatter.field("attrs", &self.attrs);
11281+ formatter.field("expr", &self.expr);
11282+ formatter.field("bracket_token", &self.bracket_token);
11283+ formatter.field("index", &self.index);
11284+ formatter.finish()
11285+ }
11286+}
11287+#[cfg(feature = "full")]
11288+impl Debug for ExprLet {
11289+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11290+ let mut formatter = formatter.debug_struct("ExprLet");
11291+ formatter.field("attrs", &self.attrs);
11292+ formatter.field("let_token", &self.let_token);
11293+ formatter.field("pat", &self.pat);
11294+ formatter.field("eq_token", &self.eq_token);
11295+ formatter.field("expr", &self.expr);
11296+ formatter.finish()
11297+ }
11298+}
11299+#[cfg(any(feature = "derive", feature = "full"))]
11300+impl Debug for ExprLit {
11301+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11302+ let mut formatter = formatter.debug_struct("ExprLit");
11303+ formatter.field("attrs", &self.attrs);
11304+ formatter.field("lit", &self.lit);
11305+ formatter.finish()
11306+ }
11307+}
11308+#[cfg(feature = "full")]
11309+impl Debug for ExprLoop {
11310+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11311+ let mut formatter = formatter.debug_struct("ExprLoop");
11312+ formatter.field("attrs", &self.attrs);
11313+ formatter.field("label", &self.label);
11314+ formatter.field("loop_token", &self.loop_token);
11315+ formatter.field("body", &self.body);
11316+ formatter.finish()
11317+ }
11318+}
11319+#[cfg(feature = "full")]
11320+impl Debug for ExprMacro {
11321+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11322+ let mut formatter = formatter.debug_struct("ExprMacro");
11323+ formatter.field("attrs", &self.attrs);
11324+ formatter.field("mac", &self.mac);
11325+ formatter.finish()
11326+ }
11327+}
11328+#[cfg(feature = "full")]
11329+impl Debug for ExprMatch {
11330+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11331+ let mut formatter = formatter.debug_struct("ExprMatch");
11332+ formatter.field("attrs", &self.attrs);
11333+ formatter.field("match_token", &self.match_token);
11334+ formatter.field("expr", &self.expr);
11335+ formatter.field("brace_token", &self.brace_token);
11336+ formatter.field("arms", &self.arms);
11337+ formatter.finish()
11338+ }
11339+}
11340+#[cfg(feature = "full")]
11341+impl Debug for ExprMethodCall {
11342+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11343+ let mut formatter = formatter.debug_struct("ExprMethodCall");
11344+ formatter.field("attrs", &self.attrs);
11345+ formatter.field("receiver", &self.receiver);
11346+ formatter.field("dot_token", &self.dot_token);
11347+ formatter.field("method", &self.method);
11348+ formatter.field("turbofish", &self.turbofish);
11349+ formatter.field("paren_token", &self.paren_token);
11350+ formatter.field("args", &self.args);
11351+ formatter.finish()
11352+ }
11353+}
11354+#[cfg(any(feature = "derive", feature = "full"))]
11355+impl Debug for ExprParen {
11356+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11357+ let mut formatter = formatter.debug_struct("ExprParen");
11358+ formatter.field("attrs", &self.attrs);
11359+ formatter.field("paren_token", &self.paren_token);
11360+ formatter.field("expr", &self.expr);
11361+ formatter.finish()
11362+ }
11363+}
11364+#[cfg(any(feature = "derive", feature = "full"))]
11365+impl Debug for ExprPath {
11366+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11367+ let mut formatter = formatter.debug_struct("ExprPath");
11368+ formatter.field("attrs", &self.attrs);
11369+ formatter.field("qself", &self.qself);
11370+ formatter.field("path", &self.path);
11371+ formatter.finish()
11372+ }
11373+}
11374+#[cfg(feature = "full")]
11375+impl Debug for ExprRange {
11376+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11377+ let mut formatter = formatter.debug_struct("ExprRange");
11378+ formatter.field("attrs", &self.attrs);
11379+ formatter.field("from", &self.from);
11380+ formatter.field("limits", &self.limits);
11381+ formatter.field("to", &self.to);
11382+ formatter.finish()
11383+ }
11384+}
11385+#[cfg(feature = "full")]
11386+impl Debug for ExprReference {
11387+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11388+ let mut formatter = formatter.debug_struct("ExprReference");
11389+ formatter.field("attrs", &self.attrs);
11390+ formatter.field("and_token", &self.and_token);
11391+ formatter.field("raw", &self.raw);
11392+ formatter.field("mutability", &self.mutability);
11393+ formatter.field("expr", &self.expr);
11394+ formatter.finish()
11395+ }
11396+}
11397+#[cfg(feature = "full")]
11398+impl Debug for ExprRepeat {
11399+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11400+ let mut formatter = formatter.debug_struct("ExprRepeat");
11401+ formatter.field("attrs", &self.attrs);
11402+ formatter.field("bracket_token", &self.bracket_token);
11403+ formatter.field("expr", &self.expr);
11404+ formatter.field("semi_token", &self.semi_token);
11405+ formatter.field("len", &self.len);
11406+ formatter.finish()
11407+ }
11408+}
11409+#[cfg(feature = "full")]
11410+impl Debug for ExprReturn {
11411+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11412+ let mut formatter = formatter.debug_struct("ExprReturn");
11413+ formatter.field("attrs", &self.attrs);
11414+ formatter.field("return_token", &self.return_token);
11415+ formatter.field("expr", &self.expr);
11416+ formatter.finish()
11417+ }
11418+}
11419+#[cfg(feature = "full")]
11420+impl Debug for ExprStruct {
11421+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11422+ let mut formatter = formatter.debug_struct("ExprStruct");
11423+ formatter.field("attrs", &self.attrs);
11424+ formatter.field("path", &self.path);
11425+ formatter.field("brace_token", &self.brace_token);
11426+ formatter.field("fields", &self.fields);
11427+ formatter.field("dot2_token", &self.dot2_token);
11428+ formatter.field("rest", &self.rest);
11429+ formatter.finish()
11430+ }
11431+}
11432+#[cfg(feature = "full")]
11433+impl Debug for ExprTry {
11434+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11435+ let mut formatter = formatter.debug_struct("ExprTry");
11436+ formatter.field("attrs", &self.attrs);
11437+ formatter.field("expr", &self.expr);
11438+ formatter.field("question_token", &self.question_token);
11439+ formatter.finish()
11440+ }
11441+}
11442+#[cfg(feature = "full")]
11443+impl Debug for ExprTryBlock {
11444+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11445+ let mut formatter = formatter.debug_struct("ExprTryBlock");
11446+ formatter.field("attrs", &self.attrs);
11447+ formatter.field("try_token", &self.try_token);
11448+ formatter.field("block", &self.block);
11449+ formatter.finish()
11450+ }
11451+}
11452+#[cfg(feature = "full")]
11453+impl Debug for ExprTuple {
11454+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11455+ let mut formatter = formatter.debug_struct("ExprTuple");
11456+ formatter.field("attrs", &self.attrs);
11457+ formatter.field("paren_token", &self.paren_token);
11458+ formatter.field("elems", &self.elems);
11459+ formatter.finish()
11460+ }
11461+}
11462+#[cfg(feature = "full")]
11463+impl Debug for ExprType {
11464+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11465+ let mut formatter = formatter.debug_struct("ExprType");
11466+ formatter.field("attrs", &self.attrs);
11467+ formatter.field("expr", &self.expr);
11468+ formatter.field("colon_token", &self.colon_token);
11469+ formatter.field("ty", &self.ty);
11470+ formatter.finish()
11471+ }
11472+}
11473+#[cfg(any(feature = "derive", feature = "full"))]
11474+impl Debug for ExprUnary {
11475+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11476+ let mut formatter = formatter.debug_struct("ExprUnary");
11477+ formatter.field("attrs", &self.attrs);
11478+ formatter.field("op", &self.op);
11479+ formatter.field("expr", &self.expr);
11480+ formatter.finish()
11481+ }
11482+}
11483+#[cfg(feature = "full")]
11484+impl Debug for ExprUnsafe {
11485+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11486+ let mut formatter = formatter.debug_struct("ExprUnsafe");
11487+ formatter.field("attrs", &self.attrs);
11488+ formatter.field("unsafe_token", &self.unsafe_token);
11489+ formatter.field("block", &self.block);
11490+ formatter.finish()
11491+ }
11492+}
11493+#[cfg(feature = "full")]
11494+impl Debug for ExprWhile {
11495+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11496+ let mut formatter = formatter.debug_struct("ExprWhile");
11497+ formatter.field("attrs", &self.attrs);
11498+ formatter.field("label", &self.label);
11499+ formatter.field("while_token", &self.while_token);
11500+ formatter.field("cond", &self.cond);
11501+ formatter.field("body", &self.body);
11502+ formatter.finish()
11503+ }
11504+}
11505+#[cfg(feature = "full")]
11506+impl Debug for ExprYield {
11507+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11508+ let mut formatter = formatter.debug_struct("ExprYield");
11509+ formatter.field("attrs", &self.attrs);
11510+ formatter.field("yield_token", &self.yield_token);
11511+ formatter.field("expr", &self.expr);
11512+ formatter.finish()
11513+ }
11514+}
11515+#[cfg(any(feature = "derive", feature = "full"))]
11516+impl Debug for Field {
11517+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11518+ let mut formatter = formatter.debug_struct("Field");
11519+ formatter.field("attrs", &self.attrs);
11520+ formatter.field("vis", &self.vis);
11521+ formatter.field("ident", &self.ident);
11522+ formatter.field("colon_token", &self.colon_token);
11523+ formatter.field("ty", &self.ty);
11524+ formatter.finish()
11525+ }
11526+}
11527+#[cfg(feature = "full")]
11528+impl Debug for FieldPat {
11529+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11530+ let mut formatter = formatter.debug_struct("FieldPat");
11531+ formatter.field("attrs", &self.attrs);
11532+ formatter.field("member", &self.member);
11533+ formatter.field("colon_token", &self.colon_token);
11534+ formatter.field("pat", &self.pat);
11535+ formatter.finish()
11536+ }
11537+}
11538+#[cfg(feature = "full")]
11539+impl Debug for FieldValue {
11540+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11541+ let mut formatter = formatter.debug_struct("FieldValue");
11542+ formatter.field("attrs", &self.attrs);
11543+ formatter.field("member", &self.member);
11544+ formatter.field("colon_token", &self.colon_token);
11545+ formatter.field("expr", &self.expr);
11546+ formatter.finish()
11547+ }
11548+}
11549+#[cfg(any(feature = "derive", feature = "full"))]
11550+impl Debug for Fields {
11551+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11552+ match self {
11553+ Fields::Named(v0) => {
11554+ let mut formatter = formatter.debug_tuple("Named");
11555+ formatter.field(v0);
11556+ formatter.finish()
11557+ }
11558+ Fields::Unnamed(v0) => {
11559+ let mut formatter = formatter.debug_tuple("Unnamed");
11560+ formatter.field(v0);
11561+ formatter.finish()
11562+ }
11563+ Fields::Unit => formatter.write_str("Unit"),
11564+ }
11565+ }
11566+}
11567+#[cfg(any(feature = "derive", feature = "full"))]
11568+impl Debug for FieldsNamed {
11569+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11570+ let mut formatter = formatter.debug_struct("FieldsNamed");
11571+ formatter.field("brace_token", &self.brace_token);
11572+ formatter.field("named", &self.named);
11573+ formatter.finish()
11574+ }
11575+}
11576+#[cfg(any(feature = "derive", feature = "full"))]
11577+impl Debug for FieldsUnnamed {
11578+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11579+ let mut formatter = formatter.debug_struct("FieldsUnnamed");
11580+ formatter.field("paren_token", &self.paren_token);
11581+ formatter.field("unnamed", &self.unnamed);
11582+ formatter.finish()
11583+ }
11584+}
11585+#[cfg(feature = "full")]
11586+impl Debug for File {
11587+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11588+ let mut formatter = formatter.debug_struct("File");
11589+ formatter.field("shebang", &self.shebang);
11590+ formatter.field("attrs", &self.attrs);
11591+ formatter.field("items", &self.items);
11592+ formatter.finish()
11593+ }
11594+}
11595+#[cfg(feature = "full")]
11596+impl Debug for FnArg {
11597+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11598+ match self {
11599+ FnArg::Receiver(v0) => {
11600+ let mut formatter = formatter.debug_tuple("Receiver");
11601+ formatter.field(v0);
11602+ formatter.finish()
11603+ }
11604+ FnArg::Typed(v0) => {
11605+ let mut formatter = formatter.debug_tuple("Typed");
11606+ formatter.field(v0);
11607+ formatter.finish()
11608+ }
11609+ }
11610+ }
11611+}
11612+#[cfg(feature = "full")]
11613+impl Debug for ForeignItem {
11614+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11615+ match self {
11616+ ForeignItem::Fn(v0) => {
11617+ let mut formatter = formatter.debug_tuple("Fn");
11618+ formatter.field(v0);
11619+ formatter.finish()
11620+ }
11621+ ForeignItem::Static(v0) => {
11622+ let mut formatter = formatter.debug_tuple("Static");
11623+ formatter.field(v0);
11624+ formatter.finish()
11625+ }
11626+ ForeignItem::Type(v0) => {
11627+ let mut formatter = formatter.debug_tuple("Type");
11628+ formatter.field(v0);
11629+ formatter.finish()
11630+ }
11631+ ForeignItem::Macro(v0) => {
11632+ let mut formatter = formatter.debug_tuple("Macro");
11633+ formatter.field(v0);
11634+ formatter.finish()
11635+ }
11636+ ForeignItem::Verbatim(v0) => {
11637+ let mut formatter = formatter.debug_tuple("Verbatim");
11638+ formatter.field(v0);
11639+ formatter.finish()
11640+ }
11641+ _ => unreachable!(),
11642+ }
11643+ }
11644+}
11645+#[cfg(feature = "full")]
11646+impl Debug for ForeignItemFn {
11647+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11648+ let mut formatter = formatter.debug_struct("ForeignItemFn");
11649+ formatter.field("attrs", &self.attrs);
11650+ formatter.field("vis", &self.vis);
11651+ formatter.field("sig", &self.sig);
11652+ formatter.field("semi_token", &self.semi_token);
11653+ formatter.finish()
11654+ }
11655+}
11656+#[cfg(feature = "full")]
11657+impl Debug for ForeignItemMacro {
11658+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11659+ let mut formatter = formatter.debug_struct("ForeignItemMacro");
11660+ formatter.field("attrs", &self.attrs);
11661+ formatter.field("mac", &self.mac);
11662+ formatter.field("semi_token", &self.semi_token);
11663+ formatter.finish()
11664+ }
11665+}
11666+#[cfg(feature = "full")]
11667+impl Debug for ForeignItemStatic {
11668+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11669+ let mut formatter = formatter.debug_struct("ForeignItemStatic");
11670+ formatter.field("attrs", &self.attrs);
11671+ formatter.field("vis", &self.vis);
11672+ formatter.field("static_token", &self.static_token);
11673+ formatter.field("mutability", &self.mutability);
11674+ formatter.field("ident", &self.ident);
11675+ formatter.field("colon_token", &self.colon_token);
11676+ formatter.field("ty", &self.ty);
11677+ formatter.field("semi_token", &self.semi_token);
11678+ formatter.finish()
11679+ }
11680+}
11681+#[cfg(feature = "full")]
11682+impl Debug for ForeignItemType {
11683+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11684+ let mut formatter = formatter.debug_struct("ForeignItemType");
11685+ formatter.field("attrs", &self.attrs);
11686+ formatter.field("vis", &self.vis);
11687+ formatter.field("type_token", &self.type_token);
11688+ formatter.field("ident", &self.ident);
11689+ formatter.field("semi_token", &self.semi_token);
11690+ formatter.finish()
11691+ }
11692+}
11693+#[cfg(any(feature = "derive", feature = "full"))]
11694+impl Debug for GenericArgument {
11695+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11696+ match self {
11697+ GenericArgument::Lifetime(v0) => {
11698+ let mut formatter = formatter.debug_tuple("Lifetime");
11699+ formatter.field(v0);
11700+ formatter.finish()
11701+ }
11702+ GenericArgument::Type(v0) => {
11703+ let mut formatter = formatter.debug_tuple("Type");
11704+ formatter.field(v0);
11705+ formatter.finish()
11706+ }
11707+ GenericArgument::Binding(v0) => {
11708+ let mut formatter = formatter.debug_tuple("Binding");
11709+ formatter.field(v0);
11710+ formatter.finish()
11711+ }
11712+ GenericArgument::Constraint(v0) => {
11713+ let mut formatter = formatter.debug_tuple("Constraint");
11714+ formatter.field(v0);
11715+ formatter.finish()
11716+ }
11717+ GenericArgument::Const(v0) => {
11718+ let mut formatter = formatter.debug_tuple("Const");
11719+ formatter.field(v0);
11720+ formatter.finish()
11721+ }
11722+ }
11723+ }
11724+}
11725+#[cfg(feature = "full")]
11726+impl Debug for GenericMethodArgument {
11727+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11728+ match self {
11729+ GenericMethodArgument::Type(v0) => {
11730+ let mut formatter = formatter.debug_tuple("Type");
11731+ formatter.field(v0);
11732+ formatter.finish()
11733+ }
11734+ GenericMethodArgument::Const(v0) => {
11735+ let mut formatter = formatter.debug_tuple("Const");
11736+ formatter.field(v0);
11737+ formatter.finish()
11738+ }
11739+ }
11740+ }
11741+}
11742+#[cfg(any(feature = "derive", feature = "full"))]
11743+impl Debug for GenericParam {
11744+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11745+ match self {
11746+ GenericParam::Type(v0) => {
11747+ let mut formatter = formatter.debug_tuple("Type");
11748+ formatter.field(v0);
11749+ formatter.finish()
11750+ }
11751+ GenericParam::Lifetime(v0) => {
11752+ let mut formatter = formatter.debug_tuple("Lifetime");
11753+ formatter.field(v0);
11754+ formatter.finish()
11755+ }
11756+ GenericParam::Const(v0) => {
11757+ let mut formatter = formatter.debug_tuple("Const");
11758+ formatter.field(v0);
11759+ formatter.finish()
11760+ }
11761+ }
11762+ }
11763+}
11764+#[cfg(any(feature = "derive", feature = "full"))]
11765+impl Debug for Generics {
11766+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11767+ let mut formatter = formatter.debug_struct("Generics");
11768+ formatter.field("lt_token", &self.lt_token);
11769+ formatter.field("params", &self.params);
11770+ formatter.field("gt_token", &self.gt_token);
11771+ formatter.field("where_clause", &self.where_clause);
11772+ formatter.finish()
11773+ }
11774+}
11775+#[cfg(feature = "full")]
11776+impl Debug for ImplItem {
11777+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11778+ match self {
11779+ ImplItem::Const(v0) => {
11780+ let mut formatter = formatter.debug_tuple("Const");
11781+ formatter.field(v0);
11782+ formatter.finish()
11783+ }
11784+ ImplItem::Method(v0) => {
11785+ let mut formatter = formatter.debug_tuple("Method");
11786+ formatter.field(v0);
11787+ formatter.finish()
11788+ }
11789+ ImplItem::Type(v0) => {
11790+ let mut formatter = formatter.debug_tuple("Type");
11791+ formatter.field(v0);
11792+ formatter.finish()
11793+ }
11794+ ImplItem::Macro(v0) => {
11795+ let mut formatter = formatter.debug_tuple("Macro");
11796+ formatter.field(v0);
11797+ formatter.finish()
11798+ }
11799+ ImplItem::Verbatim(v0) => {
11800+ let mut formatter = formatter.debug_tuple("Verbatim");
11801+ formatter.field(v0);
11802+ formatter.finish()
11803+ }
11804+ _ => unreachable!(),
11805+ }
11806+ }
11807+}
11808+#[cfg(feature = "full")]
11809+impl Debug for ImplItemConst {
11810+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11811+ let mut formatter = formatter.debug_struct("ImplItemConst");
11812+ formatter.field("attrs", &self.attrs);
11813+ formatter.field("vis", &self.vis);
11814+ formatter.field("defaultness", &self.defaultness);
11815+ formatter.field("const_token", &self.const_token);
11816+ formatter.field("ident", &self.ident);
11817+ formatter.field("colon_token", &self.colon_token);
11818+ formatter.field("ty", &self.ty);
11819+ formatter.field("eq_token", &self.eq_token);
11820+ formatter.field("expr", &self.expr);
11821+ formatter.field("semi_token", &self.semi_token);
11822+ formatter.finish()
11823+ }
11824+}
11825+#[cfg(feature = "full")]
11826+impl Debug for ImplItemMacro {
11827+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11828+ let mut formatter = formatter.debug_struct("ImplItemMacro");
11829+ formatter.field("attrs", &self.attrs);
11830+ formatter.field("mac", &self.mac);
11831+ formatter.field("semi_token", &self.semi_token);
11832+ formatter.finish()
11833+ }
11834+}
11835+#[cfg(feature = "full")]
11836+impl Debug for ImplItemMethod {
11837+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11838+ let mut formatter = formatter.debug_struct("ImplItemMethod");
11839+ formatter.field("attrs", &self.attrs);
11840+ formatter.field("vis", &self.vis);
11841+ formatter.field("defaultness", &self.defaultness);
11842+ formatter.field("sig", &self.sig);
11843+ formatter.field("block", &self.block);
11844+ formatter.finish()
11845+ }
11846+}
11847+#[cfg(feature = "full")]
11848+impl Debug for ImplItemType {
11849+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11850+ let mut formatter = formatter.debug_struct("ImplItemType");
11851+ formatter.field("attrs", &self.attrs);
11852+ formatter.field("vis", &self.vis);
11853+ formatter.field("defaultness", &self.defaultness);
11854+ formatter.field("type_token", &self.type_token);
11855+ formatter.field("ident", &self.ident);
11856+ formatter.field("generics", &self.generics);
11857+ formatter.field("eq_token", &self.eq_token);
11858+ formatter.field("ty", &self.ty);
11859+ formatter.field("semi_token", &self.semi_token);
11860+ formatter.finish()
11861+ }
11862+}
11863+#[cfg(any(feature = "derive", feature = "full"))]
11864+impl Debug for Index {
11865+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11866+ let mut formatter = formatter.debug_struct("Index");
11867+ formatter.field("index", &self.index);
11868+ formatter.field("span", &self.span);
11869+ formatter.finish()
11870+ }
11871+}
11872+#[cfg(feature = "full")]
11873+impl Debug for Item {
11874+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11875+ match self {
11876+ Item::Const(v0) => {
11877+ let mut formatter = formatter.debug_tuple("Const");
11878+ formatter.field(v0);
11879+ formatter.finish()
11880+ }
11881+ Item::Enum(v0) => {
11882+ let mut formatter = formatter.debug_tuple("Enum");
11883+ formatter.field(v0);
11884+ formatter.finish()
11885+ }
11886+ Item::ExternCrate(v0) => {
11887+ let mut formatter = formatter.debug_tuple("ExternCrate");
11888+ formatter.field(v0);
11889+ formatter.finish()
11890+ }
11891+ Item::Fn(v0) => {
11892+ let mut formatter = formatter.debug_tuple("Fn");
11893+ formatter.field(v0);
11894+ formatter.finish()
11895+ }
11896+ Item::ForeignMod(v0) => {
11897+ let mut formatter = formatter.debug_tuple("ForeignMod");
11898+ formatter.field(v0);
11899+ formatter.finish()
11900+ }
11901+ Item::Impl(v0) => {
11902+ let mut formatter = formatter.debug_tuple("Impl");
11903+ formatter.field(v0);
11904+ formatter.finish()
11905+ }
11906+ Item::Macro(v0) => {
11907+ let mut formatter = formatter.debug_tuple("Macro");
11908+ formatter.field(v0);
11909+ formatter.finish()
11910+ }
11911+ Item::Macro2(v0) => {
11912+ let mut formatter = formatter.debug_tuple("Macro2");
11913+ formatter.field(v0);
11914+ formatter.finish()
11915+ }
11916+ Item::Mod(v0) => {
11917+ let mut formatter = formatter.debug_tuple("Mod");
11918+ formatter.field(v0);
11919+ formatter.finish()
11920+ }
11921+ Item::Static(v0) => {
11922+ let mut formatter = formatter.debug_tuple("Static");
11923+ formatter.field(v0);
11924+ formatter.finish()
11925+ }
11926+ Item::Struct(v0) => {
11927+ let mut formatter = formatter.debug_tuple("Struct");
11928+ formatter.field(v0);
11929+ formatter.finish()
11930+ }
11931+ Item::Trait(v0) => {
11932+ let mut formatter = formatter.debug_tuple("Trait");
11933+ formatter.field(v0);
11934+ formatter.finish()
11935+ }
11936+ Item::TraitAlias(v0) => {
11937+ let mut formatter = formatter.debug_tuple("TraitAlias");
11938+ formatter.field(v0);
11939+ formatter.finish()
11940+ }
11941+ Item::Type(v0) => {
11942+ let mut formatter = formatter.debug_tuple("Type");
11943+ formatter.field(v0);
11944+ formatter.finish()
11945+ }
11946+ Item::Union(v0) => {
11947+ let mut formatter = formatter.debug_tuple("Union");
11948+ formatter.field(v0);
11949+ formatter.finish()
11950+ }
11951+ Item::Use(v0) => {
11952+ let mut formatter = formatter.debug_tuple("Use");
11953+ formatter.field(v0);
11954+ formatter.finish()
11955+ }
11956+ Item::Verbatim(v0) => {
11957+ let mut formatter = formatter.debug_tuple("Verbatim");
11958+ formatter.field(v0);
11959+ formatter.finish()
11960+ }
11961+ _ => unreachable!(),
11962+ }
11963+ }
11964+}
11965+#[cfg(feature = "full")]
11966+impl Debug for ItemConst {
11967+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11968+ let mut formatter = formatter.debug_struct("ItemConst");
11969+ formatter.field("attrs", &self.attrs);
11970+ formatter.field("vis", &self.vis);
11971+ formatter.field("const_token", &self.const_token);
11972+ formatter.field("ident", &self.ident);
11973+ formatter.field("colon_token", &self.colon_token);
11974+ formatter.field("ty", &self.ty);
11975+ formatter.field("eq_token", &self.eq_token);
11976+ formatter.field("expr", &self.expr);
11977+ formatter.field("semi_token", &self.semi_token);
11978+ formatter.finish()
11979+ }
11980+}
11981+#[cfg(feature = "full")]
11982+impl Debug for ItemEnum {
11983+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11984+ let mut formatter = formatter.debug_struct("ItemEnum");
11985+ formatter.field("attrs", &self.attrs);
11986+ formatter.field("vis", &self.vis);
11987+ formatter.field("enum_token", &self.enum_token);
11988+ formatter.field("ident", &self.ident);
11989+ formatter.field("generics", &self.generics);
11990+ formatter.field("brace_token", &self.brace_token);
11991+ formatter.field("variants", &self.variants);
11992+ formatter.finish()
11993+ }
11994+}
11995+#[cfg(feature = "full")]
11996+impl Debug for ItemExternCrate {
11997+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11998+ let mut formatter = formatter.debug_struct("ItemExternCrate");
11999+ formatter.field("attrs", &self.attrs);
12000+ formatter.field("vis", &self.vis);
12001+ formatter.field("extern_token", &self.extern_token);
12002+ formatter.field("crate_token", &self.crate_token);
12003+ formatter.field("ident", &self.ident);
12004+ formatter.field("rename", &self.rename);
12005+ formatter.field("semi_token", &self.semi_token);
12006+ formatter.finish()
12007+ }
12008+}
12009+#[cfg(feature = "full")]
12010+impl Debug for ItemFn {
12011+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12012+ let mut formatter = formatter.debug_struct("ItemFn");
12013+ formatter.field("attrs", &self.attrs);
12014+ formatter.field("vis", &self.vis);
12015+ formatter.field("sig", &self.sig);
12016+ formatter.field("block", &self.block);
12017+ formatter.finish()
12018+ }
12019+}
12020+#[cfg(feature = "full")]
12021+impl Debug for ItemForeignMod {
12022+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12023+ let mut formatter = formatter.debug_struct("ItemForeignMod");
12024+ formatter.field("attrs", &self.attrs);
12025+ formatter.field("abi", &self.abi);
12026+ formatter.field("brace_token", &self.brace_token);
12027+ formatter.field("items", &self.items);
12028+ formatter.finish()
12029+ }
12030+}
12031+#[cfg(feature = "full")]
12032+impl Debug for ItemImpl {
12033+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12034+ let mut formatter = formatter.debug_struct("ItemImpl");
12035+ formatter.field("attrs", &self.attrs);
12036+ formatter.field("defaultness", &self.defaultness);
12037+ formatter.field("unsafety", &self.unsafety);
12038+ formatter.field("impl_token", &self.impl_token);
12039+ formatter.field("generics", &self.generics);
12040+ formatter.field("trait_", &self.trait_);
12041+ formatter.field("self_ty", &self.self_ty);
12042+ formatter.field("brace_token", &self.brace_token);
12043+ formatter.field("items", &self.items);
12044+ formatter.finish()
12045+ }
12046+}
12047+#[cfg(feature = "full")]
12048+impl Debug for ItemMacro {
12049+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12050+ let mut formatter = formatter.debug_struct("ItemMacro");
12051+ formatter.field("attrs", &self.attrs);
12052+ formatter.field("ident", &self.ident);
12053+ formatter.field("mac", &self.mac);
12054+ formatter.field("semi_token", &self.semi_token);
12055+ formatter.finish()
12056+ }
12057+}
12058+#[cfg(feature = "full")]
12059+impl Debug for ItemMacro2 {
12060+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12061+ let mut formatter = formatter.debug_struct("ItemMacro2");
12062+ formatter.field("attrs", &self.attrs);
12063+ formatter.field("vis", &self.vis);
12064+ formatter.field("macro_token", &self.macro_token);
12065+ formatter.field("ident", &self.ident);
12066+ formatter.field("rules", &self.rules);
12067+ formatter.finish()
12068+ }
12069+}
12070+#[cfg(feature = "full")]
12071+impl Debug for ItemMod {
12072+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12073+ let mut formatter = formatter.debug_struct("ItemMod");
12074+ formatter.field("attrs", &self.attrs);
12075+ formatter.field("vis", &self.vis);
12076+ formatter.field("mod_token", &self.mod_token);
12077+ formatter.field("ident", &self.ident);
12078+ formatter.field("content", &self.content);
12079+ formatter.field("semi", &self.semi);
12080+ formatter.finish()
12081+ }
12082+}
12083+#[cfg(feature = "full")]
12084+impl Debug for ItemStatic {
12085+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12086+ let mut formatter = formatter.debug_struct("ItemStatic");
12087+ formatter.field("attrs", &self.attrs);
12088+ formatter.field("vis", &self.vis);
12089+ formatter.field("static_token", &self.static_token);
12090+ formatter.field("mutability", &self.mutability);
12091+ formatter.field("ident", &self.ident);
12092+ formatter.field("colon_token", &self.colon_token);
12093+ formatter.field("ty", &self.ty);
12094+ formatter.field("eq_token", &self.eq_token);
12095+ formatter.field("expr", &self.expr);
12096+ formatter.field("semi_token", &self.semi_token);
12097+ formatter.finish()
12098+ }
12099+}
12100+#[cfg(feature = "full")]
12101+impl Debug for ItemStruct {
12102+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12103+ let mut formatter = formatter.debug_struct("ItemStruct");
12104+ formatter.field("attrs", &self.attrs);
12105+ formatter.field("vis", &self.vis);
12106+ formatter.field("struct_token", &self.struct_token);
12107+ formatter.field("ident", &self.ident);
12108+ formatter.field("generics", &self.generics);
12109+ formatter.field("fields", &self.fields);
12110+ formatter.field("semi_token", &self.semi_token);
12111+ formatter.finish()
12112+ }
12113+}
12114+#[cfg(feature = "full")]
12115+impl Debug for ItemTrait {
12116+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12117+ let mut formatter = formatter.debug_struct("ItemTrait");
12118+ formatter.field("attrs", &self.attrs);
12119+ formatter.field("vis", &self.vis);
12120+ formatter.field("unsafety", &self.unsafety);
12121+ formatter.field("auto_token", &self.auto_token);
12122+ formatter.field("trait_token", &self.trait_token);
12123+ formatter.field("ident", &self.ident);
12124+ formatter.field("generics", &self.generics);
12125+ formatter.field("colon_token", &self.colon_token);
12126+ formatter.field("supertraits", &self.supertraits);
12127+ formatter.field("brace_token", &self.brace_token);
12128+ formatter.field("items", &self.items);
12129+ formatter.finish()
12130+ }
12131+}
12132+#[cfg(feature = "full")]
12133+impl Debug for ItemTraitAlias {
12134+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12135+ let mut formatter = formatter.debug_struct("ItemTraitAlias");
12136+ formatter.field("attrs", &self.attrs);
12137+ formatter.field("vis", &self.vis);
12138+ formatter.field("trait_token", &self.trait_token);
12139+ formatter.field("ident", &self.ident);
12140+ formatter.field("generics", &self.generics);
12141+ formatter.field("eq_token", &self.eq_token);
12142+ formatter.field("bounds", &self.bounds);
12143+ formatter.field("semi_token", &self.semi_token);
12144+ formatter.finish()
12145+ }
12146+}
12147+#[cfg(feature = "full")]
12148+impl Debug for ItemType {
12149+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12150+ let mut formatter = formatter.debug_struct("ItemType");
12151+ formatter.field("attrs", &self.attrs);
12152+ formatter.field("vis", &self.vis);
12153+ formatter.field("type_token", &self.type_token);
12154+ formatter.field("ident", &self.ident);
12155+ formatter.field("generics", &self.generics);
12156+ formatter.field("eq_token", &self.eq_token);
12157+ formatter.field("ty", &self.ty);
12158+ formatter.field("semi_token", &self.semi_token);
12159+ formatter.finish()
12160+ }
12161+}
12162+#[cfg(feature = "full")]
12163+impl Debug for ItemUnion {
12164+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12165+ let mut formatter = formatter.debug_struct("ItemUnion");
12166+ formatter.field("attrs", &self.attrs);
12167+ formatter.field("vis", &self.vis);
12168+ formatter.field("union_token", &self.union_token);
12169+ formatter.field("ident", &self.ident);
12170+ formatter.field("generics", &self.generics);
12171+ formatter.field("fields", &self.fields);
12172+ formatter.finish()
12173+ }
12174+}
12175+#[cfg(feature = "full")]
12176+impl Debug for ItemUse {
12177+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12178+ let mut formatter = formatter.debug_struct("ItemUse");
12179+ formatter.field("attrs", &self.attrs);
12180+ formatter.field("vis", &self.vis);
12181+ formatter.field("use_token", &self.use_token);
12182+ formatter.field("leading_colon", &self.leading_colon);
12183+ formatter.field("tree", &self.tree);
12184+ formatter.field("semi_token", &self.semi_token);
12185+ formatter.finish()
12186+ }
12187+}
12188+#[cfg(feature = "full")]
12189+impl Debug for Label {
12190+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12191+ let mut formatter = formatter.debug_struct("Label");
12192+ formatter.field("name", &self.name);
12193+ formatter.field("colon_token", &self.colon_token);
12194+ formatter.finish()
12195+ }
12196+}
12197+impl Debug for Lifetime {
12198+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12199+ let mut formatter = formatter.debug_struct("Lifetime");
12200+ formatter.field("apostrophe", &self.apostrophe);
12201+ formatter.field("ident", &self.ident);
12202+ formatter.finish()
12203+ }
12204+}
12205+#[cfg(any(feature = "derive", feature = "full"))]
12206+impl Debug for LifetimeDef {
12207+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12208+ let mut formatter = formatter.debug_struct("LifetimeDef");
12209+ formatter.field("attrs", &self.attrs);
12210+ formatter.field("lifetime", &self.lifetime);
12211+ formatter.field("colon_token", &self.colon_token);
12212+ formatter.field("bounds", &self.bounds);
12213+ formatter.finish()
12214+ }
12215+}
12216+impl Debug for Lit {
12217+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12218+ match self {
12219+ Lit::Str(v0) => {
12220+ let mut formatter = formatter.debug_tuple("Str");
12221+ formatter.field(v0);
12222+ formatter.finish()
12223+ }
12224+ Lit::ByteStr(v0) => {
12225+ let mut formatter = formatter.debug_tuple("ByteStr");
12226+ formatter.field(v0);
12227+ formatter.finish()
12228+ }
12229+ Lit::Byte(v0) => {
12230+ let mut formatter = formatter.debug_tuple("Byte");
12231+ formatter.field(v0);
12232+ formatter.finish()
12233+ }
12234+ Lit::Char(v0) => {
12235+ let mut formatter = formatter.debug_tuple("Char");
12236+ formatter.field(v0);
12237+ formatter.finish()
12238+ }
12239+ Lit::Int(v0) => {
12240+ let mut formatter = formatter.debug_tuple("Int");
12241+ formatter.field(v0);
12242+ formatter.finish()
12243+ }
12244+ Lit::Float(v0) => {
12245+ let mut formatter = formatter.debug_tuple("Float");
12246+ formatter.field(v0);
12247+ formatter.finish()
12248+ }
12249+ Lit::Bool(v0) => {
12250+ let mut formatter = formatter.debug_tuple("Bool");
12251+ formatter.field(v0);
12252+ formatter.finish()
12253+ }
12254+ Lit::Verbatim(v0) => {
12255+ let mut formatter = formatter.debug_tuple("Verbatim");
12256+ formatter.field(v0);
12257+ formatter.finish()
12258+ }
12259+ }
12260+ }
12261+}
12262+#[cfg(feature = "full")]
12263+impl Debug for Local {
12264+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12265+ let mut formatter = formatter.debug_struct("Local");
12266+ formatter.field("attrs", &self.attrs);
12267+ formatter.field("let_token", &self.let_token);
12268+ formatter.field("pat", &self.pat);
12269+ formatter.field("init", &self.init);
12270+ formatter.field("semi_token", &self.semi_token);
12271+ formatter.finish()
12272+ }
12273+}
12274+#[cfg(any(feature = "derive", feature = "full"))]
12275+impl Debug for Macro {
12276+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12277+ let mut formatter = formatter.debug_struct("Macro");
12278+ formatter.field("path", &self.path);
12279+ formatter.field("bang_token", &self.bang_token);
12280+ formatter.field("delimiter", &self.delimiter);
12281+ formatter.field("tokens", &self.tokens);
12282+ formatter.finish()
12283+ }
12284+}
12285+#[cfg(any(feature = "derive", feature = "full"))]
12286+impl Debug for MacroDelimiter {
12287+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12288+ match self {
12289+ MacroDelimiter::Paren(v0) => {
12290+ let mut formatter = formatter.debug_tuple("Paren");
12291+ formatter.field(v0);
12292+ formatter.finish()
12293+ }
12294+ MacroDelimiter::Brace(v0) => {
12295+ let mut formatter = formatter.debug_tuple("Brace");
12296+ formatter.field(v0);
12297+ formatter.finish()
12298+ }
12299+ MacroDelimiter::Bracket(v0) => {
12300+ let mut formatter = formatter.debug_tuple("Bracket");
12301+ formatter.field(v0);
12302+ formatter.finish()
12303+ }
12304+ }
12305+ }
12306+}
12307+#[cfg(any(feature = "derive", feature = "full"))]
12308+impl Debug for Member {
12309+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12310+ match self {
12311+ Member::Named(v0) => {
12312+ let mut formatter = formatter.debug_tuple("Named");
12313+ formatter.field(v0);
12314+ formatter.finish()
12315+ }
12316+ Member::Unnamed(v0) => {
12317+ let mut formatter = formatter.debug_tuple("Unnamed");
12318+ formatter.field(v0);
12319+ formatter.finish()
12320+ }
12321+ }
12322+ }
12323+}
12324+#[cfg(any(feature = "derive", feature = "full"))]
12325+impl Debug for Meta {
12326+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12327+ match self {
12328+ Meta::Path(v0) => {
12329+ let mut formatter = formatter.debug_tuple("Path");
12330+ formatter.field(v0);
12331+ formatter.finish()
12332+ }
12333+ Meta::List(v0) => {
12334+ let mut formatter = formatter.debug_tuple("List");
12335+ formatter.field(v0);
12336+ formatter.finish()
12337+ }
12338+ Meta::NameValue(v0) => {
12339+ let mut formatter = formatter.debug_tuple("NameValue");
12340+ formatter.field(v0);
12341+ formatter.finish()
12342+ }
12343+ }
12344+ }
12345+}
12346+#[cfg(any(feature = "derive", feature = "full"))]
12347+impl Debug for MetaList {
12348+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12349+ let mut formatter = formatter.debug_struct("MetaList");
12350+ formatter.field("path", &self.path);
12351+ formatter.field("paren_token", &self.paren_token);
12352+ formatter.field("nested", &self.nested);
12353+ formatter.finish()
12354+ }
12355+}
12356+#[cfg(any(feature = "derive", feature = "full"))]
12357+impl Debug for MetaNameValue {
12358+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12359+ let mut formatter = formatter.debug_struct("MetaNameValue");
12360+ formatter.field("path", &self.path);
12361+ formatter.field("eq_token", &self.eq_token);
12362+ formatter.field("lit", &self.lit);
12363+ formatter.finish()
12364+ }
12365+}
12366+#[cfg(feature = "full")]
12367+impl Debug for MethodTurbofish {
12368+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12369+ let mut formatter = formatter.debug_struct("MethodTurbofish");
12370+ formatter.field("colon2_token", &self.colon2_token);
12371+ formatter.field("lt_token", &self.lt_token);
12372+ formatter.field("args", &self.args);
12373+ formatter.field("gt_token", &self.gt_token);
12374+ formatter.finish()
12375+ }
12376+}
12377+#[cfg(any(feature = "derive", feature = "full"))]
12378+impl Debug for NestedMeta {
12379+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12380+ match self {
12381+ NestedMeta::Meta(v0) => {
12382+ let mut formatter = formatter.debug_tuple("Meta");
12383+ formatter.field(v0);
12384+ formatter.finish()
12385+ }
12386+ NestedMeta::Lit(v0) => {
12387+ let mut formatter = formatter.debug_tuple("Lit");
12388+ formatter.field(v0);
12389+ formatter.finish()
12390+ }
12391+ }
12392+ }
12393+}
12394+#[cfg(any(feature = "derive", feature = "full"))]
12395+impl Debug for ParenthesizedGenericArguments {
12396+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12397+ let mut formatter = formatter.debug_struct("ParenthesizedGenericArguments");
12398+ formatter.field("paren_token", &self.paren_token);
12399+ formatter.field("inputs", &self.inputs);
12400+ formatter.field("output", &self.output);
12401+ formatter.finish()
12402+ }
12403+}
12404+#[cfg(feature = "full")]
12405+impl Debug for Pat {
12406+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12407+ match self {
12408+ Pat::Box(v0) => {
12409+ let mut formatter = formatter.debug_tuple("Box");
12410+ formatter.field(v0);
12411+ formatter.finish()
12412+ }
12413+ Pat::Ident(v0) => {
12414+ let mut formatter = formatter.debug_tuple("Ident");
12415+ formatter.field(v0);
12416+ formatter.finish()
12417+ }
12418+ Pat::Lit(v0) => {
12419+ let mut formatter = formatter.debug_tuple("Lit");
12420+ formatter.field(v0);
12421+ formatter.finish()
12422+ }
12423+ Pat::Macro(v0) => {
12424+ let mut formatter = formatter.debug_tuple("Macro");
12425+ formatter.field(v0);
12426+ formatter.finish()
12427+ }
12428+ Pat::Or(v0) => {
12429+ let mut formatter = formatter.debug_tuple("Or");
12430+ formatter.field(v0);
12431+ formatter.finish()
12432+ }
12433+ Pat::Path(v0) => {
12434+ let mut formatter = formatter.debug_tuple("Path");
12435+ formatter.field(v0);
12436+ formatter.finish()
12437+ }
12438+ Pat::Range(v0) => {
12439+ let mut formatter = formatter.debug_tuple("Range");
12440+ formatter.field(v0);
12441+ formatter.finish()
12442+ }
12443+ Pat::Reference(v0) => {
12444+ let mut formatter = formatter.debug_tuple("Reference");
12445+ formatter.field(v0);
12446+ formatter.finish()
12447+ }
12448+ Pat::Rest(v0) => {
12449+ let mut formatter = formatter.debug_tuple("Rest");
12450+ formatter.field(v0);
12451+ formatter.finish()
12452+ }
12453+ Pat::Slice(v0) => {
12454+ let mut formatter = formatter.debug_tuple("Slice");
12455+ formatter.field(v0);
12456+ formatter.finish()
12457+ }
12458+ Pat::Struct(v0) => {
12459+ let mut formatter = formatter.debug_tuple("Struct");
12460+ formatter.field(v0);
12461+ formatter.finish()
12462+ }
12463+ Pat::Tuple(v0) => {
12464+ let mut formatter = formatter.debug_tuple("Tuple");
12465+ formatter.field(v0);
12466+ formatter.finish()
12467+ }
12468+ Pat::TupleStruct(v0) => {
12469+ let mut formatter = formatter.debug_tuple("TupleStruct");
12470+ formatter.field(v0);
12471+ formatter.finish()
12472+ }
12473+ Pat::Type(v0) => {
12474+ let mut formatter = formatter.debug_tuple("Type");
12475+ formatter.field(v0);
12476+ formatter.finish()
12477+ }
12478+ Pat::Verbatim(v0) => {
12479+ let mut formatter = formatter.debug_tuple("Verbatim");
12480+ formatter.field(v0);
12481+ formatter.finish()
12482+ }
12483+ Pat::Wild(v0) => {
12484+ let mut formatter = formatter.debug_tuple("Wild");
12485+ formatter.field(v0);
12486+ formatter.finish()
12487+ }
12488+ _ => unreachable!(),
12489+ }
12490+ }
12491+}
12492+#[cfg(feature = "full")]
12493+impl Debug for PatBox {
12494+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12495+ let mut formatter = formatter.debug_struct("PatBox");
12496+ formatter.field("attrs", &self.attrs);
12497+ formatter.field("box_token", &self.box_token);
12498+ formatter.field("pat", &self.pat);
12499+ formatter.finish()
12500+ }
12501+}
12502+#[cfg(feature = "full")]
12503+impl Debug for PatIdent {
12504+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12505+ let mut formatter = formatter.debug_struct("PatIdent");
12506+ formatter.field("attrs", &self.attrs);
12507+ formatter.field("by_ref", &self.by_ref);
12508+ formatter.field("mutability", &self.mutability);
12509+ formatter.field("ident", &self.ident);
12510+ formatter.field("subpat", &self.subpat);
12511+ formatter.finish()
12512+ }
12513+}
12514+#[cfg(feature = "full")]
12515+impl Debug for PatLit {
12516+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12517+ let mut formatter = formatter.debug_struct("PatLit");
12518+ formatter.field("attrs", &self.attrs);
12519+ formatter.field("expr", &self.expr);
12520+ formatter.finish()
12521+ }
12522+}
12523+#[cfg(feature = "full")]
12524+impl Debug for PatMacro {
12525+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12526+ let mut formatter = formatter.debug_struct("PatMacro");
12527+ formatter.field("attrs", &self.attrs);
12528+ formatter.field("mac", &self.mac);
12529+ formatter.finish()
12530+ }
12531+}
12532+#[cfg(feature = "full")]
12533+impl Debug for PatOr {
12534+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12535+ let mut formatter = formatter.debug_struct("PatOr");
12536+ formatter.field("attrs", &self.attrs);
12537+ formatter.field("leading_vert", &self.leading_vert);
12538+ formatter.field("cases", &self.cases);
12539+ formatter.finish()
12540+ }
12541+}
12542+#[cfg(feature = "full")]
12543+impl Debug for PatPath {
12544+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12545+ let mut formatter = formatter.debug_struct("PatPath");
12546+ formatter.field("attrs", &self.attrs);
12547+ formatter.field("qself", &self.qself);
12548+ formatter.field("path", &self.path);
12549+ formatter.finish()
12550+ }
12551+}
12552+#[cfg(feature = "full")]
12553+impl Debug for PatRange {
12554+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12555+ let mut formatter = formatter.debug_struct("PatRange");
12556+ formatter.field("attrs", &self.attrs);
12557+ formatter.field("lo", &self.lo);
12558+ formatter.field("limits", &self.limits);
12559+ formatter.field("hi", &self.hi);
12560+ formatter.finish()
12561+ }
12562+}
12563+#[cfg(feature = "full")]
12564+impl Debug for PatReference {
12565+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12566+ let mut formatter = formatter.debug_struct("PatReference");
12567+ formatter.field("attrs", &self.attrs);
12568+ formatter.field("and_token", &self.and_token);
12569+ formatter.field("mutability", &self.mutability);
12570+ formatter.field("pat", &self.pat);
12571+ formatter.finish()
12572+ }
12573+}
12574+#[cfg(feature = "full")]
12575+impl Debug for PatRest {
12576+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12577+ let mut formatter = formatter.debug_struct("PatRest");
12578+ formatter.field("attrs", &self.attrs);
12579+ formatter.field("dot2_token", &self.dot2_token);
12580+ formatter.finish()
12581+ }
12582+}
12583+#[cfg(feature = "full")]
12584+impl Debug for PatSlice {
12585+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12586+ let mut formatter = formatter.debug_struct("PatSlice");
12587+ formatter.field("attrs", &self.attrs);
12588+ formatter.field("bracket_token", &self.bracket_token);
12589+ formatter.field("elems", &self.elems);
12590+ formatter.finish()
12591+ }
12592+}
12593+#[cfg(feature = "full")]
12594+impl Debug for PatStruct {
12595+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12596+ let mut formatter = formatter.debug_struct("PatStruct");
12597+ formatter.field("attrs", &self.attrs);
12598+ formatter.field("path", &self.path);
12599+ formatter.field("brace_token", &self.brace_token);
12600+ formatter.field("fields", &self.fields);
12601+ formatter.field("dot2_token", &self.dot2_token);
12602+ formatter.finish()
12603+ }
12604+}
12605+#[cfg(feature = "full")]
12606+impl Debug for PatTuple {
12607+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12608+ let mut formatter = formatter.debug_struct("PatTuple");
12609+ formatter.field("attrs", &self.attrs);
12610+ formatter.field("paren_token", &self.paren_token);
12611+ formatter.field("elems", &self.elems);
12612+ formatter.finish()
12613+ }
12614+}
12615+#[cfg(feature = "full")]
12616+impl Debug for PatTupleStruct {
12617+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12618+ let mut formatter = formatter.debug_struct("PatTupleStruct");
12619+ formatter.field("attrs", &self.attrs);
12620+ formatter.field("path", &self.path);
12621+ formatter.field("pat", &self.pat);
12622+ formatter.finish()
12623+ }
12624+}
12625+#[cfg(feature = "full")]
12626+impl Debug for PatType {
12627+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12628+ let mut formatter = formatter.debug_struct("PatType");
12629+ formatter.field("attrs", &self.attrs);
12630+ formatter.field("pat", &self.pat);
12631+ formatter.field("colon_token", &self.colon_token);
12632+ formatter.field("ty", &self.ty);
12633+ formatter.finish()
12634+ }
12635+}
12636+#[cfg(feature = "full")]
12637+impl Debug for PatWild {
12638+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12639+ let mut formatter = formatter.debug_struct("PatWild");
12640+ formatter.field("attrs", &self.attrs);
12641+ formatter.field("underscore_token", &self.underscore_token);
12642+ formatter.finish()
12643+ }
12644+}
12645+#[cfg(any(feature = "derive", feature = "full"))]
12646+impl Debug for Path {
12647+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12648+ let mut formatter = formatter.debug_struct("Path");
12649+ formatter.field("leading_colon", &self.leading_colon);
12650+ formatter.field("segments", &self.segments);
12651+ formatter.finish()
12652+ }
12653+}
12654+#[cfg(any(feature = "derive", feature = "full"))]
12655+impl Debug for PathArguments {
12656+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12657+ match self {
12658+ PathArguments::None => formatter.write_str("None"),
12659+ PathArguments::AngleBracketed(v0) => {
12660+ let mut formatter = formatter.debug_tuple("AngleBracketed");
12661+ formatter.field(v0);
12662+ formatter.finish()
12663+ }
12664+ PathArguments::Parenthesized(v0) => {
12665+ let mut formatter = formatter.debug_tuple("Parenthesized");
12666+ formatter.field(v0);
12667+ formatter.finish()
12668+ }
12669+ }
12670+ }
12671+}
12672+#[cfg(any(feature = "derive", feature = "full"))]
12673+impl Debug for PathSegment {
12674+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12675+ let mut formatter = formatter.debug_struct("PathSegment");
12676+ formatter.field("ident", &self.ident);
12677+ formatter.field("arguments", &self.arguments);
12678+ formatter.finish()
12679+ }
12680+}
12681+#[cfg(any(feature = "derive", feature = "full"))]
12682+impl Debug for PredicateEq {
12683+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12684+ let mut formatter = formatter.debug_struct("PredicateEq");
12685+ formatter.field("lhs_ty", &self.lhs_ty);
12686+ formatter.field("eq_token", &self.eq_token);
12687+ formatter.field("rhs_ty", &self.rhs_ty);
12688+ formatter.finish()
12689+ }
12690+}
12691+#[cfg(any(feature = "derive", feature = "full"))]
12692+impl Debug for PredicateLifetime {
12693+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12694+ let mut formatter = formatter.debug_struct("PredicateLifetime");
12695+ formatter.field("lifetime", &self.lifetime);
12696+ formatter.field("colon_token", &self.colon_token);
12697+ formatter.field("bounds", &self.bounds);
12698+ formatter.finish()
12699+ }
12700+}
12701+#[cfg(any(feature = "derive", feature = "full"))]
12702+impl Debug for PredicateType {
12703+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12704+ let mut formatter = formatter.debug_struct("PredicateType");
12705+ formatter.field("lifetimes", &self.lifetimes);
12706+ formatter.field("bounded_ty", &self.bounded_ty);
12707+ formatter.field("colon_token", &self.colon_token);
12708+ formatter.field("bounds", &self.bounds);
12709+ formatter.finish()
12710+ }
12711+}
12712+#[cfg(any(feature = "derive", feature = "full"))]
12713+impl Debug for QSelf {
12714+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12715+ let mut formatter = formatter.debug_struct("QSelf");
12716+ formatter.field("lt_token", &self.lt_token);
12717+ formatter.field("ty", &self.ty);
12718+ formatter.field("position", &self.position);
12719+ formatter.field("as_token", &self.as_token);
12720+ formatter.field("gt_token", &self.gt_token);
12721+ formatter.finish()
12722+ }
12723+}
12724+#[cfg(feature = "full")]
12725+impl Debug for RangeLimits {
12726+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12727+ match self {
12728+ RangeLimits::HalfOpen(v0) => {
12729+ let mut formatter = formatter.debug_tuple("HalfOpen");
12730+ formatter.field(v0);
12731+ formatter.finish()
12732+ }
12733+ RangeLimits::Closed(v0) => {
12734+ let mut formatter = formatter.debug_tuple("Closed");
12735+ formatter.field(v0);
12736+ formatter.finish()
12737+ }
12738+ }
12739+ }
12740+}
12741+#[cfg(feature = "full")]
12742+impl Debug for Receiver {
12743+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12744+ let mut formatter = formatter.debug_struct("Receiver");
12745+ formatter.field("attrs", &self.attrs);
12746+ formatter.field("reference", &self.reference);
12747+ formatter.field("mutability", &self.mutability);
12748+ formatter.field("self_token", &self.self_token);
12749+ formatter.finish()
12750+ }
12751+}
12752+#[cfg(any(feature = "derive", feature = "full"))]
12753+impl Debug for ReturnType {
12754+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12755+ match self {
12756+ ReturnType::Default => formatter.write_str("Default"),
12757+ ReturnType::Type(v0, v1) => {
12758+ let mut formatter = formatter.debug_tuple("Type");
12759+ formatter.field(v0);
12760+ formatter.field(v1);
12761+ formatter.finish()
12762+ }
12763+ }
12764+ }
12765+}
12766+#[cfg(feature = "full")]
12767+impl Debug for Signature {
12768+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12769+ let mut formatter = formatter.debug_struct("Signature");
12770+ formatter.field("constness", &self.constness);
12771+ formatter.field("asyncness", &self.asyncness);
12772+ formatter.field("unsafety", &self.unsafety);
12773+ formatter.field("abi", &self.abi);
12774+ formatter.field("fn_token", &self.fn_token);
12775+ formatter.field("ident", &self.ident);
12776+ formatter.field("generics", &self.generics);
12777+ formatter.field("paren_token", &self.paren_token);
12778+ formatter.field("inputs", &self.inputs);
12779+ formatter.field("variadic", &self.variadic);
12780+ formatter.field("output", &self.output);
12781+ formatter.finish()
12782+ }
12783+}
12784+#[cfg(feature = "full")]
12785+impl Debug for Stmt {
12786+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12787+ match self {
12788+ Stmt::Local(v0) => {
12789+ let mut formatter = formatter.debug_tuple("Local");
12790+ formatter.field(v0);
12791+ formatter.finish()
12792+ }
12793+ Stmt::Item(v0) => {
12794+ let mut formatter = formatter.debug_tuple("Item");
12795+ formatter.field(v0);
12796+ formatter.finish()
12797+ }
12798+ Stmt::Expr(v0) => {
12799+ let mut formatter = formatter.debug_tuple("Expr");
12800+ formatter.field(v0);
12801+ formatter.finish()
12802+ }
12803+ Stmt::Semi(v0, v1) => {
12804+ let mut formatter = formatter.debug_tuple("Semi");
12805+ formatter.field(v0);
12806+ formatter.field(v1);
12807+ formatter.finish()
12808+ }
12809+ }
12810+ }
12811+}
12812+#[cfg(any(feature = "derive", feature = "full"))]
12813+impl Debug for TraitBound {
12814+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12815+ let mut formatter = formatter.debug_struct("TraitBound");
12816+ formatter.field("paren_token", &self.paren_token);
12817+ formatter.field("modifier", &self.modifier);
12818+ formatter.field("lifetimes", &self.lifetimes);
12819+ formatter.field("path", &self.path);
12820+ formatter.finish()
12821+ }
12822+}
12823+#[cfg(any(feature = "derive", feature = "full"))]
12824+impl Debug for TraitBoundModifier {
12825+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12826+ match self {
12827+ TraitBoundModifier::None => formatter.write_str("None"),
12828+ TraitBoundModifier::Maybe(v0) => {
12829+ let mut formatter = formatter.debug_tuple("Maybe");
12830+ formatter.field(v0);
12831+ formatter.finish()
12832+ }
12833+ }
12834+ }
12835+}
12836+#[cfg(feature = "full")]
12837+impl Debug for TraitItem {
12838+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12839+ match self {
12840+ TraitItem::Const(v0) => {
12841+ let mut formatter = formatter.debug_tuple("Const");
12842+ formatter.field(v0);
12843+ formatter.finish()
12844+ }
12845+ TraitItem::Method(v0) => {
12846+ let mut formatter = formatter.debug_tuple("Method");
12847+ formatter.field(v0);
12848+ formatter.finish()
12849+ }
12850+ TraitItem::Type(v0) => {
12851+ let mut formatter = formatter.debug_tuple("Type");
12852+ formatter.field(v0);
12853+ formatter.finish()
12854+ }
12855+ TraitItem::Macro(v0) => {
12856+ let mut formatter = formatter.debug_tuple("Macro");
12857+ formatter.field(v0);
12858+ formatter.finish()
12859+ }
12860+ TraitItem::Verbatim(v0) => {
12861+ let mut formatter = formatter.debug_tuple("Verbatim");
12862+ formatter.field(v0);
12863+ formatter.finish()
12864+ }
12865+ _ => unreachable!(),
12866+ }
12867+ }
12868+}
12869+#[cfg(feature = "full")]
12870+impl Debug for TraitItemConst {
12871+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12872+ let mut formatter = formatter.debug_struct("TraitItemConst");
12873+ formatter.field("attrs", &self.attrs);
12874+ formatter.field("const_token", &self.const_token);
12875+ formatter.field("ident", &self.ident);
12876+ formatter.field("colon_token", &self.colon_token);
12877+ formatter.field("ty", &self.ty);
12878+ formatter.field("default", &self.default);
12879+ formatter.field("semi_token", &self.semi_token);
12880+ formatter.finish()
12881+ }
12882+}
12883+#[cfg(feature = "full")]
12884+impl Debug for TraitItemMacro {
12885+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12886+ let mut formatter = formatter.debug_struct("TraitItemMacro");
12887+ formatter.field("attrs", &self.attrs);
12888+ formatter.field("mac", &self.mac);
12889+ formatter.field("semi_token", &self.semi_token);
12890+ formatter.finish()
12891+ }
12892+}
12893+#[cfg(feature = "full")]
12894+impl Debug for TraitItemMethod {
12895+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12896+ let mut formatter = formatter.debug_struct("TraitItemMethod");
12897+ formatter.field("attrs", &self.attrs);
12898+ formatter.field("sig", &self.sig);
12899+ formatter.field("default", &self.default);
12900+ formatter.field("semi_token", &self.semi_token);
12901+ formatter.finish()
12902+ }
12903+}
12904+#[cfg(feature = "full")]
12905+impl Debug for TraitItemType {
12906+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12907+ let mut formatter = formatter.debug_struct("TraitItemType");
12908+ formatter.field("attrs", &self.attrs);
12909+ formatter.field("type_token", &self.type_token);
12910+ formatter.field("ident", &self.ident);
12911+ formatter.field("generics", &self.generics);
12912+ formatter.field("colon_token", &self.colon_token);
12913+ formatter.field("bounds", &self.bounds);
12914+ formatter.field("default", &self.default);
12915+ formatter.field("semi_token", &self.semi_token);
12916+ formatter.finish()
12917+ }
12918+}
12919+#[cfg(any(feature = "derive", feature = "full"))]
12920+impl Debug for Type {
12921+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12922+ match self {
12923+ Type::Array(v0) => {
12924+ let mut formatter = formatter.debug_tuple("Array");
12925+ formatter.field(v0);
12926+ formatter.finish()
12927+ }
12928+ Type::BareFn(v0) => {
12929+ let mut formatter = formatter.debug_tuple("BareFn");
12930+ formatter.field(v0);
12931+ formatter.finish()
12932+ }
12933+ Type::Group(v0) => {
12934+ let mut formatter = formatter.debug_tuple("Group");
12935+ formatter.field(v0);
12936+ formatter.finish()
12937+ }
12938+ Type::ImplTrait(v0) => {
12939+ let mut formatter = formatter.debug_tuple("ImplTrait");
12940+ formatter.field(v0);
12941+ formatter.finish()
12942+ }
12943+ Type::Infer(v0) => {
12944+ let mut formatter = formatter.debug_tuple("Infer");
12945+ formatter.field(v0);
12946+ formatter.finish()
12947+ }
12948+ Type::Macro(v0) => {
12949+ let mut formatter = formatter.debug_tuple("Macro");
12950+ formatter.field(v0);
12951+ formatter.finish()
12952+ }
12953+ Type::Never(v0) => {
12954+ let mut formatter = formatter.debug_tuple("Never");
12955+ formatter.field(v0);
12956+ formatter.finish()
12957+ }
12958+ Type::Paren(v0) => {
12959+ let mut formatter = formatter.debug_tuple("Paren");
12960+ formatter.field(v0);
12961+ formatter.finish()
12962+ }
12963+ Type::Path(v0) => {
12964+ let mut formatter = formatter.debug_tuple("Path");
12965+ formatter.field(v0);
12966+ formatter.finish()
12967+ }
12968+ Type::Ptr(v0) => {
12969+ let mut formatter = formatter.debug_tuple("Ptr");
12970+ formatter.field(v0);
12971+ formatter.finish()
12972+ }
12973+ Type::Reference(v0) => {
12974+ let mut formatter = formatter.debug_tuple("Reference");
12975+ formatter.field(v0);
12976+ formatter.finish()
12977+ }
12978+ Type::Slice(v0) => {
12979+ let mut formatter = formatter.debug_tuple("Slice");
12980+ formatter.field(v0);
12981+ formatter.finish()
12982+ }
12983+ Type::TraitObject(v0) => {
12984+ let mut formatter = formatter.debug_tuple("TraitObject");
12985+ formatter.field(v0);
12986+ formatter.finish()
12987+ }
12988+ Type::Tuple(v0) => {
12989+ let mut formatter = formatter.debug_tuple("Tuple");
12990+ formatter.field(v0);
12991+ formatter.finish()
12992+ }
12993+ Type::Verbatim(v0) => {
12994+ let mut formatter = formatter.debug_tuple("Verbatim");
12995+ formatter.field(v0);
12996+ formatter.finish()
12997+ }
12998+ _ => unreachable!(),
12999+ }
13000+ }
13001+}
13002+#[cfg(any(feature = "derive", feature = "full"))]
13003+impl Debug for TypeArray {
13004+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13005+ let mut formatter = formatter.debug_struct("TypeArray");
13006+ formatter.field("bracket_token", &self.bracket_token);
13007+ formatter.field("elem", &self.elem);
13008+ formatter.field("semi_token", &self.semi_token);
13009+ formatter.field("len", &self.len);
13010+ formatter.finish()
13011+ }
13012+}
13013+#[cfg(any(feature = "derive", feature = "full"))]
13014+impl Debug for TypeBareFn {
13015+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13016+ let mut formatter = formatter.debug_struct("TypeBareFn");
13017+ formatter.field("lifetimes", &self.lifetimes);
13018+ formatter.field("unsafety", &self.unsafety);
13019+ formatter.field("abi", &self.abi);
13020+ formatter.field("fn_token", &self.fn_token);
13021+ formatter.field("paren_token", &self.paren_token);
13022+ formatter.field("inputs", &self.inputs);
13023+ formatter.field("variadic", &self.variadic);
13024+ formatter.field("output", &self.output);
13025+ formatter.finish()
13026+ }
13027+}
13028+#[cfg(any(feature = "derive", feature = "full"))]
13029+impl Debug for TypeGroup {
13030+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13031+ let mut formatter = formatter.debug_struct("TypeGroup");
13032+ formatter.field("group_token", &self.group_token);
13033+ formatter.field("elem", &self.elem);
13034+ formatter.finish()
13035+ }
13036+}
13037+#[cfg(any(feature = "derive", feature = "full"))]
13038+impl Debug for TypeImplTrait {
13039+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13040+ let mut formatter = formatter.debug_struct("TypeImplTrait");
13041+ formatter.field("impl_token", &self.impl_token);
13042+ formatter.field("bounds", &self.bounds);
13043+ formatter.finish()
13044+ }
13045+}
13046+#[cfg(any(feature = "derive", feature = "full"))]
13047+impl Debug for TypeInfer {
13048+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13049+ let mut formatter = formatter.debug_struct("TypeInfer");
13050+ formatter.field("underscore_token", &self.underscore_token);
13051+ formatter.finish()
13052+ }
13053+}
13054+#[cfg(any(feature = "derive", feature = "full"))]
13055+impl Debug for TypeMacro {
13056+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13057+ let mut formatter = formatter.debug_struct("TypeMacro");
13058+ formatter.field("mac", &self.mac);
13059+ formatter.finish()
13060+ }
13061+}
13062+#[cfg(any(feature = "derive", feature = "full"))]
13063+impl Debug for TypeNever {
13064+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13065+ let mut formatter = formatter.debug_struct("TypeNever");
13066+ formatter.field("bang_token", &self.bang_token);
13067+ formatter.finish()
13068+ }
13069+}
13070+#[cfg(any(feature = "derive", feature = "full"))]
13071+impl Debug for TypeParam {
13072+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13073+ let mut formatter = formatter.debug_struct("TypeParam");
13074+ formatter.field("attrs", &self.attrs);
13075+ formatter.field("ident", &self.ident);
13076+ formatter.field("colon_token", &self.colon_token);
13077+ formatter.field("bounds", &self.bounds);
13078+ formatter.field("eq_token", &self.eq_token);
13079+ formatter.field("default", &self.default);
13080+ formatter.finish()
13081+ }
13082+}
13083+#[cfg(any(feature = "derive", feature = "full"))]
13084+impl Debug for TypeParamBound {
13085+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13086+ match self {
13087+ TypeParamBound::Trait(v0) => {
13088+ let mut formatter = formatter.debug_tuple("Trait");
13089+ formatter.field(v0);
13090+ formatter.finish()
13091+ }
13092+ TypeParamBound::Lifetime(v0) => {
13093+ let mut formatter = formatter.debug_tuple("Lifetime");
13094+ formatter.field(v0);
13095+ formatter.finish()
13096+ }
13097+ }
13098+ }
13099+}
13100+#[cfg(any(feature = "derive", feature = "full"))]
13101+impl Debug for TypeParen {
13102+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13103+ let mut formatter = formatter.debug_struct("TypeParen");
13104+ formatter.field("paren_token", &self.paren_token);
13105+ formatter.field("elem", &self.elem);
13106+ formatter.finish()
13107+ }
13108+}
13109+#[cfg(any(feature = "derive", feature = "full"))]
13110+impl Debug for TypePath {
13111+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13112+ let mut formatter = formatter.debug_struct("TypePath");
13113+ formatter.field("qself", &self.qself);
13114+ formatter.field("path", &self.path);
13115+ formatter.finish()
13116+ }
13117+}
13118+#[cfg(any(feature = "derive", feature = "full"))]
13119+impl Debug for TypePtr {
13120+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13121+ let mut formatter = formatter.debug_struct("TypePtr");
13122+ formatter.field("star_token", &self.star_token);
13123+ formatter.field("const_token", &self.const_token);
13124+ formatter.field("mutability", &self.mutability);
13125+ formatter.field("elem", &self.elem);
13126+ formatter.finish()
13127+ }
13128+}
13129+#[cfg(any(feature = "derive", feature = "full"))]
13130+impl Debug for TypeReference {
13131+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13132+ let mut formatter = formatter.debug_struct("TypeReference");
13133+ formatter.field("and_token", &self.and_token);
13134+ formatter.field("lifetime", &self.lifetime);
13135+ formatter.field("mutability", &self.mutability);
13136+ formatter.field("elem", &self.elem);
13137+ formatter.finish()
13138+ }
13139+}
13140+#[cfg(any(feature = "derive", feature = "full"))]
13141+impl Debug for TypeSlice {
13142+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13143+ let mut formatter = formatter.debug_struct("TypeSlice");
13144+ formatter.field("bracket_token", &self.bracket_token);
13145+ formatter.field("elem", &self.elem);
13146+ formatter.finish()
13147+ }
13148+}
13149+#[cfg(any(feature = "derive", feature = "full"))]
13150+impl Debug for TypeTraitObject {
13151+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13152+ let mut formatter = formatter.debug_struct("TypeTraitObject");
13153+ formatter.field("dyn_token", &self.dyn_token);
13154+ formatter.field("bounds", &self.bounds);
13155+ formatter.finish()
13156+ }
13157+}
13158+#[cfg(any(feature = "derive", feature = "full"))]
13159+impl Debug for TypeTuple {
13160+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13161+ let mut formatter = formatter.debug_struct("TypeTuple");
13162+ formatter.field("paren_token", &self.paren_token);
13163+ formatter.field("elems", &self.elems);
13164+ formatter.finish()
13165+ }
13166+}
13167+#[cfg(any(feature = "derive", feature = "full"))]
13168+impl Debug for UnOp {
13169+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13170+ match self {
13171+ UnOp::Deref(v0) => {
13172+ let mut formatter = formatter.debug_tuple("Deref");
13173+ formatter.field(v0);
13174+ formatter.finish()
13175+ }
13176+ UnOp::Not(v0) => {
13177+ let mut formatter = formatter.debug_tuple("Not");
13178+ formatter.field(v0);
13179+ formatter.finish()
13180+ }
13181+ UnOp::Neg(v0) => {
13182+ let mut formatter = formatter.debug_tuple("Neg");
13183+ formatter.field(v0);
13184+ formatter.finish()
13185+ }
13186+ }
13187+ }
13188+}
13189+#[cfg(feature = "full")]
13190+impl Debug for UseGlob {
13191+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13192+ let mut formatter = formatter.debug_struct("UseGlob");
13193+ formatter.field("star_token", &self.star_token);
13194+ formatter.finish()
13195+ }
13196+}
13197+#[cfg(feature = "full")]
13198+impl Debug for UseGroup {
13199+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13200+ let mut formatter = formatter.debug_struct("UseGroup");
13201+ formatter.field("brace_token", &self.brace_token);
13202+ formatter.field("items", &self.items);
13203+ formatter.finish()
13204+ }
13205+}
13206+#[cfg(feature = "full")]
13207+impl Debug for UseName {
13208+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13209+ let mut formatter = formatter.debug_struct("UseName");
13210+ formatter.field("ident", &self.ident);
13211+ formatter.finish()
13212+ }
13213+}
13214+#[cfg(feature = "full")]
13215+impl Debug for UsePath {
13216+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13217+ let mut formatter = formatter.debug_struct("UsePath");
13218+ formatter.field("ident", &self.ident);
13219+ formatter.field("colon2_token", &self.colon2_token);
13220+ formatter.field("tree", &self.tree);
13221+ formatter.finish()
13222+ }
13223+}
13224+#[cfg(feature = "full")]
13225+impl Debug for UseRename {
13226+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13227+ let mut formatter = formatter.debug_struct("UseRename");
13228+ formatter.field("ident", &self.ident);
13229+ formatter.field("as_token", &self.as_token);
13230+ formatter.field("rename", &self.rename);
13231+ formatter.finish()
13232+ }
13233+}
13234+#[cfg(feature = "full")]
13235+impl Debug for UseTree {
13236+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13237+ match self {
13238+ UseTree::Path(v0) => {
13239+ let mut formatter = formatter.debug_tuple("Path");
13240+ formatter.field(v0);
13241+ formatter.finish()
13242+ }
13243+ UseTree::Name(v0) => {
13244+ let mut formatter = formatter.debug_tuple("Name");
13245+ formatter.field(v0);
13246+ formatter.finish()
13247+ }
13248+ UseTree::Rename(v0) => {
13249+ let mut formatter = formatter.debug_tuple("Rename");
13250+ formatter.field(v0);
13251+ formatter.finish()
13252+ }
13253+ UseTree::Glob(v0) => {
13254+ let mut formatter = formatter.debug_tuple("Glob");
13255+ formatter.field(v0);
13256+ formatter.finish()
13257+ }
13258+ UseTree::Group(v0) => {
13259+ let mut formatter = formatter.debug_tuple("Group");
13260+ formatter.field(v0);
13261+ formatter.finish()
13262+ }
13263+ }
13264+ }
13265+}
13266+#[cfg(any(feature = "derive", feature = "full"))]
13267+impl Debug for Variadic {
13268+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13269+ let mut formatter = formatter.debug_struct("Variadic");
13270+ formatter.field("attrs", &self.attrs);
13271+ formatter.field("dots", &self.dots);
13272+ formatter.finish()
13273+ }
13274+}
13275+#[cfg(any(feature = "derive", feature = "full"))]
13276+impl Debug for Variant {
13277+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13278+ let mut formatter = formatter.debug_struct("Variant");
13279+ formatter.field("attrs", &self.attrs);
13280+ formatter.field("ident", &self.ident);
13281+ formatter.field("fields", &self.fields);
13282+ formatter.field("discriminant", &self.discriminant);
13283+ formatter.finish()
13284+ }
13285+}
13286+#[cfg(any(feature = "derive", feature = "full"))]
13287+impl Debug for VisCrate {
13288+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13289+ let mut formatter = formatter.debug_struct("VisCrate");
13290+ formatter.field("crate_token", &self.crate_token);
13291+ formatter.finish()
13292+ }
13293+}
13294+#[cfg(any(feature = "derive", feature = "full"))]
13295+impl Debug for VisPublic {
13296+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13297+ let mut formatter = formatter.debug_struct("VisPublic");
13298+ formatter.field("pub_token", &self.pub_token);
13299+ formatter.finish()
13300+ }
13301+}
13302+#[cfg(any(feature = "derive", feature = "full"))]
13303+impl Debug for VisRestricted {
13304+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13305+ let mut formatter = formatter.debug_struct("VisRestricted");
13306+ formatter.field("pub_token", &self.pub_token);
13307+ formatter.field("paren_token", &self.paren_token);
13308+ formatter.field("in_token", &self.in_token);
13309+ formatter.field("path", &self.path);
13310+ formatter.finish()
13311+ }
13312+}
13313+#[cfg(any(feature = "derive", feature = "full"))]
13314+impl Debug for Visibility {
13315+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13316+ match self {
13317+ Visibility::Public(v0) => {
13318+ let mut formatter = formatter.debug_tuple("Public");
13319+ formatter.field(v0);
13320+ formatter.finish()
13321+ }
13322+ Visibility::Crate(v0) => {
13323+ let mut formatter = formatter.debug_tuple("Crate");
13324+ formatter.field(v0);
13325+ formatter.finish()
13326+ }
13327+ Visibility::Restricted(v0) => {
13328+ let mut formatter = formatter.debug_tuple("Restricted");
13329+ formatter.field(v0);
13330+ formatter.finish()
13331+ }
13332+ Visibility::Inherited => formatter.write_str("Inherited"),
13333+ }
13334+ }
13335+}
13336+#[cfg(any(feature = "derive", feature = "full"))]
13337+impl Debug for WhereClause {
13338+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13339+ let mut formatter = formatter.debug_struct("WhereClause");
13340+ formatter.field("where_token", &self.where_token);
13341+ formatter.field("predicates", &self.predicates);
13342+ formatter.finish()
13343+ }
13344+}
13345+#[cfg(any(feature = "derive", feature = "full"))]
13346+impl Debug for WherePredicate {
13347+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13348+ match self {
13349+ WherePredicate::Type(v0) => {
13350+ let mut formatter = formatter.debug_tuple("Type");
13351+ formatter.field(v0);
13352+ formatter.finish()
13353+ }
13354+ WherePredicate::Lifetime(v0) => {
13355+ let mut formatter = formatter.debug_tuple("Lifetime");
13356+ formatter.field(v0);
13357+ formatter.finish()
13358+ }
13359+ WherePredicate::Eq(v0) => {
13360+ let mut formatter = formatter.debug_tuple("Eq");
13361+ formatter.field(v0);
13362+ formatter.finish()
13363+ }
13364+ }
13365+ }
13366+}
13367diff --git a/third_party/rust/syn/src/gen/eq.rs b/third_party/rust/syn/src/gen/eq.rs
13368new file mode 100644
13369--- /dev/null
13370+++ b/third_party/rust/syn/src/gen/eq.rs
13371@@ -0,0 +1,1930 @@
13372+// This file is @generated by syn-internal-codegen.
13373+// It is not intended for manual editing.
13374+
13375+#[cfg(any(feature = "derive", feature = "full"))]
13376+use crate::tt::TokenStreamHelper;
13377+use crate::*;
13378+#[cfg(any(feature = "derive", feature = "full"))]
13379+impl Eq for Abi {}
13380+#[cfg(any(feature = "derive", feature = "full"))]
13381+impl PartialEq for Abi {
13382+ fn eq(&self, other: &Self) -> bool {
13383+ self.name == other.name
13384+ }
13385+}
13386+#[cfg(any(feature = "derive", feature = "full"))]
13387+impl Eq for AngleBracketedGenericArguments {}
13388+#[cfg(any(feature = "derive", feature = "full"))]
13389+impl PartialEq for AngleBracketedGenericArguments {
13390+ fn eq(&self, other: &Self) -> bool {
13391+ self.colon2_token == other.colon2_token && self.args == other.args
13392+ }
13393+}
13394+#[cfg(feature = "full")]
13395+impl Eq for Arm {}
13396+#[cfg(feature = "full")]
13397+impl PartialEq for Arm {
13398+ fn eq(&self, other: &Self) -> bool {
13399+ self.attrs == other.attrs
13400+ && self.pat == other.pat
13401+ && self.guard == other.guard
13402+ && self.body == other.body
13403+ && self.comma == other.comma
13404+ }
13405+}
13406+#[cfg(any(feature = "derive", feature = "full"))]
13407+impl Eq for AttrStyle {}
13408+#[cfg(any(feature = "derive", feature = "full"))]
13409+impl PartialEq for AttrStyle {
13410+ fn eq(&self, other: &Self) -> bool {
13411+ match (self, other) {
13412+ (AttrStyle::Outer, AttrStyle::Outer) => true,
13413+ (AttrStyle::Inner(_), AttrStyle::Inner(_)) => true,
13414+ _ => false,
13415+ }
13416+ }
13417+}
13418+#[cfg(any(feature = "derive", feature = "full"))]
13419+impl Eq for Attribute {}
13420+#[cfg(any(feature = "derive", feature = "full"))]
13421+impl PartialEq for Attribute {
13422+ fn eq(&self, other: &Self) -> bool {
13423+ self.style == other.style
13424+ && self.path == other.path
13425+ && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens)
13426+ }
13427+}
13428+#[cfg(any(feature = "derive", feature = "full"))]
13429+impl Eq for BareFnArg {}
13430+#[cfg(any(feature = "derive", feature = "full"))]
13431+impl PartialEq for BareFnArg {
13432+ fn eq(&self, other: &Self) -> bool {
13433+ self.attrs == other.attrs && self.name == other.name && self.ty == other.ty
13434+ }
13435+}
13436+#[cfg(any(feature = "derive", feature = "full"))]
13437+impl Eq for BinOp {}
13438+#[cfg(any(feature = "derive", feature = "full"))]
13439+impl PartialEq for BinOp {
13440+ fn eq(&self, other: &Self) -> bool {
13441+ match (self, other) {
13442+ (BinOp::Add(_), BinOp::Add(_)) => true,
13443+ (BinOp::Sub(_), BinOp::Sub(_)) => true,
13444+ (BinOp::Mul(_), BinOp::Mul(_)) => true,
13445+ (BinOp::Div(_), BinOp::Div(_)) => true,
13446+ (BinOp::Rem(_), BinOp::Rem(_)) => true,
13447+ (BinOp::And(_), BinOp::And(_)) => true,
13448+ (BinOp::Or(_), BinOp::Or(_)) => true,
13449+ (BinOp::BitXor(_), BinOp::BitXor(_)) => true,
13450+ (BinOp::BitAnd(_), BinOp::BitAnd(_)) => true,
13451+ (BinOp::BitOr(_), BinOp::BitOr(_)) => true,
13452+ (BinOp::Shl(_), BinOp::Shl(_)) => true,
13453+ (BinOp::Shr(_), BinOp::Shr(_)) => true,
13454+ (BinOp::Eq(_), BinOp::Eq(_)) => true,
13455+ (BinOp::Lt(_), BinOp::Lt(_)) => true,
13456+ (BinOp::Le(_), BinOp::Le(_)) => true,
13457+ (BinOp::Ne(_), BinOp::Ne(_)) => true,
13458+ (BinOp::Ge(_), BinOp::Ge(_)) => true,
13459+ (BinOp::Gt(_), BinOp::Gt(_)) => true,
13460+ (BinOp::AddEq(_), BinOp::AddEq(_)) => true,
13461+ (BinOp::SubEq(_), BinOp::SubEq(_)) => true,
13462+ (BinOp::MulEq(_), BinOp::MulEq(_)) => true,
13463+ (BinOp::DivEq(_), BinOp::DivEq(_)) => true,
13464+ (BinOp::RemEq(_), BinOp::RemEq(_)) => true,
13465+ (BinOp::BitXorEq(_), BinOp::BitXorEq(_)) => true,
13466+ (BinOp::BitAndEq(_), BinOp::BitAndEq(_)) => true,
13467+ (BinOp::BitOrEq(_), BinOp::BitOrEq(_)) => true,
13468+ (BinOp::ShlEq(_), BinOp::ShlEq(_)) => true,
13469+ (BinOp::ShrEq(_), BinOp::ShrEq(_)) => true,
13470+ _ => false,
13471+ }
13472+ }
13473+}
13474+#[cfg(any(feature = "derive", feature = "full"))]
13475+impl Eq for Binding {}
13476+#[cfg(any(feature = "derive", feature = "full"))]
13477+impl PartialEq for Binding {
13478+ fn eq(&self, other: &Self) -> bool {
13479+ self.ident == other.ident && self.ty == other.ty
13480+ }
13481+}
13482+#[cfg(feature = "full")]
13483+impl Eq for Block {}
13484+#[cfg(feature = "full")]
13485+impl PartialEq for Block {
13486+ fn eq(&self, other: &Self) -> bool {
13487+ self.stmts == other.stmts
13488+ }
13489+}
13490+#[cfg(any(feature = "derive", feature = "full"))]
13491+impl Eq for BoundLifetimes {}
13492+#[cfg(any(feature = "derive", feature = "full"))]
13493+impl PartialEq for BoundLifetimes {
13494+ fn eq(&self, other: &Self) -> bool {
13495+ self.lifetimes == other.lifetimes
13496+ }
13497+}
13498+#[cfg(any(feature = "derive", feature = "full"))]
13499+impl Eq for ConstParam {}
13500+#[cfg(any(feature = "derive", feature = "full"))]
13501+impl PartialEq for ConstParam {
13502+ fn eq(&self, other: &Self) -> bool {
13503+ self.attrs == other.attrs
13504+ && self.ident == other.ident
13505+ && self.ty == other.ty
13506+ && self.eq_token == other.eq_token
13507+ && self.default == other.default
13508+ }
13509+}
13510+#[cfg(any(feature = "derive", feature = "full"))]
13511+impl Eq for Constraint {}
13512+#[cfg(any(feature = "derive", feature = "full"))]
13513+impl PartialEq for Constraint {
13514+ fn eq(&self, other: &Self) -> bool {
13515+ self.ident == other.ident && self.bounds == other.bounds
13516+ }
13517+}
13518+#[cfg(feature = "derive")]
13519+impl Eq for Data {}
13520+#[cfg(feature = "derive")]
13521+impl PartialEq for Data {
13522+ fn eq(&self, other: &Self) -> bool {
13523+ match (self, other) {
13524+ (Data::Struct(self0), Data::Struct(other0)) => self0 == other0,
13525+ (Data::Enum(self0), Data::Enum(other0)) => self0 == other0,
13526+ (Data::Union(self0), Data::Union(other0)) => self0 == other0,
13527+ _ => false,
13528+ }
13529+ }
13530+}
13531+#[cfg(feature = "derive")]
13532+impl Eq for DataEnum {}
13533+#[cfg(feature = "derive")]
13534+impl PartialEq for DataEnum {
13535+ fn eq(&self, other: &Self) -> bool {
13536+ self.variants == other.variants
13537+ }
13538+}
13539+#[cfg(feature = "derive")]
13540+impl Eq for DataStruct {}
13541+#[cfg(feature = "derive")]
13542+impl PartialEq for DataStruct {
13543+ fn eq(&self, other: &Self) -> bool {
13544+ self.fields == other.fields && self.semi_token == other.semi_token
13545+ }
13546+}
13547+#[cfg(feature = "derive")]
13548+impl Eq for DataUnion {}
13549+#[cfg(feature = "derive")]
13550+impl PartialEq for DataUnion {
13551+ fn eq(&self, other: &Self) -> bool {
13552+ self.fields == other.fields
13553+ }
13554+}
13555+#[cfg(feature = "derive")]
13556+impl Eq for DeriveInput {}
13557+#[cfg(feature = "derive")]
13558+impl PartialEq for DeriveInput {
13559+ fn eq(&self, other: &Self) -> bool {
13560+ self.attrs == other.attrs
13561+ && self.vis == other.vis
13562+ && self.ident == other.ident
13563+ && self.generics == other.generics
13564+ && self.data == other.data
13565+ }
13566+}
13567+#[cfg(any(feature = "derive", feature = "full"))]
13568+impl Eq for Expr {}
13569+#[cfg(any(feature = "derive", feature = "full"))]
13570+impl PartialEq for Expr {
13571+ fn eq(&self, other: &Self) -> bool {
13572+ match (self, other) {
13573+ #[cfg(feature = "full")]
13574+ (Expr::Array(self0), Expr::Array(other0)) => self0 == other0,
13575+ #[cfg(feature = "full")]
13576+ (Expr::Assign(self0), Expr::Assign(other0)) => self0 == other0,
13577+ #[cfg(feature = "full")]
13578+ (Expr::AssignOp(self0), Expr::AssignOp(other0)) => self0 == other0,
13579+ #[cfg(feature = "full")]
13580+ (Expr::Async(self0), Expr::Async(other0)) => self0 == other0,
13581+ #[cfg(feature = "full")]
13582+ (Expr::Await(self0), Expr::Await(other0)) => self0 == other0,
13583+ (Expr::Binary(self0), Expr::Binary(other0)) => self0 == other0,
13584+ #[cfg(feature = "full")]
13585+ (Expr::Block(self0), Expr::Block(other0)) => self0 == other0,
13586+ #[cfg(feature = "full")]
13587+ (Expr::Box(self0), Expr::Box(other0)) => self0 == other0,
13588+ #[cfg(feature = "full")]
13589+ (Expr::Break(self0), Expr::Break(other0)) => self0 == other0,
13590+ (Expr::Call(self0), Expr::Call(other0)) => self0 == other0,
13591+ (Expr::Cast(self0), Expr::Cast(other0)) => self0 == other0,
13592+ #[cfg(feature = "full")]
13593+ (Expr::Closure(self0), Expr::Closure(other0)) => self0 == other0,
13594+ #[cfg(feature = "full")]
13595+ (Expr::Continue(self0), Expr::Continue(other0)) => self0 == other0,
13596+ (Expr::Field(self0), Expr::Field(other0)) => self0 == other0,
13597+ #[cfg(feature = "full")]
13598+ (Expr::ForLoop(self0), Expr::ForLoop(other0)) => self0 == other0,
13599+ #[cfg(feature = "full")]
13600+ (Expr::Group(self0), Expr::Group(other0)) => self0 == other0,
13601+ #[cfg(feature = "full")]
13602+ (Expr::If(self0), Expr::If(other0)) => self0 == other0,
13603+ (Expr::Index(self0), Expr::Index(other0)) => self0 == other0,
13604+ #[cfg(feature = "full")]
13605+ (Expr::Let(self0), Expr::Let(other0)) => self0 == other0,
13606+ (Expr::Lit(self0), Expr::Lit(other0)) => self0 == other0,
13607+ #[cfg(feature = "full")]
13608+ (Expr::Loop(self0), Expr::Loop(other0)) => self0 == other0,
13609+ #[cfg(feature = "full")]
13610+ (Expr::Macro(self0), Expr::Macro(other0)) => self0 == other0,
13611+ #[cfg(feature = "full")]
13612+ (Expr::Match(self0), Expr::Match(other0)) => self0 == other0,
13613+ #[cfg(feature = "full")]
13614+ (Expr::MethodCall(self0), Expr::MethodCall(other0)) => self0 == other0,
13615+ (Expr::Paren(self0), Expr::Paren(other0)) => self0 == other0,
13616+ (Expr::Path(self0), Expr::Path(other0)) => self0 == other0,
13617+ #[cfg(feature = "full")]
13618+ (Expr::Range(self0), Expr::Range(other0)) => self0 == other0,
13619+ #[cfg(feature = "full")]
13620+ (Expr::Reference(self0), Expr::Reference(other0)) => self0 == other0,
13621+ #[cfg(feature = "full")]
13622+ (Expr::Repeat(self0), Expr::Repeat(other0)) => self0 == other0,
13623+ #[cfg(feature = "full")]
13624+ (Expr::Return(self0), Expr::Return(other0)) => self0 == other0,
13625+ #[cfg(feature = "full")]
13626+ (Expr::Struct(self0), Expr::Struct(other0)) => self0 == other0,
13627+ #[cfg(feature = "full")]
13628+ (Expr::Try(self0), Expr::Try(other0)) => self0 == other0,
13629+ #[cfg(feature = "full")]
13630+ (Expr::TryBlock(self0), Expr::TryBlock(other0)) => self0 == other0,
13631+ #[cfg(feature = "full")]
13632+ (Expr::Tuple(self0), Expr::Tuple(other0)) => self0 == other0,
13633+ #[cfg(feature = "full")]
13634+ (Expr::Type(self0), Expr::Type(other0)) => self0 == other0,
13635+ (Expr::Unary(self0), Expr::Unary(other0)) => self0 == other0,
13636+ #[cfg(feature = "full")]
13637+ (Expr::Unsafe(self0), Expr::Unsafe(other0)) => self0 == other0,
13638+ (Expr::Verbatim(self0), Expr::Verbatim(other0)) => {
13639+ TokenStreamHelper(self0) == TokenStreamHelper(other0)
13640+ }
13641+ #[cfg(feature = "full")]
13642+ (Expr::While(self0), Expr::While(other0)) => self0 == other0,
13643+ #[cfg(feature = "full")]
13644+ (Expr::Yield(self0), Expr::Yield(other0)) => self0 == other0,
13645+ _ => false,
13646+ }
13647+ }
13648+}
13649+#[cfg(feature = "full")]
13650+impl Eq for ExprArray {}
13651+#[cfg(feature = "full")]
13652+impl PartialEq for ExprArray {
13653+ fn eq(&self, other: &Self) -> bool {
13654+ self.attrs == other.attrs && self.elems == other.elems
13655+ }
13656+}
13657+#[cfg(feature = "full")]
13658+impl Eq for ExprAssign {}
13659+#[cfg(feature = "full")]
13660+impl PartialEq for ExprAssign {
13661+ fn eq(&self, other: &Self) -> bool {
13662+ self.attrs == other.attrs && self.left == other.left && self.right == other.right
13663+ }
13664+}
13665+#[cfg(feature = "full")]
13666+impl Eq for ExprAssignOp {}
13667+#[cfg(feature = "full")]
13668+impl PartialEq for ExprAssignOp {
13669+ fn eq(&self, other: &Self) -> bool {
13670+ self.attrs == other.attrs
13671+ && self.left == other.left
13672+ && self.op == other.op
13673+ && self.right == other.right
13674+ }
13675+}
13676+#[cfg(feature = "full")]
13677+impl Eq for ExprAsync {}
13678+#[cfg(feature = "full")]
13679+impl PartialEq for ExprAsync {
13680+ fn eq(&self, other: &Self) -> bool {
13681+ self.attrs == other.attrs && self.capture == other.capture && self.block == other.block
13682+ }
13683+}
13684+#[cfg(feature = "full")]
13685+impl Eq for ExprAwait {}
13686+#[cfg(feature = "full")]
13687+impl PartialEq for ExprAwait {
13688+ fn eq(&self, other: &Self) -> bool {
13689+ self.attrs == other.attrs && self.base == other.base
13690+ }
13691+}
13692+#[cfg(any(feature = "derive", feature = "full"))]
13693+impl Eq for ExprBinary {}
13694+#[cfg(any(feature = "derive", feature = "full"))]
13695+impl PartialEq for ExprBinary {
13696+ fn eq(&self, other: &Self) -> bool {
13697+ self.attrs == other.attrs
13698+ && self.left == other.left
13699+ && self.op == other.op
13700+ && self.right == other.right
13701+ }
13702+}
13703+#[cfg(feature = "full")]
13704+impl Eq for ExprBlock {}
13705+#[cfg(feature = "full")]
13706+impl PartialEq for ExprBlock {
13707+ fn eq(&self, other: &Self) -> bool {
13708+ self.attrs == other.attrs && self.label == other.label && self.block == other.block
13709+ }
13710+}
13711+#[cfg(feature = "full")]
13712+impl Eq for ExprBox {}
13713+#[cfg(feature = "full")]
13714+impl PartialEq for ExprBox {
13715+ fn eq(&self, other: &Self) -> bool {
13716+ self.attrs == other.attrs && self.expr == other.expr
13717+ }
13718+}
13719+#[cfg(feature = "full")]
13720+impl Eq for ExprBreak {}
13721+#[cfg(feature = "full")]
13722+impl PartialEq for ExprBreak {
13723+ fn eq(&self, other: &Self) -> bool {
13724+ self.attrs == other.attrs && self.label == other.label && self.expr == other.expr
13725+ }
13726+}
13727+#[cfg(any(feature = "derive", feature = "full"))]
13728+impl Eq for ExprCall {}
13729+#[cfg(any(feature = "derive", feature = "full"))]
13730+impl PartialEq for ExprCall {
13731+ fn eq(&self, other: &Self) -> bool {
13732+ self.attrs == other.attrs && self.func == other.func && self.args == other.args
13733+ }
13734+}
13735+#[cfg(any(feature = "derive", feature = "full"))]
13736+impl Eq for ExprCast {}
13737+#[cfg(any(feature = "derive", feature = "full"))]
13738+impl PartialEq for ExprCast {
13739+ fn eq(&self, other: &Self) -> bool {
13740+ self.attrs == other.attrs && self.expr == other.expr && self.ty == other.ty
13741+ }
13742+}
13743+#[cfg(feature = "full")]
13744+impl Eq for ExprClosure {}
13745+#[cfg(feature = "full")]
13746+impl PartialEq for ExprClosure {
13747+ fn eq(&self, other: &Self) -> bool {
13748+ self.attrs == other.attrs
13749+ && self.asyncness == other.asyncness
13750+ && self.movability == other.movability
13751+ && self.capture == other.capture
13752+ && self.inputs == other.inputs
13753+ && self.output == other.output
13754+ && self.body == other.body
13755+ }
13756+}
13757+#[cfg(feature = "full")]
13758+impl Eq for ExprContinue {}
13759+#[cfg(feature = "full")]
13760+impl PartialEq for ExprContinue {
13761+ fn eq(&self, other: &Self) -> bool {
13762+ self.attrs == other.attrs && self.label == other.label
13763+ }
13764+}
13765+#[cfg(any(feature = "derive", feature = "full"))]
13766+impl Eq for ExprField {}
13767+#[cfg(any(feature = "derive", feature = "full"))]
13768+impl PartialEq for ExprField {
13769+ fn eq(&self, other: &Self) -> bool {
13770+ self.attrs == other.attrs && self.base == other.base && self.member == other.member
13771+ }
13772+}
13773+#[cfg(feature = "full")]
13774+impl Eq for ExprForLoop {}
13775+#[cfg(feature = "full")]
13776+impl PartialEq for ExprForLoop {
13777+ fn eq(&self, other: &Self) -> bool {
13778+ self.attrs == other.attrs
13779+ && self.label == other.label
13780+ && self.pat == other.pat
13781+ && self.expr == other.expr
13782+ && self.body == other.body
13783+ }
13784+}
13785+#[cfg(feature = "full")]
13786+impl Eq for ExprGroup {}
13787+#[cfg(feature = "full")]
13788+impl PartialEq for ExprGroup {
13789+ fn eq(&self, other: &Self) -> bool {
13790+ self.attrs == other.attrs && self.expr == other.expr
13791+ }
13792+}
13793+#[cfg(feature = "full")]
13794+impl Eq for ExprIf {}
13795+#[cfg(feature = "full")]
13796+impl PartialEq for ExprIf {
13797+ fn eq(&self, other: &Self) -> bool {
13798+ self.attrs == other.attrs
13799+ && self.cond == other.cond
13800+ && self.then_branch == other.then_branch
13801+ && self.else_branch == other.else_branch
13802+ }
13803+}
13804+#[cfg(any(feature = "derive", feature = "full"))]
13805+impl Eq for ExprIndex {}
13806+#[cfg(any(feature = "derive", feature = "full"))]
13807+impl PartialEq for ExprIndex {
13808+ fn eq(&self, other: &Self) -> bool {
13809+ self.attrs == other.attrs && self.expr == other.expr && self.index == other.index
13810+ }
13811+}
13812+#[cfg(feature = "full")]
13813+impl Eq for ExprLet {}
13814+#[cfg(feature = "full")]
13815+impl PartialEq for ExprLet {
13816+ fn eq(&self, other: &Self) -> bool {
13817+ self.attrs == other.attrs && self.pat == other.pat && self.expr == other.expr
13818+ }
13819+}
13820+#[cfg(any(feature = "derive", feature = "full"))]
13821+impl Eq for ExprLit {}
13822+#[cfg(any(feature = "derive", feature = "full"))]
13823+impl PartialEq for ExprLit {
13824+ fn eq(&self, other: &Self) -> bool {
13825+ self.attrs == other.attrs && self.lit == other.lit
13826+ }
13827+}
13828+#[cfg(feature = "full")]
13829+impl Eq for ExprLoop {}
13830+#[cfg(feature = "full")]
13831+impl PartialEq for ExprLoop {
13832+ fn eq(&self, other: &Self) -> bool {
13833+ self.attrs == other.attrs && self.label == other.label && self.body == other.body
13834+ }
13835+}
13836+#[cfg(feature = "full")]
13837+impl Eq for ExprMacro {}
13838+#[cfg(feature = "full")]
13839+impl PartialEq for ExprMacro {
13840+ fn eq(&self, other: &Self) -> bool {
13841+ self.attrs == other.attrs && self.mac == other.mac
13842+ }
13843+}
13844+#[cfg(feature = "full")]
13845+impl Eq for ExprMatch {}
13846+#[cfg(feature = "full")]
13847+impl PartialEq for ExprMatch {
13848+ fn eq(&self, other: &Self) -> bool {
13849+ self.attrs == other.attrs && self.expr == other.expr && self.arms == other.arms
13850+ }
13851+}
13852+#[cfg(feature = "full")]
13853+impl Eq for ExprMethodCall {}
13854+#[cfg(feature = "full")]
13855+impl PartialEq for ExprMethodCall {
13856+ fn eq(&self, other: &Self) -> bool {
13857+ self.attrs == other.attrs
13858+ && self.receiver == other.receiver
13859+ && self.method == other.method
13860+ && self.turbofish == other.turbofish
13861+ && self.args == other.args
13862+ }
13863+}
13864+#[cfg(any(feature = "derive", feature = "full"))]
13865+impl Eq for ExprParen {}
13866+#[cfg(any(feature = "derive", feature = "full"))]
13867+impl PartialEq for ExprParen {
13868+ fn eq(&self, other: &Self) -> bool {
13869+ self.attrs == other.attrs && self.expr == other.expr
13870+ }
13871+}
13872+#[cfg(any(feature = "derive", feature = "full"))]
13873+impl Eq for ExprPath {}
13874+#[cfg(any(feature = "derive", feature = "full"))]
13875+impl PartialEq for ExprPath {
13876+ fn eq(&self, other: &Self) -> bool {
13877+ self.attrs == other.attrs && self.qself == other.qself && self.path == other.path
13878+ }
13879+}
13880+#[cfg(feature = "full")]
13881+impl Eq for ExprRange {}
13882+#[cfg(feature = "full")]
13883+impl PartialEq for ExprRange {
13884+ fn eq(&self, other: &Self) -> bool {
13885+ self.attrs == other.attrs
13886+ && self.from == other.from
13887+ && self.limits == other.limits
13888+ && self.to == other.to
13889+ }
13890+}
13891+#[cfg(feature = "full")]
13892+impl Eq for ExprReference {}
13893+#[cfg(feature = "full")]
13894+impl PartialEq for ExprReference {
13895+ fn eq(&self, other: &Self) -> bool {
13896+ self.attrs == other.attrs && self.mutability == other.mutability && self.expr == other.expr
13897+ }
13898+}
13899+#[cfg(feature = "full")]
13900+impl Eq for ExprRepeat {}
13901+#[cfg(feature = "full")]
13902+impl PartialEq for ExprRepeat {
13903+ fn eq(&self, other: &Self) -> bool {
13904+ self.attrs == other.attrs && self.expr == other.expr && self.len == other.len
13905+ }
13906+}
13907+#[cfg(feature = "full")]
13908+impl Eq for ExprReturn {}
13909+#[cfg(feature = "full")]
13910+impl PartialEq for ExprReturn {
13911+ fn eq(&self, other: &Self) -> bool {
13912+ self.attrs == other.attrs && self.expr == other.expr
13913+ }
13914+}
13915+#[cfg(feature = "full")]
13916+impl Eq for ExprStruct {}
13917+#[cfg(feature = "full")]
13918+impl PartialEq for ExprStruct {
13919+ fn eq(&self, other: &Self) -> bool {
13920+ self.attrs == other.attrs
13921+ && self.path == other.path
13922+ && self.fields == other.fields
13923+ && self.dot2_token == other.dot2_token
13924+ && self.rest == other.rest
13925+ }
13926+}
13927+#[cfg(feature = "full")]
13928+impl Eq for ExprTry {}
13929+#[cfg(feature = "full")]
13930+impl PartialEq for ExprTry {
13931+ fn eq(&self, other: &Self) -> bool {
13932+ self.attrs == other.attrs && self.expr == other.expr
13933+ }
13934+}
13935+#[cfg(feature = "full")]
13936+impl Eq for ExprTryBlock {}
13937+#[cfg(feature = "full")]
13938+impl PartialEq for ExprTryBlock {
13939+ fn eq(&self, other: &Self) -> bool {
13940+ self.attrs == other.attrs && self.block == other.block
13941+ }
13942+}
13943+#[cfg(feature = "full")]
13944+impl Eq for ExprTuple {}
13945+#[cfg(feature = "full")]
13946+impl PartialEq for ExprTuple {
13947+ fn eq(&self, other: &Self) -> bool {
13948+ self.attrs == other.attrs && self.elems == other.elems
13949+ }
13950+}
13951+#[cfg(feature = "full")]
13952+impl Eq for ExprType {}
13953+#[cfg(feature = "full")]
13954+impl PartialEq for ExprType {
13955+ fn eq(&self, other: &Self) -> bool {
13956+ self.attrs == other.attrs && self.expr == other.expr && self.ty == other.ty
13957+ }
13958+}
13959+#[cfg(any(feature = "derive", feature = "full"))]
13960+impl Eq for ExprUnary {}
13961+#[cfg(any(feature = "derive", feature = "full"))]
13962+impl PartialEq for ExprUnary {
13963+ fn eq(&self, other: &Self) -> bool {
13964+ self.attrs == other.attrs && self.op == other.op && self.expr == other.expr
13965+ }
13966+}
13967+#[cfg(feature = "full")]
13968+impl Eq for ExprUnsafe {}
13969+#[cfg(feature = "full")]
13970+impl PartialEq for ExprUnsafe {
13971+ fn eq(&self, other: &Self) -> bool {
13972+ self.attrs == other.attrs && self.block == other.block
13973+ }
13974+}
13975+#[cfg(feature = "full")]
13976+impl Eq for ExprWhile {}
13977+#[cfg(feature = "full")]
13978+impl PartialEq for ExprWhile {
13979+ fn eq(&self, other: &Self) -> bool {
13980+ self.attrs == other.attrs
13981+ && self.label == other.label
13982+ && self.cond == other.cond
13983+ && self.body == other.body
13984+ }
13985+}
13986+#[cfg(feature = "full")]
13987+impl Eq for ExprYield {}
13988+#[cfg(feature = "full")]
13989+impl PartialEq for ExprYield {
13990+ fn eq(&self, other: &Self) -> bool {
13991+ self.attrs == other.attrs && self.expr == other.expr
13992+ }
13993+}
13994+#[cfg(any(feature = "derive", feature = "full"))]
13995+impl Eq for Field {}
13996+#[cfg(any(feature = "derive", feature = "full"))]
13997+impl PartialEq for Field {
13998+ fn eq(&self, other: &Self) -> bool {
13999+ self.attrs == other.attrs
14000+ && self.vis == other.vis
14001+ && self.ident == other.ident
14002+ && self.colon_token == other.colon_token
14003+ && self.ty == other.ty
14004+ }
14005+}
14006+#[cfg(feature = "full")]
14007+impl Eq for FieldPat {}
14008+#[cfg(feature = "full")]
14009+impl PartialEq for FieldPat {
14010+ fn eq(&self, other: &Self) -> bool {
14011+ self.attrs == other.attrs
14012+ && self.member == other.member
14013+ && self.colon_token == other.colon_token
14014+ && self.pat == other.pat
14015+ }
14016+}
14017+#[cfg(feature = "full")]
14018+impl Eq for FieldValue {}
14019+#[cfg(feature = "full")]
14020+impl PartialEq for FieldValue {
14021+ fn eq(&self, other: &Self) -> bool {
14022+ self.attrs == other.attrs
14023+ && self.member == other.member
14024+ && self.colon_token == other.colon_token
14025+ && self.expr == other.expr
14026+ }
14027+}
14028+#[cfg(any(feature = "derive", feature = "full"))]
14029+impl Eq for Fields {}
14030+#[cfg(any(feature = "derive", feature = "full"))]
14031+impl PartialEq for Fields {
14032+ fn eq(&self, other: &Self) -> bool {
14033+ match (self, other) {
14034+ (Fields::Named(self0), Fields::Named(other0)) => self0 == other0,
14035+ (Fields::Unnamed(self0), Fields::Unnamed(other0)) => self0 == other0,
14036+ (Fields::Unit, Fields::Unit) => true,
14037+ _ => false,
14038+ }
14039+ }
14040+}
14041+#[cfg(any(feature = "derive", feature = "full"))]
14042+impl Eq for FieldsNamed {}
14043+#[cfg(any(feature = "derive", feature = "full"))]
14044+impl PartialEq for FieldsNamed {
14045+ fn eq(&self, other: &Self) -> bool {
14046+ self.named == other.named
14047+ }
14048+}
14049+#[cfg(any(feature = "derive", feature = "full"))]
14050+impl Eq for FieldsUnnamed {}
14051+#[cfg(any(feature = "derive", feature = "full"))]
14052+impl PartialEq for FieldsUnnamed {
14053+ fn eq(&self, other: &Self) -> bool {
14054+ self.unnamed == other.unnamed
14055+ }
14056+}
14057+#[cfg(feature = "full")]
14058+impl Eq for File {}
14059+#[cfg(feature = "full")]
14060+impl PartialEq for File {
14061+ fn eq(&self, other: &Self) -> bool {
14062+ self.shebang == other.shebang && self.attrs == other.attrs && self.items == other.items
14063+ }
14064+}
14065+#[cfg(feature = "full")]
14066+impl Eq for FnArg {}
14067+#[cfg(feature = "full")]
14068+impl PartialEq for FnArg {
14069+ fn eq(&self, other: &Self) -> bool {
14070+ match (self, other) {
14071+ (FnArg::Receiver(self0), FnArg::Receiver(other0)) => self0 == other0,
14072+ (FnArg::Typed(self0), FnArg::Typed(other0)) => self0 == other0,
14073+ _ => false,
14074+ }
14075+ }
14076+}
14077+#[cfg(feature = "full")]
14078+impl Eq for ForeignItem {}
14079+#[cfg(feature = "full")]
14080+impl PartialEq for ForeignItem {
14081+ fn eq(&self, other: &Self) -> bool {
14082+ match (self, other) {
14083+ (ForeignItem::Fn(self0), ForeignItem::Fn(other0)) => self0 == other0,
14084+ (ForeignItem::Static(self0), ForeignItem::Static(other0)) => self0 == other0,
14085+ (ForeignItem::Type(self0), ForeignItem::Type(other0)) => self0 == other0,
14086+ (ForeignItem::Macro(self0), ForeignItem::Macro(other0)) => self0 == other0,
14087+ (ForeignItem::Verbatim(self0), ForeignItem::Verbatim(other0)) => {
14088+ TokenStreamHelper(self0) == TokenStreamHelper(other0)
14089+ }
14090+ _ => false,
14091+ }
14092+ }
14093+}
14094+#[cfg(feature = "full")]
14095+impl Eq for ForeignItemFn {}
14096+#[cfg(feature = "full")]
14097+impl PartialEq for ForeignItemFn {
14098+ fn eq(&self, other: &Self) -> bool {
14099+ self.attrs == other.attrs && self.vis == other.vis && self.sig == other.sig
14100+ }
14101+}
14102+#[cfg(feature = "full")]
14103+impl Eq for ForeignItemMacro {}
14104+#[cfg(feature = "full")]
14105+impl PartialEq for ForeignItemMacro {
14106+ fn eq(&self, other: &Self) -> bool {
14107+ self.attrs == other.attrs && self.mac == other.mac && self.semi_token == other.semi_token
14108+ }
14109+}
14110+#[cfg(feature = "full")]
14111+impl Eq for ForeignItemStatic {}
14112+#[cfg(feature = "full")]
14113+impl PartialEq for ForeignItemStatic {
14114+ fn eq(&self, other: &Self) -> bool {
14115+ self.attrs == other.attrs
14116+ && self.vis == other.vis
14117+ && self.mutability == other.mutability
14118+ && self.ident == other.ident
14119+ && self.ty == other.ty
14120+ }
14121+}
14122+#[cfg(feature = "full")]
14123+impl Eq for ForeignItemType {}
14124+#[cfg(feature = "full")]
14125+impl PartialEq for ForeignItemType {
14126+ fn eq(&self, other: &Self) -> bool {
14127+ self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident
14128+ }
14129+}
14130+#[cfg(any(feature = "derive", feature = "full"))]
14131+impl Eq for GenericArgument {}
14132+#[cfg(any(feature = "derive", feature = "full"))]
14133+impl PartialEq for GenericArgument {
14134+ fn eq(&self, other: &Self) -> bool {
14135+ match (self, other) {
14136+ (GenericArgument::Lifetime(self0), GenericArgument::Lifetime(other0)) => {
14137+ self0 == other0
14138+ }
14139+ (GenericArgument::Type(self0), GenericArgument::Type(other0)) => self0 == other0,
14140+ (GenericArgument::Binding(self0), GenericArgument::Binding(other0)) => self0 == other0,
14141+ (GenericArgument::Constraint(self0), GenericArgument::Constraint(other0)) => {
14142+ self0 == other0
14143+ }
14144+ (GenericArgument::Const(self0), GenericArgument::Const(other0)) => self0 == other0,
14145+ _ => false,
14146+ }
14147+ }
14148+}
14149+#[cfg(feature = "full")]
14150+impl Eq for GenericMethodArgument {}
14151+#[cfg(feature = "full")]
14152+impl PartialEq for GenericMethodArgument {
14153+ fn eq(&self, other: &Self) -> bool {
14154+ match (self, other) {
14155+ (GenericMethodArgument::Type(self0), GenericMethodArgument::Type(other0)) => {
14156+ self0 == other0
14157+ }
14158+ (GenericMethodArgument::Const(self0), GenericMethodArgument::Const(other0)) => {
14159+ self0 == other0
14160+ }
14161+ _ => false,
14162+ }
14163+ }
14164+}
14165+#[cfg(any(feature = "derive", feature = "full"))]
14166+impl Eq for GenericParam {}
14167+#[cfg(any(feature = "derive", feature = "full"))]
14168+impl PartialEq for GenericParam {
14169+ fn eq(&self, other: &Self) -> bool {
14170+ match (self, other) {
14171+ (GenericParam::Type(self0), GenericParam::Type(other0)) => self0 == other0,
14172+ (GenericParam::Lifetime(self0), GenericParam::Lifetime(other0)) => self0 == other0,
14173+ (GenericParam::Const(self0), GenericParam::Const(other0)) => self0 == other0,
14174+ _ => false,
14175+ }
14176+ }
14177+}
14178+#[cfg(any(feature = "derive", feature = "full"))]
14179+impl Eq for Generics {}
14180+#[cfg(any(feature = "derive", feature = "full"))]
14181+impl PartialEq for Generics {
14182+ fn eq(&self, other: &Self) -> bool {
14183+ self.lt_token == other.lt_token
14184+ && self.params == other.params
14185+ && self.gt_token == other.gt_token
14186+ && self.where_clause == other.where_clause
14187+ }
14188+}
14189+#[cfg(feature = "full")]
14190+impl Eq for ImplItem {}
14191+#[cfg(feature = "full")]
14192+impl PartialEq for ImplItem {
14193+ fn eq(&self, other: &Self) -> bool {
14194+ match (self, other) {
14195+ (ImplItem::Const(self0), ImplItem::Const(other0)) => self0 == other0,
14196+ (ImplItem::Method(self0), ImplItem::Method(other0)) => self0 == other0,
14197+ (ImplItem::Type(self0), ImplItem::Type(other0)) => self0 == other0,
14198+ (ImplItem::Macro(self0), ImplItem::Macro(other0)) => self0 == other0,
14199+ (ImplItem::Verbatim(self0), ImplItem::Verbatim(other0)) => {
14200+ TokenStreamHelper(self0) == TokenStreamHelper(other0)
14201+ }
14202+ _ => false,
14203+ }
14204+ }
14205+}
14206+#[cfg(feature = "full")]
14207+impl Eq for ImplItemConst {}
14208+#[cfg(feature = "full")]
14209+impl PartialEq for ImplItemConst {
14210+ fn eq(&self, other: &Self) -> bool {
14211+ self.attrs == other.attrs
14212+ && self.vis == other.vis
14213+ && self.defaultness == other.defaultness
14214+ && self.ident == other.ident
14215+ && self.ty == other.ty
14216+ && self.expr == other.expr
14217+ }
14218+}
14219+#[cfg(feature = "full")]
14220+impl Eq for ImplItemMacro {}
14221+#[cfg(feature = "full")]
14222+impl PartialEq for ImplItemMacro {
14223+ fn eq(&self, other: &Self) -> bool {
14224+ self.attrs == other.attrs && self.mac == other.mac && self.semi_token == other.semi_token
14225+ }
14226+}
14227+#[cfg(feature = "full")]
14228+impl Eq for ImplItemMethod {}
14229+#[cfg(feature = "full")]
14230+impl PartialEq for ImplItemMethod {
14231+ fn eq(&self, other: &Self) -> bool {
14232+ self.attrs == other.attrs
14233+ && self.vis == other.vis
14234+ && self.defaultness == other.defaultness
14235+ && self.sig == other.sig
14236+ && self.block == other.block
14237+ }
14238+}
14239+#[cfg(feature = "full")]
14240+impl Eq for ImplItemType {}
14241+#[cfg(feature = "full")]
14242+impl PartialEq for ImplItemType {
14243+ fn eq(&self, other: &Self) -> bool {
14244+ self.attrs == other.attrs
14245+ && self.vis == other.vis
14246+ && self.defaultness == other.defaultness
14247+ && self.ident == other.ident
14248+ && self.generics == other.generics
14249+ && self.ty == other.ty
14250+ }
14251+}
14252+#[cfg(feature = "full")]
14253+impl Eq for Item {}
14254+#[cfg(feature = "full")]
14255+impl PartialEq for Item {
14256+ fn eq(&self, other: &Self) -> bool {
14257+ match (self, other) {
14258+ (Item::Const(self0), Item::Const(other0)) => self0 == other0,
14259+ (Item::Enum(self0), Item::Enum(other0)) => self0 == other0,
14260+ (Item::ExternCrate(self0), Item::ExternCrate(other0)) => self0 == other0,
14261+ (Item::Fn(self0), Item::Fn(other0)) => self0 == other0,
14262+ (Item::ForeignMod(self0), Item::ForeignMod(other0)) => self0 == other0,
14263+ (Item::Impl(self0), Item::Impl(other0)) => self0 == other0,
14264+ (Item::Macro(self0), Item::Macro(other0)) => self0 == other0,
14265+ (Item::Macro2(self0), Item::Macro2(other0)) => self0 == other0,
14266+ (Item::Mod(self0), Item::Mod(other0)) => self0 == other0,
14267+ (Item::Static(self0), Item::Static(other0)) => self0 == other0,
14268+ (Item::Struct(self0), Item::Struct(other0)) => self0 == other0,
14269+ (Item::Trait(self0), Item::Trait(other0)) => self0 == other0,
14270+ (Item::TraitAlias(self0), Item::TraitAlias(other0)) => self0 == other0,
14271+ (Item::Type(self0), Item::Type(other0)) => self0 == other0,
14272+ (Item::Union(self0), Item::Union(other0)) => self0 == other0,
14273+ (Item::Use(self0), Item::Use(other0)) => self0 == other0,
14274+ (Item::Verbatim(self0), Item::Verbatim(other0)) => {
14275+ TokenStreamHelper(self0) == TokenStreamHelper(other0)
14276+ }
14277+ _ => false,
14278+ }
14279+ }
14280+}
14281+#[cfg(feature = "full")]
14282+impl Eq for ItemConst {}
14283+#[cfg(feature = "full")]
14284+impl PartialEq for ItemConst {
14285+ fn eq(&self, other: &Self) -> bool {
14286+ self.attrs == other.attrs
14287+ && self.vis == other.vis
14288+ && self.ident == other.ident
14289+ && self.ty == other.ty
14290+ && self.expr == other.expr
14291+ }
14292+}
14293+#[cfg(feature = "full")]
14294+impl Eq for ItemEnum {}
14295+#[cfg(feature = "full")]
14296+impl PartialEq for ItemEnum {
14297+ fn eq(&self, other: &Self) -> bool {
14298+ self.attrs == other.attrs
14299+ && self.vis == other.vis
14300+ && self.ident == other.ident
14301+ && self.generics == other.generics
14302+ && self.variants == other.variants
14303+ }
14304+}
14305+#[cfg(feature = "full")]
14306+impl Eq for ItemExternCrate {}
14307+#[cfg(feature = "full")]
14308+impl PartialEq for ItemExternCrate {
14309+ fn eq(&self, other: &Self) -> bool {
14310+ self.attrs == other.attrs
14311+ && self.vis == other.vis
14312+ && self.ident == other.ident
14313+ && self.rename == other.rename
14314+ }
14315+}
14316+#[cfg(feature = "full")]
14317+impl Eq for ItemFn {}
14318+#[cfg(feature = "full")]
14319+impl PartialEq for ItemFn {
14320+ fn eq(&self, other: &Self) -> bool {
14321+ self.attrs == other.attrs
14322+ && self.vis == other.vis
14323+ && self.sig == other.sig
14324+ && self.block == other.block
14325+ }
14326+}
14327+#[cfg(feature = "full")]
14328+impl Eq for ItemForeignMod {}
14329+#[cfg(feature = "full")]
14330+impl PartialEq for ItemForeignMod {
14331+ fn eq(&self, other: &Self) -> bool {
14332+ self.attrs == other.attrs && self.abi == other.abi && self.items == other.items
14333+ }
14334+}
14335+#[cfg(feature = "full")]
14336+impl Eq for ItemImpl {}
14337+#[cfg(feature = "full")]
14338+impl PartialEq for ItemImpl {
14339+ fn eq(&self, other: &Self) -> bool {
14340+ self.attrs == other.attrs
14341+ && self.defaultness == other.defaultness
14342+ && self.unsafety == other.unsafety
14343+ && self.generics == other.generics
14344+ && self.trait_ == other.trait_
14345+ && self.self_ty == other.self_ty
14346+ && self.items == other.items
14347+ }
14348+}
14349+#[cfg(feature = "full")]
14350+impl Eq for ItemMacro {}
14351+#[cfg(feature = "full")]
14352+impl PartialEq for ItemMacro {
14353+ fn eq(&self, other: &Self) -> bool {
14354+ self.attrs == other.attrs
14355+ && self.ident == other.ident
14356+ && self.mac == other.mac
14357+ && self.semi_token == other.semi_token
14358+ }
14359+}
14360+#[cfg(feature = "full")]
14361+impl Eq for ItemMacro2 {}
14362+#[cfg(feature = "full")]
14363+impl PartialEq for ItemMacro2 {
14364+ fn eq(&self, other: &Self) -> bool {
14365+ self.attrs == other.attrs
14366+ && self.vis == other.vis
14367+ && self.ident == other.ident
14368+ && TokenStreamHelper(&self.rules) == TokenStreamHelper(&other.rules)
14369+ }
14370+}
14371+#[cfg(feature = "full")]
14372+impl Eq for ItemMod {}
14373+#[cfg(feature = "full")]
14374+impl PartialEq for ItemMod {
14375+ fn eq(&self, other: &Self) -> bool {
14376+ self.attrs == other.attrs
14377+ && self.vis == other.vis
14378+ && self.ident == other.ident
14379+ && self.content == other.content
14380+ && self.semi == other.semi
14381+ }
14382+}
14383+#[cfg(feature = "full")]
14384+impl Eq for ItemStatic {}
14385+#[cfg(feature = "full")]
14386+impl PartialEq for ItemStatic {
14387+ fn eq(&self, other: &Self) -> bool {
14388+ self.attrs == other.attrs
14389+ && self.vis == other.vis
14390+ && self.mutability == other.mutability
14391+ && self.ident == other.ident
14392+ && self.ty == other.ty
14393+ && self.expr == other.expr
14394+ }
14395+}
14396+#[cfg(feature = "full")]
14397+impl Eq for ItemStruct {}
14398+#[cfg(feature = "full")]
14399+impl PartialEq for ItemStruct {
14400+ fn eq(&self, other: &Self) -> bool {
14401+ self.attrs == other.attrs
14402+ && self.vis == other.vis
14403+ && self.ident == other.ident
14404+ && self.generics == other.generics
14405+ && self.fields == other.fields
14406+ && self.semi_token == other.semi_token
14407+ }
14408+}
14409+#[cfg(feature = "full")]
14410+impl Eq for ItemTrait {}
14411+#[cfg(feature = "full")]
14412+impl PartialEq for ItemTrait {
14413+ fn eq(&self, other: &Self) -> bool {
14414+ self.attrs == other.attrs
14415+ && self.vis == other.vis
14416+ && self.unsafety == other.unsafety
14417+ && self.auto_token == other.auto_token
14418+ && self.ident == other.ident
14419+ && self.generics == other.generics
14420+ && self.colon_token == other.colon_token
14421+ && self.supertraits == other.supertraits
14422+ && self.items == other.items
14423+ }
14424+}
14425+#[cfg(feature = "full")]
14426+impl Eq for ItemTraitAlias {}
14427+#[cfg(feature = "full")]
14428+impl PartialEq for ItemTraitAlias {
14429+ fn eq(&self, other: &Self) -> bool {
14430+ self.attrs == other.attrs
14431+ && self.vis == other.vis
14432+ && self.ident == other.ident
14433+ && self.generics == other.generics
14434+ && self.bounds == other.bounds
14435+ }
14436+}
14437+#[cfg(feature = "full")]
14438+impl Eq for ItemType {}
14439+#[cfg(feature = "full")]
14440+impl PartialEq for ItemType {
14441+ fn eq(&self, other: &Self) -> bool {
14442+ self.attrs == other.attrs
14443+ && self.vis == other.vis
14444+ && self.ident == other.ident
14445+ && self.generics == other.generics
14446+ && self.ty == other.ty
14447+ }
14448+}
14449+#[cfg(feature = "full")]
14450+impl Eq for ItemUnion {}
14451+#[cfg(feature = "full")]
14452+impl PartialEq for ItemUnion {
14453+ fn eq(&self, other: &Self) -> bool {
14454+ self.attrs == other.attrs
14455+ && self.vis == other.vis
14456+ && self.ident == other.ident
14457+ && self.generics == other.generics
14458+ && self.fields == other.fields
14459+ }
14460+}
14461+#[cfg(feature = "full")]
14462+impl Eq for ItemUse {}
14463+#[cfg(feature = "full")]
14464+impl PartialEq for ItemUse {
14465+ fn eq(&self, other: &Self) -> bool {
14466+ self.attrs == other.attrs
14467+ && self.vis == other.vis
14468+ && self.leading_colon == other.leading_colon
14469+ && self.tree == other.tree
14470+ }
14471+}
14472+#[cfg(feature = "full")]
14473+impl Eq for Label {}
14474+#[cfg(feature = "full")]
14475+impl PartialEq for Label {
14476+ fn eq(&self, other: &Self) -> bool {
14477+ self.name == other.name
14478+ }
14479+}
14480+#[cfg(any(feature = "derive", feature = "full"))]
14481+impl Eq for LifetimeDef {}
14482+#[cfg(any(feature = "derive", feature = "full"))]
14483+impl PartialEq for LifetimeDef {
14484+ fn eq(&self, other: &Self) -> bool {
14485+ self.attrs == other.attrs
14486+ && self.lifetime == other.lifetime
14487+ && self.colon_token == other.colon_token
14488+ && self.bounds == other.bounds
14489+ }
14490+}
14491+impl Eq for Lit {}
14492+impl PartialEq for Lit {
14493+ fn eq(&self, other: &Self) -> bool {
14494+ match (self, other) {
14495+ (Lit::Str(self0), Lit::Str(other0)) => self0 == other0,
14496+ (Lit::ByteStr(self0), Lit::ByteStr(other0)) => self0 == other0,
14497+ (Lit::Byte(self0), Lit::Byte(other0)) => self0 == other0,
14498+ (Lit::Char(self0), Lit::Char(other0)) => self0 == other0,
14499+ (Lit::Int(self0), Lit::Int(other0)) => self0 == other0,
14500+ (Lit::Float(self0), Lit::Float(other0)) => self0 == other0,
14501+ (Lit::Bool(self0), Lit::Bool(other0)) => self0 == other0,
14502+ (Lit::Verbatim(self0), Lit::Verbatim(other0)) => {
14503+ self0.to_string() == other0.to_string()
14504+ }
14505+ _ => false,
14506+ }
14507+ }
14508+}
14509+impl Eq for LitBool {}
14510+impl PartialEq for LitBool {
14511+ fn eq(&self, other: &Self) -> bool {
14512+ self.value == other.value
14513+ }
14514+}
14515+impl Eq for LitByte {}
14516+impl Eq for LitByteStr {}
14517+impl Eq for LitChar {}
14518+impl Eq for LitFloat {}
14519+impl Eq for LitInt {}
14520+impl Eq for LitStr {}
14521+#[cfg(feature = "full")]
14522+impl Eq for Local {}
14523+#[cfg(feature = "full")]
14524+impl PartialEq for Local {
14525+ fn eq(&self, other: &Self) -> bool {
14526+ self.attrs == other.attrs && self.pat == other.pat && self.init == other.init
14527+ }
14528+}
14529+#[cfg(any(feature = "derive", feature = "full"))]
14530+impl Eq for Macro {}
14531+#[cfg(any(feature = "derive", feature = "full"))]
14532+impl PartialEq for Macro {
14533+ fn eq(&self, other: &Self) -> bool {
14534+ self.path == other.path
14535+ && self.delimiter == other.delimiter
14536+ && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens)
14537+ }
14538+}
14539+#[cfg(any(feature = "derive", feature = "full"))]
14540+impl Eq for MacroDelimiter {}
14541+#[cfg(any(feature = "derive", feature = "full"))]
14542+impl PartialEq for MacroDelimiter {
14543+ fn eq(&self, other: &Self) -> bool {
14544+ match (self, other) {
14545+ (MacroDelimiter::Paren(_), MacroDelimiter::Paren(_)) => true,
14546+ (MacroDelimiter::Brace(_), MacroDelimiter::Brace(_)) => true,
14547+ (MacroDelimiter::Bracket(_), MacroDelimiter::Bracket(_)) => true,
14548+ _ => false,
14549+ }
14550+ }
14551+}
14552+#[cfg(any(feature = "derive", feature = "full"))]
14553+impl Eq for Meta {}
14554+#[cfg(any(feature = "derive", feature = "full"))]
14555+impl PartialEq for Meta {
14556+ fn eq(&self, other: &Self) -> bool {
14557+ match (self, other) {
14558+ (Meta::Path(self0), Meta::Path(other0)) => self0 == other0,
14559+ (Meta::List(self0), Meta::List(other0)) => self0 == other0,
14560+ (Meta::NameValue(self0), Meta::NameValue(other0)) => self0 == other0,
14561+ _ => false,
14562+ }
14563+ }
14564+}
14565+#[cfg(any(feature = "derive", feature = "full"))]
14566+impl Eq for MetaList {}
14567+#[cfg(any(feature = "derive", feature = "full"))]
14568+impl PartialEq for MetaList {
14569+ fn eq(&self, other: &Self) -> bool {
14570+ self.path == other.path && self.nested == other.nested
14571+ }
14572+}
14573+#[cfg(any(feature = "derive", feature = "full"))]
14574+impl Eq for MetaNameValue {}
14575+#[cfg(any(feature = "derive", feature = "full"))]
14576+impl PartialEq for MetaNameValue {
14577+ fn eq(&self, other: &Self) -> bool {
14578+ self.path == other.path && self.lit == other.lit
14579+ }
14580+}
14581+#[cfg(feature = "full")]
14582+impl Eq for MethodTurbofish {}
14583+#[cfg(feature = "full")]
14584+impl PartialEq for MethodTurbofish {
14585+ fn eq(&self, other: &Self) -> bool {
14586+ self.args == other.args
14587+ }
14588+}
14589+#[cfg(any(feature = "derive", feature = "full"))]
14590+impl Eq for NestedMeta {}
14591+#[cfg(any(feature = "derive", feature = "full"))]
14592+impl PartialEq for NestedMeta {
14593+ fn eq(&self, other: &Self) -> bool {
14594+ match (self, other) {
14595+ (NestedMeta::Meta(self0), NestedMeta::Meta(other0)) => self0 == other0,
14596+ (NestedMeta::Lit(self0), NestedMeta::Lit(other0)) => self0 == other0,
14597+ _ => false,
14598+ }
14599+ }
14600+}
14601+#[cfg(any(feature = "derive", feature = "full"))]
14602+impl Eq for ParenthesizedGenericArguments {}
14603+#[cfg(any(feature = "derive", feature = "full"))]
14604+impl PartialEq for ParenthesizedGenericArguments {
14605+ fn eq(&self, other: &Self) -> bool {
14606+ self.inputs == other.inputs && self.output == other.output
14607+ }
14608+}
14609+#[cfg(feature = "full")]
14610+impl Eq for Pat {}
14611+#[cfg(feature = "full")]
14612+impl PartialEq for Pat {
14613+ fn eq(&self, other: &Self) -> bool {
14614+ match (self, other) {
14615+ (Pat::Box(self0), Pat::Box(other0)) => self0 == other0,
14616+ (Pat::Ident(self0), Pat::Ident(other0)) => self0 == other0,
14617+ (Pat::Lit(self0), Pat::Lit(other0)) => self0 == other0,
14618+ (Pat::Macro(self0), Pat::Macro(other0)) => self0 == other0,
14619+ (Pat::Or(self0), Pat::Or(other0)) => self0 == other0,
14620+ (Pat::Path(self0), Pat::Path(other0)) => self0 == other0,
14621+ (Pat::Range(self0), Pat::Range(other0)) => self0 == other0,
14622+ (Pat::Reference(self0), Pat::Reference(other0)) => self0 == other0,
14623+ (Pat::Rest(self0), Pat::Rest(other0)) => self0 == other0,
14624+ (Pat::Slice(self0), Pat::Slice(other0)) => self0 == other0,
14625+ (Pat::Struct(self0), Pat::Struct(other0)) => self0 == other0,
14626+ (Pat::Tuple(self0), Pat::Tuple(other0)) => self0 == other0,
14627+ (Pat::TupleStruct(self0), Pat::TupleStruct(other0)) => self0 == other0,
14628+ (Pat::Type(self0), Pat::Type(other0)) => self0 == other0,
14629+ (Pat::Verbatim(self0), Pat::Verbatim(other0)) => {
14630+ TokenStreamHelper(self0) == TokenStreamHelper(other0)
14631+ }
14632+ (Pat::Wild(self0), Pat::Wild(other0)) => self0 == other0,
14633+ _ => false,
14634+ }
14635+ }
14636+}
14637+#[cfg(feature = "full")]
14638+impl Eq for PatBox {}
14639+#[cfg(feature = "full")]
14640+impl PartialEq for PatBox {
14641+ fn eq(&self, other: &Self) -> bool {
14642+ self.attrs == other.attrs && self.pat == other.pat
14643+ }
14644+}
14645+#[cfg(feature = "full")]
14646+impl Eq for PatIdent {}
14647+#[cfg(feature = "full")]
14648+impl PartialEq for PatIdent {
14649+ fn eq(&self, other: &Self) -> bool {
14650+ self.attrs == other.attrs
14651+ && self.by_ref == other.by_ref
14652+ && self.mutability == other.mutability
14653+ && self.ident == other.ident
14654+ && self.subpat == other.subpat
14655+ }
14656+}
14657+#[cfg(feature = "full")]
14658+impl Eq for PatLit {}
14659+#[cfg(feature = "full")]
14660+impl PartialEq for PatLit {
14661+ fn eq(&self, other: &Self) -> bool {
14662+ self.attrs == other.attrs && self.expr == other.expr
14663+ }
14664+}
14665+#[cfg(feature = "full")]
14666+impl Eq for PatMacro {}
14667+#[cfg(feature = "full")]
14668+impl PartialEq for PatMacro {
14669+ fn eq(&self, other: &Self) -> bool {
14670+ self.attrs == other.attrs && self.mac == other.mac
14671+ }
14672+}
14673+#[cfg(feature = "full")]
14674+impl Eq for PatOr {}
14675+#[cfg(feature = "full")]
14676+impl PartialEq for PatOr {
14677+ fn eq(&self, other: &Self) -> bool {
14678+ self.attrs == other.attrs
14679+ && self.leading_vert == other.leading_vert
14680+ && self.cases == other.cases
14681+ }
14682+}
14683+#[cfg(feature = "full")]
14684+impl Eq for PatPath {}
14685+#[cfg(feature = "full")]
14686+impl PartialEq for PatPath {
14687+ fn eq(&self, other: &Self) -> bool {
14688+ self.attrs == other.attrs && self.qself == other.qself && self.path == other.path
14689+ }
14690+}
14691+#[cfg(feature = "full")]
14692+impl Eq for PatRange {}
14693+#[cfg(feature = "full")]
14694+impl PartialEq for PatRange {
14695+ fn eq(&self, other: &Self) -> bool {
14696+ self.attrs == other.attrs
14697+ && self.lo == other.lo
14698+ && self.limits == other.limits
14699+ && self.hi == other.hi
14700+ }
14701+}
14702+#[cfg(feature = "full")]
14703+impl Eq for PatReference {}
14704+#[cfg(feature = "full")]
14705+impl PartialEq for PatReference {
14706+ fn eq(&self, other: &Self) -> bool {
14707+ self.attrs == other.attrs && self.mutability == other.mutability && self.pat == other.pat
14708+ }
14709+}
14710+#[cfg(feature = "full")]
14711+impl Eq for PatRest {}
14712+#[cfg(feature = "full")]
14713+impl PartialEq for PatRest {
14714+ fn eq(&self, other: &Self) -> bool {
14715+ self.attrs == other.attrs
14716+ }
14717+}
14718+#[cfg(feature = "full")]
14719+impl Eq for PatSlice {}
14720+#[cfg(feature = "full")]
14721+impl PartialEq for PatSlice {
14722+ fn eq(&self, other: &Self) -> bool {
14723+ self.attrs == other.attrs && self.elems == other.elems
14724+ }
14725+}
14726+#[cfg(feature = "full")]
14727+impl Eq for PatStruct {}
14728+#[cfg(feature = "full")]
14729+impl PartialEq for PatStruct {
14730+ fn eq(&self, other: &Self) -> bool {
14731+ self.attrs == other.attrs
14732+ && self.path == other.path
14733+ && self.fields == other.fields
14734+ && self.dot2_token == other.dot2_token
14735+ }
14736+}
14737+#[cfg(feature = "full")]
14738+impl Eq for PatTuple {}
14739+#[cfg(feature = "full")]
14740+impl PartialEq for PatTuple {
14741+ fn eq(&self, other: &Self) -> bool {
14742+ self.attrs == other.attrs && self.elems == other.elems
14743+ }
14744+}
14745+#[cfg(feature = "full")]
14746+impl Eq for PatTupleStruct {}
14747+#[cfg(feature = "full")]
14748+impl PartialEq for PatTupleStruct {
14749+ fn eq(&self, other: &Self) -> bool {
14750+ self.attrs == other.attrs && self.path == other.path && self.pat == other.pat
14751+ }
14752+}
14753+#[cfg(feature = "full")]
14754+impl Eq for PatType {}
14755+#[cfg(feature = "full")]
14756+impl PartialEq for PatType {
14757+ fn eq(&self, other: &Self) -> bool {
14758+ self.attrs == other.attrs && self.pat == other.pat && self.ty == other.ty
14759+ }
14760+}
14761+#[cfg(feature = "full")]
14762+impl Eq for PatWild {}
14763+#[cfg(feature = "full")]
14764+impl PartialEq for PatWild {
14765+ fn eq(&self, other: &Self) -> bool {
14766+ self.attrs == other.attrs
14767+ }
14768+}
14769+#[cfg(any(feature = "derive", feature = "full"))]
14770+impl Eq for Path {}
14771+#[cfg(any(feature = "derive", feature = "full"))]
14772+impl PartialEq for Path {
14773+ fn eq(&self, other: &Self) -> bool {
14774+ self.leading_colon == other.leading_colon && self.segments == other.segments
14775+ }
14776+}
14777+#[cfg(any(feature = "derive", feature = "full"))]
14778+impl Eq for PathArguments {}
14779+#[cfg(any(feature = "derive", feature = "full"))]
14780+impl PartialEq for PathArguments {
14781+ fn eq(&self, other: &Self) -> bool {
14782+ match (self, other) {
14783+ (PathArguments::None, PathArguments::None) => true,
14784+ (PathArguments::AngleBracketed(self0), PathArguments::AngleBracketed(other0)) => {
14785+ self0 == other0
14786+ }
14787+ (PathArguments::Parenthesized(self0), PathArguments::Parenthesized(other0)) => {
14788+ self0 == other0
14789+ }
14790+ _ => false,
14791+ }
14792+ }
14793+}
14794+#[cfg(any(feature = "derive", feature = "full"))]
14795+impl Eq for PathSegment {}
14796+#[cfg(any(feature = "derive", feature = "full"))]
14797+impl PartialEq for PathSegment {
14798+ fn eq(&self, other: &Self) -> bool {
14799+ self.ident == other.ident && self.arguments == other.arguments
14800+ }
14801+}
14802+#[cfg(any(feature = "derive", feature = "full"))]
14803+impl Eq for PredicateEq {}
14804+#[cfg(any(feature = "derive", feature = "full"))]
14805+impl PartialEq for PredicateEq {
14806+ fn eq(&self, other: &Self) -> bool {
14807+ self.lhs_ty == other.lhs_ty && self.rhs_ty == other.rhs_ty
14808+ }
14809+}
14810+#[cfg(any(feature = "derive", feature = "full"))]
14811+impl Eq for PredicateLifetime {}
14812+#[cfg(any(feature = "derive", feature = "full"))]
14813+impl PartialEq for PredicateLifetime {
14814+ fn eq(&self, other: &Self) -> bool {
14815+ self.lifetime == other.lifetime && self.bounds == other.bounds
14816+ }
14817+}
14818+#[cfg(any(feature = "derive", feature = "full"))]
14819+impl Eq for PredicateType {}
14820+#[cfg(any(feature = "derive", feature = "full"))]
14821+impl PartialEq for PredicateType {
14822+ fn eq(&self, other: &Self) -> bool {
14823+ self.lifetimes == other.lifetimes
14824+ && self.bounded_ty == other.bounded_ty
14825+ && self.bounds == other.bounds
14826+ }
14827+}
14828+#[cfg(any(feature = "derive", feature = "full"))]
14829+impl Eq for QSelf {}
14830+#[cfg(any(feature = "derive", feature = "full"))]
14831+impl PartialEq for QSelf {
14832+ fn eq(&self, other: &Self) -> bool {
14833+ self.ty == other.ty && self.position == other.position && self.as_token == other.as_token
14834+ }
14835+}
14836+#[cfg(feature = "full")]
14837+impl Eq for RangeLimits {}
14838+#[cfg(feature = "full")]
14839+impl PartialEq for RangeLimits {
14840+ fn eq(&self, other: &Self) -> bool {
14841+ match (self, other) {
14842+ (RangeLimits::HalfOpen(_), RangeLimits::HalfOpen(_)) => true,
14843+ (RangeLimits::Closed(_), RangeLimits::Closed(_)) => true,
14844+ _ => false,
14845+ }
14846+ }
14847+}
14848+#[cfg(feature = "full")]
14849+impl Eq for Receiver {}
14850+#[cfg(feature = "full")]
14851+impl PartialEq for Receiver {
14852+ fn eq(&self, other: &Self) -> bool {
14853+ self.attrs == other.attrs
14854+ && self.reference == other.reference
14855+ && self.mutability == other.mutability
14856+ }
14857+}
14858+#[cfg(any(feature = "derive", feature = "full"))]
14859+impl Eq for ReturnType {}
14860+#[cfg(any(feature = "derive", feature = "full"))]
14861+impl PartialEq for ReturnType {
14862+ fn eq(&self, other: &Self) -> bool {
14863+ match (self, other) {
14864+ (ReturnType::Default, ReturnType::Default) => true,
14865+ (ReturnType::Type(_, self1), ReturnType::Type(_, other1)) => self1 == other1,
14866+ _ => false,
14867+ }
14868+ }
14869+}
14870+#[cfg(feature = "full")]
14871+impl Eq for Signature {}
14872+#[cfg(feature = "full")]
14873+impl PartialEq for Signature {
14874+ fn eq(&self, other: &Self) -> bool {
14875+ self.constness == other.constness
14876+ && self.asyncness == other.asyncness
14877+ && self.unsafety == other.unsafety
14878+ && self.abi == other.abi
14879+ && self.ident == other.ident
14880+ && self.generics == other.generics
14881+ && self.inputs == other.inputs
14882+ && self.variadic == other.variadic
14883+ && self.output == other.output
14884+ }
14885+}
14886+#[cfg(feature = "full")]
14887+impl Eq for Stmt {}
14888+#[cfg(feature = "full")]
14889+impl PartialEq for Stmt {
14890+ fn eq(&self, other: &Self) -> bool {
14891+ match (self, other) {
14892+ (Stmt::Local(self0), Stmt::Local(other0)) => self0 == other0,
14893+ (Stmt::Item(self0), Stmt::Item(other0)) => self0 == other0,
14894+ (Stmt::Expr(self0), Stmt::Expr(other0)) => self0 == other0,
14895+ (Stmt::Semi(self0, _), Stmt::Semi(other0, _)) => self0 == other0,
14896+ _ => false,
14897+ }
14898+ }
14899+}
14900+#[cfg(any(feature = "derive", feature = "full"))]
14901+impl Eq for TraitBound {}
14902+#[cfg(any(feature = "derive", feature = "full"))]
14903+impl PartialEq for TraitBound {
14904+ fn eq(&self, other: &Self) -> bool {
14905+ self.paren_token == other.paren_token
14906+ && self.modifier == other.modifier
14907+ && self.lifetimes == other.lifetimes
14908+ && self.path == other.path
14909+ }
14910+}
14911+#[cfg(any(feature = "derive", feature = "full"))]
14912+impl Eq for TraitBoundModifier {}
14913+#[cfg(any(feature = "derive", feature = "full"))]
14914+impl PartialEq for TraitBoundModifier {
14915+ fn eq(&self, other: &Self) -> bool {
14916+ match (self, other) {
14917+ (TraitBoundModifier::None, TraitBoundModifier::None) => true,
14918+ (TraitBoundModifier::Maybe(_), TraitBoundModifier::Maybe(_)) => true,
14919+ _ => false,
14920+ }
14921+ }
14922+}
14923+#[cfg(feature = "full")]
14924+impl Eq for TraitItem {}
14925+#[cfg(feature = "full")]
14926+impl PartialEq for TraitItem {
14927+ fn eq(&self, other: &Self) -> bool {
14928+ match (self, other) {
14929+ (TraitItem::Const(self0), TraitItem::Const(other0)) => self0 == other0,
14930+ (TraitItem::Method(self0), TraitItem::Method(other0)) => self0 == other0,
14931+ (TraitItem::Type(self0), TraitItem::Type(other0)) => self0 == other0,
14932+ (TraitItem::Macro(self0), TraitItem::Macro(other0)) => self0 == other0,
14933+ (TraitItem::Verbatim(self0), TraitItem::Verbatim(other0)) => {
14934+ TokenStreamHelper(self0) == TokenStreamHelper(other0)
14935+ }
14936+ _ => false,
14937+ }
14938+ }
14939+}
14940+#[cfg(feature = "full")]
14941+impl Eq for TraitItemConst {}
14942+#[cfg(feature = "full")]
14943+impl PartialEq for TraitItemConst {
14944+ fn eq(&self, other: &Self) -> bool {
14945+ self.attrs == other.attrs
14946+ && self.ident == other.ident
14947+ && self.ty == other.ty
14948+ && self.default == other.default
14949+ }
14950+}
14951+#[cfg(feature = "full")]
14952+impl Eq for TraitItemMacro {}
14953+#[cfg(feature = "full")]
14954+impl PartialEq for TraitItemMacro {
14955+ fn eq(&self, other: &Self) -> bool {
14956+ self.attrs == other.attrs && self.mac == other.mac && self.semi_token == other.semi_token
14957+ }
14958+}
14959+#[cfg(feature = "full")]
14960+impl Eq for TraitItemMethod {}
14961+#[cfg(feature = "full")]
14962+impl PartialEq for TraitItemMethod {
14963+ fn eq(&self, other: &Self) -> bool {
14964+ self.attrs == other.attrs
14965+ && self.sig == other.sig
14966+ && self.default == other.default
14967+ && self.semi_token == other.semi_token
14968+ }
14969+}
14970+#[cfg(feature = "full")]
14971+impl Eq for TraitItemType {}
14972+#[cfg(feature = "full")]
14973+impl PartialEq for TraitItemType {
14974+ fn eq(&self, other: &Self) -> bool {
14975+ self.attrs == other.attrs
14976+ && self.ident == other.ident
14977+ && self.generics == other.generics
14978+ && self.colon_token == other.colon_token
14979+ && self.bounds == other.bounds
14980+ && self.default == other.default
14981+ }
14982+}
14983+#[cfg(any(feature = "derive", feature = "full"))]
14984+impl Eq for Type {}
14985+#[cfg(any(feature = "derive", feature = "full"))]
14986+impl PartialEq for Type {
14987+ fn eq(&self, other: &Self) -> bool {
14988+ match (self, other) {
14989+ (Type::Array(self0), Type::Array(other0)) => self0 == other0,
14990+ (Type::BareFn(self0), Type::BareFn(other0)) => self0 == other0,
14991+ (Type::Group(self0), Type::Group(other0)) => self0 == other0,
14992+ (Type::ImplTrait(self0), Type::ImplTrait(other0)) => self0 == other0,
14993+ (Type::Infer(self0), Type::Infer(other0)) => self0 == other0,
14994+ (Type::Macro(self0), Type::Macro(other0)) => self0 == other0,
14995+ (Type::Never(self0), Type::Never(other0)) => self0 == other0,
14996+ (Type::Paren(self0), Type::Paren(other0)) => self0 == other0,
14997+ (Type::Path(self0), Type::Path(other0)) => self0 == other0,
14998+ (Type::Ptr(self0), Type::Ptr(other0)) => self0 == other0,
14999+ (Type::Reference(self0), Type::Reference(other0)) => self0 == other0,
15000+ (Type::Slice(self0), Type::Slice(other0)) => self0 == other0,
15001+ (Type::TraitObject(self0), Type::TraitObject(other0)) => self0 == other0,
15002+ (Type::Tuple(self0), Type::Tuple(other0)) => self0 == other0,
15003+ (Type::Verbatim(self0), Type::Verbatim(other0)) => {
15004+ TokenStreamHelper(self0) == TokenStreamHelper(other0)
15005+ }
15006+ _ => false,
15007+ }
15008+ }
15009+}
15010+#[cfg(any(feature = "derive", feature = "full"))]
15011+impl Eq for TypeArray {}
15012+#[cfg(any(feature = "derive", feature = "full"))]
15013+impl PartialEq for TypeArray {
15014+ fn eq(&self, other: &Self) -> bool {
15015+ self.elem == other.elem && self.len == other.len
15016+ }
15017+}
15018+#[cfg(any(feature = "derive", feature = "full"))]
15019+impl Eq for TypeBareFn {}
15020+#[cfg(any(feature = "derive", feature = "full"))]
15021+impl PartialEq for TypeBareFn {
15022+ fn eq(&self, other: &Self) -> bool {
15023+ self.lifetimes == other.lifetimes
15024+ && self.unsafety == other.unsafety
15025+ && self.abi == other.abi
15026+ && self.inputs == other.inputs
15027+ && self.variadic == other.variadic
15028+ && self.output == other.output
15029+ }
15030+}
15031+#[cfg(any(feature = "derive", feature = "full"))]
15032+impl Eq for TypeGroup {}
15033+#[cfg(any(feature = "derive", feature = "full"))]
15034+impl PartialEq for TypeGroup {
15035+ fn eq(&self, other: &Self) -> bool {
15036+ self.elem == other.elem
15037+ }
15038+}
15039+#[cfg(any(feature = "derive", feature = "full"))]
15040+impl Eq for TypeImplTrait {}
15041+#[cfg(any(feature = "derive", feature = "full"))]
15042+impl PartialEq for TypeImplTrait {
15043+ fn eq(&self, other: &Self) -> bool {
15044+ self.bounds == other.bounds
15045+ }
15046+}
15047+#[cfg(any(feature = "derive", feature = "full"))]
15048+impl Eq for TypeInfer {}
15049+#[cfg(any(feature = "derive", feature = "full"))]
15050+impl PartialEq for TypeInfer {
15051+ fn eq(&self, _other: &Self) -> bool {
15052+ true
15053+ }
15054+}
15055+#[cfg(any(feature = "derive", feature = "full"))]
15056+impl Eq for TypeMacro {}
15057+#[cfg(any(feature = "derive", feature = "full"))]
15058+impl PartialEq for TypeMacro {
15059+ fn eq(&self, other: &Self) -> bool {
15060+ self.mac == other.mac
15061+ }
15062+}
15063+#[cfg(any(feature = "derive", feature = "full"))]
15064+impl Eq for TypeNever {}
15065+#[cfg(any(feature = "derive", feature = "full"))]
15066+impl PartialEq for TypeNever {
15067+ fn eq(&self, _other: &Self) -> bool {
15068+ true
15069+ }
15070+}
15071+#[cfg(any(feature = "derive", feature = "full"))]
15072+impl Eq for TypeParam {}
15073+#[cfg(any(feature = "derive", feature = "full"))]
15074+impl PartialEq for TypeParam {
15075+ fn eq(&self, other: &Self) -> bool {
15076+ self.attrs == other.attrs
15077+ && self.ident == other.ident
15078+ && self.colon_token == other.colon_token
15079+ && self.bounds == other.bounds
15080+ && self.eq_token == other.eq_token
15081+ && self.default == other.default
15082+ }
15083+}
15084+#[cfg(any(feature = "derive", feature = "full"))]
15085+impl Eq for TypeParamBound {}
15086+#[cfg(any(feature = "derive", feature = "full"))]
15087+impl PartialEq for TypeParamBound {
15088+ fn eq(&self, other: &Self) -> bool {
15089+ match (self, other) {
15090+ (TypeParamBound::Trait(self0), TypeParamBound::Trait(other0)) => self0 == other0,
15091+ (TypeParamBound::Lifetime(self0), TypeParamBound::Lifetime(other0)) => self0 == other0,
15092+ _ => false,
15093+ }
15094+ }
15095+}
15096+#[cfg(any(feature = "derive", feature = "full"))]
15097+impl Eq for TypeParen {}
15098+#[cfg(any(feature = "derive", feature = "full"))]
15099+impl PartialEq for TypeParen {
15100+ fn eq(&self, other: &Self) -> bool {
15101+ self.elem == other.elem
15102+ }
15103+}
15104+#[cfg(any(feature = "derive", feature = "full"))]
15105+impl Eq for TypePath {}
15106+#[cfg(any(feature = "derive", feature = "full"))]
15107+impl PartialEq for TypePath {
15108+ fn eq(&self, other: &Self) -> bool {
15109+ self.qself == other.qself && self.path == other.path
15110+ }
15111+}
15112+#[cfg(any(feature = "derive", feature = "full"))]
15113+impl Eq for TypePtr {}
15114+#[cfg(any(feature = "derive", feature = "full"))]
15115+impl PartialEq for TypePtr {
15116+ fn eq(&self, other: &Self) -> bool {
15117+ self.const_token == other.const_token
15118+ && self.mutability == other.mutability
15119+ && self.elem == other.elem
15120+ }
15121+}
15122+#[cfg(any(feature = "derive", feature = "full"))]
15123+impl Eq for TypeReference {}
15124+#[cfg(any(feature = "derive", feature = "full"))]
15125+impl PartialEq for TypeReference {
15126+ fn eq(&self, other: &Self) -> bool {
15127+ self.lifetime == other.lifetime
15128+ && self.mutability == other.mutability
15129+ && self.elem == other.elem
15130+ }
15131+}
15132+#[cfg(any(feature = "derive", feature = "full"))]
15133+impl Eq for TypeSlice {}
15134+#[cfg(any(feature = "derive", feature = "full"))]
15135+impl PartialEq for TypeSlice {
15136+ fn eq(&self, other: &Self) -> bool {
15137+ self.elem == other.elem
15138+ }
15139+}
15140+#[cfg(any(feature = "derive", feature = "full"))]
15141+impl Eq for TypeTraitObject {}
15142+#[cfg(any(feature = "derive", feature = "full"))]
15143+impl PartialEq for TypeTraitObject {
15144+ fn eq(&self, other: &Self) -> bool {
15145+ self.dyn_token == other.dyn_token && self.bounds == other.bounds
15146+ }
15147+}
15148+#[cfg(any(feature = "derive", feature = "full"))]
15149+impl Eq for TypeTuple {}
15150+#[cfg(any(feature = "derive", feature = "full"))]
15151+impl PartialEq for TypeTuple {
15152+ fn eq(&self, other: &Self) -> bool {
15153+ self.elems == other.elems
15154+ }
15155+}
15156+#[cfg(any(feature = "derive", feature = "full"))]
15157+impl Eq for UnOp {}
15158+#[cfg(any(feature = "derive", feature = "full"))]
15159+impl PartialEq for UnOp {
15160+ fn eq(&self, other: &Self) -> bool {
15161+ match (self, other) {
15162+ (UnOp::Deref(_), UnOp::Deref(_)) => true,
15163+ (UnOp::Not(_), UnOp::Not(_)) => true,
15164+ (UnOp::Neg(_), UnOp::Neg(_)) => true,
15165+ _ => false,
15166+ }
15167+ }
15168+}
15169+#[cfg(feature = "full")]
15170+impl Eq for UseGlob {}
15171+#[cfg(feature = "full")]
15172+impl PartialEq for UseGlob {
15173+ fn eq(&self, _other: &Self) -> bool {
15174+ true
15175+ }
15176+}
15177+#[cfg(feature = "full")]
15178+impl Eq for UseGroup {}
15179+#[cfg(feature = "full")]
15180+impl PartialEq for UseGroup {
15181+ fn eq(&self, other: &Self) -> bool {
15182+ self.items == other.items
15183+ }
15184+}
15185+#[cfg(feature = "full")]
15186+impl Eq for UseName {}
15187+#[cfg(feature = "full")]
15188+impl PartialEq for UseName {
15189+ fn eq(&self, other: &Self) -> bool {
15190+ self.ident == other.ident
15191+ }
15192+}
15193+#[cfg(feature = "full")]
15194+impl Eq for UsePath {}
15195+#[cfg(feature = "full")]
15196+impl PartialEq for UsePath {
15197+ fn eq(&self, other: &Self) -> bool {
15198+ self.ident == other.ident && self.tree == other.tree
15199+ }
15200+}
15201+#[cfg(feature = "full")]
15202+impl Eq for UseRename {}
15203+#[cfg(feature = "full")]
15204+impl PartialEq for UseRename {
15205+ fn eq(&self, other: &Self) -> bool {
15206+ self.ident == other.ident && self.rename == other.rename
15207+ }
15208+}
15209+#[cfg(feature = "full")]
15210+impl Eq for UseTree {}
15211+#[cfg(feature = "full")]
15212+impl PartialEq for UseTree {
15213+ fn eq(&self, other: &Self) -> bool {
15214+ match (self, other) {
15215+ (UseTree::Path(self0), UseTree::Path(other0)) => self0 == other0,
15216+ (UseTree::Name(self0), UseTree::Name(other0)) => self0 == other0,
15217+ (UseTree::Rename(self0), UseTree::Rename(other0)) => self0 == other0,
15218+ (UseTree::Glob(self0), UseTree::Glob(other0)) => self0 == other0,
15219+ (UseTree::Group(self0), UseTree::Group(other0)) => self0 == other0,
15220+ _ => false,
15221+ }
15222+ }
15223+}
15224+#[cfg(any(feature = "derive", feature = "full"))]
15225+impl Eq for Variadic {}
15226+#[cfg(any(feature = "derive", feature = "full"))]
15227+impl PartialEq for Variadic {
15228+ fn eq(&self, other: &Self) -> bool {
15229+ self.attrs == other.attrs
15230+ }
15231+}
15232+#[cfg(any(feature = "derive", feature = "full"))]
15233+impl Eq for Variant {}
15234+#[cfg(any(feature = "derive", feature = "full"))]
15235+impl PartialEq for Variant {
15236+ fn eq(&self, other: &Self) -> bool {
15237+ self.attrs == other.attrs
15238+ && self.ident == other.ident
15239+ && self.fields == other.fields
15240+ && self.discriminant == other.discriminant
15241+ }
15242+}
15243+#[cfg(any(feature = "derive", feature = "full"))]
15244+impl Eq for VisCrate {}
15245+#[cfg(any(feature = "derive", feature = "full"))]
15246+impl PartialEq for VisCrate {
15247+ fn eq(&self, _other: &Self) -> bool {
15248+ true
15249+ }
15250+}
15251+#[cfg(any(feature = "derive", feature = "full"))]
15252+impl Eq for VisPublic {}
15253+#[cfg(any(feature = "derive", feature = "full"))]
15254+impl PartialEq for VisPublic {
15255+ fn eq(&self, _other: &Self) -> bool {
15256+ true
15257+ }
15258+}
15259+#[cfg(any(feature = "derive", feature = "full"))]
15260+impl Eq for VisRestricted {}
15261+#[cfg(any(feature = "derive", feature = "full"))]
15262+impl PartialEq for VisRestricted {
15263+ fn eq(&self, other: &Self) -> bool {
15264+ self.in_token == other.in_token && self.path == other.path
15265+ }
15266+}
15267+#[cfg(any(feature = "derive", feature = "full"))]
15268+impl Eq for Visibility {}
15269+#[cfg(any(feature = "derive", feature = "full"))]
15270+impl PartialEq for Visibility {
15271+ fn eq(&self, other: &Self) -> bool {
15272+ match (self, other) {
15273+ (Visibility::Public(self0), Visibility::Public(other0)) => self0 == other0,
15274+ (Visibility::Crate(self0), Visibility::Crate(other0)) => self0 == other0,
15275+ (Visibility::Restricted(self0), Visibility::Restricted(other0)) => self0 == other0,
15276+ (Visibility::Inherited, Visibility::Inherited) => true,
15277+ _ => false,
15278+ }
15279+ }
15280+}
15281+#[cfg(any(feature = "derive", feature = "full"))]
15282+impl Eq for WhereClause {}
15283+#[cfg(any(feature = "derive", feature = "full"))]
15284+impl PartialEq for WhereClause {
15285+ fn eq(&self, other: &Self) -> bool {
15286+ self.predicates == other.predicates
15287+ }
15288+}
15289+#[cfg(any(feature = "derive", feature = "full"))]
15290+impl Eq for WherePredicate {}
15291+#[cfg(any(feature = "derive", feature = "full"))]
15292+impl PartialEq for WherePredicate {
15293+ fn eq(&self, other: &Self) -> bool {
15294+ match (self, other) {
15295+ (WherePredicate::Type(self0), WherePredicate::Type(other0)) => self0 == other0,
15296+ (WherePredicate::Lifetime(self0), WherePredicate::Lifetime(other0)) => self0 == other0,
15297+ (WherePredicate::Eq(self0), WherePredicate::Eq(other0)) => self0 == other0,
15298+ _ => false,
15299+ }
15300+ }
15301+}
15302diff --git a/third_party/rust/syn/src/gen/fold.rs b/third_party/rust/syn/src/gen/fold.rs
15303--- a/third_party/rust/syn/src/gen/fold.rs
15304+++ b/third_party/rust/syn/src/gen/fold.rs
15305@@ -1,12 +1,13 @@
15306 // This file is @generated by syn-internal-codegen.
15307 // It is not intended for manual editing.
15308
15309 #![allow(unreachable_code, unused_variables)]
15310+#![allow(clippy::match_wildcard_for_single_variants)]
15311 #[cfg(any(feature = "full", feature = "derive"))]
15312 use crate::gen::helper::fold::*;
15313 #[cfg(any(feature = "full", feature = "derive"))]
15314 use crate::token::{Brace, Bracket, Group, Paren};
15315 use crate::*;
15316 use proc_macro2::Span;
15317 #[cfg(feature = "full")]
15318 macro_rules! full {
15319@@ -21,17 +22,17 @@ macro_rules! full {
15320 };
15321 }
15322 /// Syntax tree traversal to transform the nodes of an owned syntax tree.
15323 ///
15324 /// See the [module documentation] for details.
15325 ///
15326 /// [module documentation]: self
15327 ///
15328-/// *This trait is available if Syn is built with the `"fold"` feature.*
15329+/// *This trait is available only if Syn is built with the `"fold"` feature.*
15330 pub trait Fold {
15331 #[cfg(any(feature = "derive", feature = "full"))]
15332 fn fold_abi(&mut self, i: Abi) -> Abi {
15333 fold_abi(self, i)
15334 }
15335 #[cfg(any(feature = "derive", feature = "full"))]
15336 fn fold_angle_bracketed_generic_arguments(
15337 &mut self,
15338@@ -428,45 +429,37 @@ pub trait Fold {
15339 }
15340 fn fold_lifetime(&mut self, i: Lifetime) -> Lifetime {
15341 fold_lifetime(self, i)
15342 }
15343 #[cfg(any(feature = "derive", feature = "full"))]
15344 fn fold_lifetime_def(&mut self, i: LifetimeDef) -> LifetimeDef {
15345 fold_lifetime_def(self, i)
15346 }
15347- #[cfg(any(feature = "derive", feature = "full"))]
15348 fn fold_lit(&mut self, i: Lit) -> Lit {
15349 fold_lit(self, i)
15350 }
15351- #[cfg(any(feature = "derive", feature = "full"))]
15352 fn fold_lit_bool(&mut self, i: LitBool) -> LitBool {
15353 fold_lit_bool(self, i)
15354 }
15355- #[cfg(any(feature = "derive", feature = "full"))]
15356 fn fold_lit_byte(&mut self, i: LitByte) -> LitByte {
15357 fold_lit_byte(self, i)
15358 }
15359- #[cfg(any(feature = "derive", feature = "full"))]
15360 fn fold_lit_byte_str(&mut self, i: LitByteStr) -> LitByteStr {
15361 fold_lit_byte_str(self, i)
15362 }
15363- #[cfg(any(feature = "derive", feature = "full"))]
15364 fn fold_lit_char(&mut self, i: LitChar) -> LitChar {
15365 fold_lit_char(self, i)
15366 }
15367- #[cfg(any(feature = "derive", feature = "full"))]
15368 fn fold_lit_float(&mut self, i: LitFloat) -> LitFloat {
15369 fold_lit_float(self, i)
15370 }
15371- #[cfg(any(feature = "derive", feature = "full"))]
15372 fn fold_lit_int(&mut self, i: LitInt) -> LitInt {
15373 fold_lit_int(self, i)
15374 }
15375- #[cfg(any(feature = "derive", feature = "full"))]
15376 fn fold_lit_str(&mut self, i: LitStr) -> LitStr {
15377 fold_lit_str(self, i)
15378 }
15379 #[cfg(feature = "full")]
15380 fn fold_local(&mut self, i: Local) -> Local {
15381 fold_local(self, i)
15382 }
15383 #[cfg(any(feature = "derive", feature = "full"))]
15384@@ -794,39 +787,39 @@ where
15385 pub fn fold_angle_bracketed_generic_arguments<F>(
15386 f: &mut F,
15387 node: AngleBracketedGenericArguments,
15388 ) -> AngleBracketedGenericArguments
15389 where
15390 F: Fold + ?Sized,
15391 {
15392 AngleBracketedGenericArguments {
15393- colon2_token: (node.colon2_token).map(|it| Token ! [ :: ](tokens_helper(f, &it.spans))),
15394- lt_token: Token ! [ < ](tokens_helper(f, &node.lt_token.spans)),
15395+ colon2_token: (node.colon2_token).map(|it| Token ! [::](tokens_helper(f, &it.spans))),
15396+ lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)),
15397 args: FoldHelper::lift(node.args, |it| f.fold_generic_argument(it)),
15398- gt_token: Token ! [ > ](tokens_helper(f, &node.gt_token.spans)),
15399+ gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)),
15400 }
15401 }
15402 #[cfg(feature = "full")]
15403 pub fn fold_arm<F>(f: &mut F, node: Arm) -> Arm
15404 where
15405 F: Fold + ?Sized,
15406 {
15407 Arm {
15408 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15409 pat: f.fold_pat(node.pat),
15410 guard: (node.guard).map(|it| {
15411 (
15412 Token![if](tokens_helper(f, &(it).0.span)),
15413 Box::new(f.fold_expr(*(it).1)),
15414 )
15415 }),
15416- fat_arrow_token: Token ! [ => ](tokens_helper(f, &node.fat_arrow_token.spans)),
15417+ fat_arrow_token: Token ! [=>](tokens_helper(f, &node.fat_arrow_token.spans)),
15418 body: Box::new(f.fold_expr(*node.body)),
15419- comma: (node.comma).map(|it| Token ! [ , ](tokens_helper(f, &it.spans))),
15420+ comma: (node.comma).map(|it| Token ! [,](tokens_helper(f, &it.spans))),
15421 }
15422 }
15423 #[cfg(any(feature = "derive", feature = "full"))]
15424 pub fn fold_attr_style<F>(f: &mut F, node: AttrStyle) -> AttrStyle
15425 where
15426 F: Fold + ?Sized,
15427 {
15428 match node {
15429@@ -837,109 +830,97 @@ where
15430 }
15431 }
15432 #[cfg(any(feature = "derive", feature = "full"))]
15433 pub fn fold_attribute<F>(f: &mut F, node: Attribute) -> Attribute
15434 where
15435 F: Fold + ?Sized,
15436 {
15437 Attribute {
15438- pound_token: Token ! [ # ](tokens_helper(f, &node.pound_token.spans)),
15439+ pound_token: Token ! [#](tokens_helper(f, &node.pound_token.spans)),
15440 style: f.fold_attr_style(node.style),
15441 bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)),
15442 path: f.fold_path(node.path),
15443 tokens: node.tokens,
15444 }
15445 }
15446 #[cfg(any(feature = "derive", feature = "full"))]
15447 pub fn fold_bare_fn_arg<F>(f: &mut F, node: BareFnArg) -> BareFnArg
15448 where
15449 F: Fold + ?Sized,
15450 {
15451 BareFnArg {
15452 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15453 name: (node.name).map(|it| {
15454 (
15455 f.fold_ident((it).0),
15456- Token ! [ : ](tokens_helper(f, &(it).1.spans)),
15457+ Token ! [:](tokens_helper(f, &(it).1.spans)),
15458 )
15459 }),
15460 ty: f.fold_type(node.ty),
15461 }
15462 }
15463 #[cfg(any(feature = "derive", feature = "full"))]
15464 pub fn fold_bin_op<F>(f: &mut F, node: BinOp) -> BinOp
15465 where
15466 F: Fold + ?Sized,
15467 {
15468 match node {
15469- BinOp::Add(_binding_0) => BinOp::Add(Token ! [ + ](tokens_helper(f, &_binding_0.spans))),
15470- BinOp::Sub(_binding_0) => BinOp::Sub(Token ! [ - ](tokens_helper(f, &_binding_0.spans))),
15471- BinOp::Mul(_binding_0) => BinOp::Mul(Token ! [ * ](tokens_helper(f, &_binding_0.spans))),
15472- BinOp::Div(_binding_0) => BinOp::Div(Token ! [ / ](tokens_helper(f, &_binding_0.spans))),
15473- BinOp::Rem(_binding_0) => BinOp::Rem(Token ! [ % ](tokens_helper(f, &_binding_0.spans))),
15474- BinOp::And(_binding_0) => BinOp::And(Token ! [ && ](tokens_helper(f, &_binding_0.spans))),
15475- BinOp::Or(_binding_0) => BinOp::Or(Token ! [ || ](tokens_helper(f, &_binding_0.spans))),
15476+ BinOp::Add(_binding_0) => BinOp::Add(Token ! [+](tokens_helper(f, &_binding_0.spans))),
15477+ BinOp::Sub(_binding_0) => BinOp::Sub(Token ! [-](tokens_helper(f, &_binding_0.spans))),
15478+ BinOp::Mul(_binding_0) => BinOp::Mul(Token ! [*](tokens_helper(f, &_binding_0.spans))),
15479+ BinOp::Div(_binding_0) => BinOp::Div(Token ! [/](tokens_helper(f, &_binding_0.spans))),
15480+ BinOp::Rem(_binding_0) => BinOp::Rem(Token ! [%](tokens_helper(f, &_binding_0.spans))),
15481+ BinOp::And(_binding_0) => BinOp::And(Token ! [&&](tokens_helper(f, &_binding_0.spans))),
15482+ BinOp::Or(_binding_0) => BinOp::Or(Token ! [||](tokens_helper(f, &_binding_0.spans))),
15483 BinOp::BitXor(_binding_0) => {
15484- BinOp::BitXor(Token ! [ ^ ](tokens_helper(f, &_binding_0.spans)))
15485+ BinOp::BitXor(Token ! [^](tokens_helper(f, &_binding_0.spans)))
15486 }
15487 BinOp::BitAnd(_binding_0) => {
15488- BinOp::BitAnd(Token ! [ & ](tokens_helper(f, &_binding_0.spans)))
15489- }
15490- BinOp::BitOr(_binding_0) => {
15491- BinOp::BitOr(Token ! [ | ](tokens_helper(f, &_binding_0.spans)))
15492+ BinOp::BitAnd(Token ! [&](tokens_helper(f, &_binding_0.spans)))
15493 }
15494- BinOp::Shl(_binding_0) => BinOp::Shl(Token ! [ << ](tokens_helper(f, &_binding_0.spans))),
15495- BinOp::Shr(_binding_0) => BinOp::Shr(Token ! [ >> ](tokens_helper(f, &_binding_0.spans))),
15496- BinOp::Eq(_binding_0) => BinOp::Eq(Token ! [ == ](tokens_helper(f, &_binding_0.spans))),
15497- BinOp::Lt(_binding_0) => BinOp::Lt(Token ! [ < ](tokens_helper(f, &_binding_0.spans))),
15498- BinOp::Le(_binding_0) => BinOp::Le(Token ! [ <= ](tokens_helper(f, &_binding_0.spans))),
15499- BinOp::Ne(_binding_0) => BinOp::Ne(Token ! [ != ](tokens_helper(f, &_binding_0.spans))),
15500- BinOp::Ge(_binding_0) => BinOp::Ge(Token ! [ >= ](tokens_helper(f, &_binding_0.spans))),
15501- BinOp::Gt(_binding_0) => BinOp::Gt(Token ! [ > ](tokens_helper(f, &_binding_0.spans))),
15502- BinOp::AddEq(_binding_0) => {
15503- BinOp::AddEq(Token ! [ += ](tokens_helper(f, &_binding_0.spans)))
15504- }
15505- BinOp::SubEq(_binding_0) => {
15506- BinOp::SubEq(Token ! [ -= ](tokens_helper(f, &_binding_0.spans)))
15507- }
15508- BinOp::MulEq(_binding_0) => {
15509- BinOp::MulEq(Token ! [ *= ](tokens_helper(f, &_binding_0.spans)))
15510- }
15511- BinOp::DivEq(_binding_0) => {
15512- BinOp::DivEq(Token ! [ /= ](tokens_helper(f, &_binding_0.spans)))
15513- }
15514- BinOp::RemEq(_binding_0) => {
15515- BinOp::RemEq(Token ! [ %= ](tokens_helper(f, &_binding_0.spans)))
15516- }
15517+ BinOp::BitOr(_binding_0) => BinOp::BitOr(Token ! [|](tokens_helper(f, &_binding_0.spans))),
15518+ BinOp::Shl(_binding_0) => BinOp::Shl(Token ! [<<](tokens_helper(f, &_binding_0.spans))),
15519+ BinOp::Shr(_binding_0) => BinOp::Shr(Token ! [>>](tokens_helper(f, &_binding_0.spans))),
15520+ BinOp::Eq(_binding_0) => BinOp::Eq(Token ! [==](tokens_helper(f, &_binding_0.spans))),
15521+ BinOp::Lt(_binding_0) => BinOp::Lt(Token ! [<](tokens_helper(f, &_binding_0.spans))),
15522+ BinOp::Le(_binding_0) => BinOp::Le(Token ! [<=](tokens_helper(f, &_binding_0.spans))),
15523+ BinOp::Ne(_binding_0) => BinOp::Ne(Token ! [!=](tokens_helper(f, &_binding_0.spans))),
15524+ BinOp::Ge(_binding_0) => BinOp::Ge(Token ! [>=](tokens_helper(f, &_binding_0.spans))),
15525+ BinOp::Gt(_binding_0) => BinOp::Gt(Token ! [>](tokens_helper(f, &_binding_0.spans))),
15526+ BinOp::AddEq(_binding_0) => BinOp::AddEq(Token ! [+=](tokens_helper(f, &_binding_0.spans))),
15527+ BinOp::SubEq(_binding_0) => BinOp::SubEq(Token ! [-=](tokens_helper(f, &_binding_0.spans))),
15528+ BinOp::MulEq(_binding_0) => BinOp::MulEq(Token ! [*=](tokens_helper(f, &_binding_0.spans))),
15529+ BinOp::DivEq(_binding_0) => BinOp::DivEq(Token ! [/=](tokens_helper(f, &_binding_0.spans))),
15530+ BinOp::RemEq(_binding_0) => BinOp::RemEq(Token ! [%=](tokens_helper(f, &_binding_0.spans))),
15531 BinOp::BitXorEq(_binding_0) => {
15532- BinOp::BitXorEq(Token ! [ ^= ](tokens_helper(f, &_binding_0.spans)))
15533+ BinOp::BitXorEq(Token ! [^=](tokens_helper(f, &_binding_0.spans)))
15534 }
15535 BinOp::BitAndEq(_binding_0) => {
15536- BinOp::BitAndEq(Token ! [ &= ](tokens_helper(f, &_binding_0.spans)))
15537+ BinOp::BitAndEq(Token ! [&=](tokens_helper(f, &_binding_0.spans)))
15538 }
15539 BinOp::BitOrEq(_binding_0) => {
15540- BinOp::BitOrEq(Token ! [ |= ](tokens_helper(f, &_binding_0.spans)))
15541+ BinOp::BitOrEq(Token ! [|=](tokens_helper(f, &_binding_0.spans)))
15542 }
15543 BinOp::ShlEq(_binding_0) => {
15544- BinOp::ShlEq(Token ! [ <<= ](tokens_helper(f, &_binding_0.spans)))
15545+ BinOp::ShlEq(Token ! [<<=](tokens_helper(f, &_binding_0.spans)))
15546 }
15547 BinOp::ShrEq(_binding_0) => {
15548- BinOp::ShrEq(Token ! [ >>= ](tokens_helper(f, &_binding_0.spans)))
15549+ BinOp::ShrEq(Token ! [>>=](tokens_helper(f, &_binding_0.spans)))
15550 }
15551 }
15552 }
15553 #[cfg(any(feature = "derive", feature = "full"))]
15554 pub fn fold_binding<F>(f: &mut F, node: Binding) -> Binding
15555 where
15556 F: Fold + ?Sized,
15557 {
15558 Binding {
15559 ident: f.fold_ident(node.ident),
15560- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
15561+ eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)),
15562 ty: f.fold_type(node.ty),
15563 }
15564 }
15565 #[cfg(feature = "full")]
15566 pub fn fold_block<F>(f: &mut F, node: Block) -> Block
15567 where
15568 F: Fold + ?Sized,
15569 {
15570@@ -950,44 +931,44 @@ where
15571 }
15572 #[cfg(any(feature = "derive", feature = "full"))]
15573 pub fn fold_bound_lifetimes<F>(f: &mut F, node: BoundLifetimes) -> BoundLifetimes
15574 where
15575 F: Fold + ?Sized,
15576 {
15577 BoundLifetimes {
15578 for_token: Token![for](tokens_helper(f, &node.for_token.span)),
15579- lt_token: Token ! [ < ](tokens_helper(f, &node.lt_token.spans)),
15580+ lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)),
15581 lifetimes: FoldHelper::lift(node.lifetimes, |it| f.fold_lifetime_def(it)),
15582- gt_token: Token ! [ > ](tokens_helper(f, &node.gt_token.spans)),
15583+ gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)),
15584 }
15585 }
15586 #[cfg(any(feature = "derive", feature = "full"))]
15587 pub fn fold_const_param<F>(f: &mut F, node: ConstParam) -> ConstParam
15588 where
15589 F: Fold + ?Sized,
15590 {
15591 ConstParam {
15592 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15593 const_token: Token![const](tokens_helper(f, &node.const_token.span)),
15594 ident: f.fold_ident(node.ident),
15595- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
15596+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
15597 ty: f.fold_type(node.ty),
15598- eq_token: (node.eq_token).map(|it| Token ! [ = ](tokens_helper(f, &it.spans))),
15599+ eq_token: (node.eq_token).map(|it| Token ! [=](tokens_helper(f, &it.spans))),
15600 default: (node.default).map(|it| f.fold_expr(it)),
15601 }
15602 }
15603 #[cfg(any(feature = "derive", feature = "full"))]
15604 pub fn fold_constraint<F>(f: &mut F, node: Constraint) -> Constraint
15605 where
15606 F: Fold + ?Sized,
15607 {
15608 Constraint {
15609 ident: f.fold_ident(node.ident),
15610- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
15611+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
15612 bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
15613 }
15614 }
15615 #[cfg(feature = "derive")]
15616 pub fn fold_data<F>(f: &mut F, node: Data) -> Data
15617 where
15618 F: Fold + ?Sized,
15619 {
15620@@ -1011,17 +992,17 @@ where
15621 #[cfg(feature = "derive")]
15622 pub fn fold_data_struct<F>(f: &mut F, node: DataStruct) -> DataStruct
15623 where
15624 F: Fold + ?Sized,
15625 {
15626 DataStruct {
15627 struct_token: Token![struct](tokens_helper(f, &node.struct_token.span)),
15628 fields: f.fold_fields(node.fields),
15629- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
15630+ semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))),
15631 }
15632 }
15633 #[cfg(feature = "derive")]
15634 pub fn fold_data_union<F>(f: &mut F, node: DataUnion) -> DataUnion
15635 where
15636 F: Fold + ?Sized,
15637 {
15638 DataUnion {
15639@@ -1107,17 +1088,17 @@ where
15640 #[cfg(feature = "full")]
15641 pub fn fold_expr_assign<F>(f: &mut F, node: ExprAssign) -> ExprAssign
15642 where
15643 F: Fold + ?Sized,
15644 {
15645 ExprAssign {
15646 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15647 left: Box::new(f.fold_expr(*node.left)),
15648- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
15649+ eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)),
15650 right: Box::new(f.fold_expr(*node.right)),
15651 }
15652 }
15653 #[cfg(feature = "full")]
15654 pub fn fold_expr_assign_op<F>(f: &mut F, node: ExprAssignOp) -> ExprAssignOp
15655 where
15656 F: Fold + ?Sized,
15657 {
15658@@ -1143,17 +1124,17 @@ where
15659 #[cfg(feature = "full")]
15660 pub fn fold_expr_await<F>(f: &mut F, node: ExprAwait) -> ExprAwait
15661 where
15662 F: Fold + ?Sized,
15663 {
15664 ExprAwait {
15665 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15666 base: Box::new(f.fold_expr(*node.base)),
15667- dot_token: Token ! [ . ](tokens_helper(f, &node.dot_token.spans)),
15668+ dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)),
15669 await_token: crate::token::Await(tokens_helper(f, &node.await_token.span)),
15670 }
15671 }
15672 #[cfg(any(feature = "derive", feature = "full"))]
15673 pub fn fold_expr_binary<F>(f: &mut F, node: ExprBinary) -> ExprBinary
15674 where
15675 F: Fold + ?Sized,
15676 {
15677@@ -1227,19 +1208,19 @@ pub fn fold_expr_closure<F>(f: &mut F, n
15678 where
15679 F: Fold + ?Sized,
15680 {
15681 ExprClosure {
15682 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15683 asyncness: (node.asyncness).map(|it| Token![async](tokens_helper(f, &it.span))),
15684 movability: (node.movability).map(|it| Token![static](tokens_helper(f, &it.span))),
15685 capture: (node.capture).map(|it| Token![move](tokens_helper(f, &it.span))),
15686- or1_token: Token ! [ | ](tokens_helper(f, &node.or1_token.spans)),
15687+ or1_token: Token ! [|](tokens_helper(f, &node.or1_token.spans)),
15688 inputs: FoldHelper::lift(node.inputs, |it| f.fold_pat(it)),
15689- or2_token: Token ! [ | ](tokens_helper(f, &node.or2_token.spans)),
15690+ or2_token: Token ! [|](tokens_helper(f, &node.or2_token.spans)),
15691 output: f.fold_return_type(node.output),
15692 body: Box::new(f.fold_expr(*node.body)),
15693 }
15694 }
15695 #[cfg(feature = "full")]
15696 pub fn fold_expr_continue<F>(f: &mut F, node: ExprContinue) -> ExprContinue
15697 where
15698 F: Fold + ?Sized,
15699@@ -1253,17 +1234,17 @@ where
15700 #[cfg(any(feature = "derive", feature = "full"))]
15701 pub fn fold_expr_field<F>(f: &mut F, node: ExprField) -> ExprField
15702 where
15703 F: Fold + ?Sized,
15704 {
15705 ExprField {
15706 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15707 base: Box::new(f.fold_expr(*node.base)),
15708- dot_token: Token ! [ . ](tokens_helper(f, &node.dot_token.spans)),
15709+ dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)),
15710 member: f.fold_member(node.member),
15711 }
15712 }
15713 #[cfg(feature = "full")]
15714 pub fn fold_expr_for_loop<F>(f: &mut F, node: ExprForLoop) -> ExprForLoop
15715 where
15716 F: Fold + ?Sized,
15717 {
15718@@ -1322,17 +1303,17 @@ where
15719 pub fn fold_expr_let<F>(f: &mut F, node: ExprLet) -> ExprLet
15720 where
15721 F: Fold + ?Sized,
15722 {
15723 ExprLet {
15724 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15725 let_token: Token![let](tokens_helper(f, &node.let_token.span)),
15726 pat: f.fold_pat(node.pat),
15727- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
15728+ eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)),
15729 expr: Box::new(f.fold_expr(*node.expr)),
15730 }
15731 }
15732 #[cfg(any(feature = "derive", feature = "full"))]
15733 pub fn fold_expr_lit<F>(f: &mut F, node: ExprLit) -> ExprLit
15734 where
15735 F: Fold + ?Sized,
15736 {
15737@@ -1379,17 +1360,17 @@ where
15738 #[cfg(feature = "full")]
15739 pub fn fold_expr_method_call<F>(f: &mut F, node: ExprMethodCall) -> ExprMethodCall
15740 where
15741 F: Fold + ?Sized,
15742 {
15743 ExprMethodCall {
15744 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15745 receiver: Box::new(f.fold_expr(*node.receiver)),
15746- dot_token: Token ! [ . ](tokens_helper(f, &node.dot_token.spans)),
15747+ dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)),
15748 method: f.fold_ident(node.method),
15749 turbofish: (node.turbofish).map(|it| f.fold_method_turbofish(it)),
15750 paren_token: Paren(tokens_helper(f, &node.paren_token.span)),
15751 args: FoldHelper::lift(node.args, |it| f.fold_expr(it)),
15752 }
15753 }
15754 #[cfg(any(feature = "derive", feature = "full"))]
15755 pub fn fold_expr_paren<F>(f: &mut F, node: ExprParen) -> ExprParen
15756@@ -1427,32 +1408,32 @@ where
15757 }
15758 #[cfg(feature = "full")]
15759 pub fn fold_expr_reference<F>(f: &mut F, node: ExprReference) -> ExprReference
15760 where
15761 F: Fold + ?Sized,
15762 {
15763 ExprReference {
15764 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15765- and_token: Token ! [ & ](tokens_helper(f, &node.and_token.spans)),
15766+ and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)),
15767 raw: node.raw,
15768 mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
15769 expr: Box::new(f.fold_expr(*node.expr)),
15770 }
15771 }
15772 #[cfg(feature = "full")]
15773 pub fn fold_expr_repeat<F>(f: &mut F, node: ExprRepeat) -> ExprRepeat
15774 where
15775 F: Fold + ?Sized,
15776 {
15777 ExprRepeat {
15778 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15779 bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)),
15780 expr: Box::new(f.fold_expr(*node.expr)),
15781- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
15782+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
15783 len: Box::new(f.fold_expr(*node.len)),
15784 }
15785 }
15786 #[cfg(feature = "full")]
15787 pub fn fold_expr_return<F>(f: &mut F, node: ExprReturn) -> ExprReturn
15788 where
15789 F: Fold + ?Sized,
15790 {
15791@@ -1479,17 +1460,17 @@ where
15792 #[cfg(feature = "full")]
15793 pub fn fold_expr_try<F>(f: &mut F, node: ExprTry) -> ExprTry
15794 where
15795 F: Fold + ?Sized,
15796 {
15797 ExprTry {
15798 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15799 expr: Box::new(f.fold_expr(*node.expr)),
15800- question_token: Token ! [ ? ](tokens_helper(f, &node.question_token.spans)),
15801+ question_token: Token ! [?](tokens_helper(f, &node.question_token.spans)),
15802 }
15803 }
15804 #[cfg(feature = "full")]
15805 pub fn fold_expr_try_block<F>(f: &mut F, node: ExprTryBlock) -> ExprTryBlock
15806 where
15807 F: Fold + ?Sized,
15808 {
15809 ExprTryBlock {
15810@@ -1512,17 +1493,17 @@ where
15811 #[cfg(feature = "full")]
15812 pub fn fold_expr_type<F>(f: &mut F, node: ExprType) -> ExprType
15813 where
15814 F: Fold + ?Sized,
15815 {
15816 ExprType {
15817 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15818 expr: Box::new(f.fold_expr(*node.expr)),
15819- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
15820+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
15821 ty: Box::new(f.fold_type(*node.ty)),
15822 }
15823 }
15824 #[cfg(any(feature = "derive", feature = "full"))]
15825 pub fn fold_expr_unary<F>(f: &mut F, node: ExprUnary) -> ExprUnary
15826 where
15827 F: Fold + ?Sized,
15828 {
15829@@ -1571,41 +1552,41 @@ where
15830 pub fn fold_field<F>(f: &mut F, node: Field) -> Field
15831 where
15832 F: Fold + ?Sized,
15833 {
15834 Field {
15835 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15836 vis: f.fold_visibility(node.vis),
15837 ident: (node.ident).map(|it| f.fold_ident(it)),
15838- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
15839+ colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))),
15840 ty: f.fold_type(node.ty),
15841 }
15842 }
15843 #[cfg(feature = "full")]
15844 pub fn fold_field_pat<F>(f: &mut F, node: FieldPat) -> FieldPat
15845 where
15846 F: Fold + ?Sized,
15847 {
15848 FieldPat {
15849 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15850 member: f.fold_member(node.member),
15851- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
15852+ colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))),
15853 pat: Box::new(f.fold_pat(*node.pat)),
15854 }
15855 }
15856 #[cfg(feature = "full")]
15857 pub fn fold_field_value<F>(f: &mut F, node: FieldValue) -> FieldValue
15858 where
15859 F: Fold + ?Sized,
15860 {
15861 FieldValue {
15862 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15863 member: f.fold_member(node.member),
15864- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
15865+ colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))),
15866 expr: f.fold_expr(node.expr),
15867 }
15868 }
15869 #[cfg(any(feature = "derive", feature = "full"))]
15870 pub fn fold_fields<F>(f: &mut F, node: Fields) -> Fields
15871 where
15872 F: Fold + ?Sized,
15873 {
15874@@ -1676,57 +1657,57 @@ where
15875 pub fn fold_foreign_item_fn<F>(f: &mut F, node: ForeignItemFn) -> ForeignItemFn
15876 where
15877 F: Fold + ?Sized,
15878 {
15879 ForeignItemFn {
15880 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15881 vis: f.fold_visibility(node.vis),
15882 sig: f.fold_signature(node.sig),
15883- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
15884+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
15885 }
15886 }
15887 #[cfg(feature = "full")]
15888 pub fn fold_foreign_item_macro<F>(f: &mut F, node: ForeignItemMacro) -> ForeignItemMacro
15889 where
15890 F: Fold + ?Sized,
15891 {
15892 ForeignItemMacro {
15893 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15894 mac: f.fold_macro(node.mac),
15895- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
15896+ semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))),
15897 }
15898 }
15899 #[cfg(feature = "full")]
15900 pub fn fold_foreign_item_static<F>(f: &mut F, node: ForeignItemStatic) -> ForeignItemStatic
15901 where
15902 F: Fold + ?Sized,
15903 {
15904 ForeignItemStatic {
15905 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15906 vis: f.fold_visibility(node.vis),
15907 static_token: Token![static](tokens_helper(f, &node.static_token.span)),
15908 mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
15909 ident: f.fold_ident(node.ident),
15910- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
15911+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
15912 ty: Box::new(f.fold_type(*node.ty)),
15913- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
15914+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
15915 }
15916 }
15917 #[cfg(feature = "full")]
15918 pub fn fold_foreign_item_type<F>(f: &mut F, node: ForeignItemType) -> ForeignItemType
15919 where
15920 F: Fold + ?Sized,
15921 {
15922 ForeignItemType {
15923 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15924 vis: f.fold_visibility(node.vis),
15925 type_token: Token![type](tokens_helper(f, &node.type_token.span)),
15926 ident: f.fold_ident(node.ident),
15927- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
15928+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
15929 }
15930 }
15931 #[cfg(any(feature = "derive", feature = "full"))]
15932 pub fn fold_generic_argument<F>(f: &mut F, node: GenericArgument) -> GenericArgument
15933 where
15934 F: Fold + ?Sized,
15935 {
15936 match node {
15937@@ -1774,19 +1755,19 @@ where
15938 }
15939 }
15940 #[cfg(any(feature = "derive", feature = "full"))]
15941 pub fn fold_generics<F>(f: &mut F, node: Generics) -> Generics
15942 where
15943 F: Fold + ?Sized,
15944 {
15945 Generics {
15946- lt_token: (node.lt_token).map(|it| Token ! [ < ](tokens_helper(f, &it.spans))),
15947+ lt_token: (node.lt_token).map(|it| Token ! [<](tokens_helper(f, &it.spans))),
15948 params: FoldHelper::lift(node.params, |it| f.fold_generic_param(it)),
15949- gt_token: (node.gt_token).map(|it| Token ! [ > ](tokens_helper(f, &it.spans))),
15950+ gt_token: (node.gt_token).map(|it| Token ! [>](tokens_helper(f, &it.spans))),
15951 where_clause: (node.where_clause).map(|it| f.fold_where_clause(it)),
15952 }
15953 }
15954 pub fn fold_ident<F>(f: &mut F, node: Ident) -> Ident
15955 where
15956 F: Fold + ?Sized,
15957 {
15958 let mut node = node;
15959@@ -1814,32 +1795,32 @@ where
15960 F: Fold + ?Sized,
15961 {
15962 ImplItemConst {
15963 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15964 vis: f.fold_visibility(node.vis),
15965 defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))),
15966 const_token: Token![const](tokens_helper(f, &node.const_token.span)),
15967 ident: f.fold_ident(node.ident),
15968- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
15969+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
15970 ty: f.fold_type(node.ty),
15971- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
15972+ eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)),
15973 expr: f.fold_expr(node.expr),
15974- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
15975+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
15976 }
15977 }
15978 #[cfg(feature = "full")]
15979 pub fn fold_impl_item_macro<F>(f: &mut F, node: ImplItemMacro) -> ImplItemMacro
15980 where
15981 F: Fold + ?Sized,
15982 {
15983 ImplItemMacro {
15984 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15985 mac: f.fold_macro(node.mac),
15986- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
15987+ semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))),
15988 }
15989 }
15990 #[cfg(feature = "full")]
15991 pub fn fold_impl_item_method<F>(f: &mut F, node: ImplItemMethod) -> ImplItemMethod
15992 where
15993 F: Fold + ?Sized,
15994 {
15995 ImplItemMethod {
15996@@ -1857,19 +1838,19 @@ where
15997 {
15998 ImplItemType {
15999 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16000 vis: f.fold_visibility(node.vis),
16001 defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))),
16002 type_token: Token![type](tokens_helper(f, &node.type_token.span)),
16003 ident: f.fold_ident(node.ident),
16004 generics: f.fold_generics(node.generics),
16005- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
16006+ eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)),
16007 ty: f.fold_type(node.ty),
16008- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16009+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16010 }
16011 }
16012 #[cfg(any(feature = "derive", feature = "full"))]
16013 pub fn fold_index<F>(f: &mut F, node: Index) -> Index
16014 where
16015 F: Fold + ?Sized,
16016 {
16017 Index {
16018@@ -1908,21 +1889,21 @@ pub fn fold_item_const<F>(f: &mut F, nod
16019 where
16020 F: Fold + ?Sized,
16021 {
16022 ItemConst {
16023 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16024 vis: f.fold_visibility(node.vis),
16025 const_token: Token![const](tokens_helper(f, &node.const_token.span)),
16026 ident: f.fold_ident(node.ident),
16027- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
16028+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
16029 ty: Box::new(f.fold_type(*node.ty)),
16030- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
16031+ eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)),
16032 expr: Box::new(f.fold_expr(*node.expr)),
16033- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16034+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16035 }
16036 }
16037 #[cfg(feature = "full")]
16038 pub fn fold_item_enum<F>(f: &mut F, node: ItemEnum) -> ItemEnum
16039 where
16040 F: Fold + ?Sized,
16041 {
16042 ItemEnum {
16043@@ -1947,17 +1928,17 @@ where
16044 crate_token: Token![crate](tokens_helper(f, &node.crate_token.span)),
16045 ident: f.fold_ident(node.ident),
16046 rename: (node.rename).map(|it| {
16047 (
16048 Token![as](tokens_helper(f, &(it).0.span)),
16049 f.fold_ident((it).1),
16050 )
16051 }),
16052- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16053+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16054 }
16055 }
16056 #[cfg(feature = "full")]
16057 pub fn fold_item_fn<F>(f: &mut F, node: ItemFn) -> ItemFn
16058 where
16059 F: Fold + ?Sized,
16060 {
16061 ItemFn {
16062@@ -2006,17 +1987,17 @@ where
16063 pub fn fold_item_macro<F>(f: &mut F, node: ItemMacro) -> ItemMacro
16064 where
16065 F: Fold + ?Sized,
16066 {
16067 ItemMacro {
16068 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16069 ident: (node.ident).map(|it| f.fold_ident(it)),
16070 mac: f.fold_macro(node.mac),
16071- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
16072+ semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))),
16073 }
16074 }
16075 #[cfg(feature = "full")]
16076 pub fn fold_item_macro2<F>(f: &mut F, node: ItemMacro2) -> ItemMacro2
16077 where
16078 F: Fold + ?Sized,
16079 {
16080 ItemMacro2 {
16081@@ -2038,101 +2019,101 @@ where
16082 mod_token: Token![mod](tokens_helper(f, &node.mod_token.span)),
16083 ident: f.fold_ident(node.ident),
16084 content: (node.content).map(|it| {
16085 (
16086 Brace(tokens_helper(f, &(it).0.span)),
16087 FoldHelper::lift((it).1, |it| f.fold_item(it)),
16088 )
16089 }),
16090- semi: (node.semi).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
16091+ semi: (node.semi).map(|it| Token ! [;](tokens_helper(f, &it.spans))),
16092 }
16093 }
16094 #[cfg(feature = "full")]
16095 pub fn fold_item_static<F>(f: &mut F, node: ItemStatic) -> ItemStatic
16096 where
16097 F: Fold + ?Sized,
16098 {
16099 ItemStatic {
16100 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16101 vis: f.fold_visibility(node.vis),
16102 static_token: Token![static](tokens_helper(f, &node.static_token.span)),
16103 mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
16104 ident: f.fold_ident(node.ident),
16105- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
16106+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
16107 ty: Box::new(f.fold_type(*node.ty)),
16108- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
16109+ eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)),
16110 expr: Box::new(f.fold_expr(*node.expr)),
16111- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16112+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16113 }
16114 }
16115 #[cfg(feature = "full")]
16116 pub fn fold_item_struct<F>(f: &mut F, node: ItemStruct) -> ItemStruct
16117 where
16118 F: Fold + ?Sized,
16119 {
16120 ItemStruct {
16121 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16122 vis: f.fold_visibility(node.vis),
16123 struct_token: Token![struct](tokens_helper(f, &node.struct_token.span)),
16124 ident: f.fold_ident(node.ident),
16125 generics: f.fold_generics(node.generics),
16126 fields: f.fold_fields(node.fields),
16127- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
16128+ semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))),
16129 }
16130 }
16131 #[cfg(feature = "full")]
16132 pub fn fold_item_trait<F>(f: &mut F, node: ItemTrait) -> ItemTrait
16133 where
16134 F: Fold + ?Sized,
16135 {
16136 ItemTrait {
16137 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16138 vis: f.fold_visibility(node.vis),
16139 unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))),
16140 auto_token: (node.auto_token).map(|it| Token![auto](tokens_helper(f, &it.span))),
16141 trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)),
16142 ident: f.fold_ident(node.ident),
16143 generics: f.fold_generics(node.generics),
16144- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
16145+ colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))),
16146 supertraits: FoldHelper::lift(node.supertraits, |it| f.fold_type_param_bound(it)),
16147 brace_token: Brace(tokens_helper(f, &node.brace_token.span)),
16148 items: FoldHelper::lift(node.items, |it| f.fold_trait_item(it)),
16149 }
16150 }
16151 #[cfg(feature = "full")]
16152 pub fn fold_item_trait_alias<F>(f: &mut F, node: ItemTraitAlias) -> ItemTraitAlias
16153 where
16154 F: Fold + ?Sized,
16155 {
16156 ItemTraitAlias {
16157 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16158 vis: f.fold_visibility(node.vis),
16159 trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)),
16160 ident: f.fold_ident(node.ident),
16161 generics: f.fold_generics(node.generics),
16162- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
16163+ eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)),
16164 bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
16165- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16166+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16167 }
16168 }
16169 #[cfg(feature = "full")]
16170 pub fn fold_item_type<F>(f: &mut F, node: ItemType) -> ItemType
16171 where
16172 F: Fold + ?Sized,
16173 {
16174 ItemType {
16175 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16176 vis: f.fold_visibility(node.vis),
16177 type_token: Token![type](tokens_helper(f, &node.type_token.span)),
16178 ident: f.fold_ident(node.ident),
16179 generics: f.fold_generics(node.generics),
16180- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
16181+ eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)),
16182 ty: Box::new(f.fold_type(*node.ty)),
16183- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16184+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16185 }
16186 }
16187 #[cfg(feature = "full")]
16188 pub fn fold_item_union<F>(f: &mut F, node: ItemUnion) -> ItemUnion
16189 where
16190 F: Fold + ?Sized,
16191 {
16192 ItemUnion {
16193@@ -2148,29 +2129,29 @@ where
16194 pub fn fold_item_use<F>(f: &mut F, node: ItemUse) -> ItemUse
16195 where
16196 F: Fold + ?Sized,
16197 {
16198 ItemUse {
16199 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16200 vis: f.fold_visibility(node.vis),
16201 use_token: Token![use](tokens_helper(f, &node.use_token.span)),
16202- leading_colon: (node.leading_colon).map(|it| Token ! [ :: ](tokens_helper(f, &it.spans))),
16203+ leading_colon: (node.leading_colon).map(|it| Token ! [::](tokens_helper(f, &it.spans))),
16204 tree: f.fold_use_tree(node.tree),
16205- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16206+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16207 }
16208 }
16209 #[cfg(feature = "full")]
16210 pub fn fold_label<F>(f: &mut F, node: Label) -> Label
16211 where
16212 F: Fold + ?Sized,
16213 {
16214 Label {
16215 name: f.fold_lifetime(node.name),
16216- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
16217+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
16218 }
16219 }
16220 pub fn fold_lifetime<F>(f: &mut F, node: Lifetime) -> Lifetime
16221 where
16222 F: Fold + ?Sized,
16223 {
16224 Lifetime {
16225 apostrophe: f.fold_span(node.apostrophe),
16226@@ -2180,97 +2161,89 @@ where
16227 #[cfg(any(feature = "derive", feature = "full"))]
16228 pub fn fold_lifetime_def<F>(f: &mut F, node: LifetimeDef) -> LifetimeDef
16229 where
16230 F: Fold + ?Sized,
16231 {
16232 LifetimeDef {
16233 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16234 lifetime: f.fold_lifetime(node.lifetime),
16235- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
16236+ colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))),
16237 bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)),
16238 }
16239 }
16240-#[cfg(any(feature = "derive", feature = "full"))]
16241 pub fn fold_lit<F>(f: &mut F, node: Lit) -> Lit
16242 where
16243 F: Fold + ?Sized,
16244 {
16245 match node {
16246 Lit::Str(_binding_0) => Lit::Str(f.fold_lit_str(_binding_0)),
16247 Lit::ByteStr(_binding_0) => Lit::ByteStr(f.fold_lit_byte_str(_binding_0)),
16248 Lit::Byte(_binding_0) => Lit::Byte(f.fold_lit_byte(_binding_0)),
16249 Lit::Char(_binding_0) => Lit::Char(f.fold_lit_char(_binding_0)),
16250 Lit::Int(_binding_0) => Lit::Int(f.fold_lit_int(_binding_0)),
16251 Lit::Float(_binding_0) => Lit::Float(f.fold_lit_float(_binding_0)),
16252 Lit::Bool(_binding_0) => Lit::Bool(f.fold_lit_bool(_binding_0)),
16253 Lit::Verbatim(_binding_0) => Lit::Verbatim(_binding_0),
16254 }
16255 }
16256-#[cfg(any(feature = "derive", feature = "full"))]
16257 pub fn fold_lit_bool<F>(f: &mut F, node: LitBool) -> LitBool
16258 where
16259 F: Fold + ?Sized,
16260 {
16261 LitBool {
16262 value: node.value,
16263 span: f.fold_span(node.span),
16264 }
16265 }
16266-#[cfg(any(feature = "derive", feature = "full"))]
16267 pub fn fold_lit_byte<F>(f: &mut F, node: LitByte) -> LitByte
16268 where
16269 F: Fold + ?Sized,
16270 {
16271 let span = f.fold_span(node.span());
16272 let mut node = node;
16273 node.set_span(span);
16274 node
16275 }
16276-#[cfg(any(feature = "derive", feature = "full"))]
16277 pub fn fold_lit_byte_str<F>(f: &mut F, node: LitByteStr) -> LitByteStr
16278 where
16279 F: Fold + ?Sized,
16280 {
16281 let span = f.fold_span(node.span());
16282 let mut node = node;
16283 node.set_span(span);
16284 node
16285 }
16286-#[cfg(any(feature = "derive", feature = "full"))]
16287 pub fn fold_lit_char<F>(f: &mut F, node: LitChar) -> LitChar
16288 where
16289 F: Fold + ?Sized,
16290 {
16291 let span = f.fold_span(node.span());
16292 let mut node = node;
16293 node.set_span(span);
16294 node
16295 }
16296-#[cfg(any(feature = "derive", feature = "full"))]
16297 pub fn fold_lit_float<F>(f: &mut F, node: LitFloat) -> LitFloat
16298 where
16299 F: Fold + ?Sized,
16300 {
16301 let span = f.fold_span(node.span());
16302 let mut node = node;
16303 node.set_span(span);
16304 node
16305 }
16306-#[cfg(any(feature = "derive", feature = "full"))]
16307 pub fn fold_lit_int<F>(f: &mut F, node: LitInt) -> LitInt
16308 where
16309 F: Fold + ?Sized,
16310 {
16311 let span = f.fold_span(node.span());
16312 let mut node = node;
16313 node.set_span(span);
16314 node
16315 }
16316-#[cfg(any(feature = "derive", feature = "full"))]
16317 pub fn fold_lit_str<F>(f: &mut F, node: LitStr) -> LitStr
16318 where
16319 F: Fold + ?Sized,
16320 {
16321 let span = f.fold_span(node.span());
16322 let mut node = node;
16323 node.set_span(span);
16324 node
16325@@ -2281,21 +2254,21 @@ where
16326 F: Fold + ?Sized,
16327 {
16328 Local {
16329 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16330 let_token: Token![let](tokens_helper(f, &node.let_token.span)),
16331 pat: f.fold_pat(node.pat),
16332 init: (node.init).map(|it| {
16333 (
16334- Token ! [ = ](tokens_helper(f, &(it).0.spans)),
16335+ Token ! [=](tokens_helper(f, &(it).0.spans)),
16336 Box::new(f.fold_expr(*(it).1)),
16337 )
16338 }),
16339- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16340+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16341 }
16342 }
16343 #[cfg(any(feature = "derive", feature = "full"))]
16344 pub fn fold_macro<F>(f: &mut F, node: Macro) -> Macro
16345 where
16346 F: Fold + ?Sized,
16347 {
16348 Macro {
16349@@ -2356,30 +2329,30 @@ where
16350 }
16351 #[cfg(any(feature = "derive", feature = "full"))]
16352 pub fn fold_meta_name_value<F>(f: &mut F, node: MetaNameValue) -> MetaNameValue
16353 where
16354 F: Fold + ?Sized,
16355 {
16356 MetaNameValue {
16357 path: f.fold_path(node.path),
16358- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
16359+ eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)),
16360 lit: f.fold_lit(node.lit),
16361 }
16362 }
16363 #[cfg(feature = "full")]
16364 pub fn fold_method_turbofish<F>(f: &mut F, node: MethodTurbofish) -> MethodTurbofish
16365 where
16366 F: Fold + ?Sized,
16367 {
16368 MethodTurbofish {
16369- colon2_token: Token ! [ :: ](tokens_helper(f, &node.colon2_token.spans)),
16370- lt_token: Token ! [ < ](tokens_helper(f, &node.lt_token.spans)),
16371+ colon2_token: Token ! [::](tokens_helper(f, &node.colon2_token.spans)),
16372+ lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)),
16373 args: FoldHelper::lift(node.args, |it| f.fold_generic_method_argument(it)),
16374- gt_token: Token ! [ > ](tokens_helper(f, &node.gt_token.spans)),
16375+ gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)),
16376 }
16377 }
16378 #[cfg(any(feature = "derive", feature = "full"))]
16379 pub fn fold_nested_meta<F>(f: &mut F, node: NestedMeta) -> NestedMeta
16380 where
16381 F: Fold + ?Sized,
16382 {
16383 match node {
16384@@ -2444,17 +2417,17 @@ where
16385 {
16386 PatIdent {
16387 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16388 by_ref: (node.by_ref).map(|it| Token![ref](tokens_helper(f, &it.span))),
16389 mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
16390 ident: f.fold_ident(node.ident),
16391 subpat: (node.subpat).map(|it| {
16392 (
16393- Token ! [ @ ](tokens_helper(f, &(it).0.spans)),
16394+ Token ! [@](tokens_helper(f, &(it).0.spans)),
16395 Box::new(f.fold_pat(*(it).1)),
16396 )
16397 }),
16398 }
16399 }
16400 #[cfg(feature = "full")]
16401 pub fn fold_pat_lit<F>(f: &mut F, node: PatLit) -> PatLit
16402 where
16403@@ -2477,17 +2450,17 @@ where
16404 }
16405 #[cfg(feature = "full")]
16406 pub fn fold_pat_or<F>(f: &mut F, node: PatOr) -> PatOr
16407 where
16408 F: Fold + ?Sized,
16409 {
16410 PatOr {
16411 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16412- leading_vert: (node.leading_vert).map(|it| Token ! [ | ](tokens_helper(f, &it.spans))),
16413+ leading_vert: (node.leading_vert).map(|it| Token ! [|](tokens_helper(f, &it.spans))),
16414 cases: FoldHelper::lift(node.cases, |it| f.fold_pat(it)),
16415 }
16416 }
16417 #[cfg(feature = "full")]
16418 pub fn fold_pat_path<F>(f: &mut F, node: PatPath) -> PatPath
16419 where
16420 F: Fold + ?Sized,
16421 {
16422@@ -2511,17 +2484,17 @@ where
16423 }
16424 #[cfg(feature = "full")]
16425 pub fn fold_pat_reference<F>(f: &mut F, node: PatReference) -> PatReference
16426 where
16427 F: Fold + ?Sized,
16428 {
16429 PatReference {
16430 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16431- and_token: Token ! [ & ](tokens_helper(f, &node.and_token.spans)),
16432+ and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)),
16433 mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
16434 pat: Box::new(f.fold_pat(*node.pat)),
16435 }
16436 }
16437 #[cfg(feature = "full")]
16438 pub fn fold_pat_rest<F>(f: &mut F, node: PatRest) -> PatRest
16439 where
16440 F: Fold + ?Sized,
16441@@ -2580,17 +2553,17 @@ where
16442 #[cfg(feature = "full")]
16443 pub fn fold_pat_type<F>(f: &mut F, node: PatType) -> PatType
16444 where
16445 F: Fold + ?Sized,
16446 {
16447 PatType {
16448 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16449 pat: Box::new(f.fold_pat(*node.pat)),
16450- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
16451+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
16452 ty: Box::new(f.fold_type(*node.ty)),
16453 }
16454 }
16455 #[cfg(feature = "full")]
16456 pub fn fold_pat_wild<F>(f: &mut F, node: PatWild) -> PatWild
16457 where
16458 F: Fold + ?Sized,
16459 {
16460@@ -2600,17 +2573,17 @@ where
16461 }
16462 }
16463 #[cfg(any(feature = "derive", feature = "full"))]
16464 pub fn fold_path<F>(f: &mut F, node: Path) -> Path
16465 where
16466 F: Fold + ?Sized,
16467 {
16468 Path {
16469- leading_colon: (node.leading_colon).map(|it| Token ! [ :: ](tokens_helper(f, &it.spans))),
16470+ leading_colon: (node.leading_colon).map(|it| Token ! [::](tokens_helper(f, &it.spans))),
16471 segments: FoldHelper::lift(node.segments, |it| f.fold_path_segment(it)),
16472 }
16473 }
16474 #[cfg(any(feature = "derive", feature = "full"))]
16475 pub fn fold_path_arguments<F>(f: &mut F, node: PathArguments) -> PathArguments
16476 where
16477 F: Fold + ?Sized,
16478 {
16479@@ -2636,96 +2609,96 @@ where
16480 }
16481 #[cfg(any(feature = "derive", feature = "full"))]
16482 pub fn fold_predicate_eq<F>(f: &mut F, node: PredicateEq) -> PredicateEq
16483 where
16484 F: Fold + ?Sized,
16485 {
16486 PredicateEq {
16487 lhs_ty: f.fold_type(node.lhs_ty),
16488- eq_token: Token ! [ = ](tokens_helper(f, &node.eq_token.spans)),
16489+ eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)),
16490 rhs_ty: f.fold_type(node.rhs_ty),
16491 }
16492 }
16493 #[cfg(any(feature = "derive", feature = "full"))]
16494 pub fn fold_predicate_lifetime<F>(f: &mut F, node: PredicateLifetime) -> PredicateLifetime
16495 where
16496 F: Fold + ?Sized,
16497 {
16498 PredicateLifetime {
16499 lifetime: f.fold_lifetime(node.lifetime),
16500- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
16501+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
16502 bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)),
16503 }
16504 }
16505 #[cfg(any(feature = "derive", feature = "full"))]
16506 pub fn fold_predicate_type<F>(f: &mut F, node: PredicateType) -> PredicateType
16507 where
16508 F: Fold + ?Sized,
16509 {
16510 PredicateType {
16511 lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)),
16512 bounded_ty: f.fold_type(node.bounded_ty),
16513- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
16514+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
16515 bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
16516 }
16517 }
16518 #[cfg(any(feature = "derive", feature = "full"))]
16519 pub fn fold_qself<F>(f: &mut F, node: QSelf) -> QSelf
16520 where
16521 F: Fold + ?Sized,
16522 {
16523 QSelf {
16524- lt_token: Token ! [ < ](tokens_helper(f, &node.lt_token.spans)),
16525+ lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)),
16526 ty: Box::new(f.fold_type(*node.ty)),
16527 position: node.position,
16528 as_token: (node.as_token).map(|it| Token![as](tokens_helper(f, &it.span))),
16529- gt_token: Token ! [ > ](tokens_helper(f, &node.gt_token.spans)),
16530+ gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)),
16531 }
16532 }
16533 #[cfg(feature = "full")]
16534 pub fn fold_range_limits<F>(f: &mut F, node: RangeLimits) -> RangeLimits
16535 where
16536 F: Fold + ?Sized,
16537 {
16538 match node {
16539 RangeLimits::HalfOpen(_binding_0) => {
16540 RangeLimits::HalfOpen(Token![..](tokens_helper(f, &_binding_0.spans)))
16541 }
16542 RangeLimits::Closed(_binding_0) => {
16543- RangeLimits::Closed(Token ! [ ..= ](tokens_helper(f, &_binding_0.spans)))
16544+ RangeLimits::Closed(Token ! [..=](tokens_helper(f, &_binding_0.spans)))
16545 }
16546 }
16547 }
16548 #[cfg(feature = "full")]
16549 pub fn fold_receiver<F>(f: &mut F, node: Receiver) -> Receiver
16550 where
16551 F: Fold + ?Sized,
16552 {
16553 Receiver {
16554 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16555 reference: (node.reference).map(|it| {
16556 (
16557- Token ! [ & ](tokens_helper(f, &(it).0.spans)),
16558+ Token ! [&](tokens_helper(f, &(it).0.spans)),
16559 ((it).1).map(|it| f.fold_lifetime(it)),
16560 )
16561 }),
16562 mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
16563 self_token: Token![self](tokens_helper(f, &node.self_token.span)),
16564 }
16565 }
16566 #[cfg(any(feature = "derive", feature = "full"))]
16567 pub fn fold_return_type<F>(f: &mut F, node: ReturnType) -> ReturnType
16568 where
16569 F: Fold + ?Sized,
16570 {
16571 match node {
16572 ReturnType::Default => ReturnType::Default,
16573 ReturnType::Type(_binding_0, _binding_1) => ReturnType::Type(
16574- Token ! [ -> ](tokens_helper(f, &_binding_0.spans)),
16575+ Token ! [->](tokens_helper(f, &_binding_0.spans)),
16576 Box::new(f.fold_type(*_binding_1)),
16577 ),
16578 }
16579 }
16580 #[cfg(feature = "full")]
16581 pub fn fold_signature<F>(f: &mut F, node: Signature) -> Signature
16582 where
16583 F: Fold + ?Sized,
16584@@ -2756,17 +2729,17 @@ where
16585 F: Fold + ?Sized,
16586 {
16587 match node {
16588 Stmt::Local(_binding_0) => Stmt::Local(f.fold_local(_binding_0)),
16589 Stmt::Item(_binding_0) => Stmt::Item(f.fold_item(_binding_0)),
16590 Stmt::Expr(_binding_0) => Stmt::Expr(f.fold_expr(_binding_0)),
16591 Stmt::Semi(_binding_0, _binding_1) => Stmt::Semi(
16592 f.fold_expr(_binding_0),
16593- Token ! [ ; ](tokens_helper(f, &_binding_1.spans)),
16594+ Token ! [;](tokens_helper(f, &_binding_1.spans)),
16595 ),
16596 }
16597 }
16598 #[cfg(any(feature = "derive", feature = "full"))]
16599 pub fn fold_trait_bound<F>(f: &mut F, node: TraitBound) -> TraitBound
16600 where
16601 F: Fold + ?Sized,
16602 {
16603@@ -2780,17 +2753,17 @@ where
16604 #[cfg(any(feature = "derive", feature = "full"))]
16605 pub fn fold_trait_bound_modifier<F>(f: &mut F, node: TraitBoundModifier) -> TraitBoundModifier
16606 where
16607 F: Fold + ?Sized,
16608 {
16609 match node {
16610 TraitBoundModifier::None => TraitBoundModifier::None,
16611 TraitBoundModifier::Maybe(_binding_0) => {
16612- TraitBoundModifier::Maybe(Token ! [ ? ](tokens_helper(f, &_binding_0.spans)))
16613+ TraitBoundModifier::Maybe(Token ! [?](tokens_helper(f, &_binding_0.spans)))
16614 }
16615 }
16616 }
16617 #[cfg(feature = "full")]
16618 pub fn fold_trait_item<F>(f: &mut F, node: TraitItem) -> TraitItem
16619 where
16620 F: Fold + ?Sized,
16621 {
16622@@ -2807,69 +2780,69 @@ where
16623 pub fn fold_trait_item_const<F>(f: &mut F, node: TraitItemConst) -> TraitItemConst
16624 where
16625 F: Fold + ?Sized,
16626 {
16627 TraitItemConst {
16628 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16629 const_token: Token![const](tokens_helper(f, &node.const_token.span)),
16630 ident: f.fold_ident(node.ident),
16631- colon_token: Token ! [ : ](tokens_helper(f, &node.colon_token.spans)),
16632+ colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)),
16633 ty: f.fold_type(node.ty),
16634 default: (node.default).map(|it| {
16635 (
16636- Token ! [ = ](tokens_helper(f, &(it).0.spans)),
16637+ Token ! [=](tokens_helper(f, &(it).0.spans)),
16638 f.fold_expr((it).1),
16639 )
16640 }),
16641- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16642+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16643 }
16644 }
16645 #[cfg(feature = "full")]
16646 pub fn fold_trait_item_macro<F>(f: &mut F, node: TraitItemMacro) -> TraitItemMacro
16647 where
16648 F: Fold + ?Sized,
16649 {
16650 TraitItemMacro {
16651 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16652 mac: f.fold_macro(node.mac),
16653- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
16654+ semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))),
16655 }
16656 }
16657 #[cfg(feature = "full")]
16658 pub fn fold_trait_item_method<F>(f: &mut F, node: TraitItemMethod) -> TraitItemMethod
16659 where
16660 F: Fold + ?Sized,
16661 {
16662 TraitItemMethod {
16663 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16664 sig: f.fold_signature(node.sig),
16665 default: (node.default).map(|it| f.fold_block(it)),
16666- semi_token: (node.semi_token).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
16667+ semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))),
16668 }
16669 }
16670 #[cfg(feature = "full")]
16671 pub fn fold_trait_item_type<F>(f: &mut F, node: TraitItemType) -> TraitItemType
16672 where
16673 F: Fold + ?Sized,
16674 {
16675 TraitItemType {
16676 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16677 type_token: Token![type](tokens_helper(f, &node.type_token.span)),
16678 ident: f.fold_ident(node.ident),
16679 generics: f.fold_generics(node.generics),
16680- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
16681+ colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))),
16682 bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
16683 default: (node.default).map(|it| {
16684 (
16685- Token ! [ = ](tokens_helper(f, &(it).0.spans)),
16686+ Token ! [=](tokens_helper(f, &(it).0.spans)),
16687 f.fold_type((it).1),
16688 )
16689 }),
16690- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16691+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16692 }
16693 }
16694 #[cfg(any(feature = "derive", feature = "full"))]
16695 pub fn fold_type<F>(f: &mut F, node: Type) -> Type
16696 where
16697 F: Fold + ?Sized,
16698 {
16699 match node {
16700@@ -2894,17 +2867,17 @@ where
16701 #[cfg(any(feature = "derive", feature = "full"))]
16702 pub fn fold_type_array<F>(f: &mut F, node: TypeArray) -> TypeArray
16703 where
16704 F: Fold + ?Sized,
16705 {
16706 TypeArray {
16707 bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)),
16708 elem: Box::new(f.fold_type(*node.elem)),
16709- semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16710+ semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16711 len: f.fold_expr(node.len),
16712 }
16713 }
16714 #[cfg(any(feature = "derive", feature = "full"))]
16715 pub fn fold_type_bare_fn<F>(f: &mut F, node: TypeBareFn) -> TypeBareFn
16716 where
16717 F: Fold + ?Sized,
16718 {
16719@@ -2969,19 +2942,19 @@ where
16720 #[cfg(any(feature = "derive", feature = "full"))]
16721 pub fn fold_type_param<F>(f: &mut F, node: TypeParam) -> TypeParam
16722 where
16723 F: Fold + ?Sized,
16724 {
16725 TypeParam {
16726 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16727 ident: f.fold_ident(node.ident),
16728- colon_token: (node.colon_token).map(|it| Token ! [ : ](tokens_helper(f, &it.spans))),
16729+ colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))),
16730 bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)),
16731- eq_token: (node.eq_token).map(|it| Token ! [ = ](tokens_helper(f, &it.spans))),
16732+ eq_token: (node.eq_token).map(|it| Token ! [=](tokens_helper(f, &it.spans))),
16733 default: (node.default).map(|it| f.fold_type(it)),
16734 }
16735 }
16736 #[cfg(any(feature = "derive", feature = "full"))]
16737 pub fn fold_type_param_bound<F>(f: &mut F, node: TypeParamBound) -> TypeParamBound
16738 where
16739 F: Fold + ?Sized,
16740 {
16741@@ -3013,29 +2986,29 @@ where
16742 }
16743 }
16744 #[cfg(any(feature = "derive", feature = "full"))]
16745 pub fn fold_type_ptr<F>(f: &mut F, node: TypePtr) -> TypePtr
16746 where
16747 F: Fold + ?Sized,
16748 {
16749 TypePtr {
16750- star_token: Token ! [ * ](tokens_helper(f, &node.star_token.spans)),
16751+ star_token: Token ! [*](tokens_helper(f, &node.star_token.spans)),
16752 const_token: (node.const_token).map(|it| Token![const](tokens_helper(f, &it.span))),
16753 mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
16754 elem: Box::new(f.fold_type(*node.elem)),
16755 }
16756 }
16757 #[cfg(any(feature = "derive", feature = "full"))]
16758 pub fn fold_type_reference<F>(f: &mut F, node: TypeReference) -> TypeReference
16759 where
16760 F: Fold + ?Sized,
16761 {
16762 TypeReference {
16763- and_token: Token ! [ & ](tokens_helper(f, &node.and_token.spans)),
16764+ and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)),
16765 lifetime: (node.lifetime).map(|it| f.fold_lifetime(it)),
16766 mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
16767 elem: Box::new(f.fold_type(*node.elem)),
16768 }
16769 }
16770 #[cfg(any(feature = "derive", feature = "full"))]
16771 pub fn fold_type_slice<F>(f: &mut F, node: TypeSlice) -> TypeSlice
16772 where
16773@@ -3067,28 +3040,28 @@ where
16774 }
16775 }
16776 #[cfg(any(feature = "derive", feature = "full"))]
16777 pub fn fold_un_op<F>(f: &mut F, node: UnOp) -> UnOp
16778 where
16779 F: Fold + ?Sized,
16780 {
16781 match node {
16782- UnOp::Deref(_binding_0) => UnOp::Deref(Token ! [ * ](tokens_helper(f, &_binding_0.spans))),
16783+ UnOp::Deref(_binding_0) => UnOp::Deref(Token ! [*](tokens_helper(f, &_binding_0.spans))),
16784 UnOp::Not(_binding_0) => UnOp::Not(Token![!](tokens_helper(f, &_binding_0.spans))),
16785- UnOp::Neg(_binding_0) => UnOp::Neg(Token ! [ - ](tokens_helper(f, &_binding_0.spans))),
16786+ UnOp::Neg(_binding_0) => UnOp::Neg(Token ! [-](tokens_helper(f, &_binding_0.spans))),
16787 }
16788 }
16789 #[cfg(feature = "full")]
16790 pub fn fold_use_glob<F>(f: &mut F, node: UseGlob) -> UseGlob
16791 where
16792 F: Fold + ?Sized,
16793 {
16794 UseGlob {
16795- star_token: Token ! [ * ](tokens_helper(f, &node.star_token.spans)),
16796+ star_token: Token ! [*](tokens_helper(f, &node.star_token.spans)),
16797 }
16798 }
16799 #[cfg(feature = "full")]
16800 pub fn fold_use_group<F>(f: &mut F, node: UseGroup) -> UseGroup
16801 where
16802 F: Fold + ?Sized,
16803 {
16804 UseGroup {
16805@@ -3107,17 +3080,17 @@ where
16806 }
16807 #[cfg(feature = "full")]
16808 pub fn fold_use_path<F>(f: &mut F, node: UsePath) -> UsePath
16809 where
16810 F: Fold + ?Sized,
16811 {
16812 UsePath {
16813 ident: f.fold_ident(node.ident),
16814- colon2_token: Token ! [ :: ](tokens_helper(f, &node.colon2_token.spans)),
16815+ colon2_token: Token ! [::](tokens_helper(f, &node.colon2_token.spans)),
16816 tree: Box::new(f.fold_use_tree(*node.tree)),
16817 }
16818 }
16819 #[cfg(feature = "full")]
16820 pub fn fold_use_rename<F>(f: &mut F, node: UseRename) -> UseRename
16821 where
16822 F: Fold + ?Sized,
16823 {
16824@@ -3142,31 +3115,31 @@ where
16825 }
16826 #[cfg(any(feature = "derive", feature = "full"))]
16827 pub fn fold_variadic<F>(f: &mut F, node: Variadic) -> Variadic
16828 where
16829 F: Fold + ?Sized,
16830 {
16831 Variadic {
16832 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16833- dots: Token ! [ ... ](tokens_helper(f, &node.dots.spans)),
16834+ dots: Token ! [...](tokens_helper(f, &node.dots.spans)),
16835 }
16836 }
16837 #[cfg(any(feature = "derive", feature = "full"))]
16838 pub fn fold_variant<F>(f: &mut F, node: Variant) -> Variant
16839 where
16840 F: Fold + ?Sized,
16841 {
16842 Variant {
16843 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16844 ident: f.fold_ident(node.ident),
16845 fields: f.fold_fields(node.fields),
16846 discriminant: (node.discriminant).map(|it| {
16847 (
16848- Token ! [ = ](tokens_helper(f, &(it).0.spans)),
16849+ Token ! [=](tokens_helper(f, &(it).0.spans)),
16850 f.fold_expr((it).1),
16851 )
16852 }),
16853 }
16854 }
16855 #[cfg(any(feature = "derive", feature = "full"))]
16856 pub fn fold_vis_crate<F>(f: &mut F, node: VisCrate) -> VisCrate
16857 where
16858diff --git a/third_party/rust/syn/src/gen/hash.rs b/third_party/rust/syn/src/gen/hash.rs
16859new file mode 100644
16860--- /dev/null
16861+++ b/third_party/rust/syn/src/gen/hash.rs
16862@@ -0,0 +1,2691 @@
16863+// This file is @generated by syn-internal-codegen.
16864+// It is not intended for manual editing.
16865+
16866+#[cfg(any(feature = "derive", feature = "full"))]
16867+use crate::tt::TokenStreamHelper;
16868+use crate::*;
16869+use std::hash::{Hash, Hasher};
16870+#[cfg(any(feature = "derive", feature = "full"))]
16871+impl Hash for Abi {
16872+ fn hash<H>(&self, state: &mut H)
16873+ where
16874+ H: Hasher,
16875+ {
16876+ self.name.hash(state);
16877+ }
16878+}
16879+#[cfg(any(feature = "derive", feature = "full"))]
16880+impl Hash for AngleBracketedGenericArguments {
16881+ fn hash<H>(&self, state: &mut H)
16882+ where
16883+ H: Hasher,
16884+ {
16885+ self.colon2_token.hash(state);
16886+ self.args.hash(state);
16887+ }
16888+}
16889+#[cfg(feature = "full")]
16890+impl Hash for Arm {
16891+ fn hash<H>(&self, state: &mut H)
16892+ where
16893+ H: Hasher,
16894+ {
16895+ self.attrs.hash(state);
16896+ self.pat.hash(state);
16897+ self.guard.hash(state);
16898+ self.body.hash(state);
16899+ self.comma.hash(state);
16900+ }
16901+}
16902+#[cfg(any(feature = "derive", feature = "full"))]
16903+impl Hash for AttrStyle {
16904+ fn hash<H>(&self, state: &mut H)
16905+ where
16906+ H: Hasher,
16907+ {
16908+ match self {
16909+ AttrStyle::Outer => {
16910+ state.write_u8(0u8);
16911+ }
16912+ AttrStyle::Inner(_) => {
16913+ state.write_u8(1u8);
16914+ }
16915+ }
16916+ }
16917+}
16918+#[cfg(any(feature = "derive", feature = "full"))]
16919+impl Hash for Attribute {
16920+ fn hash<H>(&self, state: &mut H)
16921+ where
16922+ H: Hasher,
16923+ {
16924+ self.style.hash(state);
16925+ self.path.hash(state);
16926+ TokenStreamHelper(&self.tokens).hash(state);
16927+ }
16928+}
16929+#[cfg(any(feature = "derive", feature = "full"))]
16930+impl Hash for BareFnArg {
16931+ fn hash<H>(&self, state: &mut H)
16932+ where
16933+ H: Hasher,
16934+ {
16935+ self.attrs.hash(state);
16936+ self.name.hash(state);
16937+ self.ty.hash(state);
16938+ }
16939+}
16940+#[cfg(any(feature = "derive", feature = "full"))]
16941+impl Hash for BinOp {
16942+ fn hash<H>(&self, state: &mut H)
16943+ where
16944+ H: Hasher,
16945+ {
16946+ match self {
16947+ BinOp::Add(_) => {
16948+ state.write_u8(0u8);
16949+ }
16950+ BinOp::Sub(_) => {
16951+ state.write_u8(1u8);
16952+ }
16953+ BinOp::Mul(_) => {
16954+ state.write_u8(2u8);
16955+ }
16956+ BinOp::Div(_) => {
16957+ state.write_u8(3u8);
16958+ }
16959+ BinOp::Rem(_) => {
16960+ state.write_u8(4u8);
16961+ }
16962+ BinOp::And(_) => {
16963+ state.write_u8(5u8);
16964+ }
16965+ BinOp::Or(_) => {
16966+ state.write_u8(6u8);
16967+ }
16968+ BinOp::BitXor(_) => {
16969+ state.write_u8(7u8);
16970+ }
16971+ BinOp::BitAnd(_) => {
16972+ state.write_u8(8u8);
16973+ }
16974+ BinOp::BitOr(_) => {
16975+ state.write_u8(9u8);
16976+ }
16977+ BinOp::Shl(_) => {
16978+ state.write_u8(10u8);
16979+ }
16980+ BinOp::Shr(_) => {
16981+ state.write_u8(11u8);
16982+ }
16983+ BinOp::Eq(_) => {
16984+ state.write_u8(12u8);
16985+ }
16986+ BinOp::Lt(_) => {
16987+ state.write_u8(13u8);
16988+ }
16989+ BinOp::Le(_) => {
16990+ state.write_u8(14u8);
16991+ }
16992+ BinOp::Ne(_) => {
16993+ state.write_u8(15u8);
16994+ }
16995+ BinOp::Ge(_) => {
16996+ state.write_u8(16u8);
16997+ }
16998+ BinOp::Gt(_) => {
16999+ state.write_u8(17u8);
17000+ }
17001+ BinOp::AddEq(_) => {
17002+ state.write_u8(18u8);
17003+ }
17004+ BinOp::SubEq(_) => {
17005+ state.write_u8(19u8);
17006+ }
17007+ BinOp::MulEq(_) => {
17008+ state.write_u8(20u8);
17009+ }
17010+ BinOp::DivEq(_) => {
17011+ state.write_u8(21u8);
17012+ }
17013+ BinOp::RemEq(_) => {
17014+ state.write_u8(22u8);
17015+ }
17016+ BinOp::BitXorEq(_) => {
17017+ state.write_u8(23u8);
17018+ }
17019+ BinOp::BitAndEq(_) => {
17020+ state.write_u8(24u8);
17021+ }
17022+ BinOp::BitOrEq(_) => {
17023+ state.write_u8(25u8);
17024+ }
17025+ BinOp::ShlEq(_) => {
17026+ state.write_u8(26u8);
17027+ }
17028+ BinOp::ShrEq(_) => {
17029+ state.write_u8(27u8);
17030+ }
17031+ }
17032+ }
17033+}
17034+#[cfg(any(feature = "derive", feature = "full"))]
17035+impl Hash for Binding {
17036+ fn hash<H>(&self, state: &mut H)
17037+ where
17038+ H: Hasher,
17039+ {
17040+ self.ident.hash(state);
17041+ self.ty.hash(state);
17042+ }
17043+}
17044+#[cfg(feature = "full")]
17045+impl Hash for Block {
17046+ fn hash<H>(&self, state: &mut H)
17047+ where
17048+ H: Hasher,
17049+ {
17050+ self.stmts.hash(state);
17051+ }
17052+}
17053+#[cfg(any(feature = "derive", feature = "full"))]
17054+impl Hash for BoundLifetimes {
17055+ fn hash<H>(&self, state: &mut H)
17056+ where
17057+ H: Hasher,
17058+ {
17059+ self.lifetimes.hash(state);
17060+ }
17061+}
17062+#[cfg(any(feature = "derive", feature = "full"))]
17063+impl Hash for ConstParam {
17064+ fn hash<H>(&self, state: &mut H)
17065+ where
17066+ H: Hasher,
17067+ {
17068+ self.attrs.hash(state);
17069+ self.ident.hash(state);
17070+ self.ty.hash(state);
17071+ self.eq_token.hash(state);
17072+ self.default.hash(state);
17073+ }
17074+}
17075+#[cfg(any(feature = "derive", feature = "full"))]
17076+impl Hash for Constraint {
17077+ fn hash<H>(&self, state: &mut H)
17078+ where
17079+ H: Hasher,
17080+ {
17081+ self.ident.hash(state);
17082+ self.bounds.hash(state);
17083+ }
17084+}
17085+#[cfg(feature = "derive")]
17086+impl Hash for Data {
17087+ fn hash<H>(&self, state: &mut H)
17088+ where
17089+ H: Hasher,
17090+ {
17091+ match self {
17092+ Data::Struct(v0) => {
17093+ state.write_u8(0u8);
17094+ v0.hash(state);
17095+ }
17096+ Data::Enum(v0) => {
17097+ state.write_u8(1u8);
17098+ v0.hash(state);
17099+ }
17100+ Data::Union(v0) => {
17101+ state.write_u8(2u8);
17102+ v0.hash(state);
17103+ }
17104+ }
17105+ }
17106+}
17107+#[cfg(feature = "derive")]
17108+impl Hash for DataEnum {
17109+ fn hash<H>(&self, state: &mut H)
17110+ where
17111+ H: Hasher,
17112+ {
17113+ self.variants.hash(state);
17114+ }
17115+}
17116+#[cfg(feature = "derive")]
17117+impl Hash for DataStruct {
17118+ fn hash<H>(&self, state: &mut H)
17119+ where
17120+ H: Hasher,
17121+ {
17122+ self.fields.hash(state);
17123+ self.semi_token.hash(state);
17124+ }
17125+}
17126+#[cfg(feature = "derive")]
17127+impl Hash for DataUnion {
17128+ fn hash<H>(&self, state: &mut H)
17129+ where
17130+ H: Hasher,
17131+ {
17132+ self.fields.hash(state);
17133+ }
17134+}
17135+#[cfg(feature = "derive")]
17136+impl Hash for DeriveInput {
17137+ fn hash<H>(&self, state: &mut H)
17138+ where
17139+ H: Hasher,
17140+ {
17141+ self.attrs.hash(state);
17142+ self.vis.hash(state);
17143+ self.ident.hash(state);
17144+ self.generics.hash(state);
17145+ self.data.hash(state);
17146+ }
17147+}
17148+#[cfg(any(feature = "derive", feature = "full"))]
17149+impl Hash for Expr {
17150+ fn hash<H>(&self, state: &mut H)
17151+ where
17152+ H: Hasher,
17153+ {
17154+ match self {
17155+ #[cfg(feature = "full")]
17156+ Expr::Array(v0) => {
17157+ state.write_u8(0u8);
17158+ v0.hash(state);
17159+ }
17160+ #[cfg(feature = "full")]
17161+ Expr::Assign(v0) => {
17162+ state.write_u8(1u8);
17163+ v0.hash(state);
17164+ }
17165+ #[cfg(feature = "full")]
17166+ Expr::AssignOp(v0) => {
17167+ state.write_u8(2u8);
17168+ v0.hash(state);
17169+ }
17170+ #[cfg(feature = "full")]
17171+ Expr::Async(v0) => {
17172+ state.write_u8(3u8);
17173+ v0.hash(state);
17174+ }
17175+ #[cfg(feature = "full")]
17176+ Expr::Await(v0) => {
17177+ state.write_u8(4u8);
17178+ v0.hash(state);
17179+ }
17180+ Expr::Binary(v0) => {
17181+ state.write_u8(5u8);
17182+ v0.hash(state);
17183+ }
17184+ #[cfg(feature = "full")]
17185+ Expr::Block(v0) => {
17186+ state.write_u8(6u8);
17187+ v0.hash(state);
17188+ }
17189+ #[cfg(feature = "full")]
17190+ Expr::Box(v0) => {
17191+ state.write_u8(7u8);
17192+ v0.hash(state);
17193+ }
17194+ #[cfg(feature = "full")]
17195+ Expr::Break(v0) => {
17196+ state.write_u8(8u8);
17197+ v0.hash(state);
17198+ }
17199+ Expr::Call(v0) => {
17200+ state.write_u8(9u8);
17201+ v0.hash(state);
17202+ }
17203+ Expr::Cast(v0) => {
17204+ state.write_u8(10u8);
17205+ v0.hash(state);
17206+ }
17207+ #[cfg(feature = "full")]
17208+ Expr::Closure(v0) => {
17209+ state.write_u8(11u8);
17210+ v0.hash(state);
17211+ }
17212+ #[cfg(feature = "full")]
17213+ Expr::Continue(v0) => {
17214+ state.write_u8(12u8);
17215+ v0.hash(state);
17216+ }
17217+ Expr::Field(v0) => {
17218+ state.write_u8(13u8);
17219+ v0.hash(state);
17220+ }
17221+ #[cfg(feature = "full")]
17222+ Expr::ForLoop(v0) => {
17223+ state.write_u8(14u8);
17224+ v0.hash(state);
17225+ }
17226+ #[cfg(feature = "full")]
17227+ Expr::Group(v0) => {
17228+ state.write_u8(15u8);
17229+ v0.hash(state);
17230+ }
17231+ #[cfg(feature = "full")]
17232+ Expr::If(v0) => {
17233+ state.write_u8(16u8);
17234+ v0.hash(state);
17235+ }
17236+ Expr::Index(v0) => {
17237+ state.write_u8(17u8);
17238+ v0.hash(state);
17239+ }
17240+ #[cfg(feature = "full")]
17241+ Expr::Let(v0) => {
17242+ state.write_u8(18u8);
17243+ v0.hash(state);
17244+ }
17245+ Expr::Lit(v0) => {
17246+ state.write_u8(19u8);
17247+ v0.hash(state);
17248+ }
17249+ #[cfg(feature = "full")]
17250+ Expr::Loop(v0) => {
17251+ state.write_u8(20u8);
17252+ v0.hash(state);
17253+ }
17254+ #[cfg(feature = "full")]
17255+ Expr::Macro(v0) => {
17256+ state.write_u8(21u8);
17257+ v0.hash(state);
17258+ }
17259+ #[cfg(feature = "full")]
17260+ Expr::Match(v0) => {
17261+ state.write_u8(22u8);
17262+ v0.hash(state);
17263+ }
17264+ #[cfg(feature = "full")]
17265+ Expr::MethodCall(v0) => {
17266+ state.write_u8(23u8);
17267+ v0.hash(state);
17268+ }
17269+ Expr::Paren(v0) => {
17270+ state.write_u8(24u8);
17271+ v0.hash(state);
17272+ }
17273+ Expr::Path(v0) => {
17274+ state.write_u8(25u8);
17275+ v0.hash(state);
17276+ }
17277+ #[cfg(feature = "full")]
17278+ Expr::Range(v0) => {
17279+ state.write_u8(26u8);
17280+ v0.hash(state);
17281+ }
17282+ #[cfg(feature = "full")]
17283+ Expr::Reference(v0) => {
17284+ state.write_u8(27u8);
17285+ v0.hash(state);
17286+ }
17287+ #[cfg(feature = "full")]
17288+ Expr::Repeat(v0) => {
17289+ state.write_u8(28u8);
17290+ v0.hash(state);
17291+ }
17292+ #[cfg(feature = "full")]
17293+ Expr::Return(v0) => {
17294+ state.write_u8(29u8);
17295+ v0.hash(state);
17296+ }
17297+ #[cfg(feature = "full")]
17298+ Expr::Struct(v0) => {
17299+ state.write_u8(30u8);
17300+ v0.hash(state);
17301+ }
17302+ #[cfg(feature = "full")]
17303+ Expr::Try(v0) => {
17304+ state.write_u8(31u8);
17305+ v0.hash(state);
17306+ }
17307+ #[cfg(feature = "full")]
17308+ Expr::TryBlock(v0) => {
17309+ state.write_u8(32u8);
17310+ v0.hash(state);
17311+ }
17312+ #[cfg(feature = "full")]
17313+ Expr::Tuple(v0) => {
17314+ state.write_u8(33u8);
17315+ v0.hash(state);
17316+ }
17317+ #[cfg(feature = "full")]
17318+ Expr::Type(v0) => {
17319+ state.write_u8(34u8);
17320+ v0.hash(state);
17321+ }
17322+ Expr::Unary(v0) => {
17323+ state.write_u8(35u8);
17324+ v0.hash(state);
17325+ }
17326+ #[cfg(feature = "full")]
17327+ Expr::Unsafe(v0) => {
17328+ state.write_u8(36u8);
17329+ v0.hash(state);
17330+ }
17331+ Expr::Verbatim(v0) => {
17332+ state.write_u8(37u8);
17333+ TokenStreamHelper(v0).hash(state);
17334+ }
17335+ #[cfg(feature = "full")]
17336+ Expr::While(v0) => {
17337+ state.write_u8(38u8);
17338+ v0.hash(state);
17339+ }
17340+ #[cfg(feature = "full")]
17341+ Expr::Yield(v0) => {
17342+ state.write_u8(39u8);
17343+ v0.hash(state);
17344+ }
17345+ _ => unreachable!(),
17346+ }
17347+ }
17348+}
17349+#[cfg(feature = "full")]
17350+impl Hash for ExprArray {
17351+ fn hash<H>(&self, state: &mut H)
17352+ where
17353+ H: Hasher,
17354+ {
17355+ self.attrs.hash(state);
17356+ self.elems.hash(state);
17357+ }
17358+}
17359+#[cfg(feature = "full")]
17360+impl Hash for ExprAssign {
17361+ fn hash<H>(&self, state: &mut H)
17362+ where
17363+ H: Hasher,
17364+ {
17365+ self.attrs.hash(state);
17366+ self.left.hash(state);
17367+ self.right.hash(state);
17368+ }
17369+}
17370+#[cfg(feature = "full")]
17371+impl Hash for ExprAssignOp {
17372+ fn hash<H>(&self, state: &mut H)
17373+ where
17374+ H: Hasher,
17375+ {
17376+ self.attrs.hash(state);
17377+ self.left.hash(state);
17378+ self.op.hash(state);
17379+ self.right.hash(state);
17380+ }
17381+}
17382+#[cfg(feature = "full")]
17383+impl Hash for ExprAsync {
17384+ fn hash<H>(&self, state: &mut H)
17385+ where
17386+ H: Hasher,
17387+ {
17388+ self.attrs.hash(state);
17389+ self.capture.hash(state);
17390+ self.block.hash(state);
17391+ }
17392+}
17393+#[cfg(feature = "full")]
17394+impl Hash for ExprAwait {
17395+ fn hash<H>(&self, state: &mut H)
17396+ where
17397+ H: Hasher,
17398+ {
17399+ self.attrs.hash(state);
17400+ self.base.hash(state);
17401+ }
17402+}
17403+#[cfg(any(feature = "derive", feature = "full"))]
17404+impl Hash for ExprBinary {
17405+ fn hash<H>(&self, state: &mut H)
17406+ where
17407+ H: Hasher,
17408+ {
17409+ self.attrs.hash(state);
17410+ self.left.hash(state);
17411+ self.op.hash(state);
17412+ self.right.hash(state);
17413+ }
17414+}
17415+#[cfg(feature = "full")]
17416+impl Hash for ExprBlock {
17417+ fn hash<H>(&self, state: &mut H)
17418+ where
17419+ H: Hasher,
17420+ {
17421+ self.attrs.hash(state);
17422+ self.label.hash(state);
17423+ self.block.hash(state);
17424+ }
17425+}
17426+#[cfg(feature = "full")]
17427+impl Hash for ExprBox {
17428+ fn hash<H>(&self, state: &mut H)
17429+ where
17430+ H: Hasher,
17431+ {
17432+ self.attrs.hash(state);
17433+ self.expr.hash(state);
17434+ }
17435+}
17436+#[cfg(feature = "full")]
17437+impl Hash for ExprBreak {
17438+ fn hash<H>(&self, state: &mut H)
17439+ where
17440+ H: Hasher,
17441+ {
17442+ self.attrs.hash(state);
17443+ self.label.hash(state);
17444+ self.expr.hash(state);
17445+ }
17446+}
17447+#[cfg(any(feature = "derive", feature = "full"))]
17448+impl Hash for ExprCall {
17449+ fn hash<H>(&self, state: &mut H)
17450+ where
17451+ H: Hasher,
17452+ {
17453+ self.attrs.hash(state);
17454+ self.func.hash(state);
17455+ self.args.hash(state);
17456+ }
17457+}
17458+#[cfg(any(feature = "derive", feature = "full"))]
17459+impl Hash for ExprCast {
17460+ fn hash<H>(&self, state: &mut H)
17461+ where
17462+ H: Hasher,
17463+ {
17464+ self.attrs.hash(state);
17465+ self.expr.hash(state);
17466+ self.ty.hash(state);
17467+ }
17468+}
17469+#[cfg(feature = "full")]
17470+impl Hash for ExprClosure {
17471+ fn hash<H>(&self, state: &mut H)
17472+ where
17473+ H: Hasher,
17474+ {
17475+ self.attrs.hash(state);
17476+ self.asyncness.hash(state);
17477+ self.movability.hash(state);
17478+ self.capture.hash(state);
17479+ self.inputs.hash(state);
17480+ self.output.hash(state);
17481+ self.body.hash(state);
17482+ }
17483+}
17484+#[cfg(feature = "full")]
17485+impl Hash for ExprContinue {
17486+ fn hash<H>(&self, state: &mut H)
17487+ where
17488+ H: Hasher,
17489+ {
17490+ self.attrs.hash(state);
17491+ self.label.hash(state);
17492+ }
17493+}
17494+#[cfg(any(feature = "derive", feature = "full"))]
17495+impl Hash for ExprField {
17496+ fn hash<H>(&self, state: &mut H)
17497+ where
17498+ H: Hasher,
17499+ {
17500+ self.attrs.hash(state);
17501+ self.base.hash(state);
17502+ self.member.hash(state);
17503+ }
17504+}
17505+#[cfg(feature = "full")]
17506+impl Hash for ExprForLoop {
17507+ fn hash<H>(&self, state: &mut H)
17508+ where
17509+ H: Hasher,
17510+ {
17511+ self.attrs.hash(state);
17512+ self.label.hash(state);
17513+ self.pat.hash(state);
17514+ self.expr.hash(state);
17515+ self.body.hash(state);
17516+ }
17517+}
17518+#[cfg(feature = "full")]
17519+impl Hash for ExprGroup {
17520+ fn hash<H>(&self, state: &mut H)
17521+ where
17522+ H: Hasher,
17523+ {
17524+ self.attrs.hash(state);
17525+ self.expr.hash(state);
17526+ }
17527+}
17528+#[cfg(feature = "full")]
17529+impl Hash for ExprIf {
17530+ fn hash<H>(&self, state: &mut H)
17531+ where
17532+ H: Hasher,
17533+ {
17534+ self.attrs.hash(state);
17535+ self.cond.hash(state);
17536+ self.then_branch.hash(state);
17537+ self.else_branch.hash(state);
17538+ }
17539+}
17540+#[cfg(any(feature = "derive", feature = "full"))]
17541+impl Hash for ExprIndex {
17542+ fn hash<H>(&self, state: &mut H)
17543+ where
17544+ H: Hasher,
17545+ {
17546+ self.attrs.hash(state);
17547+ self.expr.hash(state);
17548+ self.index.hash(state);
17549+ }
17550+}
17551+#[cfg(feature = "full")]
17552+impl Hash for ExprLet {
17553+ fn hash<H>(&self, state: &mut H)
17554+ where
17555+ H: Hasher,
17556+ {
17557+ self.attrs.hash(state);
17558+ self.pat.hash(state);
17559+ self.expr.hash(state);
17560+ }
17561+}
17562+#[cfg(any(feature = "derive", feature = "full"))]
17563+impl Hash for ExprLit {
17564+ fn hash<H>(&self, state: &mut H)
17565+ where
17566+ H: Hasher,
17567+ {
17568+ self.attrs.hash(state);
17569+ self.lit.hash(state);
17570+ }
17571+}
17572+#[cfg(feature = "full")]
17573+impl Hash for ExprLoop {
17574+ fn hash<H>(&self, state: &mut H)
17575+ where
17576+ H: Hasher,
17577+ {
17578+ self.attrs.hash(state);
17579+ self.label.hash(state);
17580+ self.body.hash(state);
17581+ }
17582+}
17583+#[cfg(feature = "full")]
17584+impl Hash for ExprMacro {
17585+ fn hash<H>(&self, state: &mut H)
17586+ where
17587+ H: Hasher,
17588+ {
17589+ self.attrs.hash(state);
17590+ self.mac.hash(state);
17591+ }
17592+}
17593+#[cfg(feature = "full")]
17594+impl Hash for ExprMatch {
17595+ fn hash<H>(&self, state: &mut H)
17596+ where
17597+ H: Hasher,
17598+ {
17599+ self.attrs.hash(state);
17600+ self.expr.hash(state);
17601+ self.arms.hash(state);
17602+ }
17603+}
17604+#[cfg(feature = "full")]
17605+impl Hash for ExprMethodCall {
17606+ fn hash<H>(&self, state: &mut H)
17607+ where
17608+ H: Hasher,
17609+ {
17610+ self.attrs.hash(state);
17611+ self.receiver.hash(state);
17612+ self.method.hash(state);
17613+ self.turbofish.hash(state);
17614+ self.args.hash(state);
17615+ }
17616+}
17617+#[cfg(any(feature = "derive", feature = "full"))]
17618+impl Hash for ExprParen {
17619+ fn hash<H>(&self, state: &mut H)
17620+ where
17621+ H: Hasher,
17622+ {
17623+ self.attrs.hash(state);
17624+ self.expr.hash(state);
17625+ }
17626+}
17627+#[cfg(any(feature = "derive", feature = "full"))]
17628+impl Hash for ExprPath {
17629+ fn hash<H>(&self, state: &mut H)
17630+ where
17631+ H: Hasher,
17632+ {
17633+ self.attrs.hash(state);
17634+ self.qself.hash(state);
17635+ self.path.hash(state);
17636+ }
17637+}
17638+#[cfg(feature = "full")]
17639+impl Hash for ExprRange {
17640+ fn hash<H>(&self, state: &mut H)
17641+ where
17642+ H: Hasher,
17643+ {
17644+ self.attrs.hash(state);
17645+ self.from.hash(state);
17646+ self.limits.hash(state);
17647+ self.to.hash(state);
17648+ }
17649+}
17650+#[cfg(feature = "full")]
17651+impl Hash for ExprReference {
17652+ fn hash<H>(&self, state: &mut H)
17653+ where
17654+ H: Hasher,
17655+ {
17656+ self.attrs.hash(state);
17657+ self.mutability.hash(state);
17658+ self.expr.hash(state);
17659+ }
17660+}
17661+#[cfg(feature = "full")]
17662+impl Hash for ExprRepeat {
17663+ fn hash<H>(&self, state: &mut H)
17664+ where
17665+ H: Hasher,
17666+ {
17667+ self.attrs.hash(state);
17668+ self.expr.hash(state);
17669+ self.len.hash(state);
17670+ }
17671+}
17672+#[cfg(feature = "full")]
17673+impl Hash for ExprReturn {
17674+ fn hash<H>(&self, state: &mut H)
17675+ where
17676+ H: Hasher,
17677+ {
17678+ self.attrs.hash(state);
17679+ self.expr.hash(state);
17680+ }
17681+}
17682+#[cfg(feature = "full")]
17683+impl Hash for ExprStruct {
17684+ fn hash<H>(&self, state: &mut H)
17685+ where
17686+ H: Hasher,
17687+ {
17688+ self.attrs.hash(state);
17689+ self.path.hash(state);
17690+ self.fields.hash(state);
17691+ self.dot2_token.hash(state);
17692+ self.rest.hash(state);
17693+ }
17694+}
17695+#[cfg(feature = "full")]
17696+impl Hash for ExprTry {
17697+ fn hash<H>(&self, state: &mut H)
17698+ where
17699+ H: Hasher,
17700+ {
17701+ self.attrs.hash(state);
17702+ self.expr.hash(state);
17703+ }
17704+}
17705+#[cfg(feature = "full")]
17706+impl Hash for ExprTryBlock {
17707+ fn hash<H>(&self, state: &mut H)
17708+ where
17709+ H: Hasher,
17710+ {
17711+ self.attrs.hash(state);
17712+ self.block.hash(state);
17713+ }
17714+}
17715+#[cfg(feature = "full")]
17716+impl Hash for ExprTuple {
17717+ fn hash<H>(&self, state: &mut H)
17718+ where
17719+ H: Hasher,
17720+ {
17721+ self.attrs.hash(state);
17722+ self.elems.hash(state);
17723+ }
17724+}
17725+#[cfg(feature = "full")]
17726+impl Hash for ExprType {
17727+ fn hash<H>(&self, state: &mut H)
17728+ where
17729+ H: Hasher,
17730+ {
17731+ self.attrs.hash(state);
17732+ self.expr.hash(state);
17733+ self.ty.hash(state);
17734+ }
17735+}
17736+#[cfg(any(feature = "derive", feature = "full"))]
17737+impl Hash for ExprUnary {
17738+ fn hash<H>(&self, state: &mut H)
17739+ where
17740+ H: Hasher,
17741+ {
17742+ self.attrs.hash(state);
17743+ self.op.hash(state);
17744+ self.expr.hash(state);
17745+ }
17746+}
17747+#[cfg(feature = "full")]
17748+impl Hash for ExprUnsafe {
17749+ fn hash<H>(&self, state: &mut H)
17750+ where
17751+ H: Hasher,
17752+ {
17753+ self.attrs.hash(state);
17754+ self.block.hash(state);
17755+ }
17756+}
17757+#[cfg(feature = "full")]
17758+impl Hash for ExprWhile {
17759+ fn hash<H>(&self, state: &mut H)
17760+ where
17761+ H: Hasher,
17762+ {
17763+ self.attrs.hash(state);
17764+ self.label.hash(state);
17765+ self.cond.hash(state);
17766+ self.body.hash(state);
17767+ }
17768+}
17769+#[cfg(feature = "full")]
17770+impl Hash for ExprYield {
17771+ fn hash<H>(&self, state: &mut H)
17772+ where
17773+ H: Hasher,
17774+ {
17775+ self.attrs.hash(state);
17776+ self.expr.hash(state);
17777+ }
17778+}
17779+#[cfg(any(feature = "derive", feature = "full"))]
17780+impl Hash for Field {
17781+ fn hash<H>(&self, state: &mut H)
17782+ where
17783+ H: Hasher,
17784+ {
17785+ self.attrs.hash(state);
17786+ self.vis.hash(state);
17787+ self.ident.hash(state);
17788+ self.colon_token.hash(state);
17789+ self.ty.hash(state);
17790+ }
17791+}
17792+#[cfg(feature = "full")]
17793+impl Hash for FieldPat {
17794+ fn hash<H>(&self, state: &mut H)
17795+ where
17796+ H: Hasher,
17797+ {
17798+ self.attrs.hash(state);
17799+ self.member.hash(state);
17800+ self.colon_token.hash(state);
17801+ self.pat.hash(state);
17802+ }
17803+}
17804+#[cfg(feature = "full")]
17805+impl Hash for FieldValue {
17806+ fn hash<H>(&self, state: &mut H)
17807+ where
17808+ H: Hasher,
17809+ {
17810+ self.attrs.hash(state);
17811+ self.member.hash(state);
17812+ self.colon_token.hash(state);
17813+ self.expr.hash(state);
17814+ }
17815+}
17816+#[cfg(any(feature = "derive", feature = "full"))]
17817+impl Hash for Fields {
17818+ fn hash<H>(&self, state: &mut H)
17819+ where
17820+ H: Hasher,
17821+ {
17822+ match self {
17823+ Fields::Named(v0) => {
17824+ state.write_u8(0u8);
17825+ v0.hash(state);
17826+ }
17827+ Fields::Unnamed(v0) => {
17828+ state.write_u8(1u8);
17829+ v0.hash(state);
17830+ }
17831+ Fields::Unit => {
17832+ state.write_u8(2u8);
17833+ }
17834+ }
17835+ }
17836+}
17837+#[cfg(any(feature = "derive", feature = "full"))]
17838+impl Hash for FieldsNamed {
17839+ fn hash<H>(&self, state: &mut H)
17840+ where
17841+ H: Hasher,
17842+ {
17843+ self.named.hash(state);
17844+ }
17845+}
17846+#[cfg(any(feature = "derive", feature = "full"))]
17847+impl Hash for FieldsUnnamed {
17848+ fn hash<H>(&self, state: &mut H)
17849+ where
17850+ H: Hasher,
17851+ {
17852+ self.unnamed.hash(state);
17853+ }
17854+}
17855+#[cfg(feature = "full")]
17856+impl Hash for File {
17857+ fn hash<H>(&self, state: &mut H)
17858+ where
17859+ H: Hasher,
17860+ {
17861+ self.shebang.hash(state);
17862+ self.attrs.hash(state);
17863+ self.items.hash(state);
17864+ }
17865+}
17866+#[cfg(feature = "full")]
17867+impl Hash for FnArg {
17868+ fn hash<H>(&self, state: &mut H)
17869+ where
17870+ H: Hasher,
17871+ {
17872+ match self {
17873+ FnArg::Receiver(v0) => {
17874+ state.write_u8(0u8);
17875+ v0.hash(state);
17876+ }
17877+ FnArg::Typed(v0) => {
17878+ state.write_u8(1u8);
17879+ v0.hash(state);
17880+ }
17881+ }
17882+ }
17883+}
17884+#[cfg(feature = "full")]
17885+impl Hash for ForeignItem {
17886+ fn hash<H>(&self, state: &mut H)
17887+ where
17888+ H: Hasher,
17889+ {
17890+ match self {
17891+ ForeignItem::Fn(v0) => {
17892+ state.write_u8(0u8);
17893+ v0.hash(state);
17894+ }
17895+ ForeignItem::Static(v0) => {
17896+ state.write_u8(1u8);
17897+ v0.hash(state);
17898+ }
17899+ ForeignItem::Type(v0) => {
17900+ state.write_u8(2u8);
17901+ v0.hash(state);
17902+ }
17903+ ForeignItem::Macro(v0) => {
17904+ state.write_u8(3u8);
17905+ v0.hash(state);
17906+ }
17907+ ForeignItem::Verbatim(v0) => {
17908+ state.write_u8(4u8);
17909+ TokenStreamHelper(v0).hash(state);
17910+ }
17911+ _ => unreachable!(),
17912+ }
17913+ }
17914+}
17915+#[cfg(feature = "full")]
17916+impl Hash for ForeignItemFn {
17917+ fn hash<H>(&self, state: &mut H)
17918+ where
17919+ H: Hasher,
17920+ {
17921+ self.attrs.hash(state);
17922+ self.vis.hash(state);
17923+ self.sig.hash(state);
17924+ }
17925+}
17926+#[cfg(feature = "full")]
17927+impl Hash for ForeignItemMacro {
17928+ fn hash<H>(&self, state: &mut H)
17929+ where
17930+ H: Hasher,
17931+ {
17932+ self.attrs.hash(state);
17933+ self.mac.hash(state);
17934+ self.semi_token.hash(state);
17935+ }
17936+}
17937+#[cfg(feature = "full")]
17938+impl Hash for ForeignItemStatic {
17939+ fn hash<H>(&self, state: &mut H)
17940+ where
17941+ H: Hasher,
17942+ {
17943+ self.attrs.hash(state);
17944+ self.vis.hash(state);
17945+ self.mutability.hash(state);
17946+ self.ident.hash(state);
17947+ self.ty.hash(state);
17948+ }
17949+}
17950+#[cfg(feature = "full")]
17951+impl Hash for ForeignItemType {
17952+ fn hash<H>(&self, state: &mut H)
17953+ where
17954+ H: Hasher,
17955+ {
17956+ self.attrs.hash(state);
17957+ self.vis.hash(state);
17958+ self.ident.hash(state);
17959+ }
17960+}
17961+#[cfg(any(feature = "derive", feature = "full"))]
17962+impl Hash for GenericArgument {
17963+ fn hash<H>(&self, state: &mut H)
17964+ where
17965+ H: Hasher,
17966+ {
17967+ match self {
17968+ GenericArgument::Lifetime(v0) => {
17969+ state.write_u8(0u8);
17970+ v0.hash(state);
17971+ }
17972+ GenericArgument::Type(v0) => {
17973+ state.write_u8(1u8);
17974+ v0.hash(state);
17975+ }
17976+ GenericArgument::Binding(v0) => {
17977+ state.write_u8(2u8);
17978+ v0.hash(state);
17979+ }
17980+ GenericArgument::Constraint(v0) => {
17981+ state.write_u8(3u8);
17982+ v0.hash(state);
17983+ }
17984+ GenericArgument::Const(v0) => {
17985+ state.write_u8(4u8);
17986+ v0.hash(state);
17987+ }
17988+ }
17989+ }
17990+}
17991+#[cfg(feature = "full")]
17992+impl Hash for GenericMethodArgument {
17993+ fn hash<H>(&self, state: &mut H)
17994+ where
17995+ H: Hasher,
17996+ {
17997+ match self {
17998+ GenericMethodArgument::Type(v0) => {
17999+ state.write_u8(0u8);
18000+ v0.hash(state);
18001+ }
18002+ GenericMethodArgument::Const(v0) => {
18003+ state.write_u8(1u8);
18004+ v0.hash(state);
18005+ }
18006+ }
18007+ }
18008+}
18009+#[cfg(any(feature = "derive", feature = "full"))]
18010+impl Hash for GenericParam {
18011+ fn hash<H>(&self, state: &mut H)
18012+ where
18013+ H: Hasher,
18014+ {
18015+ match self {
18016+ GenericParam::Type(v0) => {
18017+ state.write_u8(0u8);
18018+ v0.hash(state);
18019+ }
18020+ GenericParam::Lifetime(v0) => {
18021+ state.write_u8(1u8);
18022+ v0.hash(state);
18023+ }
18024+ GenericParam::Const(v0) => {
18025+ state.write_u8(2u8);
18026+ v0.hash(state);
18027+ }
18028+ }
18029+ }
18030+}
18031+#[cfg(any(feature = "derive", feature = "full"))]
18032+impl Hash for Generics {
18033+ fn hash<H>(&self, state: &mut H)
18034+ where
18035+ H: Hasher,
18036+ {
18037+ self.lt_token.hash(state);
18038+ self.params.hash(state);
18039+ self.gt_token.hash(state);
18040+ self.where_clause.hash(state);
18041+ }
18042+}
18043+#[cfg(feature = "full")]
18044+impl Hash for ImplItem {
18045+ fn hash<H>(&self, state: &mut H)
18046+ where
18047+ H: Hasher,
18048+ {
18049+ match self {
18050+ ImplItem::Const(v0) => {
18051+ state.write_u8(0u8);
18052+ v0.hash(state);
18053+ }
18054+ ImplItem::Method(v0) => {
18055+ state.write_u8(1u8);
18056+ v0.hash(state);
18057+ }
18058+ ImplItem::Type(v0) => {
18059+ state.write_u8(2u8);
18060+ v0.hash(state);
18061+ }
18062+ ImplItem::Macro(v0) => {
18063+ state.write_u8(3u8);
18064+ v0.hash(state);
18065+ }
18066+ ImplItem::Verbatim(v0) => {
18067+ state.write_u8(4u8);
18068+ TokenStreamHelper(v0).hash(state);
18069+ }
18070+ _ => unreachable!(),
18071+ }
18072+ }
18073+}
18074+#[cfg(feature = "full")]
18075+impl Hash for ImplItemConst {
18076+ fn hash<H>(&self, state: &mut H)
18077+ where
18078+ H: Hasher,
18079+ {
18080+ self.attrs.hash(state);
18081+ self.vis.hash(state);
18082+ self.defaultness.hash(state);
18083+ self.ident.hash(state);
18084+ self.ty.hash(state);
18085+ self.expr.hash(state);
18086+ }
18087+}
18088+#[cfg(feature = "full")]
18089+impl Hash for ImplItemMacro {
18090+ fn hash<H>(&self, state: &mut H)
18091+ where
18092+ H: Hasher,
18093+ {
18094+ self.attrs.hash(state);
18095+ self.mac.hash(state);
18096+ self.semi_token.hash(state);
18097+ }
18098+}
18099+#[cfg(feature = "full")]
18100+impl Hash for ImplItemMethod {
18101+ fn hash<H>(&self, state: &mut H)
18102+ where
18103+ H: Hasher,
18104+ {
18105+ self.attrs.hash(state);
18106+ self.vis.hash(state);
18107+ self.defaultness.hash(state);
18108+ self.sig.hash(state);
18109+ self.block.hash(state);
18110+ }
18111+}
18112+#[cfg(feature = "full")]
18113+impl Hash for ImplItemType {
18114+ fn hash<H>(&self, state: &mut H)
18115+ where
18116+ H: Hasher,
18117+ {
18118+ self.attrs.hash(state);
18119+ self.vis.hash(state);
18120+ self.defaultness.hash(state);
18121+ self.ident.hash(state);
18122+ self.generics.hash(state);
18123+ self.ty.hash(state);
18124+ }
18125+}
18126+#[cfg(feature = "full")]
18127+impl Hash for Item {
18128+ fn hash<H>(&self, state: &mut H)
18129+ where
18130+ H: Hasher,
18131+ {
18132+ match self {
18133+ Item::Const(v0) => {
18134+ state.write_u8(0u8);
18135+ v0.hash(state);
18136+ }
18137+ Item::Enum(v0) => {
18138+ state.write_u8(1u8);
18139+ v0.hash(state);
18140+ }
18141+ Item::ExternCrate(v0) => {
18142+ state.write_u8(2u8);
18143+ v0.hash(state);
18144+ }
18145+ Item::Fn(v0) => {
18146+ state.write_u8(3u8);
18147+ v0.hash(state);
18148+ }
18149+ Item::ForeignMod(v0) => {
18150+ state.write_u8(4u8);
18151+ v0.hash(state);
18152+ }
18153+ Item::Impl(v0) => {
18154+ state.write_u8(5u8);
18155+ v0.hash(state);
18156+ }
18157+ Item::Macro(v0) => {
18158+ state.write_u8(6u8);
18159+ v0.hash(state);
18160+ }
18161+ Item::Macro2(v0) => {
18162+ state.write_u8(7u8);
18163+ v0.hash(state);
18164+ }
18165+ Item::Mod(v0) => {
18166+ state.write_u8(8u8);
18167+ v0.hash(state);
18168+ }
18169+ Item::Static(v0) => {
18170+ state.write_u8(9u8);
18171+ v0.hash(state);
18172+ }
18173+ Item::Struct(v0) => {
18174+ state.write_u8(10u8);
18175+ v0.hash(state);
18176+ }
18177+ Item::Trait(v0) => {
18178+ state.write_u8(11u8);
18179+ v0.hash(state);
18180+ }
18181+ Item::TraitAlias(v0) => {
18182+ state.write_u8(12u8);
18183+ v0.hash(state);
18184+ }
18185+ Item::Type(v0) => {
18186+ state.write_u8(13u8);
18187+ v0.hash(state);
18188+ }
18189+ Item::Union(v0) => {
18190+ state.write_u8(14u8);
18191+ v0.hash(state);
18192+ }
18193+ Item::Use(v0) => {
18194+ state.write_u8(15u8);
18195+ v0.hash(state);
18196+ }
18197+ Item::Verbatim(v0) => {
18198+ state.write_u8(16u8);
18199+ TokenStreamHelper(v0).hash(state);
18200+ }
18201+ _ => unreachable!(),
18202+ }
18203+ }
18204+}
18205+#[cfg(feature = "full")]
18206+impl Hash for ItemConst {
18207+ fn hash<H>(&self, state: &mut H)
18208+ where
18209+ H: Hasher,
18210+ {
18211+ self.attrs.hash(state);
18212+ self.vis.hash(state);
18213+ self.ident.hash(state);
18214+ self.ty.hash(state);
18215+ self.expr.hash(state);
18216+ }
18217+}
18218+#[cfg(feature = "full")]
18219+impl Hash for ItemEnum {
18220+ fn hash<H>(&self, state: &mut H)
18221+ where
18222+ H: Hasher,
18223+ {
18224+ self.attrs.hash(state);
18225+ self.vis.hash(state);
18226+ self.ident.hash(state);
18227+ self.generics.hash(state);
18228+ self.variants.hash(state);
18229+ }
18230+}
18231+#[cfg(feature = "full")]
18232+impl Hash for ItemExternCrate {
18233+ fn hash<H>(&self, state: &mut H)
18234+ where
18235+ H: Hasher,
18236+ {
18237+ self.attrs.hash(state);
18238+ self.vis.hash(state);
18239+ self.ident.hash(state);
18240+ self.rename.hash(state);
18241+ }
18242+}
18243+#[cfg(feature = "full")]
18244+impl Hash for ItemFn {
18245+ fn hash<H>(&self, state: &mut H)
18246+ where
18247+ H: Hasher,
18248+ {
18249+ self.attrs.hash(state);
18250+ self.vis.hash(state);
18251+ self.sig.hash(state);
18252+ self.block.hash(state);
18253+ }
18254+}
18255+#[cfg(feature = "full")]
18256+impl Hash for ItemForeignMod {
18257+ fn hash<H>(&self, state: &mut H)
18258+ where
18259+ H: Hasher,
18260+ {
18261+ self.attrs.hash(state);
18262+ self.abi.hash(state);
18263+ self.items.hash(state);
18264+ }
18265+}
18266+#[cfg(feature = "full")]
18267+impl Hash for ItemImpl {
18268+ fn hash<H>(&self, state: &mut H)
18269+ where
18270+ H: Hasher,
18271+ {
18272+ self.attrs.hash(state);
18273+ self.defaultness.hash(state);
18274+ self.unsafety.hash(state);
18275+ self.generics.hash(state);
18276+ self.trait_.hash(state);
18277+ self.self_ty.hash(state);
18278+ self.items.hash(state);
18279+ }
18280+}
18281+#[cfg(feature = "full")]
18282+impl Hash for ItemMacro {
18283+ fn hash<H>(&self, state: &mut H)
18284+ where
18285+ H: Hasher,
18286+ {
18287+ self.attrs.hash(state);
18288+ self.ident.hash(state);
18289+ self.mac.hash(state);
18290+ self.semi_token.hash(state);
18291+ }
18292+}
18293+#[cfg(feature = "full")]
18294+impl Hash for ItemMacro2 {
18295+ fn hash<H>(&self, state: &mut H)
18296+ where
18297+ H: Hasher,
18298+ {
18299+ self.attrs.hash(state);
18300+ self.vis.hash(state);
18301+ self.ident.hash(state);
18302+ TokenStreamHelper(&self.rules).hash(state);
18303+ }
18304+}
18305+#[cfg(feature = "full")]
18306+impl Hash for ItemMod {
18307+ fn hash<H>(&self, state: &mut H)
18308+ where
18309+ H: Hasher,
18310+ {
18311+ self.attrs.hash(state);
18312+ self.vis.hash(state);
18313+ self.ident.hash(state);
18314+ self.content.hash(state);
18315+ self.semi.hash(state);
18316+ }
18317+}
18318+#[cfg(feature = "full")]
18319+impl Hash for ItemStatic {
18320+ fn hash<H>(&self, state: &mut H)
18321+ where
18322+ H: Hasher,
18323+ {
18324+ self.attrs.hash(state);
18325+ self.vis.hash(state);
18326+ self.mutability.hash(state);
18327+ self.ident.hash(state);
18328+ self.ty.hash(state);
18329+ self.expr.hash(state);
18330+ }
18331+}
18332+#[cfg(feature = "full")]
18333+impl Hash for ItemStruct {
18334+ fn hash<H>(&self, state: &mut H)
18335+ where
18336+ H: Hasher,
18337+ {
18338+ self.attrs.hash(state);
18339+ self.vis.hash(state);
18340+ self.ident.hash(state);
18341+ self.generics.hash(state);
18342+ self.fields.hash(state);
18343+ self.semi_token.hash(state);
18344+ }
18345+}
18346+#[cfg(feature = "full")]
18347+impl Hash for ItemTrait {
18348+ fn hash<H>(&self, state: &mut H)
18349+ where
18350+ H: Hasher,
18351+ {
18352+ self.attrs.hash(state);
18353+ self.vis.hash(state);
18354+ self.unsafety.hash(state);
18355+ self.auto_token.hash(state);
18356+ self.ident.hash(state);
18357+ self.generics.hash(state);
18358+ self.colon_token.hash(state);
18359+ self.supertraits.hash(state);
18360+ self.items.hash(state);
18361+ }
18362+}
18363+#[cfg(feature = "full")]
18364+impl Hash for ItemTraitAlias {
18365+ fn hash<H>(&self, state: &mut H)
18366+ where
18367+ H: Hasher,
18368+ {
18369+ self.attrs.hash(state);
18370+ self.vis.hash(state);
18371+ self.ident.hash(state);
18372+ self.generics.hash(state);
18373+ self.bounds.hash(state);
18374+ }
18375+}
18376+#[cfg(feature = "full")]
18377+impl Hash for ItemType {
18378+ fn hash<H>(&self, state: &mut H)
18379+ where
18380+ H: Hasher,
18381+ {
18382+ self.attrs.hash(state);
18383+ self.vis.hash(state);
18384+ self.ident.hash(state);
18385+ self.generics.hash(state);
18386+ self.ty.hash(state);
18387+ }
18388+}
18389+#[cfg(feature = "full")]
18390+impl Hash for ItemUnion {
18391+ fn hash<H>(&self, state: &mut H)
18392+ where
18393+ H: Hasher,
18394+ {
18395+ self.attrs.hash(state);
18396+ self.vis.hash(state);
18397+ self.ident.hash(state);
18398+ self.generics.hash(state);
18399+ self.fields.hash(state);
18400+ }
18401+}
18402+#[cfg(feature = "full")]
18403+impl Hash for ItemUse {
18404+ fn hash<H>(&self, state: &mut H)
18405+ where
18406+ H: Hasher,
18407+ {
18408+ self.attrs.hash(state);
18409+ self.vis.hash(state);
18410+ self.leading_colon.hash(state);
18411+ self.tree.hash(state);
18412+ }
18413+}
18414+#[cfg(feature = "full")]
18415+impl Hash for Label {
18416+ fn hash<H>(&self, state: &mut H)
18417+ where
18418+ H: Hasher,
18419+ {
18420+ self.name.hash(state);
18421+ }
18422+}
18423+#[cfg(any(feature = "derive", feature = "full"))]
18424+impl Hash for LifetimeDef {
18425+ fn hash<H>(&self, state: &mut H)
18426+ where
18427+ H: Hasher,
18428+ {
18429+ self.attrs.hash(state);
18430+ self.lifetime.hash(state);
18431+ self.colon_token.hash(state);
18432+ self.bounds.hash(state);
18433+ }
18434+}
18435+impl Hash for Lit {
18436+ fn hash<H>(&self, state: &mut H)
18437+ where
18438+ H: Hasher,
18439+ {
18440+ match self {
18441+ Lit::Str(v0) => {
18442+ state.write_u8(0u8);
18443+ v0.hash(state);
18444+ }
18445+ Lit::ByteStr(v0) => {
18446+ state.write_u8(1u8);
18447+ v0.hash(state);
18448+ }
18449+ Lit::Byte(v0) => {
18450+ state.write_u8(2u8);
18451+ v0.hash(state);
18452+ }
18453+ Lit::Char(v0) => {
18454+ state.write_u8(3u8);
18455+ v0.hash(state);
18456+ }
18457+ Lit::Int(v0) => {
18458+ state.write_u8(4u8);
18459+ v0.hash(state);
18460+ }
18461+ Lit::Float(v0) => {
18462+ state.write_u8(5u8);
18463+ v0.hash(state);
18464+ }
18465+ Lit::Bool(v0) => {
18466+ state.write_u8(6u8);
18467+ v0.hash(state);
18468+ }
18469+ Lit::Verbatim(v0) => {
18470+ state.write_u8(7u8);
18471+ v0.to_string().hash(state);
18472+ }
18473+ }
18474+ }
18475+}
18476+impl Hash for LitBool {
18477+ fn hash<H>(&self, state: &mut H)
18478+ where
18479+ H: Hasher,
18480+ {
18481+ self.value.hash(state);
18482+ }
18483+}
18484+#[cfg(feature = "full")]
18485+impl Hash for Local {
18486+ fn hash<H>(&self, state: &mut H)
18487+ where
18488+ H: Hasher,
18489+ {
18490+ self.attrs.hash(state);
18491+ self.pat.hash(state);
18492+ self.init.hash(state);
18493+ }
18494+}
18495+#[cfg(any(feature = "derive", feature = "full"))]
18496+impl Hash for Macro {
18497+ fn hash<H>(&self, state: &mut H)
18498+ where
18499+ H: Hasher,
18500+ {
18501+ self.path.hash(state);
18502+ self.delimiter.hash(state);
18503+ TokenStreamHelper(&self.tokens).hash(state);
18504+ }
18505+}
18506+#[cfg(any(feature = "derive", feature = "full"))]
18507+impl Hash for MacroDelimiter {
18508+ fn hash<H>(&self, state: &mut H)
18509+ where
18510+ H: Hasher,
18511+ {
18512+ match self {
18513+ MacroDelimiter::Paren(_) => {
18514+ state.write_u8(0u8);
18515+ }
18516+ MacroDelimiter::Brace(_) => {
18517+ state.write_u8(1u8);
18518+ }
18519+ MacroDelimiter::Bracket(_) => {
18520+ state.write_u8(2u8);
18521+ }
18522+ }
18523+ }
18524+}
18525+#[cfg(any(feature = "derive", feature = "full"))]
18526+impl Hash for Meta {
18527+ fn hash<H>(&self, state: &mut H)
18528+ where
18529+ H: Hasher,
18530+ {
18531+ match self {
18532+ Meta::Path(v0) => {
18533+ state.write_u8(0u8);
18534+ v0.hash(state);
18535+ }
18536+ Meta::List(v0) => {
18537+ state.write_u8(1u8);
18538+ v0.hash(state);
18539+ }
18540+ Meta::NameValue(v0) => {
18541+ state.write_u8(2u8);
18542+ v0.hash(state);
18543+ }
18544+ }
18545+ }
18546+}
18547+#[cfg(any(feature = "derive", feature = "full"))]
18548+impl Hash for MetaList {
18549+ fn hash<H>(&self, state: &mut H)
18550+ where
18551+ H: Hasher,
18552+ {
18553+ self.path.hash(state);
18554+ self.nested.hash(state);
18555+ }
18556+}
18557+#[cfg(any(feature = "derive", feature = "full"))]
18558+impl Hash for MetaNameValue {
18559+ fn hash<H>(&self, state: &mut H)
18560+ where
18561+ H: Hasher,
18562+ {
18563+ self.path.hash(state);
18564+ self.lit.hash(state);
18565+ }
18566+}
18567+#[cfg(feature = "full")]
18568+impl Hash for MethodTurbofish {
18569+ fn hash<H>(&self, state: &mut H)
18570+ where
18571+ H: Hasher,
18572+ {
18573+ self.args.hash(state);
18574+ }
18575+}
18576+#[cfg(any(feature = "derive", feature = "full"))]
18577+impl Hash for NestedMeta {
18578+ fn hash<H>(&self, state: &mut H)
18579+ where
18580+ H: Hasher,
18581+ {
18582+ match self {
18583+ NestedMeta::Meta(v0) => {
18584+ state.write_u8(0u8);
18585+ v0.hash(state);
18586+ }
18587+ NestedMeta::Lit(v0) => {
18588+ state.write_u8(1u8);
18589+ v0.hash(state);
18590+ }
18591+ }
18592+ }
18593+}
18594+#[cfg(any(feature = "derive", feature = "full"))]
18595+impl Hash for ParenthesizedGenericArguments {
18596+ fn hash<H>(&self, state: &mut H)
18597+ where
18598+ H: Hasher,
18599+ {
18600+ self.inputs.hash(state);
18601+ self.output.hash(state);
18602+ }
18603+}
18604+#[cfg(feature = "full")]
18605+impl Hash for Pat {
18606+ fn hash<H>(&self, state: &mut H)
18607+ where
18608+ H: Hasher,
18609+ {
18610+ match self {
18611+ Pat::Box(v0) => {
18612+ state.write_u8(0u8);
18613+ v0.hash(state);
18614+ }
18615+ Pat::Ident(v0) => {
18616+ state.write_u8(1u8);
18617+ v0.hash(state);
18618+ }
18619+ Pat::Lit(v0) => {
18620+ state.write_u8(2u8);
18621+ v0.hash(state);
18622+ }
18623+ Pat::Macro(v0) => {
18624+ state.write_u8(3u8);
18625+ v0.hash(state);
18626+ }
18627+ Pat::Or(v0) => {
18628+ state.write_u8(4u8);
18629+ v0.hash(state);
18630+ }
18631+ Pat::Path(v0) => {
18632+ state.write_u8(5u8);
18633+ v0.hash(state);
18634+ }
18635+ Pat::Range(v0) => {
18636+ state.write_u8(6u8);
18637+ v0.hash(state);
18638+ }
18639+ Pat::Reference(v0) => {
18640+ state.write_u8(7u8);
18641+ v0.hash(state);
18642+ }
18643+ Pat::Rest(v0) => {
18644+ state.write_u8(8u8);
18645+ v0.hash(state);
18646+ }
18647+ Pat::Slice(v0) => {
18648+ state.write_u8(9u8);
18649+ v0.hash(state);
18650+ }
18651+ Pat::Struct(v0) => {
18652+ state.write_u8(10u8);
18653+ v0.hash(state);
18654+ }
18655+ Pat::Tuple(v0) => {
18656+ state.write_u8(11u8);
18657+ v0.hash(state);
18658+ }
18659+ Pat::TupleStruct(v0) => {
18660+ state.write_u8(12u8);
18661+ v0.hash(state);
18662+ }
18663+ Pat::Type(v0) => {
18664+ state.write_u8(13u8);
18665+ v0.hash(state);
18666+ }
18667+ Pat::Verbatim(v0) => {
18668+ state.write_u8(14u8);
18669+ TokenStreamHelper(v0).hash(state);
18670+ }
18671+ Pat::Wild(v0) => {
18672+ state.write_u8(15u8);
18673+ v0.hash(state);
18674+ }
18675+ _ => unreachable!(),
18676+ }
18677+ }
18678+}
18679+#[cfg(feature = "full")]
18680+impl Hash for PatBox {
18681+ fn hash<H>(&self, state: &mut H)
18682+ where
18683+ H: Hasher,
18684+ {
18685+ self.attrs.hash(state);
18686+ self.pat.hash(state);
18687+ }
18688+}
18689+#[cfg(feature = "full")]
18690+impl Hash for PatIdent {
18691+ fn hash<H>(&self, state: &mut H)
18692+ where
18693+ H: Hasher,
18694+ {
18695+ self.attrs.hash(state);
18696+ self.by_ref.hash(state);
18697+ self.mutability.hash(state);
18698+ self.ident.hash(state);
18699+ self.subpat.hash(state);
18700+ }
18701+}
18702+#[cfg(feature = "full")]
18703+impl Hash for PatLit {
18704+ fn hash<H>(&self, state: &mut H)
18705+ where
18706+ H: Hasher,
18707+ {
18708+ self.attrs.hash(state);
18709+ self.expr.hash(state);
18710+ }
18711+}
18712+#[cfg(feature = "full")]
18713+impl Hash for PatMacro {
18714+ fn hash<H>(&self, state: &mut H)
18715+ where
18716+ H: Hasher,
18717+ {
18718+ self.attrs.hash(state);
18719+ self.mac.hash(state);
18720+ }
18721+}
18722+#[cfg(feature = "full")]
18723+impl Hash for PatOr {
18724+ fn hash<H>(&self, state: &mut H)
18725+ where
18726+ H: Hasher,
18727+ {
18728+ self.attrs.hash(state);
18729+ self.leading_vert.hash(state);
18730+ self.cases.hash(state);
18731+ }
18732+}
18733+#[cfg(feature = "full")]
18734+impl Hash for PatPath {
18735+ fn hash<H>(&self, state: &mut H)
18736+ where
18737+ H: Hasher,
18738+ {
18739+ self.attrs.hash(state);
18740+ self.qself.hash(state);
18741+ self.path.hash(state);
18742+ }
18743+}
18744+#[cfg(feature = "full")]
18745+impl Hash for PatRange {
18746+ fn hash<H>(&self, state: &mut H)
18747+ where
18748+ H: Hasher,
18749+ {
18750+ self.attrs.hash(state);
18751+ self.lo.hash(state);
18752+ self.limits.hash(state);
18753+ self.hi.hash(state);
18754+ }
18755+}
18756+#[cfg(feature = "full")]
18757+impl Hash for PatReference {
18758+ fn hash<H>(&self, state: &mut H)
18759+ where
18760+ H: Hasher,
18761+ {
18762+ self.attrs.hash(state);
18763+ self.mutability.hash(state);
18764+ self.pat.hash(state);
18765+ }
18766+}
18767+#[cfg(feature = "full")]
18768+impl Hash for PatRest {
18769+ fn hash<H>(&self, state: &mut H)
18770+ where
18771+ H: Hasher,
18772+ {
18773+ self.attrs.hash(state);
18774+ }
18775+}
18776+#[cfg(feature = "full")]
18777+impl Hash for PatSlice {
18778+ fn hash<H>(&self, state: &mut H)
18779+ where
18780+ H: Hasher,
18781+ {
18782+ self.attrs.hash(state);
18783+ self.elems.hash(state);
18784+ }
18785+}
18786+#[cfg(feature = "full")]
18787+impl Hash for PatStruct {
18788+ fn hash<H>(&self, state: &mut H)
18789+ where
18790+ H: Hasher,
18791+ {
18792+ self.attrs.hash(state);
18793+ self.path.hash(state);
18794+ self.fields.hash(state);
18795+ self.dot2_token.hash(state);
18796+ }
18797+}
18798+#[cfg(feature = "full")]
18799+impl Hash for PatTuple {
18800+ fn hash<H>(&self, state: &mut H)
18801+ where
18802+ H: Hasher,
18803+ {
18804+ self.attrs.hash(state);
18805+ self.elems.hash(state);
18806+ }
18807+}
18808+#[cfg(feature = "full")]
18809+impl Hash for PatTupleStruct {
18810+ fn hash<H>(&self, state: &mut H)
18811+ where
18812+ H: Hasher,
18813+ {
18814+ self.attrs.hash(state);
18815+ self.path.hash(state);
18816+ self.pat.hash(state);
18817+ }
18818+}
18819+#[cfg(feature = "full")]
18820+impl Hash for PatType {
18821+ fn hash<H>(&self, state: &mut H)
18822+ where
18823+ H: Hasher,
18824+ {
18825+ self.attrs.hash(state);
18826+ self.pat.hash(state);
18827+ self.ty.hash(state);
18828+ }
18829+}
18830+#[cfg(feature = "full")]
18831+impl Hash for PatWild {
18832+ fn hash<H>(&self, state: &mut H)
18833+ where
18834+ H: Hasher,
18835+ {
18836+ self.attrs.hash(state);
18837+ }
18838+}
18839+#[cfg(any(feature = "derive", feature = "full"))]
18840+impl Hash for Path {
18841+ fn hash<H>(&self, state: &mut H)
18842+ where
18843+ H: Hasher,
18844+ {
18845+ self.leading_colon.hash(state);
18846+ self.segments.hash(state);
18847+ }
18848+}
18849+#[cfg(any(feature = "derive", feature = "full"))]
18850+impl Hash for PathArguments {
18851+ fn hash<H>(&self, state: &mut H)
18852+ where
18853+ H: Hasher,
18854+ {
18855+ match self {
18856+ PathArguments::None => {
18857+ state.write_u8(0u8);
18858+ }
18859+ PathArguments::AngleBracketed(v0) => {
18860+ state.write_u8(1u8);
18861+ v0.hash(state);
18862+ }
18863+ PathArguments::Parenthesized(v0) => {
18864+ state.write_u8(2u8);
18865+ v0.hash(state);
18866+ }
18867+ }
18868+ }
18869+}
18870+#[cfg(any(feature = "derive", feature = "full"))]
18871+impl Hash for PathSegment {
18872+ fn hash<H>(&self, state: &mut H)
18873+ where
18874+ H: Hasher,
18875+ {
18876+ self.ident.hash(state);
18877+ self.arguments.hash(state);
18878+ }
18879+}
18880+#[cfg(any(feature = "derive", feature = "full"))]
18881+impl Hash for PredicateEq {
18882+ fn hash<H>(&self, state: &mut H)
18883+ where
18884+ H: Hasher,
18885+ {
18886+ self.lhs_ty.hash(state);
18887+ self.rhs_ty.hash(state);
18888+ }
18889+}
18890+#[cfg(any(feature = "derive", feature = "full"))]
18891+impl Hash for PredicateLifetime {
18892+ fn hash<H>(&self, state: &mut H)
18893+ where
18894+ H: Hasher,
18895+ {
18896+ self.lifetime.hash(state);
18897+ self.bounds.hash(state);
18898+ }
18899+}
18900+#[cfg(any(feature = "derive", feature = "full"))]
18901+impl Hash for PredicateType {
18902+ fn hash<H>(&self, state: &mut H)
18903+ where
18904+ H: Hasher,
18905+ {
18906+ self.lifetimes.hash(state);
18907+ self.bounded_ty.hash(state);
18908+ self.bounds.hash(state);
18909+ }
18910+}
18911+#[cfg(any(feature = "derive", feature = "full"))]
18912+impl Hash for QSelf {
18913+ fn hash<H>(&self, state: &mut H)
18914+ where
18915+ H: Hasher,
18916+ {
18917+ self.ty.hash(state);
18918+ self.position.hash(state);
18919+ self.as_token.hash(state);
18920+ }
18921+}
18922+#[cfg(feature = "full")]
18923+impl Hash for RangeLimits {
18924+ fn hash<H>(&self, state: &mut H)
18925+ where
18926+ H: Hasher,
18927+ {
18928+ match self {
18929+ RangeLimits::HalfOpen(_) => {
18930+ state.write_u8(0u8);
18931+ }
18932+ RangeLimits::Closed(_) => {
18933+ state.write_u8(1u8);
18934+ }
18935+ }
18936+ }
18937+}
18938+#[cfg(feature = "full")]
18939+impl Hash for Receiver {
18940+ fn hash<H>(&self, state: &mut H)
18941+ where
18942+ H: Hasher,
18943+ {
18944+ self.attrs.hash(state);
18945+ self.reference.hash(state);
18946+ self.mutability.hash(state);
18947+ }
18948+}
18949+#[cfg(any(feature = "derive", feature = "full"))]
18950+impl Hash for ReturnType {
18951+ fn hash<H>(&self, state: &mut H)
18952+ where
18953+ H: Hasher,
18954+ {
18955+ match self {
18956+ ReturnType::Default => {
18957+ state.write_u8(0u8);
18958+ }
18959+ ReturnType::Type(_, v1) => {
18960+ state.write_u8(1u8);
18961+ v1.hash(state);
18962+ }
18963+ }
18964+ }
18965+}
18966+#[cfg(feature = "full")]
18967+impl Hash for Signature {
18968+ fn hash<H>(&self, state: &mut H)
18969+ where
18970+ H: Hasher,
18971+ {
18972+ self.constness.hash(state);
18973+ self.asyncness.hash(state);
18974+ self.unsafety.hash(state);
18975+ self.abi.hash(state);
18976+ self.ident.hash(state);
18977+ self.generics.hash(state);
18978+ self.inputs.hash(state);
18979+ self.variadic.hash(state);
18980+ self.output.hash(state);
18981+ }
18982+}
18983+#[cfg(feature = "full")]
18984+impl Hash for Stmt {
18985+ fn hash<H>(&self, state: &mut H)
18986+ where
18987+ H: Hasher,
18988+ {
18989+ match self {
18990+ Stmt::Local(v0) => {
18991+ state.write_u8(0u8);
18992+ v0.hash(state);
18993+ }
18994+ Stmt::Item(v0) => {
18995+ state.write_u8(1u8);
18996+ v0.hash(state);
18997+ }
18998+ Stmt::Expr(v0) => {
18999+ state.write_u8(2u8);
19000+ v0.hash(state);
19001+ }
19002+ Stmt::Semi(v0, _) => {
19003+ state.write_u8(3u8);
19004+ v0.hash(state);
19005+ }
19006+ }
19007+ }
19008+}
19009+#[cfg(any(feature = "derive", feature = "full"))]
19010+impl Hash for TraitBound {
19011+ fn hash<H>(&self, state: &mut H)
19012+ where
19013+ H: Hasher,
19014+ {
19015+ self.paren_token.hash(state);
19016+ self.modifier.hash(state);
19017+ self.lifetimes.hash(state);
19018+ self.path.hash(state);
19019+ }
19020+}
19021+#[cfg(any(feature = "derive", feature = "full"))]
19022+impl Hash for TraitBoundModifier {
19023+ fn hash<H>(&self, state: &mut H)
19024+ where
19025+ H: Hasher,
19026+ {
19027+ match self {
19028+ TraitBoundModifier::None => {
19029+ state.write_u8(0u8);
19030+ }
19031+ TraitBoundModifier::Maybe(_) => {
19032+ state.write_u8(1u8);
19033+ }
19034+ }
19035+ }
19036+}
19037+#[cfg(feature = "full")]
19038+impl Hash for TraitItem {
19039+ fn hash<H>(&self, state: &mut H)
19040+ where
19041+ H: Hasher,
19042+ {
19043+ match self {
19044+ TraitItem::Const(v0) => {
19045+ state.write_u8(0u8);
19046+ v0.hash(state);
19047+ }
19048+ TraitItem::Method(v0) => {
19049+ state.write_u8(1u8);
19050+ v0.hash(state);
19051+ }
19052+ TraitItem::Type(v0) => {
19053+ state.write_u8(2u8);
19054+ v0.hash(state);
19055+ }
19056+ TraitItem::Macro(v0) => {
19057+ state.write_u8(3u8);
19058+ v0.hash(state);
19059+ }
19060+ TraitItem::Verbatim(v0) => {
19061+ state.write_u8(4u8);
19062+ TokenStreamHelper(v0).hash(state);
19063+ }
19064+ _ => unreachable!(),
19065+ }
19066+ }
19067+}
19068+#[cfg(feature = "full")]
19069+impl Hash for TraitItemConst {
19070+ fn hash<H>(&self, state: &mut H)
19071+ where
19072+ H: Hasher,
19073+ {
19074+ self.attrs.hash(state);
19075+ self.ident.hash(state);
19076+ self.ty.hash(state);
19077+ self.default.hash(state);
19078+ }
19079+}
19080+#[cfg(feature = "full")]
19081+impl Hash for TraitItemMacro {
19082+ fn hash<H>(&self, state: &mut H)
19083+ where
19084+ H: Hasher,
19085+ {
19086+ self.attrs.hash(state);
19087+ self.mac.hash(state);
19088+ self.semi_token.hash(state);
19089+ }
19090+}
19091+#[cfg(feature = "full")]
19092+impl Hash for TraitItemMethod {
19093+ fn hash<H>(&self, state: &mut H)
19094+ where
19095+ H: Hasher,
19096+ {
19097+ self.attrs.hash(state);
19098+ self.sig.hash(state);
19099+ self.default.hash(state);
19100+ self.semi_token.hash(state);
19101+ }
19102+}
19103+#[cfg(feature = "full")]
19104+impl Hash for TraitItemType {
19105+ fn hash<H>(&self, state: &mut H)
19106+ where
19107+ H: Hasher,
19108+ {
19109+ self.attrs.hash(state);
19110+ self.ident.hash(state);
19111+ self.generics.hash(state);
19112+ self.colon_token.hash(state);
19113+ self.bounds.hash(state);
19114+ self.default.hash(state);
19115+ }
19116+}
19117+#[cfg(any(feature = "derive", feature = "full"))]
19118+impl Hash for Type {
19119+ fn hash<H>(&self, state: &mut H)
19120+ where
19121+ H: Hasher,
19122+ {
19123+ match self {
19124+ Type::Array(v0) => {
19125+ state.write_u8(0u8);
19126+ v0.hash(state);
19127+ }
19128+ Type::BareFn(v0) => {
19129+ state.write_u8(1u8);
19130+ v0.hash(state);
19131+ }
19132+ Type::Group(v0) => {
19133+ state.write_u8(2u8);
19134+ v0.hash(state);
19135+ }
19136+ Type::ImplTrait(v0) => {
19137+ state.write_u8(3u8);
19138+ v0.hash(state);
19139+ }
19140+ Type::Infer(v0) => {
19141+ state.write_u8(4u8);
19142+ v0.hash(state);
19143+ }
19144+ Type::Macro(v0) => {
19145+ state.write_u8(5u8);
19146+ v0.hash(state);
19147+ }
19148+ Type::Never(v0) => {
19149+ state.write_u8(6u8);
19150+ v0.hash(state);
19151+ }
19152+ Type::Paren(v0) => {
19153+ state.write_u8(7u8);
19154+ v0.hash(state);
19155+ }
19156+ Type::Path(v0) => {
19157+ state.write_u8(8u8);
19158+ v0.hash(state);
19159+ }
19160+ Type::Ptr(v0) => {
19161+ state.write_u8(9u8);
19162+ v0.hash(state);
19163+ }
19164+ Type::Reference(v0) => {
19165+ state.write_u8(10u8);
19166+ v0.hash(state);
19167+ }
19168+ Type::Slice(v0) => {
19169+ state.write_u8(11u8);
19170+ v0.hash(state);
19171+ }
19172+ Type::TraitObject(v0) => {
19173+ state.write_u8(12u8);
19174+ v0.hash(state);
19175+ }
19176+ Type::Tuple(v0) => {
19177+ state.write_u8(13u8);
19178+ v0.hash(state);
19179+ }
19180+ Type::Verbatim(v0) => {
19181+ state.write_u8(14u8);
19182+ TokenStreamHelper(v0).hash(state);
19183+ }
19184+ _ => unreachable!(),
19185+ }
19186+ }
19187+}
19188+#[cfg(any(feature = "derive", feature = "full"))]
19189+impl Hash for TypeArray {
19190+ fn hash<H>(&self, state: &mut H)
19191+ where
19192+ H: Hasher,
19193+ {
19194+ self.elem.hash(state);
19195+ self.len.hash(state);
19196+ }
19197+}
19198+#[cfg(any(feature = "derive", feature = "full"))]
19199+impl Hash for TypeBareFn {
19200+ fn hash<H>(&self, state: &mut H)
19201+ where
19202+ H: Hasher,
19203+ {
19204+ self.lifetimes.hash(state);
19205+ self.unsafety.hash(state);
19206+ self.abi.hash(state);
19207+ self.inputs.hash(state);
19208+ self.variadic.hash(state);
19209+ self.output.hash(state);
19210+ }
19211+}
19212+#[cfg(any(feature = "derive", feature = "full"))]
19213+impl Hash for TypeGroup {
19214+ fn hash<H>(&self, state: &mut H)
19215+ where
19216+ H: Hasher,
19217+ {
19218+ self.elem.hash(state);
19219+ }
19220+}
19221+#[cfg(any(feature = "derive", feature = "full"))]
19222+impl Hash for TypeImplTrait {
19223+ fn hash<H>(&self, state: &mut H)
19224+ where
19225+ H: Hasher,
19226+ {
19227+ self.bounds.hash(state);
19228+ }
19229+}
19230+#[cfg(any(feature = "derive", feature = "full"))]
19231+impl Hash for TypeInfer {
19232+ fn hash<H>(&self, _state: &mut H)
19233+ where
19234+ H: Hasher,
19235+ {
19236+ }
19237+}
19238+#[cfg(any(feature = "derive", feature = "full"))]
19239+impl Hash for TypeMacro {
19240+ fn hash<H>(&self, state: &mut H)
19241+ where
19242+ H: Hasher,
19243+ {
19244+ self.mac.hash(state);
19245+ }
19246+}
19247+#[cfg(any(feature = "derive", feature = "full"))]
19248+impl Hash for TypeNever {
19249+ fn hash<H>(&self, _state: &mut H)
19250+ where
19251+ H: Hasher,
19252+ {
19253+ }
19254+}
19255+#[cfg(any(feature = "derive", feature = "full"))]
19256+impl Hash for TypeParam {
19257+ fn hash<H>(&self, state: &mut H)
19258+ where
19259+ H: Hasher,
19260+ {
19261+ self.attrs.hash(state);
19262+ self.ident.hash(state);
19263+ self.colon_token.hash(state);
19264+ self.bounds.hash(state);
19265+ self.eq_token.hash(state);
19266+ self.default.hash(state);
19267+ }
19268+}
19269+#[cfg(any(feature = "derive", feature = "full"))]
19270+impl Hash for TypeParamBound {
19271+ fn hash<H>(&self, state: &mut H)
19272+ where
19273+ H: Hasher,
19274+ {
19275+ match self {
19276+ TypeParamBound::Trait(v0) => {
19277+ state.write_u8(0u8);
19278+ v0.hash(state);
19279+ }
19280+ TypeParamBound::Lifetime(v0) => {
19281+ state.write_u8(1u8);
19282+ v0.hash(state);
19283+ }
19284+ }
19285+ }
19286+}
19287+#[cfg(any(feature = "derive", feature = "full"))]
19288+impl Hash for TypeParen {
19289+ fn hash<H>(&self, state: &mut H)
19290+ where
19291+ H: Hasher,
19292+ {
19293+ self.elem.hash(state);
19294+ }
19295+}
19296+#[cfg(any(feature = "derive", feature = "full"))]
19297+impl Hash for TypePath {
19298+ fn hash<H>(&self, state: &mut H)
19299+ where
19300+ H: Hasher,
19301+ {
19302+ self.qself.hash(state);
19303+ self.path.hash(state);
19304+ }
19305+}
19306+#[cfg(any(feature = "derive", feature = "full"))]
19307+impl Hash for TypePtr {
19308+ fn hash<H>(&self, state: &mut H)
19309+ where
19310+ H: Hasher,
19311+ {
19312+ self.const_token.hash(state);
19313+ self.mutability.hash(state);
19314+ self.elem.hash(state);
19315+ }
19316+}
19317+#[cfg(any(feature = "derive", feature = "full"))]
19318+impl Hash for TypeReference {
19319+ fn hash<H>(&self, state: &mut H)
19320+ where
19321+ H: Hasher,
19322+ {
19323+ self.lifetime.hash(state);
19324+ self.mutability.hash(state);
19325+ self.elem.hash(state);
19326+ }
19327+}
19328+#[cfg(any(feature = "derive", feature = "full"))]
19329+impl Hash for TypeSlice {
19330+ fn hash<H>(&self, state: &mut H)
19331+ where
19332+ H: Hasher,
19333+ {
19334+ self.elem.hash(state);
19335+ }
19336+}
19337+#[cfg(any(feature = "derive", feature = "full"))]
19338+impl Hash for TypeTraitObject {
19339+ fn hash<H>(&self, state: &mut H)
19340+ where
19341+ H: Hasher,
19342+ {
19343+ self.dyn_token.hash(state);
19344+ self.bounds.hash(state);
19345+ }
19346+}
19347+#[cfg(any(feature = "derive", feature = "full"))]
19348+impl Hash for TypeTuple {
19349+ fn hash<H>(&self, state: &mut H)
19350+ where
19351+ H: Hasher,
19352+ {
19353+ self.elems.hash(state);
19354+ }
19355+}
19356+#[cfg(any(feature = "derive", feature = "full"))]
19357+impl Hash for UnOp {
19358+ fn hash<H>(&self, state: &mut H)
19359+ where
19360+ H: Hasher,
19361+ {
19362+ match self {
19363+ UnOp::Deref(_) => {
19364+ state.write_u8(0u8);
19365+ }
19366+ UnOp::Not(_) => {
19367+ state.write_u8(1u8);
19368+ }
19369+ UnOp::Neg(_) => {
19370+ state.write_u8(2u8);
19371+ }
19372+ }
19373+ }
19374+}
19375+#[cfg(feature = "full")]
19376+impl Hash for UseGlob {
19377+ fn hash<H>(&self, _state: &mut H)
19378+ where
19379+ H: Hasher,
19380+ {
19381+ }
19382+}
19383+#[cfg(feature = "full")]
19384+impl Hash for UseGroup {
19385+ fn hash<H>(&self, state: &mut H)
19386+ where
19387+ H: Hasher,
19388+ {
19389+ self.items.hash(state);
19390+ }
19391+}
19392+#[cfg(feature = "full")]
19393+impl Hash for UseName {
19394+ fn hash<H>(&self, state: &mut H)
19395+ where
19396+ H: Hasher,
19397+ {
19398+ self.ident.hash(state);
19399+ }
19400+}
19401+#[cfg(feature = "full")]
19402+impl Hash for UsePath {
19403+ fn hash<H>(&self, state: &mut H)
19404+ where
19405+ H: Hasher,
19406+ {
19407+ self.ident.hash(state);
19408+ self.tree.hash(state);
19409+ }
19410+}
19411+#[cfg(feature = "full")]
19412+impl Hash for UseRename {
19413+ fn hash<H>(&self, state: &mut H)
19414+ where
19415+ H: Hasher,
19416+ {
19417+ self.ident.hash(state);
19418+ self.rename.hash(state);
19419+ }
19420+}
19421+#[cfg(feature = "full")]
19422+impl Hash for UseTree {
19423+ fn hash<H>(&self, state: &mut H)
19424+ where
19425+ H: Hasher,
19426+ {
19427+ match self {
19428+ UseTree::Path(v0) => {
19429+ state.write_u8(0u8);
19430+ v0.hash(state);
19431+ }
19432+ UseTree::Name(v0) => {
19433+ state.write_u8(1u8);
19434+ v0.hash(state);
19435+ }
19436+ UseTree::Rename(v0) => {
19437+ state.write_u8(2u8);
19438+ v0.hash(state);
19439+ }
19440+ UseTree::Glob(v0) => {
19441+ state.write_u8(3u8);
19442+ v0.hash(state);
19443+ }
19444+ UseTree::Group(v0) => {
19445+ state.write_u8(4u8);
19446+ v0.hash(state);
19447+ }
19448+ }
19449+ }
19450+}
19451+#[cfg(any(feature = "derive", feature = "full"))]
19452+impl Hash for Variadic {
19453+ fn hash<H>(&self, state: &mut H)
19454+ where
19455+ H: Hasher,
19456+ {
19457+ self.attrs.hash(state);
19458+ }
19459+}
19460+#[cfg(any(feature = "derive", feature = "full"))]
19461+impl Hash for Variant {
19462+ fn hash<H>(&self, state: &mut H)
19463+ where
19464+ H: Hasher,
19465+ {
19466+ self.attrs.hash(state);
19467+ self.ident.hash(state);
19468+ self.fields.hash(state);
19469+ self.discriminant.hash(state);
19470+ }
19471+}
19472+#[cfg(any(feature = "derive", feature = "full"))]
19473+impl Hash for VisCrate {
19474+ fn hash<H>(&self, _state: &mut H)
19475+ where
19476+ H: Hasher,
19477+ {
19478+ }
19479+}
19480+#[cfg(any(feature = "derive", feature = "full"))]
19481+impl Hash for VisPublic {
19482+ fn hash<H>(&self, _state: &mut H)
19483+ where
19484+ H: Hasher,
19485+ {
19486+ }
19487+}
19488+#[cfg(any(feature = "derive", feature = "full"))]
19489+impl Hash for VisRestricted {
19490+ fn hash<H>(&self, state: &mut H)
19491+ where
19492+ H: Hasher,
19493+ {
19494+ self.in_token.hash(state);
19495+ self.path.hash(state);
19496+ }
19497+}
19498+#[cfg(any(feature = "derive", feature = "full"))]
19499+impl Hash for Visibility {
19500+ fn hash<H>(&self, state: &mut H)
19501+ where
19502+ H: Hasher,
19503+ {
19504+ match self {
19505+ Visibility::Public(v0) => {
19506+ state.write_u8(0u8);
19507+ v0.hash(state);
19508+ }
19509+ Visibility::Crate(v0) => {
19510+ state.write_u8(1u8);
19511+ v0.hash(state);
19512+ }
19513+ Visibility::Restricted(v0) => {
19514+ state.write_u8(2u8);
19515+ v0.hash(state);
19516+ }
19517+ Visibility::Inherited => {
19518+ state.write_u8(3u8);
19519+ }
19520+ }
19521+ }
19522+}
19523+#[cfg(any(feature = "derive", feature = "full"))]
19524+impl Hash for WhereClause {
19525+ fn hash<H>(&self, state: &mut H)
19526+ where
19527+ H: Hasher,
19528+ {
19529+ self.predicates.hash(state);
19530+ }
19531+}
19532+#[cfg(any(feature = "derive", feature = "full"))]
19533+impl Hash for WherePredicate {
19534+ fn hash<H>(&self, state: &mut H)
19535+ where
19536+ H: Hasher,
19537+ {
19538+ match self {
19539+ WherePredicate::Type(v0) => {
19540+ state.write_u8(0u8);
19541+ v0.hash(state);
19542+ }
19543+ WherePredicate::Lifetime(v0) => {
19544+ state.write_u8(1u8);
19545+ v0.hash(state);
19546+ }
19547+ WherePredicate::Eq(v0) => {
19548+ state.write_u8(2u8);
19549+ v0.hash(state);
19550+ }
19551+ }
19552+ }
19553+}
19554diff --git a/third_party/rust/syn/src/gen/visit.rs b/third_party/rust/syn/src/gen/visit.rs
19555--- a/third_party/rust/syn/src/gen/visit.rs
19556+++ b/third_party/rust/syn/src/gen/visit.rs
19557@@ -15,27 +15,26 @@ macro_rules! full {
19558 };
19559 }
19560 #[cfg(all(feature = "derive", not(feature = "full")))]
19561 macro_rules! full {
19562 ($e:expr) => {
19563 unreachable!()
19564 };
19565 }
19566-#[cfg(any(feature = "full", feature = "derive"))]
19567 macro_rules! skip {
19568 ($($tt:tt)*) => {};
19569 }
19570 /// Syntax tree traversal to walk a shared borrow of a syntax tree.
19571 ///
19572 /// See the [module documentation] for details.
19573 ///
19574 /// [module documentation]: self
19575 ///
19576-/// *This trait is available if Syn is built with the `"visit"` feature.*
19577+/// *This trait is available only if Syn is built with the `"visit"` feature.*
19578 pub trait Visit<'ast> {
19579 #[cfg(any(feature = "derive", feature = "full"))]
19580 fn visit_abi(&mut self, i: &'ast Abi) {
19581 visit_abi(self, i)
19582 }
19583 #[cfg(any(feature = "derive", feature = "full"))]
19584 fn visit_angle_bracketed_generic_arguments(&mut self, i: &'ast AngleBracketedGenericArguments) {
19585 visit_angle_bracketed_generic_arguments(self, i)
19586@@ -429,45 +428,37 @@ pub trait Visit<'ast> {
19587 }
19588 fn visit_lifetime(&mut self, i: &'ast Lifetime) {
19589 visit_lifetime(self, i)
19590 }
19591 #[cfg(any(feature = "derive", feature = "full"))]
19592 fn visit_lifetime_def(&mut self, i: &'ast LifetimeDef) {
19593 visit_lifetime_def(self, i)
19594 }
19595- #[cfg(any(feature = "derive", feature = "full"))]
19596 fn visit_lit(&mut self, i: &'ast Lit) {
19597 visit_lit(self, i)
19598 }
19599- #[cfg(any(feature = "derive", feature = "full"))]
19600 fn visit_lit_bool(&mut self, i: &'ast LitBool) {
19601 visit_lit_bool(self, i)
19602 }
19603- #[cfg(any(feature = "derive", feature = "full"))]
19604 fn visit_lit_byte(&mut self, i: &'ast LitByte) {
19605 visit_lit_byte(self, i)
19606 }
19607- #[cfg(any(feature = "derive", feature = "full"))]
19608 fn visit_lit_byte_str(&mut self, i: &'ast LitByteStr) {
19609 visit_lit_byte_str(self, i)
19610 }
19611- #[cfg(any(feature = "derive", feature = "full"))]
19612 fn visit_lit_char(&mut self, i: &'ast LitChar) {
19613 visit_lit_char(self, i)
19614 }
19615- #[cfg(any(feature = "derive", feature = "full"))]
19616 fn visit_lit_float(&mut self, i: &'ast LitFloat) {
19617 visit_lit_float(self, i)
19618 }
19619- #[cfg(any(feature = "derive", feature = "full"))]
19620 fn visit_lit_int(&mut self, i: &'ast LitInt) {
19621 visit_lit_int(self, i)
19622 }
19623- #[cfg(any(feature = "derive", feature = "full"))]
19624 fn visit_lit_str(&mut self, i: &'ast LitStr) {
19625 visit_lit_str(self, i)
19626 }
19627 #[cfg(feature = "full")]
19628 fn visit_local(&mut self, i: &'ast Local) {
19629 visit_local(self, i)
19630 }
19631 #[cfg(any(feature = "derive", feature = "full"))]
19632@@ -2532,17 +2523,16 @@ where
19633 for el in Punctuated::pairs(&node.bounds) {
19634 let (it, p) = el.into_tuple();
19635 v.visit_lifetime(it);
19636 if let Some(p) = p {
19637 tokens_helper(v, &p.spans);
19638 }
19639 }
19640 }
19641-#[cfg(any(feature = "derive", feature = "full"))]
19642 pub fn visit_lit<'ast, V>(v: &mut V, node: &'ast Lit)
19643 where
19644 V: Visit<'ast> + ?Sized,
19645 {
19646 match node {
19647 Lit::Str(_binding_0) => {
19648 v.visit_lit_str(_binding_0);
19649 }
19650@@ -2564,55 +2554,48 @@ where
19651 Lit::Bool(_binding_0) => {
19652 v.visit_lit_bool(_binding_0);
19653 }
19654 Lit::Verbatim(_binding_0) => {
19655 skip!(_binding_0);
19656 }
19657 }
19658 }
19659-#[cfg(any(feature = "derive", feature = "full"))]
19660 pub fn visit_lit_bool<'ast, V>(v: &mut V, node: &'ast LitBool)
19661 where
19662 V: Visit<'ast> + ?Sized,
19663 {
19664 skip!(node.value);
19665 v.visit_span(&node.span);
19666 }
19667-#[cfg(any(feature = "derive", feature = "full"))]
19668 pub fn visit_lit_byte<'ast, V>(v: &mut V, node: &'ast LitByte)
19669 where
19670 V: Visit<'ast> + ?Sized,
19671 {
19672 }
19673-#[cfg(any(feature = "derive", feature = "full"))]
19674 pub fn visit_lit_byte_str<'ast, V>(v: &mut V, node: &'ast LitByteStr)
19675 where
19676 V: Visit<'ast> + ?Sized,
19677 {
19678 }
19679-#[cfg(any(feature = "derive", feature = "full"))]
19680 pub fn visit_lit_char<'ast, V>(v: &mut V, node: &'ast LitChar)
19681 where
19682 V: Visit<'ast> + ?Sized,
19683 {
19684 }
19685-#[cfg(any(feature = "derive", feature = "full"))]
19686 pub fn visit_lit_float<'ast, V>(v: &mut V, node: &'ast LitFloat)
19687 where
19688 V: Visit<'ast> + ?Sized,
19689 {
19690 }
19691-#[cfg(any(feature = "derive", feature = "full"))]
19692 pub fn visit_lit_int<'ast, V>(v: &mut V, node: &'ast LitInt)
19693 where
19694 V: Visit<'ast> + ?Sized,
19695 {
19696 }
19697-#[cfg(any(feature = "derive", feature = "full"))]
19698 pub fn visit_lit_str<'ast, V>(v: &mut V, node: &'ast LitStr)
19699 where
19700 V: Visit<'ast> + ?Sized,
19701 {
19702 }
19703 #[cfg(feature = "full")]
19704 pub fn visit_local<'ast, V>(v: &mut V, node: &'ast Local)
19705 where
19706diff --git a/third_party/rust/syn/src/gen/visit_mut.rs b/third_party/rust/syn/src/gen/visit_mut.rs
19707--- a/third_party/rust/syn/src/gen/visit_mut.rs
19708+++ b/third_party/rust/syn/src/gen/visit_mut.rs
19709@@ -15,28 +15,27 @@ macro_rules! full {
19710 };
19711 }
19712 #[cfg(all(feature = "derive", not(feature = "full")))]
19713 macro_rules! full {
19714 ($e:expr) => {
19715 unreachable!()
19716 };
19717 }
19718-#[cfg(any(feature = "full", feature = "derive"))]
19719 macro_rules! skip {
19720 ($($tt:tt)*) => {};
19721 }
19722 /// Syntax tree traversal to mutate an exclusive borrow of a syntax tree in
19723 /// place.
19724 ///
19725 /// See the [module documentation] for details.
19726 ///
19727 /// [module documentation]: self
19728 ///
19729-/// *This trait is available if Syn is built with the `"visit-mut"` feature.*
19730+/// *This trait is available only if Syn is built with the `"visit-mut"` feature.*
19731 pub trait VisitMut {
19732 #[cfg(any(feature = "derive", feature = "full"))]
19733 fn visit_abi_mut(&mut self, i: &mut Abi) {
19734 visit_abi_mut(self, i)
19735 }
19736 #[cfg(any(feature = "derive", feature = "full"))]
19737 fn visit_angle_bracketed_generic_arguments_mut(
19738 &mut self,
19739@@ -433,45 +432,37 @@ pub trait VisitMut {
19740 }
19741 fn visit_lifetime_mut(&mut self, i: &mut Lifetime) {
19742 visit_lifetime_mut(self, i)
19743 }
19744 #[cfg(any(feature = "derive", feature = "full"))]
19745 fn visit_lifetime_def_mut(&mut self, i: &mut LifetimeDef) {
19746 visit_lifetime_def_mut(self, i)
19747 }
19748- #[cfg(any(feature = "derive", feature = "full"))]
19749 fn visit_lit_mut(&mut self, i: &mut Lit) {
19750 visit_lit_mut(self, i)
19751 }
19752- #[cfg(any(feature = "derive", feature = "full"))]
19753 fn visit_lit_bool_mut(&mut self, i: &mut LitBool) {
19754 visit_lit_bool_mut(self, i)
19755 }
19756- #[cfg(any(feature = "derive", feature = "full"))]
19757 fn visit_lit_byte_mut(&mut self, i: &mut LitByte) {
19758 visit_lit_byte_mut(self, i)
19759 }
19760- #[cfg(any(feature = "derive", feature = "full"))]
19761 fn visit_lit_byte_str_mut(&mut self, i: &mut LitByteStr) {
19762 visit_lit_byte_str_mut(self, i)
19763 }
19764- #[cfg(any(feature = "derive", feature = "full"))]
19765 fn visit_lit_char_mut(&mut self, i: &mut LitChar) {
19766 visit_lit_char_mut(self, i)
19767 }
19768- #[cfg(any(feature = "derive", feature = "full"))]
19769 fn visit_lit_float_mut(&mut self, i: &mut LitFloat) {
19770 visit_lit_float_mut(self, i)
19771 }
19772- #[cfg(any(feature = "derive", feature = "full"))]
19773 fn visit_lit_int_mut(&mut self, i: &mut LitInt) {
19774 visit_lit_int_mut(self, i)
19775 }
19776- #[cfg(any(feature = "derive", feature = "full"))]
19777 fn visit_lit_str_mut(&mut self, i: &mut LitStr) {
19778 visit_lit_str_mut(self, i)
19779 }
19780 #[cfg(feature = "full")]
19781 fn visit_local_mut(&mut self, i: &mut Local) {
19782 visit_local_mut(self, i)
19783 }
19784 #[cfg(any(feature = "derive", feature = "full"))]
19785@@ -2538,17 +2529,16 @@ where
19786 for el in Punctuated::pairs_mut(&mut node.bounds) {
19787 let (it, p) = el.into_tuple();
19788 v.visit_lifetime_mut(it);
19789 if let Some(p) = p {
19790 tokens_helper(v, &mut p.spans);
19791 }
19792 }
19793 }
19794-#[cfg(any(feature = "derive", feature = "full"))]
19795 pub fn visit_lit_mut<V>(v: &mut V, node: &mut Lit)
19796 where
19797 V: VisitMut + ?Sized,
19798 {
19799 match node {
19800 Lit::Str(_binding_0) => {
19801 v.visit_lit_str_mut(_binding_0);
19802 }
19803@@ -2570,55 +2560,48 @@ where
19804 Lit::Bool(_binding_0) => {
19805 v.visit_lit_bool_mut(_binding_0);
19806 }
19807 Lit::Verbatim(_binding_0) => {
19808 skip!(_binding_0);
19809 }
19810 }
19811 }
19812-#[cfg(any(feature = "derive", feature = "full"))]
19813 pub fn visit_lit_bool_mut<V>(v: &mut V, node: &mut LitBool)
19814 where
19815 V: VisitMut + ?Sized,
19816 {
19817 skip!(node.value);
19818 v.visit_span_mut(&mut node.span);
19819 }
19820-#[cfg(any(feature = "derive", feature = "full"))]
19821 pub fn visit_lit_byte_mut<V>(v: &mut V, node: &mut LitByte)
19822 where
19823 V: VisitMut + ?Sized,
19824 {
19825 }
19826-#[cfg(any(feature = "derive", feature = "full"))]
19827 pub fn visit_lit_byte_str_mut<V>(v: &mut V, node: &mut LitByteStr)
19828 where
19829 V: VisitMut + ?Sized,
19830 {
19831 }
19832-#[cfg(any(feature = "derive", feature = "full"))]
19833 pub fn visit_lit_char_mut<V>(v: &mut V, node: &mut LitChar)
19834 where
19835 V: VisitMut + ?Sized,
19836 {
19837 }
19838-#[cfg(any(feature = "derive", feature = "full"))]
19839 pub fn visit_lit_float_mut<V>(v: &mut V, node: &mut LitFloat)
19840 where
19841 V: VisitMut + ?Sized,
19842 {
19843 }
19844-#[cfg(any(feature = "derive", feature = "full"))]
19845 pub fn visit_lit_int_mut<V>(v: &mut V, node: &mut LitInt)
19846 where
19847 V: VisitMut + ?Sized,
19848 {
19849 }
19850-#[cfg(any(feature = "derive", feature = "full"))]
19851 pub fn visit_lit_str_mut<V>(v: &mut V, node: &mut LitStr)
19852 where
19853 V: VisitMut + ?Sized,
19854 {
19855 }
19856 #[cfg(feature = "full")]
19857 pub fn visit_local_mut<V>(v: &mut V, node: &mut Local)
19858 where
19859diff --git a/third_party/rust/syn/src/generics.rs b/third_party/rust/syn/src/generics.rs
19860--- a/third_party/rust/syn/src/generics.rs
19861+++ b/third_party/rust/syn/src/generics.rs
19862@@ -1,97 +1,108 @@
19863 use super::*;
19864 use crate::punctuated::{Iter, IterMut, Punctuated};
19865+#[cfg(all(feature = "printing", feature = "extra-traits"))]
19866+use std::fmt::{self, Debug};
19867+#[cfg(all(feature = "printing", feature = "extra-traits"))]
19868+use std::hash::{Hash, Hasher};
19869
19870 ast_struct! {
19871 /// Lifetimes and type parameters attached to a declaration of a function,
19872 /// enum, trait, etc.
19873 ///
19874- /// *This type is available if Syn is built with the `"derive"` or `"full"`
19875+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
19876 /// feature.*
19877- #[derive(Default)]
19878 pub struct Generics {
19879 pub lt_token: Option<Token![<]>,
19880 pub params: Punctuated<GenericParam, Token![,]>,
19881 pub gt_token: Option<Token![>]>,
19882 pub where_clause: Option<WhereClause>,
19883 }
19884 }
19885
19886 ast_enum_of_structs! {
19887 /// A generic type parameter, lifetime, or const generic: `T: Into<String>`,
19888 /// `'a: 'b`, `const LEN: usize`.
19889 ///
19890- /// *This type is available if Syn is built with the `"derive"` or `"full"`
19891+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
19892 /// feature.*
19893 ///
19894 /// # Syntax tree enum
19895 ///
19896 /// This type is a [syntax tree enum].
19897 ///
19898 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
19899- //
19900- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
19901- // blocked on https://github.com/rust-lang/rust/issues/62833
19902 pub enum GenericParam {
19903 /// A generic type parameter: `T: Into<String>`.
19904 Type(TypeParam),
19905
19906 /// A lifetime definition: `'a: 'b + 'c + 'd`.
19907 Lifetime(LifetimeDef),
19908
19909 /// A const generic parameter: `const LENGTH: usize`.
19910 Const(ConstParam),
19911 }
19912 }
19913
19914 ast_struct! {
19915 /// A generic type parameter: `T: Into<String>`.
19916 ///
19917- /// *This type is available if Syn is built with the `"derive"` or
19918+ /// *This type is available only if Syn is built with the `"derive"` or
19919 /// `"full"` feature.*
19920 pub struct TypeParam {
19921 pub attrs: Vec<Attribute>,
19922 pub ident: Ident,
19923 pub colon_token: Option<Token![:]>,
19924 pub bounds: Punctuated<TypeParamBound, Token![+]>,
19925 pub eq_token: Option<Token![=]>,
19926 pub default: Option<Type>,
19927 }
19928 }
19929
19930 ast_struct! {
19931 /// A lifetime definition: `'a: 'b + 'c + 'd`.
19932 ///
19933- /// *This type is available if Syn is built with the `"derive"` or
19934+ /// *This type is available only if Syn is built with the `"derive"` or
19935 /// `"full"` feature.*
19936 pub struct LifetimeDef {
19937 pub attrs: Vec<Attribute>,
19938 pub lifetime: Lifetime,
19939 pub colon_token: Option<Token![:]>,
19940 pub bounds: Punctuated<Lifetime, Token![+]>,
19941 }
19942 }
19943
19944 ast_struct! {
19945 /// A const generic parameter: `const LENGTH: usize`.
19946 ///
19947- /// *This type is available if Syn is built with the `"derive"` or
19948+ /// *This type is available only if Syn is built with the `"derive"` or
19949 /// `"full"` feature.*
19950 pub struct ConstParam {
19951 pub attrs: Vec<Attribute>,
19952 pub const_token: Token![const],
19953 pub ident: Ident,
19954 pub colon_token: Token![:],
19955 pub ty: Type,
19956 pub eq_token: Option<Token![=]>,
19957 pub default: Option<Expr>,
19958 }
19959 }
19960
19961+impl Default for Generics {
19962+ fn default() -> Self {
19963+ Generics {
19964+ lt_token: None,
19965+ params: Punctuated::new(),
19966+ gt_token: None,
19967+ where_clause: None,
19968+ }
19969+ }
19970+}
19971+
19972 impl Generics {
19973 /// Returns an
19974 /// <code
19975 /// style="padding-right:0;">Iterator&lt;Item = &amp;</code><a
19976 /// href="struct.TypeParam.html"><code
19977 /// style="padding-left:0;padding-right:0;">TypeParam</code></a><code
19978 /// style="padding-left:0;">&gt;</code>
19979 /// over the type parameters in `self.params`.
19980@@ -275,100 +286,148 @@ impl<'a> Iterator for ConstParamsMut<'a>
19981 } else {
19982 self.next()
19983 }
19984 }
19985 }
19986
19987 /// Returned by `Generics::split_for_impl`.
19988 ///
19989-/// *This type is available if Syn is built with the `"derive"` or `"full"`
19990+/// *This type is available only if Syn is built with the `"derive"` or `"full"`
19991 /// feature and the `"printing"` feature.*
19992 #[cfg(feature = "printing")]
19993-#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
19994-#[cfg_attr(feature = "clone-impls", derive(Clone))]
19995 pub struct ImplGenerics<'a>(&'a Generics);
19996
19997 /// Returned by `Generics::split_for_impl`.
19998 ///
19999-/// *This type is available if Syn is built with the `"derive"` or `"full"`
20000+/// *This type is available only if Syn is built with the `"derive"` or `"full"`
20001 /// feature and the `"printing"` feature.*
20002 #[cfg(feature = "printing")]
20003-#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
20004-#[cfg_attr(feature = "clone-impls", derive(Clone))]
20005 pub struct TypeGenerics<'a>(&'a Generics);
20006
20007 /// Returned by `TypeGenerics::as_turbofish`.
20008 ///
20009-/// *This type is available if Syn is built with the `"derive"` or `"full"`
20010+/// *This type is available only if Syn is built with the `"derive"` or `"full"`
20011 /// feature and the `"printing"` feature.*
20012 #[cfg(feature = "printing")]
20013-#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
20014-#[cfg_attr(feature = "clone-impls", derive(Clone))]
20015 pub struct Turbofish<'a>(&'a Generics);
20016
20017 #[cfg(feature = "printing")]
20018 impl Generics {
20019 /// Split a type's generics into the pieces required for impl'ing a trait
20020 /// for that type.
20021 ///
20022 /// ```
20023 /// # use proc_macro2::{Span, Ident};
20024 /// # use quote::quote;
20025 /// #
20026- /// # fn main() {
20027- /// # let generics: syn::Generics = Default::default();
20028- /// # let name = Ident::new("MyType", Span::call_site());
20029+ /// # let generics: syn::Generics = Default::default();
20030+ /// # let name = Ident::new("MyType", Span::call_site());
20031 /// #
20032 /// let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
20033 /// quote! {
20034 /// impl #impl_generics MyTrait for #name #ty_generics #where_clause {
20035 /// // ...
20036 /// }
20037 /// }
20038- /// # ;
20039- /// # }
20040+ /// # ;
20041 /// ```
20042 ///
20043- /// *This method is available if Syn is built with the `"derive"` or
20044+ /// *This method is available only if Syn is built with the `"derive"` or
20045 /// `"full"` feature and the `"printing"` feature.*
20046 pub fn split_for_impl(&self) -> (ImplGenerics, TypeGenerics, Option<&WhereClause>) {
20047 (
20048 ImplGenerics(self),
20049 TypeGenerics(self),
20050 self.where_clause.as_ref(),
20051 )
20052 }
20053 }
20054
20055 #[cfg(feature = "printing")]
20056+macro_rules! generics_wrapper_impls {
20057+ ($ty:ident) => {
20058+ #[cfg(feature = "clone-impls")]
20059+ impl<'a> Clone for $ty<'a> {
20060+ fn clone(&self) -> Self {
20061+ $ty(self.0)
20062+ }
20063+ }
20064+
20065+ #[cfg(feature = "extra-traits")]
20066+ impl<'a> Debug for $ty<'a> {
20067+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
20068+ formatter
20069+ .debug_tuple(stringify!($ty))
20070+ .field(self.0)
20071+ .finish()
20072+ }
20073+ }
20074+
20075+ #[cfg(feature = "extra-traits")]
20076+ impl<'a> Eq for $ty<'a> {}
20077+
20078+ #[cfg(feature = "extra-traits")]
20079+ impl<'a> PartialEq for $ty<'a> {
20080+ fn eq(&self, other: &Self) -> bool {
20081+ self.0 == other.0
20082+ }
20083+ }
20084+
20085+ #[cfg(feature = "extra-traits")]
20086+ impl<'a> Hash for $ty<'a> {
20087+ fn hash<H: Hasher>(&self, state: &mut H) {
20088+ self.0.hash(state);
20089+ }
20090+ }
20091+ };
20092+}
20093+
20094+#[cfg(feature = "printing")]
20095+generics_wrapper_impls!(ImplGenerics);
20096+#[cfg(feature = "printing")]
20097+generics_wrapper_impls!(TypeGenerics);
20098+#[cfg(feature = "printing")]
20099+generics_wrapper_impls!(Turbofish);
20100+
20101+#[cfg(feature = "printing")]
20102 impl<'a> TypeGenerics<'a> {
20103 /// Turn a type's generics like `<X, Y>` into a turbofish like `::<X, Y>`.
20104 ///
20105- /// *This method is available if Syn is built with the `"derive"` or
20106+ /// *This method is available only if Syn is built with the `"derive"` or
20107 /// `"full"` feature and the `"printing"` feature.*
20108 pub fn as_turbofish(&self) -> Turbofish {
20109 Turbofish(self.0)
20110 }
20111 }
20112
20113 ast_struct! {
20114 /// A set of bound lifetimes: `for<'a, 'b, 'c>`.
20115 ///
20116- /// *This type is available if Syn is built with the `"derive"` or `"full"`
20117+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
20118 /// feature.*
20119- #[derive(Default)]
20120 pub struct BoundLifetimes {
20121 pub for_token: Token![for],
20122 pub lt_token: Token![<],
20123 pub lifetimes: Punctuated<LifetimeDef, Token![,]>,
20124 pub gt_token: Token![>],
20125 }
20126 }
20127
20128+impl Default for BoundLifetimes {
20129+ fn default() -> Self {
20130+ BoundLifetimes {
20131+ for_token: Default::default(),
20132+ lt_token: Default::default(),
20133+ lifetimes: Punctuated::new(),
20134+ gt_token: Default::default(),
20135+ }
20136+ }
20137+}
20138+
20139 impl LifetimeDef {
20140 pub fn new(lifetime: Lifetime) -> Self {
20141 LifetimeDef {
20142 attrs: Vec::new(),
20143 lifetime,
20144 colon_token: None,
20145 bounds: Punctuated::new(),
20146 }
20147@@ -386,122 +445,118 @@ impl From<Ident> for TypeParam {
20148 default: None,
20149 }
20150 }
20151 }
20152
20153 ast_enum_of_structs! {
20154 /// A trait or lifetime used as a bound on a type parameter.
20155 ///
20156- /// *This type is available if Syn is built with the `"derive"` or `"full"`
20157+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
20158 /// feature.*
20159 pub enum TypeParamBound {
20160 Trait(TraitBound),
20161 Lifetime(Lifetime),
20162 }
20163 }
20164
20165 ast_struct! {
20166 /// A trait used as a bound on a type parameter.
20167 ///
20168- /// *This type is available if Syn is built with the `"derive"` or `"full"`
20169+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
20170 /// feature.*
20171 pub struct TraitBound {
20172 pub paren_token: Option<token::Paren>,
20173 pub modifier: TraitBoundModifier,
20174 /// The `for<'a>` in `for<'a> Foo<&'a T>`
20175 pub lifetimes: Option<BoundLifetimes>,
20176 /// The `Foo<&'a T>` in `for<'a> Foo<&'a T>`
20177 pub path: Path,
20178 }
20179 }
20180
20181 ast_enum! {
20182 /// A modifier on a trait bound, currently only used for the `?` in
20183 /// `?Sized`.
20184 ///
20185- /// *This type is available if Syn is built with the `"derive"` or `"full"`
20186+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
20187 /// feature.*
20188- #[cfg_attr(feature = "clone-impls", derive(Copy))]
20189 pub enum TraitBoundModifier {
20190 None,
20191 Maybe(Token![?]),
20192 }
20193 }
20194
20195 ast_struct! {
20196 /// A `where` clause in a definition: `where T: Deserialize<'de>, D:
20197 /// 'static`.
20198 ///
20199- /// *This type is available if Syn is built with the `"derive"` or `"full"`
20200+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
20201 /// feature.*
20202 pub struct WhereClause {
20203 pub where_token: Token![where],
20204 pub predicates: Punctuated<WherePredicate, Token![,]>,
20205 }
20206 }
20207
20208 ast_enum_of_structs! {
20209 /// A single predicate in a `where` clause: `T: Deserialize<'de>`.
20210 ///
20211- /// *This type is available if Syn is built with the `"derive"` or `"full"`
20212+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
20213 /// feature.*
20214 ///
20215 /// # Syntax tree enum
20216 ///
20217 /// This type is a [syntax tree enum].
20218 ///
20219 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
20220- //
20221- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
20222- // blocked on https://github.com/rust-lang/rust/issues/62833
20223 pub enum WherePredicate {
20224 /// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`.
20225 Type(PredicateType),
20226
20227 /// A lifetime predicate in a `where` clause: `'a: 'b + 'c`.
20228 Lifetime(PredicateLifetime),
20229
20230 /// An equality predicate in a `where` clause (unsupported).
20231 Eq(PredicateEq),
20232 }
20233 }
20234
20235 ast_struct! {
20236 /// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`.
20237 ///
20238- /// *This type is available if Syn is built with the `"derive"` or
20239+ /// *This type is available only if Syn is built with the `"derive"` or
20240 /// `"full"` feature.*
20241 pub struct PredicateType {
20242 /// Any lifetimes from a `for` binding
20243 pub lifetimes: Option<BoundLifetimes>,
20244 /// The type being bounded
20245 pub bounded_ty: Type,
20246 pub colon_token: Token![:],
20247 /// Trait and lifetime bounds (`Clone+Send+'static`)
20248 pub bounds: Punctuated<TypeParamBound, Token![+]>,
20249 }
20250 }
20251
20252 ast_struct! {
20253 /// A lifetime predicate in a `where` clause: `'a: 'b + 'c`.
20254 ///
20255- /// *This type is available if Syn is built with the `"derive"` or
20256+ /// *This type is available only if Syn is built with the `"derive"` or
20257 /// `"full"` feature.*
20258 pub struct PredicateLifetime {
20259 pub lifetime: Lifetime,
20260 pub colon_token: Token![:],
20261 pub bounds: Punctuated<Lifetime, Token![+]>,
20262 }
20263 }
20264
20265 ast_struct! {
20266 /// An equality predicate in a `where` clause (unsupported).
20267 ///
20268- /// *This type is available if Syn is built with the `"derive"` or
20269+ /// *This type is available only if Syn is built with the `"derive"` or
20270 /// `"full"` feature.*
20271 pub struct PredicateEq {
20272 pub lhs_ty: Type,
20273 pub eq_token: Token![=],
20274 pub rhs_ty: Type,
20275 }
20276 }
20277
20278@@ -516,38 +571,36 @@ pub mod parsing {
20279 if !input.peek(Token![<]) {
20280 return Ok(Generics::default());
20281 }
20282
20283 let lt_token: Token![<] = input.parse()?;
20284
20285 let mut params = Punctuated::new();
20286 let mut allow_lifetime_param = true;
20287- let mut allow_type_param = true;
20288 loop {
20289 if input.peek(Token![>]) {
20290 break;
20291 }
20292
20293 let attrs = input.call(Attribute::parse_outer)?;
20294 let lookahead = input.lookahead1();
20295 if allow_lifetime_param && lookahead.peek(Lifetime) {
20296 params.push_value(GenericParam::Lifetime(LifetimeDef {
20297 attrs,
20298 ..input.parse()?
20299 }));
20300- } else if allow_type_param && lookahead.peek(Ident) {
20301+ } else if lookahead.peek(Ident) {
20302 allow_lifetime_param = false;
20303 params.push_value(GenericParam::Type(TypeParam {
20304 attrs,
20305 ..input.parse()?
20306 }));
20307 } else if lookahead.peek(Token![const]) {
20308 allow_lifetime_param = false;
20309- allow_type_param = false;
20310 params.push_value(GenericParam::Const(ConstParam {
20311 attrs,
20312 ..input.parse()?
20313 }));
20314 } else {
20315 return Err(lookahead.error());
20316 }
20317
20318@@ -660,67 +713,63 @@ pub mod parsing {
20319 } else {
20320 Ok(None)
20321 }
20322 }
20323 }
20324
20325 impl Parse for TypeParam {
20326 fn parse(input: ParseStream) -> Result<Self> {
20327- let has_colon;
20328- let has_default;
20329- Ok(TypeParam {
20330- attrs: input.call(Attribute::parse_outer)?,
20331- ident: input.parse()?,
20332- colon_token: {
20333- if input.peek(Token![:]) {
20334- has_colon = true;
20335- Some(input.parse()?)
20336- } else {
20337- has_colon = false;
20338- None
20339+ let attrs = input.call(Attribute::parse_outer)?;
20340+ let ident: Ident = input.parse()?;
20341+ let colon_token: Option<Token![:]> = input.parse()?;
20342+
20343+ let begin_bound = input.fork();
20344+ let mut is_maybe_const = false;
20345+ let mut bounds = Punctuated::new();
20346+ if colon_token.is_some() {
20347+ loop {
20348+ if input.peek(Token![,]) || input.peek(Token![>]) || input.peek(Token![=]) {
20349+ break;
20350+ }
20351+ if input.peek(Token![?]) && input.peek2(Token![const]) {
20352+ input.parse::<Token![?]>()?;
20353+ input.parse::<Token![const]>()?;
20354+ is_maybe_const = true;
20355+ }
20356+ let value: TypeParamBound = input.parse()?;
20357+ bounds.push_value(value);
20358+ if !input.peek(Token![+]) {
20359+ break;
20360 }
20361- },
20362- bounds: {
20363- let mut bounds = Punctuated::new();
20364- if has_colon {
20365- loop {
20366- if input.peek(Token![,])
20367- || input.peek(Token![>])
20368- || input.peek(Token![=])
20369- {
20370- break;
20371- }
20372- let value = input.parse()?;
20373- bounds.push_value(value);
20374- if !input.peek(Token![+]) {
20375- break;
20376- }
20377- let punct = input.parse()?;
20378- bounds.push_punct(punct);
20379- }
20380- }
20381- bounds
20382- },
20383- eq_token: {
20384- if input.peek(Token![=]) {
20385- has_default = true;
20386- Some(input.parse()?)
20387- } else {
20388- has_default = false;
20389- None
20390- }
20391- },
20392- default: {
20393- if has_default {
20394- Some(input.parse()?)
20395- } else {
20396- None
20397- }
20398- },
20399+ let punct: Token![+] = input.parse()?;
20400+ bounds.push_punct(punct);
20401+ }
20402+ }
20403+
20404+ let mut eq_token: Option<Token![=]> = input.parse()?;
20405+ let mut default = if eq_token.is_some() {
20406+ Some(input.parse::<Type>()?)
20407+ } else {
20408+ None
20409+ };
20410+
20411+ if is_maybe_const {
20412+ bounds.clear();
20413+ eq_token = None;
20414+ default = Some(Type::Verbatim(verbatim::between(begin_bound, input)));
20415+ }
20416+
20417+ Ok(TypeParam {
20418+ attrs,
20419+ ident,
20420+ colon_token,
20421+ bounds,
20422+ eq_token,
20423+ default,
20424 })
20425 }
20426 }
20427
20428 impl Parse for TypeParamBound {
20429 fn parse(input: ParseStream) -> Result<Self> {
20430 if input.peek(Lifetime) {
20431 return input.parse().map(TypeParamBound::Lifetime);
20432@@ -893,16 +942,18 @@ pub mod parsing {
20433 }
20434 }
20435
20436 #[cfg(feature = "printing")]
20437 mod printing {
20438 use super::*;
20439
20440 use proc_macro2::TokenStream;
20441+ #[cfg(feature = "full")]
20442+ use proc_macro2::TokenTree;
20443 use quote::{ToTokens, TokenStreamExt};
20444
20445 use crate::attr::FilterAttrs;
20446 use crate::print::TokensOrDefault;
20447
20448 impl ToTokens for Generics {
20449 fn to_tokens(&self, tokens: &mut TokenStream) {
20450 if self.params.is_empty() {
20451@@ -1075,19 +1126,35 @@ mod printing {
20452 impl ToTokens for TypeParam {
20453 fn to_tokens(&self, tokens: &mut TokenStream) {
20454 tokens.append_all(self.attrs.outer());
20455 self.ident.to_tokens(tokens);
20456 if !self.bounds.is_empty() {
20457 TokensOrDefault(&self.colon_token).to_tokens(tokens);
20458 self.bounds.to_tokens(tokens);
20459 }
20460- if self.default.is_some() {
20461+ if let Some(default) = &self.default {
20462+ #[cfg(feature = "full")]
20463+ {
20464+ if self.eq_token.is_none() {
20465+ if let Type::Verbatim(default) = default {
20466+ let mut iter = default.clone().into_iter();
20467+ match (iter.next(), iter.next()) {
20468+ (Some(TokenTree::Punct(ref q)), Some(TokenTree::Ident(ref c)))
20469+ if q.as_char() == '?' && c == "const" =>
20470+ {
20471+ return default.to_tokens(tokens);
20472+ }
20473+ _ => {}
20474+ }
20475+ }
20476+ }
20477+ }
20478 TokensOrDefault(&self.eq_token).to_tokens(tokens);
20479- self.default.to_tokens(tokens);
20480+ default.to_tokens(tokens);
20481 }
20482 }
20483 }
20484
20485 impl ToTokens for TraitBound {
20486 fn to_tokens(&self, tokens: &mut TokenStream) {
20487 let to_tokens = |tokens: &mut TokenStream| {
20488 self.modifier.to_tokens(tokens);
20489@@ -1112,19 +1179,19 @@ mod printing {
20490
20491 impl ToTokens for ConstParam {
20492 fn to_tokens(&self, tokens: &mut TokenStream) {
20493 tokens.append_all(self.attrs.outer());
20494 self.const_token.to_tokens(tokens);
20495 self.ident.to_tokens(tokens);
20496 self.colon_token.to_tokens(tokens);
20497 self.ty.to_tokens(tokens);
20498- if self.default.is_some() {
20499+ if let Some(default) = &self.default {
20500 TokensOrDefault(&self.eq_token).to_tokens(tokens);
20501- self.default.to_tokens(tokens);
20502+ default.to_tokens(tokens);
20503 }
20504 }
20505 }
20506
20507 impl ToTokens for WhereClause {
20508 fn to_tokens(&self, tokens: &mut TokenStream) {
20509 if !self.predicates.is_empty() {
20510 self.where_token.to_tokens(tokens);
20511diff --git a/third_party/rust/syn/src/item.rs b/third_party/rust/syn/src/item.rs
20512--- a/third_party/rust/syn/src/item.rs
20513+++ b/third_party/rust/syn/src/item.rs
20514@@ -1,32 +1,30 @@
20515 use super::*;
20516-use crate::derive::{Data, DeriveInput};
20517+use crate::derive::{Data, DataEnum, DataStruct, DataUnion, DeriveInput};
20518 use crate::punctuated::Punctuated;
20519 use proc_macro2::TokenStream;
20520
20521-#[cfg(feature = "extra-traits")]
20522-use crate::tt::TokenStreamHelper;
20523-#[cfg(feature = "extra-traits")]
20524-use std::hash::{Hash, Hasher};
20525+#[cfg(feature = "parsing")]
20526+use std::mem;
20527
20528 ast_enum_of_structs! {
20529 /// Things that can appear directly inside of a module or scope.
20530 ///
20531- /// *This type is available if Syn is built with the `"full"` feature.*
20532+ /// *This type is available only if Syn is built with the `"full"` feature.*
20533 ///
20534 /// # Syntax tree enum
20535 ///
20536 /// This type is a [syntax tree enum].
20537 ///
20538 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
20539 //
20540 // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
20541 // blocked on https://github.com/rust-lang/rust/issues/62833
20542- pub enum Item #manual_extra_traits {
20543+ pub enum Item {
20544 /// A constant item: `const MAX: u16 = 65535`.
20545 Const(ItemConst),
20546
20547 /// An enum definition: `enum Foo<A, B> { A(A), B(B) }`.
20548 Enum(ItemEnum),
20549
20550 /// An `extern crate` item: `extern crate serde`.
20551 ExternCrate(ItemExternCrate),
20552@@ -78,90 +76,90 @@ ast_enum_of_structs! {
20553 #[doc(hidden)]
20554 __Nonexhaustive,
20555 }
20556 }
20557
20558 ast_struct! {
20559 /// A constant item: `const MAX: u16 = 65535`.
20560 ///
20561- /// *This type is available if Syn is built with the `"full"` feature.*
20562+ /// *This type is available only if Syn is built with the `"full"` feature.*
20563 pub struct ItemConst {
20564 pub attrs: Vec<Attribute>,
20565 pub vis: Visibility,
20566 pub const_token: Token![const],
20567 pub ident: Ident,
20568 pub colon_token: Token![:],
20569 pub ty: Box<Type>,
20570 pub eq_token: Token![=],
20571 pub expr: Box<Expr>,
20572 pub semi_token: Token![;],
20573 }
20574 }
20575
20576 ast_struct! {
20577 /// An enum definition: `enum Foo<A, B> { A(A), B(B) }`.
20578 ///
20579- /// *This type is available if Syn is built with the `"full"` feature.*
20580+ /// *This type is available only if Syn is built with the `"full"` feature.*
20581 pub struct ItemEnum {
20582 pub attrs: Vec<Attribute>,
20583 pub vis: Visibility,
20584 pub enum_token: Token![enum],
20585 pub ident: Ident,
20586 pub generics: Generics,
20587 pub brace_token: token::Brace,
20588 pub variants: Punctuated<Variant, Token![,]>,
20589 }
20590 }
20591
20592 ast_struct! {
20593 /// An `extern crate` item: `extern crate serde`.
20594 ///
20595- /// *This type is available if Syn is built with the `"full"` feature.*
20596+ /// *This type is available only if Syn is built with the `"full"` feature.*
20597 pub struct ItemExternCrate {
20598 pub attrs: Vec<Attribute>,
20599 pub vis: Visibility,
20600 pub extern_token: Token![extern],
20601 pub crate_token: Token![crate],
20602 pub ident: Ident,
20603 pub rename: Option<(Token![as], Ident)>,
20604 pub semi_token: Token![;],
20605 }
20606 }
20607
20608 ast_struct! {
20609 /// A free-standing function: `fn process(n: usize) -> Result<()> { ...
20610 /// }`.
20611 ///
20612- /// *This type is available if Syn is built with the `"full"` feature.*
20613+ /// *This type is available only if Syn is built with the `"full"` feature.*
20614 pub struct ItemFn {
20615 pub attrs: Vec<Attribute>,
20616 pub vis: Visibility,
20617 pub sig: Signature,
20618 pub block: Box<Block>,
20619 }
20620 }
20621
20622 ast_struct! {
20623 /// A block of foreign items: `extern "C" { ... }`.
20624 ///
20625- /// *This type is available if Syn is built with the `"full"` feature.*
20626+ /// *This type is available only if Syn is built with the `"full"` feature.*
20627 pub struct ItemForeignMod {
20628 pub attrs: Vec<Attribute>,
20629 pub abi: Abi,
20630 pub brace_token: token::Brace,
20631 pub items: Vec<ForeignItem>,
20632 }
20633 }
20634
20635 ast_struct! {
20636 /// An impl block providing trait or associated items: `impl<A> Trait
20637 /// for Data<A> { ... }`.
20638 ///
20639- /// *This type is available if Syn is built with the `"full"` feature.*
20640+ /// *This type is available only if Syn is built with the `"full"` feature.*
20641 pub struct ItemImpl {
20642 pub attrs: Vec<Attribute>,
20643 pub defaultness: Option<Token![default]>,
20644 pub unsafety: Option<Token![unsafe]>,
20645 pub impl_token: Token![impl],
20646 pub generics: Generics,
20647 /// Trait this impl implements.
20648 pub trait_: Option<(Option<Token![!]>, Path, Token![for])>,
20649@@ -170,57 +168,57 @@ ast_struct! {
20650 pub brace_token: token::Brace,
20651 pub items: Vec<ImplItem>,
20652 }
20653 }
20654
20655 ast_struct! {
20656 /// A macro invocation, which includes `macro_rules!` definitions.
20657 ///
20658- /// *This type is available if Syn is built with the `"full"` feature.*
20659+ /// *This type is available only if Syn is built with the `"full"` feature.*
20660 pub struct ItemMacro {
20661 pub attrs: Vec<Attribute>,
20662 /// The `example` in `macro_rules! example { ... }`.
20663 pub ident: Option<Ident>,
20664 pub mac: Macro,
20665 pub semi_token: Option<Token![;]>,
20666 }
20667 }
20668
20669 ast_struct! {
20670 /// A 2.0-style declarative macro introduced by the `macro` keyword.
20671 ///
20672- /// *This type is available if Syn is built with the `"full"` feature.*
20673- pub struct ItemMacro2 #manual_extra_traits {
20674+ /// *This type is available only if Syn is built with the `"full"` feature.*
20675+ pub struct ItemMacro2 {
20676 pub attrs: Vec<Attribute>,
20677 pub vis: Visibility,
20678 pub macro_token: Token![macro],
20679 pub ident: Ident,
20680 pub rules: TokenStream,
20681 }
20682 }
20683
20684 ast_struct! {
20685 /// A module or module declaration: `mod m` or `mod m { ... }`.
20686 ///
20687- /// *This type is available if Syn is built with the `"full"` feature.*
20688+ /// *This type is available only if Syn is built with the `"full"` feature.*
20689 pub struct ItemMod {
20690 pub attrs: Vec<Attribute>,
20691 pub vis: Visibility,
20692 pub mod_token: Token![mod],
20693 pub ident: Ident,
20694 pub content: Option<(token::Brace, Vec<Item>)>,
20695 pub semi: Option<Token![;]>,
20696 }
20697 }
20698
20699 ast_struct! {
20700 /// A static item: `static BIKE: Shed = Shed(42)`.
20701 ///
20702- /// *This type is available if Syn is built with the `"full"` feature.*
20703+ /// *This type is available only if Syn is built with the `"full"` feature.*
20704 pub struct ItemStatic {
20705 pub attrs: Vec<Attribute>,
20706 pub vis: Visibility,
20707 pub static_token: Token![static],
20708 pub mutability: Option<Token![mut]>,
20709 pub ident: Ident,
20710 pub colon_token: Token![:],
20711 pub ty: Box<Type>,
20712@@ -228,32 +226,32 @@ ast_struct! {
20713 pub expr: Box<Expr>,
20714 pub semi_token: Token![;],
20715 }
20716 }
20717
20718 ast_struct! {
20719 /// A struct definition: `struct Foo<A> { x: A }`.
20720 ///
20721- /// *This type is available if Syn is built with the `"full"` feature.*
20722+ /// *This type is available only if Syn is built with the `"full"` feature.*
20723 pub struct ItemStruct {
20724 pub attrs: Vec<Attribute>,
20725 pub vis: Visibility,
20726 pub struct_token: Token![struct],
20727 pub ident: Ident,
20728 pub generics: Generics,
20729 pub fields: Fields,
20730 pub semi_token: Option<Token![;]>,
20731 }
20732 }
20733
20734 ast_struct! {
20735 /// A trait definition: `pub trait Iterator { ... }`.
20736 ///
20737- /// *This type is available if Syn is built with the `"full"` feature.*
20738+ /// *This type is available only if Syn is built with the `"full"` feature.*
20739 pub struct ItemTrait {
20740 pub attrs: Vec<Attribute>,
20741 pub vis: Visibility,
20742 pub unsafety: Option<Token![unsafe]>,
20743 pub auto_token: Option<Token![auto]>,
20744 pub trait_token: Token![trait],
20745 pub ident: Ident,
20746 pub generics: Generics,
20747@@ -262,212 +260,99 @@ ast_struct! {
20748 pub brace_token: token::Brace,
20749 pub items: Vec<TraitItem>,
20750 }
20751 }
20752
20753 ast_struct! {
20754 /// A trait alias: `pub trait SharableIterator = Iterator + Sync`.
20755 ///
20756- /// *This type is available if Syn is built with the `"full"` feature.*
20757+ /// *This type is available only if Syn is built with the `"full"` feature.*
20758 pub struct ItemTraitAlias {
20759 pub attrs: Vec<Attribute>,
20760 pub vis: Visibility,
20761 pub trait_token: Token![trait],
20762 pub ident: Ident,
20763 pub generics: Generics,
20764 pub eq_token: Token![=],
20765 pub bounds: Punctuated<TypeParamBound, Token![+]>,
20766 pub semi_token: Token![;],
20767 }
20768 }
20769
20770 ast_struct! {
20771 /// A type alias: `type Result<T> = std::result::Result<T, MyError>`.
20772 ///
20773- /// *This type is available if Syn is built with the `"full"` feature.*
20774+ /// *This type is available only if Syn is built with the `"full"` feature.*
20775 pub struct ItemType {
20776 pub attrs: Vec<Attribute>,
20777 pub vis: Visibility,
20778 pub type_token: Token![type],
20779 pub ident: Ident,
20780 pub generics: Generics,
20781 pub eq_token: Token![=],
20782 pub ty: Box<Type>,
20783 pub semi_token: Token![;],
20784 }
20785 }
20786
20787 ast_struct! {
20788 /// A union definition: `union Foo<A, B> { x: A, y: B }`.
20789 ///
20790- /// *This type is available if Syn is built with the `"full"` feature.*
20791+ /// *This type is available only if Syn is built with the `"full"` feature.*
20792 pub struct ItemUnion {
20793 pub attrs: Vec<Attribute>,
20794 pub vis: Visibility,
20795 pub union_token: Token![union],
20796 pub ident: Ident,
20797 pub generics: Generics,
20798 pub fields: FieldsNamed,
20799 }
20800 }
20801
20802 ast_struct! {
20803 /// A use declaration: `use std::collections::HashMap`.
20804 ///
20805- /// *This type is available if Syn is built with the `"full"` feature.*
20806+ /// *This type is available only if Syn is built with the `"full"` feature.*
20807 pub struct ItemUse {
20808 pub attrs: Vec<Attribute>,
20809 pub vis: Visibility,
20810 pub use_token: Token![use],
20811 pub leading_colon: Option<Token![::]>,
20812 pub tree: UseTree,
20813 pub semi_token: Token![;],
20814 }
20815 }
20816
20817-#[cfg(feature = "extra-traits")]
20818-impl Eq for Item {}
20819-
20820-#[cfg(feature = "extra-traits")]
20821-impl PartialEq for Item {
20822- fn eq(&self, other: &Self) -> bool {
20823- match (self, other) {
20824- (Item::Const(this), Item::Const(other)) => this == other,
20825- (Item::Enum(this), Item::Enum(other)) => this == other,
20826- (Item::ExternCrate(this), Item::ExternCrate(other)) => this == other,
20827- (Item::Fn(this), Item::Fn(other)) => this == other,
20828- (Item::ForeignMod(this), Item::ForeignMod(other)) => this == other,
20829- (Item::Impl(this), Item::Impl(other)) => this == other,
20830- (Item::Macro(this), Item::Macro(other)) => this == other,
20831- (Item::Macro2(this), Item::Macro2(other)) => this == other,
20832- (Item::Mod(this), Item::Mod(other)) => this == other,
20833- (Item::Static(this), Item::Static(other)) => this == other,
20834- (Item::Struct(this), Item::Struct(other)) => this == other,
20835- (Item::Trait(this), Item::Trait(other)) => this == other,
20836- (Item::TraitAlias(this), Item::TraitAlias(other)) => this == other,
20837- (Item::Type(this), Item::Type(other)) => this == other,
20838- (Item::Union(this), Item::Union(other)) => this == other,
20839- (Item::Use(this), Item::Use(other)) => this == other,
20840- (Item::Verbatim(this), Item::Verbatim(other)) => {
20841- TokenStreamHelper(this) == TokenStreamHelper(other)
20842- }
20843- _ => false,
20844- }
20845- }
20846-}
20847-
20848-#[cfg(feature = "extra-traits")]
20849-impl Hash for Item {
20850- fn hash<H>(&self, state: &mut H)
20851- where
20852- H: Hasher,
20853- {
20854+impl Item {
20855+ #[cfg(feature = "parsing")]
20856+ pub(crate) fn replace_attrs(&mut self, new: Vec<Attribute>) -> Vec<Attribute> {
20857 match self {
20858- Item::Const(item) => {
20859- state.write_u8(0);
20860- item.hash(state);
20861- }
20862- Item::Enum(item) => {
20863- state.write_u8(1);
20864- item.hash(state);
20865- }
20866- Item::ExternCrate(item) => {
20867- state.write_u8(2);
20868- item.hash(state);
20869- }
20870- Item::Fn(item) => {
20871- state.write_u8(3);
20872- item.hash(state);
20873- }
20874- Item::ForeignMod(item) => {
20875- state.write_u8(4);
20876- item.hash(state);
20877- }
20878- Item::Impl(item) => {
20879- state.write_u8(5);
20880- item.hash(state);
20881- }
20882- Item::Macro(item) => {
20883- state.write_u8(6);
20884- item.hash(state);
20885- }
20886- Item::Macro2(item) => {
20887- state.write_u8(7);
20888- item.hash(state);
20889- }
20890- Item::Mod(item) => {
20891- state.write_u8(8);
20892- item.hash(state);
20893- }
20894- Item::Static(item) => {
20895- state.write_u8(9);
20896- item.hash(state);
20897- }
20898- Item::Struct(item) => {
20899- state.write_u8(10);
20900- item.hash(state);
20901- }
20902- Item::Trait(item) => {
20903- state.write_u8(11);
20904- item.hash(state);
20905- }
20906- Item::TraitAlias(item) => {
20907- state.write_u8(12);
20908- item.hash(state);
20909- }
20910- Item::Type(item) => {
20911- state.write_u8(13);
20912- item.hash(state);
20913- }
20914- Item::Union(item) => {
20915- state.write_u8(14);
20916- item.hash(state);
20917- }
20918- Item::Use(item) => {
20919- state.write_u8(15);
20920- item.hash(state);
20921- }
20922- Item::Verbatim(item) => {
20923- state.write_u8(16);
20924- TokenStreamHelper(item).hash(state);
20925- }
20926+ Item::ExternCrate(ItemExternCrate { attrs, .. })
20927+ | Item::Use(ItemUse { attrs, .. })
20928+ | Item::Static(ItemStatic { attrs, .. })
20929+ | Item::Const(ItemConst { attrs, .. })
20930+ | Item::Fn(ItemFn { attrs, .. })
20931+ | Item::Mod(ItemMod { attrs, .. })
20932+ | Item::ForeignMod(ItemForeignMod { attrs, .. })
20933+ | Item::Type(ItemType { attrs, .. })
20934+ | Item::Struct(ItemStruct { attrs, .. })
20935+ | Item::Enum(ItemEnum { attrs, .. })
20936+ | Item::Union(ItemUnion { attrs, .. })
20937+ | Item::Trait(ItemTrait { attrs, .. })
20938+ | Item::TraitAlias(ItemTraitAlias { attrs, .. })
20939+ | Item::Impl(ItemImpl { attrs, .. })
20940+ | Item::Macro(ItemMacro { attrs, .. })
20941+ | Item::Macro2(ItemMacro2 { attrs, .. }) => mem::replace(attrs, new),
20942+ Item::Verbatim(_) => Vec::new(),
20943 Item::__Nonexhaustive => unreachable!(),
20944 }
20945 }
20946 }
20947
20948-#[cfg(feature = "extra-traits")]
20949-impl Eq for ItemMacro2 {}
20950-
20951-#[cfg(feature = "extra-traits")]
20952-impl PartialEq for ItemMacro2 {
20953- fn eq(&self, other: &Self) -> bool {
20954- self.attrs == other.attrs
20955- && self.vis == other.vis
20956- && self.macro_token == other.macro_token
20957- && self.ident == other.ident
20958- && TokenStreamHelper(&self.rules) == TokenStreamHelper(&other.rules)
20959- }
20960-}
20961-
20962-#[cfg(feature = "extra-traits")]
20963-impl Hash for ItemMacro2 {
20964- fn hash<H>(&self, state: &mut H)
20965- where
20966- H: Hasher,
20967- {
20968- self.attrs.hash(state);
20969- self.vis.hash(state);
20970- self.macro_token.hash(state);
20971- self.ident.hash(state);
20972- TokenStreamHelper(&self.rules).hash(state);
20973- }
20974-}
20975-
20976 impl From<DeriveInput> for Item {
20977 fn from(input: DeriveInput) -> Item {
20978 match input.data {
20979 Data::Struct(data) => Item::Struct(ItemStruct {
20980 attrs: input.attrs,
20981 vis: input.vis,
20982 struct_token: data.struct_token,
20983 ident: input.ident,
20984@@ -491,20 +376,67 @@ impl From<DeriveInput> for Item {
20985 ident: input.ident,
20986 generics: input.generics,
20987 fields: data.fields,
20988 }),
20989 }
20990 }
20991 }
20992
20993+impl From<ItemStruct> for DeriveInput {
20994+ fn from(input: ItemStruct) -> DeriveInput {
20995+ DeriveInput {
20996+ attrs: input.attrs,
20997+ vis: input.vis,
20998+ ident: input.ident,
20999+ generics: input.generics,
21000+ data: Data::Struct(DataStruct {
21001+ struct_token: input.struct_token,
21002+ fields: input.fields,
21003+ semi_token: input.semi_token,
21004+ }),
21005+ }
21006+ }
21007+}
21008+
21009+impl From<ItemEnum> for DeriveInput {
21010+ fn from(input: ItemEnum) -> DeriveInput {
21011+ DeriveInput {
21012+ attrs: input.attrs,
21013+ vis: input.vis,
21014+ ident: input.ident,
21015+ generics: input.generics,
21016+ data: Data::Enum(DataEnum {
21017+ enum_token: input.enum_token,
21018+ brace_token: input.brace_token,
21019+ variants: input.variants,
21020+ }),
21021+ }
21022+ }
21023+}
21024+
21025+impl From<ItemUnion> for DeriveInput {
21026+ fn from(input: ItemUnion) -> DeriveInput {
21027+ DeriveInput {
21028+ attrs: input.attrs,
21029+ vis: input.vis,
21030+ ident: input.ident,
21031+ generics: input.generics,
21032+ data: Data::Union(DataUnion {
21033+ union_token: input.union_token,
21034+ fields: input.fields,
21035+ }),
21036+ }
21037+ }
21038+}
21039+
21040 ast_enum_of_structs! {
21041 /// A suffix of an import tree in a `use` item: `Type as Renamed` or `*`.
21042 ///
21043- /// *This type is available if Syn is built with the `"full"` feature.*
21044+ /// *This type is available only if Syn is built with the `"full"` feature.*
21045 ///
21046 /// # Syntax tree enum
21047 ///
21048 /// This type is a [syntax tree enum].
21049 ///
21050 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
21051 //
21052 // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
21053@@ -525,77 +457,77 @@ ast_enum_of_structs! {
21054 /// A braced group of imports in a `use` item: `{A, B, C}`.
21055 Group(UseGroup),
21056 }
21057 }
21058
21059 ast_struct! {
21060 /// A path prefix of imports in a `use` item: `std::...`.
21061 ///
21062- /// *This type is available if Syn is built with the `"full"` feature.*
21063+ /// *This type is available only if Syn is built with the `"full"` feature.*
21064 pub struct UsePath {
21065 pub ident: Ident,
21066 pub colon2_token: Token![::],
21067 pub tree: Box<UseTree>,
21068 }
21069 }
21070
21071 ast_struct! {
21072 /// An identifier imported by a `use` item: `HashMap`.
21073 ///
21074- /// *This type is available if Syn is built with the `"full"` feature.*
21075+ /// *This type is available only if Syn is built with the `"full"` feature.*
21076 pub struct UseName {
21077 pub ident: Ident,
21078 }
21079 }
21080
21081 ast_struct! {
21082 /// An renamed identifier imported by a `use` item: `HashMap as Map`.
21083 ///
21084- /// *This type is available if Syn is built with the `"full"` feature.*
21085+ /// *This type is available only if Syn is built with the `"full"` feature.*
21086 pub struct UseRename {
21087 pub ident: Ident,
21088 pub as_token: Token![as],
21089 pub rename: Ident,
21090 }
21091 }
21092
21093 ast_struct! {
21094 /// A glob import in a `use` item: `*`.
21095 ///
21096- /// *This type is available if Syn is built with the `"full"` feature.*
21097+ /// *This type is available only if Syn is built with the `"full"` feature.*
21098 pub struct UseGlob {
21099 pub star_token: Token![*],
21100 }
21101 }
21102
21103 ast_struct! {
21104 /// A braced group of imports in a `use` item: `{A, B, C}`.
21105 ///
21106- /// *This type is available if Syn is built with the `"full"` feature.*
21107+ /// *This type is available only if Syn is built with the `"full"` feature.*
21108 pub struct UseGroup {
21109 pub brace_token: token::Brace,
21110 pub items: Punctuated<UseTree, Token![,]>,
21111 }
21112 }
21113
21114 ast_enum_of_structs! {
21115 /// An item within an `extern` block.
21116 ///
21117- /// *This type is available if Syn is built with the `"full"` feature.*
21118+ /// *This type is available only if Syn is built with the `"full"` feature.*
21119 ///
21120 /// # Syntax tree enum
21121 ///
21122 /// This type is a [syntax tree enum].
21123 ///
21124 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
21125 //
21126 // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
21127 // blocked on https://github.com/rust-lang/rust/issues/62833
21128- pub enum ForeignItem #manual_extra_traits {
21129+ pub enum ForeignItem {
21130 /// A foreign function in an `extern` block.
21131 Fn(ForeignItemFn),
21132
21133 /// A foreign static item in an `extern` block: `static ext: u8`.
21134 Static(ForeignItemStatic),
21135
21136 /// A foreign type in an `extern` block: `type void`.
21137 Type(ForeignItemType),
21138@@ -609,130 +541,79 @@ ast_enum_of_structs! {
21139 #[doc(hidden)]
21140 __Nonexhaustive,
21141 }
21142 }
21143
21144 ast_struct! {
21145 /// A foreign function in an `extern` block.
21146 ///
21147- /// *This type is available if Syn is built with the `"full"` feature.*
21148+ /// *This type is available only if Syn is built with the `"full"` feature.*
21149 pub struct ForeignItemFn {
21150 pub attrs: Vec<Attribute>,
21151 pub vis: Visibility,
21152 pub sig: Signature,
21153 pub semi_token: Token![;],
21154 }
21155 }
21156
21157 ast_struct! {
21158 /// A foreign static item in an `extern` block: `static ext: u8`.
21159 ///
21160- /// *This type is available if Syn is built with the `"full"` feature.*
21161+ /// *This type is available only if Syn is built with the `"full"` feature.*
21162 pub struct ForeignItemStatic {
21163 pub attrs: Vec<Attribute>,
21164 pub vis: Visibility,
21165 pub static_token: Token![static],
21166 pub mutability: Option<Token![mut]>,
21167 pub ident: Ident,
21168 pub colon_token: Token![:],
21169 pub ty: Box<Type>,
21170 pub semi_token: Token![;],
21171 }
21172 }
21173
21174 ast_struct! {
21175 /// A foreign type in an `extern` block: `type void`.
21176 ///
21177- /// *This type is available if Syn is built with the `"full"` feature.*
21178+ /// *This type is available only if Syn is built with the `"full"` feature.*
21179 pub struct ForeignItemType {
21180 pub attrs: Vec<Attribute>,
21181 pub vis: Visibility,
21182 pub type_token: Token![type],
21183 pub ident: Ident,
21184 pub semi_token: Token![;],
21185 }
21186 }
21187
21188 ast_struct! {
21189 /// A macro invocation within an extern block.
21190 ///
21191- /// *This type is available if Syn is built with the `"full"` feature.*
21192+ /// *This type is available only if Syn is built with the `"full"` feature.*
21193 pub struct ForeignItemMacro {
21194 pub attrs: Vec<Attribute>,
21195 pub mac: Macro,
21196 pub semi_token: Option<Token![;]>,
21197 }
21198 }
21199
21200-#[cfg(feature = "extra-traits")]
21201-impl Eq for ForeignItem {}
21202-
21203-#[cfg(feature = "extra-traits")]
21204-impl PartialEq for ForeignItem {
21205- fn eq(&self, other: &Self) -> bool {
21206- match (self, other) {
21207- (ForeignItem::Fn(this), ForeignItem::Fn(other)) => this == other,
21208- (ForeignItem::Static(this), ForeignItem::Static(other)) => this == other,
21209- (ForeignItem::Type(this), ForeignItem::Type(other)) => this == other,
21210- (ForeignItem::Macro(this), ForeignItem::Macro(other)) => this == other,
21211- (ForeignItem::Verbatim(this), ForeignItem::Verbatim(other)) => {
21212- TokenStreamHelper(this) == TokenStreamHelper(other)
21213- }
21214- _ => false,
21215- }
21216- }
21217-}
21218-
21219-#[cfg(feature = "extra-traits")]
21220-impl Hash for ForeignItem {
21221- fn hash<H>(&self, state: &mut H)
21222- where
21223- H: Hasher,
21224- {
21225- match self {
21226- ForeignItem::Fn(item) => {
21227- state.write_u8(0);
21228- item.hash(state);
21229- }
21230- ForeignItem::Static(item) => {
21231- state.write_u8(1);
21232- item.hash(state);
21233- }
21234- ForeignItem::Type(item) => {
21235- state.write_u8(2);
21236- item.hash(state);
21237- }
21238- ForeignItem::Macro(item) => {
21239- state.write_u8(3);
21240- item.hash(state);
21241- }
21242- ForeignItem::Verbatim(item) => {
21243- state.write_u8(4);
21244- TokenStreamHelper(item).hash(state);
21245- }
21246- ForeignItem::__Nonexhaustive => unreachable!(),
21247- }
21248- }
21249-}
21250-
21251 ast_enum_of_structs! {
21252 /// An item declaration within the definition of a trait.
21253 ///
21254- /// *This type is available if Syn is built with the `"full"` feature.*
21255+ /// *This type is available only if Syn is built with the `"full"` feature.*
21256 ///
21257 /// # Syntax tree enum
21258 ///
21259 /// This type is a [syntax tree enum].
21260 ///
21261 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
21262 //
21263 // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
21264 // blocked on https://github.com/rust-lang/rust/issues/62833
21265- pub enum TraitItem #manual_extra_traits {
21266+ pub enum TraitItem {
21267 /// An associated constant within the definition of a trait.
21268 Const(TraitItemConst),
21269
21270 /// A trait method within the definition of a trait.
21271 Method(TraitItemMethod),
21272
21273 /// An associated type within the definition of a trait.
21274 Type(TraitItemType),
21275@@ -746,132 +627,81 @@ ast_enum_of_structs! {
21276 #[doc(hidden)]
21277 __Nonexhaustive,
21278 }
21279 }
21280
21281 ast_struct! {
21282 /// An associated constant within the definition of a trait.
21283 ///
21284- /// *This type is available if Syn is built with the `"full"` feature.*
21285+ /// *This type is available only if Syn is built with the `"full"` feature.*
21286 pub struct TraitItemConst {
21287 pub attrs: Vec<Attribute>,
21288 pub const_token: Token![const],
21289 pub ident: Ident,
21290 pub colon_token: Token![:],
21291 pub ty: Type,
21292 pub default: Option<(Token![=], Expr)>,
21293 pub semi_token: Token![;],
21294 }
21295 }
21296
21297 ast_struct! {
21298 /// A trait method within the definition of a trait.
21299 ///
21300- /// *This type is available if Syn is built with the `"full"` feature.*
21301+ /// *This type is available only if Syn is built with the `"full"` feature.*
21302 pub struct TraitItemMethod {
21303 pub attrs: Vec<Attribute>,
21304 pub sig: Signature,
21305 pub default: Option<Block>,
21306 pub semi_token: Option<Token![;]>,
21307 }
21308 }
21309
21310 ast_struct! {
21311 /// An associated type within the definition of a trait.
21312 ///
21313- /// *This type is available if Syn is built with the `"full"` feature.*
21314+ /// *This type is available only if Syn is built with the `"full"` feature.*
21315 pub struct TraitItemType {
21316 pub attrs: Vec<Attribute>,
21317 pub type_token: Token![type],
21318 pub ident: Ident,
21319 pub generics: Generics,
21320 pub colon_token: Option<Token![:]>,
21321 pub bounds: Punctuated<TypeParamBound, Token![+]>,
21322 pub default: Option<(Token![=], Type)>,
21323 pub semi_token: Token![;],
21324 }
21325 }
21326
21327 ast_struct! {
21328 /// A macro invocation within the definition of a trait.
21329 ///
21330- /// *This type is available if Syn is built with the `"full"` feature.*
21331+ /// *This type is available only if Syn is built with the `"full"` feature.*
21332 pub struct TraitItemMacro {
21333 pub attrs: Vec<Attribute>,
21334 pub mac: Macro,
21335 pub semi_token: Option<Token![;]>,
21336 }
21337 }
21338
21339-#[cfg(feature = "extra-traits")]
21340-impl Eq for TraitItem {}
21341-
21342-#[cfg(feature = "extra-traits")]
21343-impl PartialEq for TraitItem {
21344- fn eq(&self, other: &Self) -> bool {
21345- match (self, other) {
21346- (TraitItem::Const(this), TraitItem::Const(other)) => this == other,
21347- (TraitItem::Method(this), TraitItem::Method(other)) => this == other,
21348- (TraitItem::Type(this), TraitItem::Type(other)) => this == other,
21349- (TraitItem::Macro(this), TraitItem::Macro(other)) => this == other,
21350- (TraitItem::Verbatim(this), TraitItem::Verbatim(other)) => {
21351- TokenStreamHelper(this) == TokenStreamHelper(other)
21352- }
21353- _ => false,
21354- }
21355- }
21356-}
21357-
21358-#[cfg(feature = "extra-traits")]
21359-impl Hash for TraitItem {
21360- fn hash<H>(&self, state: &mut H)
21361- where
21362- H: Hasher,
21363- {
21364- match self {
21365- TraitItem::Const(item) => {
21366- state.write_u8(0);
21367- item.hash(state);
21368- }
21369- TraitItem::Method(item) => {
21370- state.write_u8(1);
21371- item.hash(state);
21372- }
21373- TraitItem::Type(item) => {
21374- state.write_u8(2);
21375- item.hash(state);
21376- }
21377- TraitItem::Macro(item) => {
21378- state.write_u8(3);
21379- item.hash(state);
21380- }
21381- TraitItem::Verbatim(item) => {
21382- state.write_u8(4);
21383- TokenStreamHelper(item).hash(state);
21384- }
21385- TraitItem::__Nonexhaustive => unreachable!(),
21386- }
21387- }
21388-}
21389-
21390 ast_enum_of_structs! {
21391 /// An item within an impl block.
21392 ///
21393- /// *This type is available if Syn is built with the `"full"` feature.*
21394+ /// *This type is available only if Syn is built with the `"full"` feature.*
21395 ///
21396 /// # Syntax tree enum
21397 ///
21398 /// This type is a [syntax tree enum].
21399 ///
21400 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
21401 //
21402 // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
21403 // blocked on https://github.com/rust-lang/rust/issues/62833
21404- pub enum ImplItem #manual_extra_traits {
21405+ pub enum ImplItem {
21406 /// An associated constant within an impl block.
21407 Const(ImplItemConst),
21408
21409 /// A method within an impl block.
21410 Method(ImplItemMethod),
21411
21412 /// An associated type within an impl block.
21413 Type(ImplItemType),
21414@@ -885,17 +715,17 @@ ast_enum_of_structs! {
21415 #[doc(hidden)]
21416 __Nonexhaustive,
21417 }
21418 }
21419
21420 ast_struct! {
21421 /// An associated constant within an impl block.
21422 ///
21423- /// *This type is available if Syn is built with the `"full"` feature.*
21424+ /// *This type is available only if Syn is built with the `"full"` feature.*
21425 pub struct ImplItemConst {
21426 pub attrs: Vec<Attribute>,
21427 pub vis: Visibility,
21428 pub defaultness: Option<Token![default]>,
21429 pub const_token: Token![const],
21430 pub ident: Ident,
21431 pub colon_token: Token![:],
21432 pub ty: Type,
21433@@ -903,144 +733,117 @@ ast_struct! {
21434 pub expr: Expr,
21435 pub semi_token: Token![;],
21436 }
21437 }
21438
21439 ast_struct! {
21440 /// A method within an impl block.
21441 ///
21442- /// *This type is available if Syn is built with the `"full"` feature.*
21443+ /// *This type is available only if Syn is built with the `"full"` feature.*
21444 pub struct ImplItemMethod {
21445 pub attrs: Vec<Attribute>,
21446 pub vis: Visibility,
21447 pub defaultness: Option<Token![default]>,
21448 pub sig: Signature,
21449 pub block: Block,
21450 }
21451 }
21452
21453 ast_struct! {
21454 /// An associated type within an impl block.
21455 ///
21456- /// *This type is available if Syn is built with the `"full"` feature.*
21457+ /// *This type is available only if Syn is built with the `"full"` feature.*
21458 pub struct ImplItemType {
21459 pub attrs: Vec<Attribute>,
21460 pub vis: Visibility,
21461 pub defaultness: Option<Token![default]>,
21462 pub type_token: Token![type],
21463 pub ident: Ident,
21464 pub generics: Generics,
21465 pub eq_token: Token![=],
21466 pub ty: Type,
21467 pub semi_token: Token![;],
21468 }
21469 }
21470
21471 ast_struct! {
21472 /// A macro invocation within an impl block.
21473 ///
21474- /// *This type is available if Syn is built with the `"full"` feature.*
21475+ /// *This type is available only if Syn is built with the `"full"` feature.*
21476 pub struct ImplItemMacro {
21477 pub attrs: Vec<Attribute>,
21478 pub mac: Macro,
21479 pub semi_token: Option<Token![;]>,
21480 }
21481 }
21482
21483-#[cfg(feature = "extra-traits")]
21484-impl Eq for ImplItem {}
21485-
21486-#[cfg(feature = "extra-traits")]
21487-impl PartialEq for ImplItem {
21488- fn eq(&self, other: &Self) -> bool {
21489- match (self, other) {
21490- (ImplItem::Const(this), ImplItem::Const(other)) => this == other,
21491- (ImplItem::Method(this), ImplItem::Method(other)) => this == other,
21492- (ImplItem::Type(this), ImplItem::Type(other)) => this == other,
21493- (ImplItem::Macro(this), ImplItem::Macro(other)) => this == other,
21494- (ImplItem::Verbatim(this), ImplItem::Verbatim(other)) => {
21495- TokenStreamHelper(this) == TokenStreamHelper(other)
21496- }
21497- _ => false,
21498- }
21499- }
21500-}
21501-
21502-#[cfg(feature = "extra-traits")]
21503-impl Hash for ImplItem {
21504- fn hash<H>(&self, state: &mut H)
21505- where
21506- H: Hasher,
21507- {
21508- match self {
21509- ImplItem::Const(item) => {
21510- state.write_u8(0);
21511- item.hash(state);
21512- }
21513- ImplItem::Method(item) => {
21514- state.write_u8(1);
21515- item.hash(state);
21516- }
21517- ImplItem::Type(item) => {
21518- state.write_u8(2);
21519- item.hash(state);
21520- }
21521- ImplItem::Macro(item) => {
21522- state.write_u8(3);
21523- item.hash(state);
21524- }
21525- ImplItem::Verbatim(item) => {
21526- state.write_u8(4);
21527- TokenStreamHelper(item).hash(state);
21528- }
21529- ImplItem::__Nonexhaustive => unreachable!(),
21530- }
21531- }
21532-}
21533-
21534 ast_struct! {
21535 /// A function signature in a trait or implementation: `unsafe fn
21536 /// initialize(&self)`.
21537 ///
21538- /// *This type is available if Syn is built with the `"full"` feature.*
21539+ /// *This type is available only if Syn is built with the `"full"` feature.*
21540 pub struct Signature {
21541 pub constness: Option<Token![const]>,
21542 pub asyncness: Option<Token![async]>,
21543 pub unsafety: Option<Token![unsafe]>,
21544 pub abi: Option<Abi>,
21545 pub fn_token: Token![fn],
21546 pub ident: Ident,
21547 pub generics: Generics,
21548 pub paren_token: token::Paren,
21549 pub inputs: Punctuated<FnArg, Token![,]>,
21550 pub variadic: Option<Variadic>,
21551 pub output: ReturnType,
21552 }
21553 }
21554
21555+impl Signature {
21556+ /// A method's `self` receiver, such as `&self` or `self: Box<Self>`.
21557+ pub fn receiver(&self) -> Option<&FnArg> {
21558+ let arg = self.inputs.first()?;
21559+ match arg {
21560+ FnArg::Receiver(_) => Some(arg),
21561+ FnArg::Typed(PatType { pat, .. }) => {
21562+ if let Pat::Ident(PatIdent { ident, .. }) = &**pat {
21563+ if ident == "self" {
21564+ return Some(arg);
21565+ }
21566+ }
21567+ None
21568+ }
21569+ }
21570+ }
21571+}
21572+
21573 ast_enum_of_structs! {
21574 /// An argument in a function signature: the `n: usize` in `fn f(n: usize)`.
21575 ///
21576- /// *This type is available if Syn is built with the `"full"` feature.*
21577+ /// *This type is available only if Syn is built with the `"full"` feature.*
21578 pub enum FnArg {
21579 /// The `self` argument of an associated method, whether taken by value
21580 /// or by reference.
21581+ ///
21582+ /// Note that `self` receivers with a specified type, such as `self:
21583+ /// Box<Self>`, are parsed as a `FnArg::Typed`.
21584 Receiver(Receiver),
21585
21586 /// A function argument accepted by pattern and type.
21587 Typed(PatType),
21588 }
21589 }
21590
21591 ast_struct! {
21592 /// The `self` argument of an associated method, whether taken by value
21593 /// or by reference.
21594 ///
21595- /// *This type is available if Syn is built with the `"full"` feature.*
21596+ /// Note that `self` receivers with a specified type, such as `self:
21597+ /// Box<Self>`, are parsed as a `FnArg::Typed`.
21598+ ///
21599+ /// *This type is available only if Syn is built with the `"full"` feature.*
21600 pub struct Receiver {
21601 pub attrs: Vec<Attribute>,
21602 pub reference: Option<(Token![&], Option<Lifetime>)>,
21603 pub mutability: Option<Token![mut]>,
21604 pub self_token: Token![self],
21605 }
21606 }
21607
21608@@ -1051,149 +854,233 @@ impl Receiver {
21609 }
21610
21611 #[cfg(feature = "parsing")]
21612 pub mod parsing {
21613 use super::*;
21614
21615 use crate::ext::IdentExt;
21616 use crate::parse::discouraged::Speculative;
21617- use crate::parse::{Parse, ParseStream, Result};
21618+ use crate::parse::{Parse, ParseBuffer, ParseStream, Result};
21619+ use crate::token::Brace;
21620 use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenTree};
21621 use std::iter::{self, FromIterator};
21622
21623 crate::custom_keyword!(existential);
21624
21625 impl Parse for Item {
21626 fn parse(input: ParseStream) -> Result<Self> {
21627+ let begin = input.fork();
21628 let mut attrs = input.call(Attribute::parse_outer)?;
21629 let ahead = input.fork();
21630 let vis: Visibility = ahead.parse()?;
21631
21632 let lookahead = ahead.lookahead1();
21633- let mut item = if lookahead.peek(Token![extern]) {
21634+ let mut item = if lookahead.peek(Token![fn]) || peek_signature(&ahead) {
21635+ let vis: Visibility = input.parse()?;
21636+ let sig = parse_signature(input)?;
21637+ if input.peek(Token![;]) {
21638+ input.parse::<Token![;]>()?;
21639+ Ok(Item::Verbatim(verbatim::between(begin, input)))
21640+ } else {
21641+ parse_rest_of_fn(input, Vec::new(), vis, sig).map(Item::Fn)
21642+ }
21643+ } else if lookahead.peek(Token![extern]) {
21644 ahead.parse::<Token![extern]>()?;
21645 let lookahead = ahead.lookahead1();
21646 if lookahead.peek(Token![crate]) {
21647 input.parse().map(Item::ExternCrate)
21648- } else if lookahead.peek(Token![fn]) {
21649- input.parse().map(Item::Fn)
21650 } else if lookahead.peek(token::Brace) {
21651 input.parse().map(Item::ForeignMod)
21652 } else if lookahead.peek(LitStr) {
21653 ahead.parse::<LitStr>()?;
21654 let lookahead = ahead.lookahead1();
21655 if lookahead.peek(token::Brace) {
21656 input.parse().map(Item::ForeignMod)
21657- } else if lookahead.peek(Token![fn]) {
21658- input.parse().map(Item::Fn)
21659 } else {
21660 Err(lookahead.error())
21661 }
21662 } else {
21663 Err(lookahead.error())
21664 }
21665 } else if lookahead.peek(Token![use]) {
21666 input.parse().map(Item::Use)
21667 } else if lookahead.peek(Token![static]) {
21668- input.parse().map(Item::Static)
21669+ let vis = input.parse()?;
21670+ let static_token = input.parse()?;
21671+ let mutability = input.parse()?;
21672+ let ident = input.parse()?;
21673+ let colon_token = input.parse()?;
21674+ let ty = input.parse()?;
21675+ if input.peek(Token![;]) {
21676+ input.parse::<Token![;]>()?;
21677+ Ok(Item::Verbatim(verbatim::between(begin, input)))
21678+ } else {
21679+ Ok(Item::Static(ItemStatic {
21680+ attrs: Vec::new(),
21681+ vis,
21682+ static_token,
21683+ mutability,
21684+ ident,
21685+ colon_token,
21686+ ty,
21687+ eq_token: input.parse()?,
21688+ expr: input.parse()?,
21689+ semi_token: input.parse()?,
21690+ }))
21691+ }
21692 } else if lookahead.peek(Token![const]) {
21693 ahead.parse::<Token![const]>()?;
21694 let lookahead = ahead.lookahead1();
21695 if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
21696- input.parse().map(Item::Const)
21697- } else if lookahead.peek(Token![unsafe])
21698- || lookahead.peek(Token![async])
21699- || lookahead.peek(Token![extern])
21700- || lookahead.peek(Token![fn])
21701- {
21702- input.parse().map(Item::Fn)
21703+ let vis = input.parse()?;
21704+ let const_token = input.parse()?;
21705+ let ident = {
21706+ let lookahead = input.lookahead1();
21707+ if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
21708+ input.call(Ident::parse_any)?
21709+ } else {
21710+ return Err(lookahead.error());
21711+ }
21712+ };
21713+ let colon_token = input.parse()?;
21714+ let ty = input.parse()?;
21715+ if input.peek(Token![;]) {
21716+ input.parse::<Token![;]>()?;
21717+ Ok(Item::Verbatim(verbatim::between(begin, input)))
21718+ } else {
21719+ Ok(Item::Const(ItemConst {
21720+ attrs: Vec::new(),
21721+ vis,
21722+ const_token,
21723+ ident,
21724+ colon_token,
21725+ ty,
21726+ eq_token: input.parse()?,
21727+ expr: input.parse()?,
21728+ semi_token: input.parse()?,
21729+ }))
21730+ }
21731 } else {
21732 Err(lookahead.error())
21733 }
21734 } else if lookahead.peek(Token![unsafe]) {
21735 ahead.parse::<Token![unsafe]>()?;
21736 let lookahead = ahead.lookahead1();
21737 if lookahead.peek(Token![trait])
21738 || lookahead.peek(Token![auto]) && ahead.peek2(Token![trait])
21739 {
21740 input.parse().map(Item::Trait)
21741 } else if lookahead.peek(Token![impl]) {
21742- input.parse().map(Item::Impl)
21743- } else if lookahead.peek(Token![async])
21744- || lookahead.peek(Token![extern])
21745- || lookahead.peek(Token![fn])
21746- {
21747- input.parse().map(Item::Fn)
21748+ let allow_const_impl = true;
21749+ if let Some(item) = parse_impl(input, allow_const_impl)? {
21750+ Ok(Item::Impl(item))
21751+ } else {
21752+ Ok(Item::Verbatim(verbatim::between(begin, input)))
21753+ }
21754 } else {
21755 Err(lookahead.error())
21756 }
21757- } else if lookahead.peek(Token![async]) || lookahead.peek(Token![fn]) {
21758- input.parse().map(Item::Fn)
21759 } else if lookahead.peek(Token![mod]) {
21760 input.parse().map(Item::Mod)
21761 } else if lookahead.peek(Token![type]) {
21762- input.parse().map(Item::Type)
21763+ parse_item_type(begin, input)
21764 } else if lookahead.peek(existential) {
21765 input.call(item_existential).map(Item::Verbatim)
21766 } else if lookahead.peek(Token![struct]) {
21767 input.parse().map(Item::Struct)
21768 } else if lookahead.peek(Token![enum]) {
21769 input.parse().map(Item::Enum)
21770 } else if lookahead.peek(Token![union]) && ahead.peek2(Ident) {
21771 input.parse().map(Item::Union)
21772 } else if lookahead.peek(Token![trait]) {
21773 input.call(parse_trait_or_trait_alias)
21774 } else if lookahead.peek(Token![auto]) && ahead.peek2(Token![trait]) {
21775 input.parse().map(Item::Trait)
21776 } else if lookahead.peek(Token![impl])
21777 || lookahead.peek(Token![default]) && !ahead.peek2(Token![!])
21778 {
21779- input.parse().map(Item::Impl)
21780+ let allow_const_impl = true;
21781+ if let Some(item) = parse_impl(input, allow_const_impl)? {
21782+ Ok(Item::Impl(item))
21783+ } else {
21784+ Ok(Item::Verbatim(verbatim::between(begin, input)))
21785+ }
21786 } else if lookahead.peek(Token![macro]) {
21787 input.parse().map(Item::Macro2)
21788 } else if vis.is_inherited()
21789 && (lookahead.peek(Ident)
21790 || lookahead.peek(Token![self])
21791 || lookahead.peek(Token![super])
21792- || lookahead.peek(Token![extern])
21793 || lookahead.peek(Token![crate])
21794 || lookahead.peek(Token![::]))
21795 {
21796 input.parse().map(Item::Macro)
21797 } else {
21798 Err(lookahead.error())
21799 }?;
21800
21801- {
21802- let item_attrs = match &mut item {
21803- Item::ExternCrate(item) => &mut item.attrs,
21804- Item::Use(item) => &mut item.attrs,
21805- Item::Static(item) => &mut item.attrs,
21806- Item::Const(item) => &mut item.attrs,
21807- Item::Fn(item) => &mut item.attrs,
21808- Item::Mod(item) => &mut item.attrs,
21809- Item::ForeignMod(item) => &mut item.attrs,
21810- Item::Type(item) => &mut item.attrs,
21811- Item::Struct(item) => &mut item.attrs,
21812- Item::Enum(item) => &mut item.attrs,
21813- Item::Union(item) => &mut item.attrs,
21814- Item::Trait(item) => &mut item.attrs,
21815- Item::TraitAlias(item) => &mut item.attrs,
21816- Item::Impl(item) => &mut item.attrs,
21817- Item::Macro(item) => &mut item.attrs,
21818- Item::Macro2(item) => &mut item.attrs,
21819- Item::Verbatim(_) => return Ok(item),
21820- Item::__Nonexhaustive => unreachable!(),
21821- };
21822- attrs.extend(item_attrs.drain(..));
21823- *item_attrs = attrs;
21824+ attrs.extend(item.replace_attrs(Vec::new()));
21825+ item.replace_attrs(attrs);
21826+ Ok(item)
21827+ }
21828+ }
21829+
21830+ struct FlexibleItemType {
21831+ vis: Visibility,
21832+ defaultness: Option<Token![default]>,
21833+ type_token: Token![type],
21834+ ident: Ident,
21835+ generics: Generics,
21836+ colon_token: Option<Token![:]>,
21837+ bounds: Punctuated<TypeParamBound, Token![+]>,
21838+ ty: Option<(Token![=], Type)>,
21839+ semi_token: Token![;],
21840+ }
21841+
21842+ impl Parse for FlexibleItemType {
21843+ fn parse(input: ParseStream) -> Result<Self> {
21844+ let vis: Visibility = input.parse()?;
21845+ let defaultness: Option<Token![default]> = input.parse()?;
21846+ let type_token: Token![type] = input.parse()?;
21847+ let ident: Ident = input.parse()?;
21848+ let mut generics: Generics = input.parse()?;
21849+ let colon_token: Option<Token![:]> = input.parse()?;
21850+ let mut bounds = Punctuated::new();
21851+ if colon_token.is_some() {
21852+ loop {
21853+ bounds.push_value(input.parse::<TypeParamBound>()?);
21854+ if input.peek(Token![where]) || input.peek(Token![=]) || input.peek(Token![;]) {
21855+ break;
21856+ }
21857+ bounds.push_punct(input.parse::<Token![+]>()?);
21858+ if input.peek(Token![where]) || input.peek(Token![=]) || input.peek(Token![;]) {
21859+ break;
21860+ }
21861+ }
21862 }
21863+ generics.where_clause = input.parse()?;
21864+ let ty = if let Some(eq_token) = input.parse()? {
21865+ Some((eq_token, input.parse::<Type>()?))
21866+ } else {
21867+ None
21868+ };
21869+ let semi_token: Token![;] = input.parse()?;
21870
21871- Ok(item)
21872+ Ok(FlexibleItemType {
21873+ vis,
21874+ defaultness,
21875+ type_token,
21876+ ident,
21877+ generics,
21878+ colon_token,
21879+ bounds,
21880+ ty,
21881+ semi_token,
21882+ })
21883 }
21884 }
21885
21886 impl Parse for ItemMacro {
21887 fn parse(input: ParseStream) -> Result<Self> {
21888 let attrs = input.call(Attribute::parse_outer)?;
21889 let path = input.call(Path::parse_mod_style)?;
21890 let bang_token: Token![!] = input.parse()?;
21891@@ -1305,17 +1192,16 @@ pub mod parsing {
21892
21893 impl Parse for UseTree {
21894 fn parse(input: ParseStream) -> Result<UseTree> {
21895 let lookahead = input.lookahead1();
21896 if lookahead.peek(Ident)
21897 || lookahead.peek(Token![self])
21898 || lookahead.peek(Token![super])
21899 || lookahead.peek(Token![crate])
21900- || lookahead.peek(Token![extern])
21901 {
21902 let ident = input.call(Ident::parse_any)?;
21903 if input.peek(Token![::]) {
21904 Ok(UseTree::Path(UsePath {
21905 ident,
21906 colon2_token: input.parse()?,
21907 tree: Box::new(input.parse()?),
21908 }))
21909@@ -1387,77 +1273,134 @@ pub mod parsing {
21910 ty: input.parse()?,
21911 eq_token: input.parse()?,
21912 expr: input.parse()?,
21913 semi_token: input.parse()?,
21914 })
21915 }
21916 }
21917
21918+ fn pop_variadic(args: &mut Punctuated<FnArg, Token![,]>) -> Option<Variadic> {
21919+ let trailing_punct = args.trailing_punct();
21920+
21921+ let last = match args.last_mut()? {
21922+ FnArg::Typed(last) => last,
21923+ _ => return None,
21924+ };
21925+
21926+ let ty = match last.ty.as_ref() {
21927+ Type::Verbatim(ty) => ty,
21928+ _ => return None,
21929+ };
21930+
21931+ let mut variadic = Variadic {
21932+ attrs: Vec::new(),
21933+ dots: parse2(ty.clone()).ok()?,
21934+ };
21935+
21936+ if let Pat::Verbatim(pat) = last.pat.as_ref() {
21937+ if pat.to_string() == "..." && !trailing_punct {
21938+ variadic.attrs = mem::replace(&mut last.attrs, Vec::new());
21939+ args.pop();
21940+ }
21941+ }
21942+
21943+ Some(variadic)
21944+ }
21945+
21946+ fn variadic_to_tokens(dots: &Token![...]) -> TokenStream {
21947+ TokenStream::from_iter(vec![
21948+ TokenTree::Punct({
21949+ let mut dot = Punct::new('.', Spacing::Joint);
21950+ dot.set_span(dots.spans[0]);
21951+ dot
21952+ }),
21953+ TokenTree::Punct({
21954+ let mut dot = Punct::new('.', Spacing::Joint);
21955+ dot.set_span(dots.spans[1]);
21956+ dot
21957+ }),
21958+ TokenTree::Punct({
21959+ let mut dot = Punct::new('.', Spacing::Alone);
21960+ dot.set_span(dots.spans[2]);
21961+ dot
21962+ }),
21963+ ])
21964+ }
21965+
21966+ fn peek_signature(input: ParseStream) -> bool {
21967+ let fork = input.fork();
21968+ fork.parse::<Option<Token![const]>>().is_ok()
21969+ && fork.parse::<Option<Token![async]>>().is_ok()
21970+ && fork.parse::<Option<Token![unsafe]>>().is_ok()
21971+ && fork.parse::<Option<Abi>>().is_ok()
21972+ && fork.peek(Token![fn])
21973+ }
21974+
21975+ fn parse_signature(input: ParseStream) -> Result<Signature> {
21976+ let constness: Option<Token![const]> = input.parse()?;
21977+ let asyncness: Option<Token![async]> = input.parse()?;
21978+ let unsafety: Option<Token![unsafe]> = input.parse()?;
21979+ let abi: Option<Abi> = input.parse()?;
21980+ let fn_token: Token![fn] = input.parse()?;
21981+ let ident: Ident = input.parse()?;
21982+ let generics: Generics = input.parse()?;
21983+
21984+ let content;
21985+ let paren_token = parenthesized!(content in input);
21986+ let mut inputs = parse_fn_args(&content)?;
21987+ let variadic = pop_variadic(&mut inputs);
21988+
21989+ let output: ReturnType = input.parse()?;
21990+ let where_clause: Option<WhereClause> = input.parse()?;
21991+
21992+ Ok(Signature {
21993+ constness,
21994+ asyncness,
21995+ unsafety,
21996+ abi,
21997+ fn_token,
21998+ ident,
21999+ paren_token,
22000+ inputs,
22001+ output,
22002+ variadic,
22003+ generics: Generics {
22004+ where_clause,
22005+ ..generics
22006+ },
22007+ })
22008+ }
22009+
22010 impl Parse for ItemFn {
22011 fn parse(input: ParseStream) -> Result<Self> {
22012 let outer_attrs = input.call(Attribute::parse_outer)?;
22013 let vis: Visibility = input.parse()?;
22014- let constness: Option<Token![const]> = input.parse()?;
22015- let asyncness: Option<Token![async]> = input.parse()?;
22016- let unsafety: Option<Token![unsafe]> = input.parse()?;
22017- let abi: Option<Abi> = input.parse()?;
22018- let fn_token: Token![fn] = input.parse()?;
22019- let ident: Ident = input.parse()?;
22020- let generics: Generics = input.parse()?;
22021-
22022- let content;
22023- let paren_token = parenthesized!(content in input);
22024- let inputs = content.parse_terminated(FnArg::parse)?;
22025- let variadic = inputs.last().as_ref().and_then(get_variadic);
22026-
22027- fn get_variadic(input: &&FnArg) -> Option<Variadic> {
22028- if let FnArg::Typed(PatType { ty, .. }) = input {
22029- if let Type::Verbatim(tokens) = &**ty {
22030- if let Ok(dots) = parse2(tokens.clone()) {
22031- return Some(Variadic {
22032- attrs: Vec::new(),
22033- dots,
22034- });
22035- }
22036- }
22037- }
22038- None
22039- }
22040+ let sig = parse_signature(input)?;
22041+ parse_rest_of_fn(input, outer_attrs, vis, sig)
22042+ }
22043+ }
22044
22045- let output: ReturnType = input.parse()?;
22046- let where_clause: Option<WhereClause> = input.parse()?;
22047-
22048- let content;
22049- let brace_token = braced!(content in input);
22050- let inner_attrs = content.call(Attribute::parse_inner)?;
22051- let stmts = content.call(Block::parse_within)?;
22052+ fn parse_rest_of_fn(
22053+ input: ParseStream,
22054+ outer_attrs: Vec<Attribute>,
22055+ vis: Visibility,
22056+ sig: Signature,
22057+ ) -> Result<ItemFn> {
22058+ let content;
22059+ let brace_token = braced!(content in input);
22060+ let inner_attrs = content.call(Attribute::parse_inner)?;
22061+ let stmts = content.call(Block::parse_within)?;
22062
22063- Ok(ItemFn {
22064- attrs: private::attrs(outer_attrs, inner_attrs),
22065- vis,
22066- sig: Signature {
22067- constness,
22068- asyncness,
22069- unsafety,
22070- abi,
22071- fn_token,
22072- ident,
22073- paren_token,
22074- inputs,
22075- output,
22076- variadic,
22077- generics: Generics {
22078- where_clause,
22079- ..generics
22080- },
22081- },
22082- block: Box::new(Block { brace_token, stmts }),
22083- })
22084- }
22085+ Ok(ItemFn {
22086+ attrs: private::attrs(outer_attrs, inner_attrs),
22087+ vis,
22088+ sig,
22089+ block: Box::new(Block { brace_token, stmts }),
22090+ })
22091 }
22092
22093 impl Parse for FnArg {
22094 fn parse(input: ParseStream) -> Result<Self> {
22095 let attrs = input.call(Attribute::parse_outer)?;
22096
22097 let ahead = input.fork();
22098 if let Ok(mut receiver) = ahead.parse::<Receiver>() {
22099@@ -1486,36 +1429,89 @@ pub mod parsing {
22100 }
22101 },
22102 mutability: input.parse()?,
22103 self_token: input.parse()?,
22104 })
22105 }
22106 }
22107
22108+ fn parse_fn_args(input: ParseStream) -> Result<Punctuated<FnArg, Token![,]>> {
22109+ let mut args = Punctuated::new();
22110+ let mut has_receiver = false;
22111+
22112+ while !input.is_empty() {
22113+ let attrs = input.call(Attribute::parse_outer)?;
22114+
22115+ let arg = if let Some(dots) = input.parse::<Option<Token![...]>>()? {
22116+ FnArg::Typed(PatType {
22117+ attrs,
22118+ pat: Box::new(Pat::Verbatim(variadic_to_tokens(&dots))),
22119+ colon_token: Token![:](dots.spans[0]),
22120+ ty: Box::new(Type::Verbatim(variadic_to_tokens(&dots))),
22121+ })
22122+ } else {
22123+ let mut arg: FnArg = input.parse()?;
22124+ match &mut arg {
22125+ FnArg::Receiver(receiver) if has_receiver => {
22126+ return Err(Error::new(
22127+ receiver.self_token.span,
22128+ "unexpected second method receiver",
22129+ ));
22130+ }
22131+ FnArg::Receiver(receiver) if !args.is_empty() => {
22132+ return Err(Error::new(
22133+ receiver.self_token.span,
22134+ "unexpected method receiver",
22135+ ));
22136+ }
22137+ FnArg::Receiver(receiver) => {
22138+ has_receiver = true;
22139+ receiver.attrs = attrs;
22140+ }
22141+ FnArg::Typed(arg) => arg.attrs = attrs,
22142+ }
22143+ arg
22144+ };
22145+ args.push_value(arg);
22146+
22147+ if input.is_empty() {
22148+ break;
22149+ }
22150+
22151+ let comma: Token![,] = input.parse()?;
22152+ args.push_punct(comma);
22153+ }
22154+
22155+ Ok(args)
22156+ }
22157+
22158 fn fn_arg_typed(input: ParseStream) -> Result<PatType> {
22159+ // Hack to parse pre-2018 syntax in
22160+ // test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs
22161+ // because the rest of the test case is valuable.
22162+ if input.peek(Ident) && input.peek2(Token![<]) {
22163+ let span = input.fork().parse::<Ident>()?.span();
22164+ return Ok(PatType {
22165+ attrs: Vec::new(),
22166+ pat: Box::new(Pat::Wild(PatWild {
22167+ attrs: Vec::new(),
22168+ underscore_token: Token![_](span),
22169+ })),
22170+ colon_token: Token![:](span),
22171+ ty: input.parse()?,
22172+ });
22173+ }
22174+
22175 Ok(PatType {
22176 attrs: Vec::new(),
22177- pat: input.parse()?,
22178+ pat: Box::new(pat::parsing::multi_pat(input)?),
22179 colon_token: input.parse()?,
22180 ty: Box::new(match input.parse::<Option<Token![...]>>()? {
22181- Some(dot3) => {
22182- let args = vec![
22183- TokenTree::Punct(Punct::new('.', Spacing::Joint)),
22184- TokenTree::Punct(Punct::new('.', Spacing::Joint)),
22185- TokenTree::Punct(Punct::new('.', Spacing::Alone)),
22186- ];
22187- let tokens = TokenStream::from_iter(args.into_iter().zip(&dot3.spans).map(
22188- |(mut arg, span)| {
22189- arg.set_span(*span);
22190- arg
22191- },
22192- ));
22193- Type::Verbatim(tokens)
22194- }
22195+ Some(dot3) => Type::Verbatim(variadic_to_tokens(&dot3)),
22196 None => input.parse()?,
22197 }),
22198 })
22199 }
22200
22201 impl Parse for ItemMod {
22202 fn parse(input: ParseStream) -> Result<Self> {
22203 let outer_attrs = input.call(Attribute::parse_outer)?;
22204@@ -1576,109 +1572,103 @@ pub mod parsing {
22205 brace_token,
22206 items,
22207 })
22208 }
22209 }
22210
22211 impl Parse for ForeignItem {
22212 fn parse(input: ParseStream) -> Result<Self> {
22213+ let begin = input.fork();
22214 let mut attrs = input.call(Attribute::parse_outer)?;
22215 let ahead = input.fork();
22216 let vis: Visibility = ahead.parse()?;
22217
22218 let lookahead = ahead.lookahead1();
22219- let mut item = if lookahead.peek(Token![fn]) {
22220- input.parse().map(ForeignItem::Fn)
22221+ let mut item = if lookahead.peek(Token![fn]) || peek_signature(&ahead) {
22222+ let vis: Visibility = input.parse()?;
22223+ let sig = parse_signature(input)?;
22224+ if input.peek(token::Brace) {
22225+ let content;
22226+ braced!(content in input);
22227+ content.call(Attribute::parse_inner)?;
22228+ content.call(Block::parse_within)?;
22229+
22230+ Ok(ForeignItem::Verbatim(verbatim::between(begin, input)))
22231+ } else {
22232+ Ok(ForeignItem::Fn(ForeignItemFn {
22233+ attrs: Vec::new(),
22234+ vis,
22235+ sig,
22236+ semi_token: input.parse()?,
22237+ }))
22238+ }
22239 } else if lookahead.peek(Token![static]) {
22240- input.parse().map(ForeignItem::Static)
22241+ let vis = input.parse()?;
22242+ let static_token = input.parse()?;
22243+ let mutability = input.parse()?;
22244+ let ident = input.parse()?;
22245+ let colon_token = input.parse()?;
22246+ let ty = input.parse()?;
22247+ if input.peek(Token![=]) {
22248+ input.parse::<Token![=]>()?;
22249+ input.parse::<Expr>()?;
22250+ input.parse::<Token![;]>()?;
22251+ Ok(ForeignItem::Verbatim(verbatim::between(begin, input)))
22252+ } else {
22253+ Ok(ForeignItem::Static(ForeignItemStatic {
22254+ attrs: Vec::new(),
22255+ vis,
22256+ static_token,
22257+ mutability,
22258+ ident,
22259+ colon_token,
22260+ ty,
22261+ semi_token: input.parse()?,
22262+ }))
22263+ }
22264 } else if lookahead.peek(Token![type]) {
22265- input.parse().map(ForeignItem::Type)
22266+ parse_foreign_item_type(begin, input)
22267 } else if vis.is_inherited()
22268 && (lookahead.peek(Ident)
22269 || lookahead.peek(Token![self])
22270 || lookahead.peek(Token![super])
22271- || lookahead.peek(Token![extern])
22272 || lookahead.peek(Token![crate])
22273 || lookahead.peek(Token![::]))
22274 {
22275 input.parse().map(ForeignItem::Macro)
22276 } else {
22277 Err(lookahead.error())
22278 }?;
22279
22280- {
22281- let item_attrs = match &mut item {
22282- ForeignItem::Fn(item) => &mut item.attrs,
22283- ForeignItem::Static(item) => &mut item.attrs,
22284- ForeignItem::Type(item) => &mut item.attrs,
22285- ForeignItem::Macro(item) => &mut item.attrs,
22286- ForeignItem::Verbatim(_) | ForeignItem::__Nonexhaustive => unreachable!(),
22287- };
22288- attrs.extend(item_attrs.drain(..));
22289- *item_attrs = attrs;
22290- }
22291+ let item_attrs = match &mut item {
22292+ ForeignItem::Fn(item) => &mut item.attrs,
22293+ ForeignItem::Static(item) => &mut item.attrs,
22294+ ForeignItem::Type(item) => &mut item.attrs,
22295+ ForeignItem::Macro(item) => &mut item.attrs,
22296+ ForeignItem::Verbatim(_) => return Ok(item),
22297+ ForeignItem::__Nonexhaustive => unreachable!(),
22298+ };
22299+ attrs.extend(item_attrs.drain(..));
22300+ *item_attrs = attrs;
22301
22302 Ok(item)
22303 }
22304 }
22305
22306 impl Parse for ForeignItemFn {
22307 fn parse(input: ParseStream) -> Result<Self> {
22308 let attrs = input.call(Attribute::parse_outer)?;
22309 let vis: Visibility = input.parse()?;
22310- let fn_token: Token![fn] = input.parse()?;
22311- let ident: Ident = input.parse()?;
22312- let generics: Generics = input.parse()?;
22313-
22314- let content;
22315- let paren_token = parenthesized!(content in input);
22316- let mut inputs = Punctuated::new();
22317- let mut variadic = None;
22318- while !content.is_empty() {
22319- let attrs = content.call(Attribute::parse_outer)?;
22320-
22321- if let Some(dots) = content.parse()? {
22322- variadic = Some(Variadic { attrs, dots });
22323- break;
22324- }
22325-
22326- let mut arg = content.call(fn_arg_typed)?;
22327- arg.attrs = attrs;
22328- inputs.push_value(FnArg::Typed(arg));
22329- if content.is_empty() {
22330- break;
22331- }
22332-
22333- inputs.push_punct(content.parse()?);
22334- }
22335-
22336- let output: ReturnType = input.parse()?;
22337- let where_clause: Option<WhereClause> = input.parse()?;
22338+ let sig = parse_signature(input)?;
22339 let semi_token: Token![;] = input.parse()?;
22340-
22341 Ok(ForeignItemFn {
22342 attrs,
22343 vis,
22344- sig: Signature {
22345- constness: None,
22346- asyncness: None,
22347- unsafety: None,
22348- abi: None,
22349- fn_token,
22350- ident,
22351- paren_token,
22352- inputs,
22353- output,
22354- variadic,
22355- generics: Generics {
22356- where_clause,
22357- ..generics
22358- },
22359- },
22360+ sig,
22361 semi_token,
22362 })
22363 }
22364 }
22365
22366 impl Parse for ForeignItemStatic {
22367 fn parse(input: ParseStream) -> Result<Self> {
22368 Ok(ForeignItemStatic {
22369@@ -1701,16 +1691,47 @@ pub mod parsing {
22370 vis: input.parse()?,
22371 type_token: input.parse()?,
22372 ident: input.parse()?,
22373 semi_token: input.parse()?,
22374 })
22375 }
22376 }
22377
22378+ fn parse_foreign_item_type(begin: ParseBuffer, input: ParseStream) -> Result<ForeignItem> {
22379+ let FlexibleItemType {
22380+ vis,
22381+ defaultness,
22382+ type_token,
22383+ ident,
22384+ generics,
22385+ colon_token,
22386+ bounds: _,
22387+ ty,
22388+ semi_token,
22389+ } = input.parse()?;
22390+
22391+ if defaultness.is_some()
22392+ || generics.lt_token.is_some()
22393+ || generics.where_clause.is_some()
22394+ || colon_token.is_some()
22395+ || ty.is_some()
22396+ {
22397+ Ok(ForeignItem::Verbatim(verbatim::between(begin, input)))
22398+ } else {
22399+ Ok(ForeignItem::Type(ForeignItemType {
22400+ attrs: Vec::new(),
22401+ vis,
22402+ type_token,
22403+ ident,
22404+ semi_token,
22405+ }))
22406+ }
22407+ }
22408+
22409 impl Parse for ForeignItemMacro {
22410 fn parse(input: ParseStream) -> Result<Self> {
22411 let attrs = input.call(Attribute::parse_outer)?;
22412 let mac: Macro = input.parse()?;
22413 let semi_token: Option<Token![;]> = if mac.delimiter.is_brace() {
22414 None
22415 } else {
22416 Some(input.parse()?)
22417@@ -1737,16 +1758,46 @@ pub mod parsing {
22418 },
22419 eq_token: input.parse()?,
22420 ty: input.parse()?,
22421 semi_token: input.parse()?,
22422 })
22423 }
22424 }
22425
22426+ fn parse_item_type(begin: ParseBuffer, input: ParseStream) -> Result<Item> {
22427+ let FlexibleItemType {
22428+ vis,
22429+ defaultness,
22430+ type_token,
22431+ ident,
22432+ generics,
22433+ colon_token,
22434+ bounds: _,
22435+ ty,
22436+ semi_token,
22437+ } = input.parse()?;
22438+
22439+ if defaultness.is_some() || colon_token.is_some() || ty.is_none() {
22440+ Ok(Item::Verbatim(verbatim::between(begin, input)))
22441+ } else {
22442+ let (eq_token, ty) = ty.unwrap();
22443+ Ok(Item::Type(ItemType {
22444+ attrs: Vec::new(),
22445+ vis,
22446+ type_token,
22447+ ident,
22448+ generics,
22449+ eq_token,
22450+ ty: Box::new(ty),
22451+ semi_token,
22452+ }))
22453+ }
22454+ }
22455+
22456 #[cfg(not(feature = "printing"))]
22457 fn item_existential(input: ParseStream) -> Result<TokenStream> {
22458 Err(input.error("existential type is not supported"))
22459 }
22460
22461 #[cfg(feature = "printing")]
22462 fn item_existential(input: ParseStream) -> Result<TokenStream> {
22463 use crate::attr::FilterAttrs;
22464@@ -1882,39 +1933,39 @@ pub mod parsing {
22465 .map(Item::TraitAlias)
22466 } else {
22467 Err(lookahead.error())
22468 }
22469 }
22470
22471 impl Parse for ItemTrait {
22472 fn parse(input: ParseStream) -> Result<Self> {
22473- let attrs = input.call(Attribute::parse_outer)?;
22474+ let outer_attrs = input.call(Attribute::parse_outer)?;
22475 let vis: Visibility = input.parse()?;
22476 let unsafety: Option<Token![unsafe]> = input.parse()?;
22477 let auto_token: Option<Token![auto]> = input.parse()?;
22478 let trait_token: Token![trait] = input.parse()?;
22479 let ident: Ident = input.parse()?;
22480 let generics: Generics = input.parse()?;
22481 parse_rest_of_trait(
22482 input,
22483- attrs,
22484+ outer_attrs,
22485 vis,
22486 unsafety,
22487 auto_token,
22488 trait_token,
22489 ident,
22490 generics,
22491 )
22492 }
22493 }
22494
22495 fn parse_rest_of_trait(
22496 input: ParseStream,
22497- attrs: Vec<Attribute>,
22498+ outer_attrs: Vec<Attribute>,
22499 vis: Visibility,
22500 unsafety: Option<Token![unsafe]>,
22501 auto_token: Option<Token![auto]>,
22502 trait_token: Token![trait],
22503 ident: Ident,
22504 mut generics: Generics,
22505 ) -> Result<ItemTrait> {
22506 let colon_token: Option<Token![:]> = input.parse()?;
22507@@ -1932,23 +1983,24 @@ pub mod parsing {
22508 }
22509 }
22510 }
22511
22512 generics.where_clause = input.parse()?;
22513
22514 let content;
22515 let brace_token = braced!(content in input);
22516+ let inner_attrs = content.call(Attribute::parse_inner)?;
22517 let mut items = Vec::new();
22518 while !content.is_empty() {
22519 items.push(content.parse()?);
22520 }
22521
22522 Ok(ItemTrait {
22523- attrs,
22524+ attrs: private::attrs(outer_attrs, inner_attrs),
22525 vis,
22526 unsafety,
22527 auto_token,
22528 trait_token,
22529 ident,
22530 generics,
22531 colon_token,
22532 supertraits,
22533@@ -2009,76 +2061,83 @@ pub mod parsing {
22534 eq_token,
22535 bounds,
22536 semi_token,
22537 })
22538 }
22539
22540 impl Parse for TraitItem {
22541 fn parse(input: ParseStream) -> Result<Self> {
22542+ let begin = input.fork();
22543 let mut attrs = input.call(Attribute::parse_outer)?;
22544+ let vis: Visibility = input.parse()?;
22545+ let defaultness: Option<Token![default]> = input.parse()?;
22546 let ahead = input.fork();
22547
22548 let lookahead = ahead.lookahead1();
22549- let mut item = if lookahead.peek(Token![const]) {
22550+ let mut item = if lookahead.peek(Token![fn]) || peek_signature(&ahead) {
22551+ input.parse().map(TraitItem::Method)
22552+ } else if lookahead.peek(Token![const]) {
22553 ahead.parse::<Token![const]>()?;
22554 let lookahead = ahead.lookahead1();
22555- if lookahead.peek(Ident) {
22556+ if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
22557 input.parse().map(TraitItem::Const)
22558 } else if lookahead.peek(Token![async])
22559 || lookahead.peek(Token![unsafe])
22560 || lookahead.peek(Token![extern])
22561 || lookahead.peek(Token![fn])
22562 {
22563 input.parse().map(TraitItem::Method)
22564 } else {
22565 Err(lookahead.error())
22566 }
22567- } else if lookahead.peek(Token![async])
22568- || lookahead.peek(Token![unsafe])
22569- || lookahead.peek(Token![extern])
22570- || lookahead.peek(Token![fn])
22571- {
22572- input.parse().map(TraitItem::Method)
22573 } else if lookahead.peek(Token![type]) {
22574- input.parse().map(TraitItem::Type)
22575+ parse_trait_item_type(begin.fork(), input)
22576 } else if lookahead.peek(Ident)
22577 || lookahead.peek(Token![self])
22578 || lookahead.peek(Token![super])
22579- || lookahead.peek(Token![extern])
22580 || lookahead.peek(Token![crate])
22581 || lookahead.peek(Token![::])
22582 {
22583 input.parse().map(TraitItem::Macro)
22584 } else {
22585 Err(lookahead.error())
22586 }?;
22587
22588- {
22589- let item_attrs = match &mut item {
22590- TraitItem::Const(item) => &mut item.attrs,
22591- TraitItem::Method(item) => &mut item.attrs,
22592- TraitItem::Type(item) => &mut item.attrs,
22593- TraitItem::Macro(item) => &mut item.attrs,
22594- TraitItem::Verbatim(_) | TraitItem::__Nonexhaustive => unreachable!(),
22595- };
22596- attrs.extend(item_attrs.drain(..));
22597- *item_attrs = attrs;
22598+ match (vis, defaultness) {
22599+ (Visibility::Inherited, None) => {}
22600+ _ => return Ok(TraitItem::Verbatim(verbatim::between(begin, input))),
22601 }
22602
22603+ let item_attrs = match &mut item {
22604+ TraitItem::Const(item) => &mut item.attrs,
22605+ TraitItem::Method(item) => &mut item.attrs,
22606+ TraitItem::Type(item) => &mut item.attrs,
22607+ TraitItem::Macro(item) => &mut item.attrs,
22608+ TraitItem::Verbatim(_) | TraitItem::__Nonexhaustive => unreachable!(),
22609+ };
22610+ attrs.extend(item_attrs.drain(..));
22611+ *item_attrs = attrs;
22612 Ok(item)
22613 }
22614 }
22615
22616 impl Parse for TraitItemConst {
22617 fn parse(input: ParseStream) -> Result<Self> {
22618 Ok(TraitItemConst {
22619 attrs: input.call(Attribute::parse_outer)?,
22620 const_token: input.parse()?,
22621- ident: input.parse()?,
22622+ ident: {
22623+ let lookahead = input.lookahead1();
22624+ if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
22625+ input.call(Ident::parse_any)?
22626+ } else {
22627+ return Err(lookahead.error());
22628+ }
22629+ },
22630 colon_token: input.parse()?,
22631 ty: input.parse()?,
22632 default: {
22633 if input.peek(Token![=]) {
22634 let eq_token: Token![=] = input.parse()?;
22635 let default: Expr = input.parse()?;
22636 Some((eq_token, default))
22637 } else {
22638@@ -2088,30 +2147,17 @@ pub mod parsing {
22639 semi_token: input.parse()?,
22640 })
22641 }
22642 }
22643
22644 impl Parse for TraitItemMethod {
22645 fn parse(input: ParseStream) -> Result<Self> {
22646 let outer_attrs = input.call(Attribute::parse_outer)?;
22647- let constness: Option<Token![const]> = input.parse()?;
22648- let asyncness: Option<Token![async]> = input.parse()?;
22649- let unsafety: Option<Token![unsafe]> = input.parse()?;
22650- let abi: Option<Abi> = input.parse()?;
22651- let fn_token: Token![fn] = input.parse()?;
22652- let ident: Ident = input.parse()?;
22653- let generics: Generics = input.parse()?;
22654-
22655- let content;
22656- let paren_token = parenthesized!(content in input);
22657- let inputs = content.parse_terminated(FnArg::parse)?;
22658-
22659- let output: ReturnType = input.parse()?;
22660- let where_clause: Option<WhereClause> = input.parse()?;
22661+ let sig = parse_signature(input)?;
22662
22663 let lookahead = input.lookahead1();
22664 let (brace_token, inner_attrs, stmts, semi_token) = if lookahead.peek(token::Brace) {
22665 let content;
22666 let brace_token = braced!(content in input);
22667 let inner_attrs = content.call(Attribute::parse_inner)?;
22668 let stmts = content.call(Block::parse_within)?;
22669 (Some(brace_token), inner_attrs, stmts, None)
22670@@ -2119,32 +2165,17 @@ pub mod parsing {
22671 let semi_token: Token![;] = input.parse()?;
22672 (None, Vec::new(), Vec::new(), Some(semi_token))
22673 } else {
22674 return Err(lookahead.error());
22675 };
22676
22677 Ok(TraitItemMethod {
22678 attrs: private::attrs(outer_attrs, inner_attrs),
22679- sig: Signature {
22680- constness,
22681- asyncness,
22682- unsafety,
22683- abi,
22684- fn_token,
22685- ident,
22686- paren_token,
22687- inputs,
22688- output,
22689- variadic: None,
22690- generics: Generics {
22691- where_clause,
22692- ..generics
22693- },
22694- },
22695+ sig,
22696 default: brace_token.map(|brace_token| Block { brace_token, stmts }),
22697 semi_token,
22698 })
22699 }
22700 }
22701
22702 impl Parse for TraitItemType {
22703 fn parse(input: ParseStream) -> Result<Self> {
22704@@ -2183,16 +2214,45 @@ pub mod parsing {
22705 colon_token,
22706 bounds,
22707 default,
22708 semi_token,
22709 })
22710 }
22711 }
22712
22713+ fn parse_trait_item_type(begin: ParseBuffer, input: ParseStream) -> Result<TraitItem> {
22714+ let FlexibleItemType {
22715+ vis,
22716+ defaultness,
22717+ type_token,
22718+ ident,
22719+ generics,
22720+ colon_token,
22721+ bounds,
22722+ ty,
22723+ semi_token,
22724+ } = input.parse()?;
22725+
22726+ if defaultness.is_some() || vis.is_some() {
22727+ Ok(TraitItem::Verbatim(verbatim::between(begin, input)))
22728+ } else {
22729+ Ok(TraitItem::Type(TraitItemType {
22730+ attrs: Vec::new(),
22731+ type_token,
22732+ ident,
22733+ generics,
22734+ colon_token,
22735+ bounds,
22736+ default: ty,
22737+ semi_token,
22738+ }))
22739+ }
22740+ }
22741+
22742 impl Parse for TraitItemMacro {
22743 fn parse(input: ParseStream) -> Result<Self> {
22744 let attrs = input.call(Attribute::parse_outer)?;
22745 let mac: Macro = input.parse()?;
22746 let semi_token: Option<Token![;]> = if mac.delimiter.is_brace() {
22747 None
22748 } else {
22749 Some(input.parse()?)
22750@@ -2202,123 +2262,148 @@ pub mod parsing {
22751 mac,
22752 semi_token,
22753 })
22754 }
22755 }
22756
22757 impl Parse for ItemImpl {
22758 fn parse(input: ParseStream) -> Result<Self> {
22759- let outer_attrs = input.call(Attribute::parse_outer)?;
22760- let defaultness: Option<Token![default]> = input.parse()?;
22761- let unsafety: Option<Token![unsafe]> = input.parse()?;
22762- let impl_token: Token![impl] = input.parse()?;
22763+ let allow_const_impl = false;
22764+ parse_impl(input, allow_const_impl).map(Option::unwrap)
22765+ }
22766+ }
22767+
22768+ fn parse_impl(input: ParseStream, allow_const_impl: bool) -> Result<Option<ItemImpl>> {
22769+ let outer_attrs = input.call(Attribute::parse_outer)?;
22770+ let defaultness: Option<Token![default]> = input.parse()?;
22771+ let unsafety: Option<Token![unsafe]> = input.parse()?;
22772+ let impl_token: Token![impl] = input.parse()?;
22773
22774- let has_generics = input.peek(Token![<])
22775- && (input.peek2(Token![>])
22776- || input.peek2(Token![#])
22777- || (input.peek2(Ident) || input.peek2(Lifetime))
22778- && (input.peek3(Token![:])
22779- || input.peek3(Token![,])
22780- || input.peek3(Token![>])));
22781- let generics: Generics = if has_generics {
22782- input.parse()?
22783- } else {
22784- Generics::default()
22785- };
22786+ let has_generics = input.peek(Token![<])
22787+ && (input.peek2(Token![>])
22788+ || input.peek2(Token![#])
22789+ || (input.peek2(Ident) || input.peek2(Lifetime))
22790+ && (input.peek3(Token![:])
22791+ || input.peek3(Token![,])
22792+ || input.peek3(Token![>]))
22793+ || input.peek2(Token![const]));
22794+ let generics: Generics = if has_generics {
22795+ input.parse()?
22796+ } else {
22797+ Generics::default()
22798+ };
22799
22800- let trait_ = {
22801- // TODO: optimize using advance_to
22802- let ahead = input.fork();
22803- if ahead.parse::<Option<Token![!]>>().is_ok()
22804- && ahead.parse::<Path>().is_ok()
22805- && ahead.parse::<Token![for]>().is_ok()
22806- {
22807- let polarity: Option<Token![!]> = input.parse()?;
22808- let path: Path = input.parse()?;
22809- let for_token: Token![for] = input.parse()?;
22810- Some((polarity, path, for_token))
22811- } else {
22812- None
22813- }
22814- };
22815- let self_ty: Type = input.parse()?;
22816- let where_clause: Option<WhereClause> = input.parse()?;
22817+ let is_const_impl = allow_const_impl
22818+ && (input.peek(Token![const]) || input.peek(Token![?]) && input.peek2(Token![const]));
22819+ if is_const_impl {
22820+ input.parse::<Option<Token![?]>>()?;
22821+ input.parse::<Token![const]>()?;
22822+ }
22823
22824- let content;
22825- let brace_token = braced!(content in input);
22826- let inner_attrs = content.call(Attribute::parse_inner)?;
22827+ let trait_ = (|| -> Option<_> {
22828+ let ahead = input.fork();
22829+ let polarity: Option<Token![!]> = ahead.parse().ok()?;
22830+ let mut path: Path = ahead.parse().ok()?;
22831+ if path.segments.last().unwrap().arguments.is_empty() && ahead.peek(token::Paren) {
22832+ let parenthesized = PathArguments::Parenthesized(ahead.parse().ok()?);
22833+ path.segments.last_mut().unwrap().arguments = parenthesized;
22834+ }
22835+ let for_token: Token![for] = ahead.parse().ok()?;
22836+ input.advance_to(&ahead);
22837+ Some((polarity, path, for_token))
22838+ })();
22839
22840- let mut items = Vec::new();
22841- while !content.is_empty() {
22842- items.push(content.parse()?);
22843- }
22844+ let self_ty: Type = input.parse()?;
22845+ let where_clause: Option<WhereClause> = input.parse()?;
22846+
22847+ let content;
22848+ let brace_token = braced!(content in input);
22849+ let inner_attrs = content.call(Attribute::parse_inner)?;
22850
22851- Ok(ItemImpl {
22852+ let mut items = Vec::new();
22853+ while !content.is_empty() {
22854+ items.push(content.parse()?);
22855+ }
22856+
22857+ if is_const_impl {
22858+ Ok(None)
22859+ } else {
22860+ Ok(Some(ItemImpl {
22861 attrs: private::attrs(outer_attrs, inner_attrs),
22862 defaultness,
22863 unsafety,
22864 impl_token,
22865 generics: Generics {
22866 where_clause,
22867 ..generics
22868 },
22869 trait_,
22870 self_ty: Box::new(self_ty),
22871 brace_token,
22872 items,
22873- })
22874+ }))
22875 }
22876 }
22877
22878 impl Parse for ImplItem {
22879 fn parse(input: ParseStream) -> Result<Self> {
22880+ let begin = input.fork();
22881 let mut attrs = input.call(Attribute::parse_outer)?;
22882 let ahead = input.fork();
22883 let vis: Visibility = ahead.parse()?;
22884
22885 let mut lookahead = ahead.lookahead1();
22886 let defaultness = if lookahead.peek(Token![default]) && !ahead.peek2(Token![!]) {
22887 let defaultness: Token![default] = ahead.parse()?;
22888 lookahead = ahead.lookahead1();
22889 Some(defaultness)
22890 } else {
22891 None
22892 };
22893
22894- let mut item = if lookahead.peek(Token![const]) {
22895- ahead.parse::<Token![const]>()?;
22896+ let mut item = if lookahead.peek(Token![fn]) || peek_signature(&ahead) {
22897+ input.parse().map(ImplItem::Method)
22898+ } else if lookahead.peek(Token![const]) {
22899+ let const_token: Token![const] = ahead.parse()?;
22900 let lookahead = ahead.lookahead1();
22901- if lookahead.peek(Ident) {
22902- input.parse().map(ImplItem::Const)
22903- } else if lookahead.peek(Token![unsafe])
22904- || lookahead.peek(Token![async])
22905- || lookahead.peek(Token![extern])
22906- || lookahead.peek(Token![fn])
22907- {
22908- input.parse().map(ImplItem::Method)
22909+ if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
22910+ input.advance_to(&ahead);
22911+ let ident: Ident = input.call(Ident::parse_any)?;
22912+ let colon_token: Token![:] = input.parse()?;
22913+ let ty: Type = input.parse()?;
22914+ if let Some(eq_token) = input.parse()? {
22915+ return Ok(ImplItem::Const(ImplItemConst {
22916+ attrs,
22917+ vis,
22918+ defaultness,
22919+ const_token,
22920+ ident,
22921+ colon_token,
22922+ ty,
22923+ eq_token,
22924+ expr: input.parse()?,
22925+ semi_token: input.parse()?,
22926+ }));
22927+ } else {
22928+ input.parse::<Token![;]>()?;
22929+ return Ok(ImplItem::Verbatim(verbatim::between(begin, input)));
22930+ }
22931 } else {
22932 Err(lookahead.error())
22933 }
22934- } else if lookahead.peek(Token![unsafe])
22935- || lookahead.peek(Token![async])
22936- || lookahead.peek(Token![extern])
22937- || lookahead.peek(Token![fn])
22938- {
22939- input.parse().map(ImplItem::Method)
22940 } else if lookahead.peek(Token![type]) {
22941- input.parse().map(ImplItem::Type)
22942+ parse_impl_item_type(begin, input)
22943 } else if vis.is_inherited() && defaultness.is_none() && lookahead.peek(existential) {
22944 input.call(item_existential).map(ImplItem::Verbatim)
22945 } else if vis.is_inherited()
22946 && defaultness.is_none()
22947 && (lookahead.peek(Ident)
22948 || lookahead.peek(Token![self])
22949 || lookahead.peek(Token![super])
22950- || lookahead.peek(Token![extern])
22951 || lookahead.peek(Token![crate])
22952 || lookahead.peek(Token![::]))
22953 {
22954 input.parse().map(ImplItem::Macro)
22955 } else {
22956 Err(lookahead.error())
22957 }?;
22958
22959@@ -2341,72 +2426,68 @@ pub mod parsing {
22960
22961 impl Parse for ImplItemConst {
22962 fn parse(input: ParseStream) -> Result<Self> {
22963 Ok(ImplItemConst {
22964 attrs: input.call(Attribute::parse_outer)?,
22965 vis: input.parse()?,
22966 defaultness: input.parse()?,
22967 const_token: input.parse()?,
22968- ident: input.parse()?,
22969+ ident: {
22970+ let lookahead = input.lookahead1();
22971+ if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
22972+ input.call(Ident::parse_any)?
22973+ } else {
22974+ return Err(lookahead.error());
22975+ }
22976+ },
22977 colon_token: input.parse()?,
22978 ty: input.parse()?,
22979 eq_token: input.parse()?,
22980 expr: input.parse()?,
22981 semi_token: input.parse()?,
22982 })
22983 }
22984 }
22985
22986 impl Parse for ImplItemMethod {
22987 fn parse(input: ParseStream) -> Result<Self> {
22988- let outer_attrs = input.call(Attribute::parse_outer)?;
22989+ let mut attrs = input.call(Attribute::parse_outer)?;
22990 let vis: Visibility = input.parse()?;
22991 let defaultness: Option<Token![default]> = input.parse()?;
22992- let constness: Option<Token![const]> = input.parse()?;
22993- let asyncness: Option<Token![async]> = input.parse()?;
22994- let unsafety: Option<Token![unsafe]> = input.parse()?;
22995- let abi: Option<Abi> = input.parse()?;
22996- let fn_token: Token![fn] = input.parse()?;
22997- let ident: Ident = input.parse()?;
22998- let generics: Generics = input.parse()?;
22999+ let sig = parse_signature(input)?;
23000
23001- let content;
23002- let paren_token = parenthesized!(content in input);
23003- let inputs = content.parse_terminated(FnArg::parse)?;
23004-
23005- let output: ReturnType = input.parse()?;
23006- let where_clause: Option<WhereClause> = input.parse()?;
23007-
23008- let content;
23009- let brace_token = braced!(content in input);
23010- let inner_attrs = content.call(Attribute::parse_inner)?;
23011- let stmts = content.call(Block::parse_within)?;
23012+ let block = if let Some(semi) = input.parse::<Option<Token![;]>>()? {
23013+ // Accept methods without a body in an impl block because
23014+ // rustc's *parser* does not reject them (the compilation error
23015+ // is emitted later than parsing) and it can be useful for macro
23016+ // DSLs.
23017+ let mut punct = Punct::new(';', Spacing::Alone);
23018+ punct.set_span(semi.span);
23019+ let tokens = TokenStream::from_iter(vec![TokenTree::Punct(punct)]);
23020+ Block {
23021+ brace_token: Brace::default(),
23022+ stmts: vec![Stmt::Item(Item::Verbatim(tokens))],
23023+ }
23024+ } else {
23025+ let content;
23026+ let brace_token = braced!(content in input);
23027+ attrs.extend(content.call(Attribute::parse_inner)?);
23028+ Block {
23029+ brace_token,
23030+ stmts: content.call(Block::parse_within)?,
23031+ }
23032+ };
23033
23034 Ok(ImplItemMethod {
23035- attrs: private::attrs(outer_attrs, inner_attrs),
23036+ attrs,
23037 vis,
23038 defaultness,
23039- sig: Signature {
23040- constness,
23041- asyncness,
23042- unsafety,
23043- abi,
23044- fn_token,
23045- ident,
23046- paren_token,
23047- inputs,
23048- output,
23049- variadic: None,
23050- generics: Generics {
23051- where_clause,
23052- ..generics
23053- },
23054- },
23055- block: Block { brace_token, stmts },
23056+ sig,
23057+ block,
23058 })
23059 }
23060 }
23061
23062 impl Parse for ImplItemType {
23063 fn parse(input: ParseStream) -> Result<Self> {
23064 Ok(ImplItemType {
23065 attrs: input.call(Attribute::parse_outer)?,
23066@@ -2421,16 +2502,47 @@ pub mod parsing {
23067 },
23068 eq_token: input.parse()?,
23069 ty: input.parse()?,
23070 semi_token: input.parse()?,
23071 })
23072 }
23073 }
23074
23075+ fn parse_impl_item_type(begin: ParseBuffer, input: ParseStream) -> Result<ImplItem> {
23076+ let FlexibleItemType {
23077+ vis,
23078+ defaultness,
23079+ type_token,
23080+ ident,
23081+ generics,
23082+ colon_token,
23083+ bounds: _,
23084+ ty,
23085+ semi_token,
23086+ } = input.parse()?;
23087+
23088+ if colon_token.is_some() || ty.is_none() {
23089+ Ok(ImplItem::Verbatim(verbatim::between(begin, input)))
23090+ } else {
23091+ let (eq_token, ty) = ty.unwrap();
23092+ Ok(ImplItem::Type(ImplItemType {
23093+ attrs: Vec::new(),
23094+ vis,
23095+ defaultness,
23096+ type_token,
23097+ ident,
23098+ generics,
23099+ eq_token,
23100+ ty,
23101+ semi_token,
23102+ }))
23103+ }
23104+ }
23105+
23106 impl Parse for ImplItemMacro {
23107 fn parse(input: ParseStream) -> Result<Self> {
23108 let attrs = input.call(Attribute::parse_outer)?;
23109 let mac: Macro = input.parse()?;
23110 let semi_token: Option<Token![;]> = if mac.delimiter.is_brace() {
23111 None
23112 } else {
23113 Some(input.parse()?)
23114@@ -2466,16 +2578,17 @@ pub mod parsing {
23115 mod printing {
23116 use super::*;
23117
23118 use proc_macro2::TokenStream;
23119 use quote::{ToTokens, TokenStreamExt};
23120
23121 use crate::attr::FilterAttrs;
23122 use crate::print::TokensOrDefault;
23123+ use crate::punctuated::Pair;
23124
23125 impl ToTokens for ItemExternCrate {
23126 fn to_tokens(&self, tokens: &mut TokenStream) {
23127 tokens.append_all(self.attrs.outer());
23128 self.vis.to_tokens(tokens);
23129 self.extern_token.to_tokens(tokens);
23130 self.crate_token.to_tokens(tokens);
23131 self.ident.to_tokens(tokens);
23132@@ -2830,16 +2943,24 @@ mod printing {
23133 }
23134
23135 impl ToTokens for ImplItemMethod {
23136 fn to_tokens(&self, tokens: &mut TokenStream) {
23137 tokens.append_all(self.attrs.outer());
23138 self.vis.to_tokens(tokens);
23139 self.defaultness.to_tokens(tokens);
23140 self.sig.to_tokens(tokens);
23141+ if self.block.stmts.len() == 1 {
23142+ if let Stmt::Item(Item::Verbatim(verbatim)) = &self.block.stmts[0] {
23143+ if verbatim.to_string() == ";" {
23144+ verbatim.to_tokens(tokens);
23145+ return;
23146+ }
23147+ }
23148+ }
23149 self.block.brace_token.surround(tokens, |tokens| {
23150 tokens.append_all(self.attrs.inner());
23151 tokens.append_all(&self.block.stmts);
23152 });
23153 }
23154 }
23155
23156 impl ToTokens for ImplItemType {
23157@@ -2900,31 +3021,71 @@ mod printing {
23158 impl ToTokens for ForeignItemMacro {
23159 fn to_tokens(&self, tokens: &mut TokenStream) {
23160 tokens.append_all(self.attrs.outer());
23161 self.mac.to_tokens(tokens);
23162 self.semi_token.to_tokens(tokens);
23163 }
23164 }
23165
23166+ fn maybe_variadic_to_tokens(arg: &FnArg, tokens: &mut TokenStream) -> bool {
23167+ let arg = match arg {
23168+ FnArg::Typed(arg) => arg,
23169+ FnArg::Receiver(receiver) => {
23170+ receiver.to_tokens(tokens);
23171+ return false;
23172+ }
23173+ };
23174+
23175+ match arg.ty.as_ref() {
23176+ Type::Verbatim(ty) if ty.to_string() == "..." => {
23177+ match arg.pat.as_ref() {
23178+ Pat::Verbatim(pat) if pat.to_string() == "..." => {
23179+ tokens.append_all(arg.attrs.outer());
23180+ pat.to_tokens(tokens);
23181+ }
23182+ _ => arg.to_tokens(tokens),
23183+ }
23184+ true
23185+ }
23186+ _ => {
23187+ arg.to_tokens(tokens);
23188+ false
23189+ }
23190+ }
23191+ }
23192+
23193 impl ToTokens for Signature {
23194 fn to_tokens(&self, tokens: &mut TokenStream) {
23195 self.constness.to_tokens(tokens);
23196 self.asyncness.to_tokens(tokens);
23197 self.unsafety.to_tokens(tokens);
23198 self.abi.to_tokens(tokens);
23199 self.fn_token.to_tokens(tokens);
23200 self.ident.to_tokens(tokens);
23201 self.generics.to_tokens(tokens);
23202 self.paren_token.surround(tokens, |tokens| {
23203- self.inputs.to_tokens(tokens);
23204- if self.variadic.is_some() && !self.inputs.empty_or_trailing() {
23205- <Token![,]>::default().to_tokens(tokens);
23206+ let mut last_is_variadic = false;
23207+ for input in self.inputs.pairs() {
23208+ match input {
23209+ Pair::Punctuated(input, comma) => {
23210+ maybe_variadic_to_tokens(input, tokens);
23211+ comma.to_tokens(tokens);
23212+ }
23213+ Pair::End(input) => {
23214+ last_is_variadic = maybe_variadic_to_tokens(input, tokens);
23215+ }
23216+ }
23217 }
23218- self.variadic.to_tokens(tokens);
23219+ if self.variadic.is_some() && !last_is_variadic {
23220+ if !self.inputs.empty_or_trailing() {
23221+ <Token![,]>::default().to_tokens(tokens);
23222+ }
23223+ self.variadic.to_tokens(tokens);
23224+ }
23225 });
23226 self.output.to_tokens(tokens);
23227 self.generics.where_clause.to_tokens(tokens);
23228 }
23229 }
23230
23231 impl ToTokens for Receiver {
23232 fn to_tokens(&self, tokens: &mut TokenStream) {
23233diff --git a/third_party/rust/syn/src/lib.rs b/third_party/rust/syn/src/lib.rs
23234--- a/third_party/rust/syn/src/lib.rs
23235+++ b/third_party/rust/syn/src/lib.rs
23236@@ -1,8 +1,16 @@
23237+//! [![github]](https://github.com/dtolnay/syn)&ensp;[![crates-io]](https://crates.io/crates/syn)&ensp;[![docs-rs]](https://docs.rs/syn)
23238+//!
23239+//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
23240+//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
23241+//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K
23242+//!
23243+//! <br>
23244+//!
23245 //! Syn is a parsing library for parsing a stream of Rust tokens into a syntax
23246 //! tree of Rust source code.
23247 //!
23248 //! Currently this library is geared toward use in Rust procedural macros, but
23249 //! contains some APIs that may be useful more generally.
23250 //!
23251 //! - **Data structures** — Syn provides a complete syntax tree that can
23252 //! represent any valid Rust source code. The syntax tree is rooted at
23253@@ -57,18 +65,18 @@
23254 //! syn = "1.0"
23255 //! quote = "1.0"
23256 //!
23257 //! [lib]
23258 //! proc-macro = true
23259 //! ```
23260 //!
23261 //! ```
23262-//! extern crate proc_macro;
23263-//!
23264+//! # extern crate proc_macro;
23265+//! #
23266 //! use proc_macro::TokenStream;
23267 //! use quote::quote;
23268 //! use syn::{parse_macro_input, DeriveInput};
23269 //!
23270 //! # const IGNORE_TOKENS: &str = stringify! {
23271 //! #[proc_macro_derive(MyMacro)]
23272 //! # };
23273 //! pub fn my_macro(input: TokenStream) -> TokenStream {
23274@@ -237,59 +245,71 @@
23275 //! - **`clone-impls`** *(enabled by default)* — Clone impls for all syntax tree
23276 //! types.
23277 //! - **`extra-traits`** — Debug, Eq, PartialEq, Hash impls for all syntax tree
23278 //! types.
23279 //! - **`proc-macro`** *(enabled by default)* — Runtime dependency on the
23280 //! dynamic library libproc_macro from rustc toolchain.
23281
23282 // Syn types in rustdoc of other crates get linked to here.
23283-#![doc(html_root_url = "https://docs.rs/syn/1.0.5")]
23284+#![doc(html_root_url = "https://docs.rs/syn/1.0.40")]
23285 #![deny(clippy::all, clippy::pedantic)]
23286 // Ignored clippy lints.
23287 #![allow(
23288- clippy::block_in_if_condition_stmt,
23289+ clippy::blocks_in_if_conditions,
23290 clippy::cognitive_complexity,
23291 clippy::doc_markdown,
23292 clippy::eval_order_dependence,
23293 clippy::inherent_to_string,
23294 clippy::large_enum_variant,
23295+ clippy::manual_non_exhaustive,
23296+ clippy::match_like_matches_macro,
23297+ clippy::match_on_vec_items,
23298+ clippy::needless_doctest_main,
23299 clippy::needless_pass_by_value,
23300 clippy::never_loop,
23301 clippy::suspicious_op_assign_impl,
23302 clippy::too_many_arguments,
23303- clippy::trivially_copy_pass_by_ref
23304+ clippy::trivially_copy_pass_by_ref,
23305+ clippy::unnecessary_unwrap
23306 )]
23307 // Ignored clippy_pedantic lints.
23308 #![allow(
23309 clippy::cast_possible_truncation,
23310+ clippy::default_trait_access,
23311 clippy::empty_enum,
23312+ clippy::expl_impl_clone_on_copy,
23313 clippy::if_not_else,
23314 clippy::items_after_statements,
23315+ clippy::match_same_arms,
23316+ clippy::missing_errors_doc,
23317 clippy::module_name_repetitions,
23318+ clippy::must_use_candidate,
23319+ clippy::option_if_let_else,
23320 clippy::shadow_unrelated,
23321 clippy::similar_names,
23322 clippy::single_match_else,
23323+ clippy::too_many_lines,
23324 clippy::unseparated_literal_suffix,
23325 clippy::use_self,
23326- clippy::used_underscore_binding
23327+ clippy::used_underscore_binding,
23328+ clippy::wildcard_imports
23329 )]
23330
23331 #[cfg(all(
23332 not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
23333 feature = "proc-macro"
23334 ))]
23335 extern crate proc_macro;
23336 extern crate proc_macro2;
23337 extern crate unicode_xid;
23338
23339 #[cfg(feature = "printing")]
23340 extern crate quote;
23341
23342-#[cfg(any(feature = "full", feature = "derive"))]
23343 #[macro_use]
23344 mod macros;
23345
23346 // Not public API.
23347 #[cfg(feature = "parsing")]
23348 #[doc(hidden)]
23349 #[macro_use]
23350 pub mod group;
23351@@ -302,17 +322,16 @@ pub use crate::ident::Ident;
23352
23353 #[cfg(any(feature = "full", feature = "derive"))]
23354 mod attr;
23355 #[cfg(any(feature = "full", feature = "derive"))]
23356 pub use crate::attr::{
23357 AttrStyle, Attribute, AttributeArgs, Meta, MetaList, MetaNameValue, NestedMeta,
23358 };
23359
23360-#[cfg(any(feature = "full", feature = "derive"))]
23361 mod bigint;
23362
23363 #[cfg(any(feature = "full", feature = "derive"))]
23364 mod data;
23365 #[cfg(any(feature = "full", feature = "derive"))]
23366 pub use crate::data::{
23367 Field, Fields, FieldsNamed, FieldsUnnamed, Variant, VisCrate, VisPublic, VisRestricted,
23368 Visibility,
23369@@ -359,19 +378,17 @@ pub use crate::item::{
23370 #[cfg(feature = "full")]
23371 mod file;
23372 #[cfg(feature = "full")]
23373 pub use crate::file::File;
23374
23375 mod lifetime;
23376 pub use crate::lifetime::Lifetime;
23377
23378-#[cfg(any(feature = "full", feature = "derive"))]
23379 mod lit;
23380-#[cfg(any(feature = "full", feature = "derive"))]
23381 pub use crate::lit::{
23382 Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr, StrStyle,
23383 };
23384
23385 #[cfg(any(feature = "full", feature = "derive"))]
23386 mod mac;
23387 #[cfg(any(feature = "full", feature = "derive"))]
23388 pub use crate::mac::{Macro, MacroDelimiter};
23389@@ -436,16 +453,19 @@ pub mod parse_quote;
23390 feature = "proc-macro"
23391 ))]
23392 #[doc(hidden)]
23393 pub mod parse_macro_input;
23394
23395 #[cfg(all(feature = "parsing", feature = "printing"))]
23396 pub mod spanned;
23397
23398+#[cfg(all(feature = "parsing", feature = "full"))]
23399+mod whitespace;
23400+
23401 mod gen {
23402 /// Syntax tree traversal to walk a shared borrow of a syntax tree.
23403 ///
23404 /// Each method of the [`Visit`] trait is a hook that can be overridden to
23405 /// customize the behavior when visiting the corresponding type of node. By
23406 /// default, every method recursively visits the substructure of the input
23407 /// by invoking the right visitor method of each of its fields.
23408 ///
23409@@ -477,17 +497,17 @@ mod gen {
23410 /// v.visit_expr(&*node.left);
23411 /// v.visit_bin_op(&node.op);
23412 /// v.visit_expr(&*node.right);
23413 /// }
23414 ///
23415 /// /* ... */
23416 /// ```
23417 ///
23418- /// *This module is available if Syn is built with the `"visit"` feature.*
23419+ /// *This module is available only if Syn is built with the `"visit"` feature.*
23420 ///
23421 /// <br>
23422 ///
23423 /// # Example
23424 ///
23425 /// This visitor will print the name of every freestanding function in the
23426 /// syntax tree, including nested functions.
23427 ///
23428@@ -598,17 +618,17 @@ mod gen {
23429 /// v.visit_expr_mut(&mut *node.left);
23430 /// v.visit_bin_op_mut(&mut node.op);
23431 /// v.visit_expr_mut(&mut *node.right);
23432 /// }
23433 ///
23434 /// /* ... */
23435 /// ```
23436 ///
23437- /// *This module is available if Syn is built with the `"visit-mut"`
23438+ /// *This module is available only if Syn is built with the `"visit-mut"`
23439 /// feature.*
23440 ///
23441 /// <br>
23442 ///
23443 /// # Example
23444 ///
23445 /// This mut visitor replace occurrences of u256 suffixed integer literals
23446 /// like `999u256` with a macro invocation `bigint::u256!(999)`.
23447@@ -697,17 +717,17 @@ mod gen {
23448 /// op: v.fold_bin_op(node.op),
23449 /// right: Box::new(v.fold_expr(*node.right)),
23450 /// }
23451 /// }
23452 ///
23453 /// /* ... */
23454 /// ```
23455 ///
23456- /// *This module is available if Syn is built with the `"fold"` feature.*
23457+ /// *This module is available only if Syn is built with the `"fold"` feature.*
23458 ///
23459 /// <br>
23460 ///
23461 /// # Example
23462 ///
23463 /// This fold inserts parentheses to fully parenthesizes any expression.
23464 ///
23465 /// ```
23466@@ -739,43 +759,63 @@ mod gen {
23467 ///
23468 /// // Output: (((a)()) + (((b)((1))) * ((c).d)))
23469 /// }
23470 /// ```
23471 #[cfg(feature = "fold")]
23472 #[rustfmt::skip]
23473 pub mod fold;
23474
23475+ #[cfg(feature = "clone-impls")]
23476+ #[rustfmt::skip]
23477+ mod clone;
23478+
23479+ #[cfg(feature = "extra-traits")]
23480+ #[rustfmt::skip]
23481+ mod eq;
23482+
23483+ #[cfg(feature = "extra-traits")]
23484+ #[rustfmt::skip]
23485+ mod hash;
23486+
23487+ #[cfg(feature = "extra-traits")]
23488+ #[rustfmt::skip]
23489+ mod debug;
23490+
23491 #[cfg(any(feature = "full", feature = "derive"))]
23492 #[path = "../gen_helper.rs"]
23493 mod helper;
23494 }
23495 pub use crate::gen::*;
23496
23497 // Not public API.
23498 #[doc(hidden)]
23499 pub mod export;
23500
23501 mod custom_keyword;
23502 mod custom_punctuation;
23503 mod sealed;
23504+mod span;
23505+mod thread;
23506
23507 #[cfg(feature = "parsing")]
23508 mod lookahead;
23509
23510 #[cfg(feature = "parsing")]
23511 pub mod parse;
23512
23513-mod span;
23514+#[cfg(feature = "full")]
23515+mod reserved;
23516+
23517+#[cfg(all(any(feature = "full", feature = "derive"), feature = "parsing"))]
23518+mod verbatim;
23519
23520 #[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))]
23521 mod print;
23522
23523-mod thread;
23524-
23525 ////////////////////////////////////////////////////////////////////////////////
23526
23527 #[allow(dead_code, non_camel_case_types)]
23528 struct private;
23529
23530 // https://github.com/rust-lang/rust/issues/62830
23531 #[cfg(feature = "parsing")]
23532 mod rustdoc_workaround {
23533@@ -795,24 +835,24 @@ pub use crate::error::{Error, Result};
23534 /// messages.
23535 ///
23536 /// This function parses a `proc_macro::TokenStream` which is the type used for
23537 /// interop with the compiler in a procedural macro. To parse a
23538 /// `proc_macro2::TokenStream`, use [`syn::parse2`] instead.
23539 ///
23540 /// [`syn::parse2`]: parse2
23541 ///
23542-/// *This function is available if Syn is built with both the `"parsing"` and
23543+/// *This function is available only if Syn is built with both the `"parsing"` and
23544 /// `"proc-macro"` features.*
23545 ///
23546 /// # Examples
23547 ///
23548 /// ```
23549-/// extern crate proc_macro;
23550-///
23551+/// # extern crate proc_macro;
23552+/// #
23553 /// use proc_macro::TokenStream;
23554 /// use quote::quote;
23555 /// use syn::DeriveInput;
23556 ///
23557 /// # const IGNORE_TOKENS: &str = stringify! {
23558 /// #[proc_macro_derive(MyMacro)]
23559 /// # };
23560 /// pub fn my_macro(input: TokenStream) -> TokenStream {
23561@@ -842,25 +882,25 @@ pub fn parse<T: parse::Parse>(tokens: pr
23562 /// This function parses a `proc_macro2::TokenStream` which is commonly useful
23563 /// when the input comes from a node of the Syn syntax tree, for example the
23564 /// body tokens of a [`Macro`] node. When in a procedural macro parsing the
23565 /// `proc_macro::TokenStream` provided by the compiler, use [`syn::parse`]
23566 /// instead.
23567 ///
23568 /// [`syn::parse`]: parse()
23569 ///
23570-/// *This function is available if Syn is built with the `"parsing"` feature.*
23571+/// *This function is available only if Syn is built with the `"parsing"` feature.*
23572 #[cfg(feature = "parsing")]
23573 pub fn parse2<T: parse::Parse>(tokens: proc_macro2::TokenStream) -> Result<T> {
23574 parse::Parser::parse2(T::parse, tokens)
23575 }
23576
23577 /// Parse a string of Rust code into the chosen syntax tree node.
23578 ///
23579-/// *This function is available if Syn is built with the `"parsing"` feature.*
23580+/// *This function is available only if Syn is built with the `"parsing"` feature.*
23581 ///
23582 /// # Hygiene
23583 ///
23584 /// Every span in the resulting syntax tree will be set to resolve at the macro
23585 /// call site.
23586 ///
23587 /// # Examples
23588 ///
23589@@ -869,19 +909,17 @@ pub fn parse2<T: parse::Parse>(tokens: p
23590 ///
23591 /// fn run() -> Result<()> {
23592 /// let code = "assert_eq!(u8::max_value(), 255)";
23593 /// let expr = syn::parse_str::<Expr>(code)?;
23594 /// println!("{:#?}", expr);
23595 /// Ok(())
23596 /// }
23597 /// #
23598-/// # fn main() {
23599-/// # run().unwrap();
23600-/// # }
23601+/// # run().unwrap();
23602 /// ```
23603 #[cfg(feature = "parsing")]
23604 pub fn parse_str<T: parse::Parse>(s: &str) -> Result<T> {
23605 parse::Parser::parse_str(T::parse, s)
23606 }
23607
23608 // FIXME the name parse_file makes it sound like you might pass in a path to a
23609 // file, rather than the content.
23610@@ -889,17 +927,17 @@ pub fn parse_str<T: parse::Parse>(s: &st
23611 ///
23612 /// This is different from `syn::parse_str::<File>(content)` in two ways:
23613 ///
23614 /// - It discards a leading byte order mark `\u{FEFF}` if the file has one.
23615 /// - It preserves the shebang line of the file, such as `#!/usr/bin/env rustx`.
23616 ///
23617 /// If present, either of these would be an error using `from_str`.
23618 ///
23619-/// *This function is available if Syn is built with the `"parsing"` and
23620+/// *This function is available only if Syn is built with the `"parsing"` and
23621 /// `"full"` features.*
23622 ///
23623 /// # Examples
23624 ///
23625 /// ```no_run
23626 /// use std::error::Error;
23627 /// use std::fs::File;
23628 /// use std::io::Read;
23629@@ -913,35 +951,36 @@ pub fn parse_str<T: parse::Parse>(s: &st
23630 /// if let Some(shebang) = ast.shebang {
23631 /// println!("{}", shebang);
23632 /// }
23633 /// println!("{} items", ast.items.len());
23634 ///
23635 /// Ok(())
23636 /// }
23637 /// #
23638-/// # fn main() {
23639-/// # run().unwrap();
23640-/// # }
23641+/// # run().unwrap();
23642 /// ```
23643 #[cfg(all(feature = "parsing", feature = "full"))]
23644 pub fn parse_file(mut content: &str) -> Result<File> {
23645 // Strip the BOM if it is present
23646 const BOM: &str = "\u{feff}";
23647 if content.starts_with(BOM) {
23648 content = &content[BOM.len()..];
23649 }
23650
23651 let mut shebang = None;
23652- if content.starts_with("#!") && !content.starts_with("#![") {
23653- if let Some(idx) = content.find('\n') {
23654- shebang = Some(content[..idx].to_string());
23655- content = &content[idx..];
23656- } else {
23657- shebang = Some(content.to_string());
23658- content = "";
23659+ if content.starts_with("#!") {
23660+ let rest = whitespace::skip(&content[2..]);
23661+ if !rest.starts_with('[') {
23662+ if let Some(idx) = content.find('\n') {
23663+ shebang = Some(content[..idx].to_string());
23664+ content = &content[idx..];
23665+ } else {
23666+ shebang = Some(content.to_string());
23667+ content = "";
23668+ }
23669 }
23670 }
23671
23672 let mut file: File = parse_str(content)?;
23673 file.shebang = shebang;
23674 Ok(file)
23675 }
23676diff --git a/third_party/rust/syn/src/lifetime.rs b/third_party/rust/syn/src/lifetime.rs
23677--- a/third_party/rust/syn/src/lifetime.rs
23678+++ b/third_party/rust/syn/src/lifetime.rs
23679@@ -13,20 +13,18 @@ use crate::lookahead;
23680 ///
23681 /// - Must start with an apostrophe.
23682 /// - Must not consist of just an apostrophe: `'`.
23683 /// - Character after the apostrophe must be `_` or a Unicode code point with
23684 /// the XID_Start property.
23685 /// - All following characters must be Unicode code points with the XID_Continue
23686 /// property.
23687 ///
23688-/// *This type is available if Syn is built with the `"derive"` or `"full"`
23689+/// *This type is available only if Syn is built with the `"derive"` or `"full"`
23690 /// feature.*
23691-#[cfg_attr(feature = "extra-traits", derive(Debug))]
23692-#[derive(Clone)]
23693 pub struct Lifetime {
23694 pub apostrophe: Span,
23695 pub ident: Ident,
23696 }
23697
23698 impl Lifetime {
23699 /// # Panics
23700 ///
23701@@ -67,16 +65,25 @@ impl Lifetime {
23702
23703 impl Display for Lifetime {
23704 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
23705 "'".fmt(formatter)?;
23706 self.ident.fmt(formatter)
23707 }
23708 }
23709
23710+impl Clone for Lifetime {
23711+ fn clone(&self) -> Self {
23712+ Lifetime {
23713+ apostrophe: self.apostrophe,
23714+ ident: self.ident.clone(),
23715+ }
23716+ }
23717+}
23718+
23719 impl PartialEq for Lifetime {
23720 fn eq(&self, other: &Lifetime) -> bool {
23721 self.ident.eq(&other.ident)
23722 }
23723 }
23724
23725 impl Eq for Lifetime {}
23726
23727diff --git a/third_party/rust/syn/src/lit.rs b/third_party/rust/syn/src/lit.rs
23728--- a/third_party/rust/syn/src/lit.rs
23729+++ b/third_party/rust/syn/src/lit.rs
23730@@ -17,28 +17,25 @@ use std::hash::{Hash, Hasher};
23731 use crate::lookahead;
23732 #[cfg(feature = "parsing")]
23733 use crate::parse::{Parse, Parser};
23734 use crate::{Error, Result};
23735
23736 ast_enum_of_structs! {
23737 /// A Rust literal such as a string or integer or boolean.
23738 ///
23739- /// *This type is available if Syn is built with the `"derive"` or `"full"`
23740- /// feature.*
23741- ///
23742 /// # Syntax tree enum
23743 ///
23744 /// This type is a [syntax tree enum].
23745 ///
23746 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
23747 //
23748 // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
23749 // blocked on https://github.com/rust-lang/rust/issues/62833
23750- pub enum Lit #manual_extra_traits {
23751+ pub enum Lit {
23752 /// A UTF-8 string literal: `"foo"`.
23753 Str(LitStr),
23754
23755 /// A byte string literal: `b"foo"`.
23756 ByteStr(LitByteStr),
23757
23758 /// A byte literal: `b'f'`.
23759 Byte(LitByte),
23760@@ -59,184 +56,98 @@ ast_enum_of_structs! {
23761
23762 /// A raw token literal not interpreted by Syn.
23763 Verbatim(Literal),
23764 }
23765 }
23766
23767 ast_struct! {
23768 /// A UTF-8 string literal: `"foo"`.
23769- ///
23770- /// *This type is available if Syn is built with the `"derive"` or
23771- /// `"full"` feature.*
23772- pub struct LitStr #manual_extra_traits_debug {
23773- repr: Box<LitStrRepr>,
23774+ pub struct LitStr {
23775+ repr: Box<LitRepr>,
23776 }
23777 }
23778
23779-#[cfg_attr(feature = "clone-impls", derive(Clone))]
23780-struct LitStrRepr {
23781- token: Literal,
23782- suffix: Box<str>,
23783-}
23784-
23785 ast_struct! {
23786 /// A byte string literal: `b"foo"`.
23787- ///
23788- /// *This type is available if Syn is built with the `"derive"` or
23789- /// `"full"` feature.*
23790- pub struct LitByteStr #manual_extra_traits_debug {
23791- token: Literal,
23792+ pub struct LitByteStr {
23793+ repr: Box<LitRepr>,
23794 }
23795 }
23796
23797 ast_struct! {
23798 /// A byte literal: `b'f'`.
23799- ///
23800- /// *This type is available if Syn is built with the `"derive"` or
23801- /// `"full"` feature.*
23802- pub struct LitByte #manual_extra_traits_debug {
23803- token: Literal,
23804+ pub struct LitByte {
23805+ repr: Box<LitRepr>,
23806 }
23807 }
23808
23809 ast_struct! {
23810 /// A character literal: `'a'`.
23811- ///
23812- /// *This type is available if Syn is built with the `"derive"` or
23813- /// `"full"` feature.*
23814- pub struct LitChar #manual_extra_traits_debug {
23815- token: Literal,
23816+ pub struct LitChar {
23817+ repr: Box<LitRepr>,
23818 }
23819 }
23820
23821+struct LitRepr {
23822+ token: Literal,
23823+ suffix: Box<str>,
23824+}
23825+
23826 ast_struct! {
23827 /// An integer literal: `1` or `1u16`.
23828- ///
23829- /// *This type is available if Syn is built with the `"derive"` or
23830- /// `"full"` feature.*
23831- pub struct LitInt #manual_extra_traits_debug {
23832+ pub struct LitInt {
23833 repr: Box<LitIntRepr>,
23834 }
23835 }
23836
23837-#[cfg_attr(feature = "clone-impls", derive(Clone))]
23838 struct LitIntRepr {
23839 token: Literal,
23840 digits: Box<str>,
23841 suffix: Box<str>,
23842 }
23843
23844 ast_struct! {
23845 /// A floating point literal: `1f64` or `1.0e10f64`.
23846 ///
23847 /// Must be finite. May not be infinte or NaN.
23848- ///
23849- /// *This type is available if Syn is built with the `"derive"` or
23850- /// `"full"` feature.*
23851- pub struct LitFloat #manual_extra_traits_debug {
23852+ pub struct LitFloat {
23853 repr: Box<LitFloatRepr>,
23854 }
23855 }
23856
23857-#[cfg_attr(feature = "clone-impls", derive(Clone))]
23858 struct LitFloatRepr {
23859 token: Literal,
23860 digits: Box<str>,
23861 suffix: Box<str>,
23862 }
23863
23864 ast_struct! {
23865 /// A boolean literal: `true` or `false`.
23866- ///
23867- /// *This type is available if Syn is built with the `"derive"` or
23868- /// `"full"` feature.*
23869- pub struct LitBool #manual_extra_traits_debug {
23870+ pub struct LitBool {
23871 pub value: bool,
23872 pub span: Span,
23873 }
23874 }
23875
23876-#[cfg(feature = "extra-traits")]
23877-impl Eq for Lit {}
23878-
23879-#[cfg(feature = "extra-traits")]
23880-impl PartialEq for Lit {
23881- fn eq(&self, other: &Self) -> bool {
23882- match (self, other) {
23883- (Lit::Str(this), Lit::Str(other)) => this == other,
23884- (Lit::ByteStr(this), Lit::ByteStr(other)) => this == other,
23885- (Lit::Byte(this), Lit::Byte(other)) => this == other,
23886- (Lit::Char(this), Lit::Char(other)) => this == other,
23887- (Lit::Int(this), Lit::Int(other)) => this == other,
23888- (Lit::Float(this), Lit::Float(other)) => this == other,
23889- (Lit::Bool(this), Lit::Bool(other)) => this == other,
23890- (Lit::Verbatim(this), Lit::Verbatim(other)) => this.to_string() == other.to_string(),
23891- _ => false,
23892- }
23893- }
23894-}
23895-
23896-#[cfg(feature = "extra-traits")]
23897-impl Hash for Lit {
23898- fn hash<H>(&self, hash: &mut H)
23899- where
23900- H: Hasher,
23901- {
23902- match self {
23903- Lit::Str(lit) => {
23904- hash.write_u8(0);
23905- lit.hash(hash);
23906- }
23907- Lit::ByteStr(lit) => {
23908- hash.write_u8(1);
23909- lit.hash(hash);
23910- }
23911- Lit::Byte(lit) => {
23912- hash.write_u8(2);
23913- lit.hash(hash);
23914- }
23915- Lit::Char(lit) => {
23916- hash.write_u8(3);
23917- lit.hash(hash);
23918- }
23919- Lit::Int(lit) => {
23920- hash.write_u8(4);
23921- lit.hash(hash);
23922- }
23923- Lit::Float(lit) => {
23924- hash.write_u8(5);
23925- lit.hash(hash);
23926- }
23927- Lit::Bool(lit) => {
23928- hash.write_u8(6);
23929- lit.hash(hash);
23930- }
23931- Lit::Verbatim(lit) => {
23932- hash.write_u8(7);
23933- lit.to_string().hash(hash);
23934- }
23935- }
23936- }
23937-}
23938-
23939 impl LitStr {
23940 pub fn new(value: &str, span: Span) -> Self {
23941- let mut lit = Literal::string(value);
23942- lit.set_span(span);
23943+ let mut token = Literal::string(value);
23944+ token.set_span(span);
23945 LitStr {
23946- repr: Box::new(LitStrRepr {
23947- token: lit,
23948+ repr: Box::new(LitRepr {
23949+ token,
23950 suffix: Box::<str>::default(),
23951 }),
23952 }
23953 }
23954
23955 pub fn value(&self) -> String {
23956- let (value, _) = value::parse_lit_str(&self.repr.token.to_string());
23957+ let repr = self.repr.token.to_string();
23958+ let (value, _suffix) = value::parse_lit_str(&repr);
23959 String::from(value)
23960 }
23961
23962 /// Parse a syntax tree node from the content of this string literal.
23963 ///
23964 /// All spans in the syntax tree will point to the span of this `LitStr`.
23965 ///
23966 /// # Example
23967@@ -306,17 +217,17 @@ impl LitStr {
23968 .map(|token| respan_token_tree(token, span))
23969 .collect()
23970 }
23971
23972 // Token tree with every span replaced by the given one.
23973 fn respan_token_tree(mut token: TokenTree, span: Span) -> TokenTree {
23974 match &mut token {
23975 TokenTree::Group(g) => {
23976- let stream = respan_token_stream(g.stream().clone(), span);
23977+ let stream = respan_token_stream(g.stream(), span);
23978 *g = Group::new(g.delimiter(), stream);
23979 g.set_span(span);
23980 }
23981 other => other.set_span(span),
23982 }
23983 token
23984 }
23985
23986@@ -340,86 +251,124 @@ impl LitStr {
23987 &self.repr.suffix
23988 }
23989 }
23990
23991 impl LitByteStr {
23992 pub fn new(value: &[u8], span: Span) -> Self {
23993 let mut token = Literal::byte_string(value);
23994 token.set_span(span);
23995- LitByteStr { token }
23996+ LitByteStr {
23997+ repr: Box::new(LitRepr {
23998+ token,
23999+ suffix: Box::<str>::default(),
24000+ }),
24001+ }
24002 }
24003
24004 pub fn value(&self) -> Vec<u8> {
24005- value::parse_lit_byte_str(&self.token.to_string())
24006+ let repr = self.repr.token.to_string();
24007+ let (value, _suffix) = value::parse_lit_byte_str(&repr);
24008+ value
24009 }
24010
24011 pub fn span(&self) -> Span {
24012- self.token.span()
24013+ self.repr.token.span()
24014 }
24015
24016 pub fn set_span(&mut self, span: Span) {
24017- self.token.set_span(span)
24018+ self.repr.token.set_span(span)
24019+ }
24020+
24021+ pub fn suffix(&self) -> &str {
24022+ &self.repr.suffix
24023 }
24024 }
24025
24026 impl LitByte {
24027 pub fn new(value: u8, span: Span) -> Self {
24028 let mut token = Literal::u8_suffixed(value);
24029 token.set_span(span);
24030- LitByte { token }
24031+ LitByte {
24032+ repr: Box::new(LitRepr {
24033+ token,
24034+ suffix: Box::<str>::default(),
24035+ }),
24036+ }
24037 }
24038
24039 pub fn value(&self) -> u8 {
24040- value::parse_lit_byte(&self.token.to_string())
24041+ let repr = self.repr.token.to_string();
24042+ let (value, _suffix) = value::parse_lit_byte(&repr);
24043+ value
24044 }
24045
24046 pub fn span(&self) -> Span {
24047- self.token.span()
24048+ self.repr.token.span()
24049 }
24050
24051 pub fn set_span(&mut self, span: Span) {
24052- self.token.set_span(span)
24053+ self.repr.token.set_span(span)
24054+ }
24055+
24056+ pub fn suffix(&self) -> &str {
24057+ &self.repr.suffix
24058 }
24059 }
24060
24061 impl LitChar {
24062 pub fn new(value: char, span: Span) -> Self {
24063 let mut token = Literal::character(value);
24064 token.set_span(span);
24065- LitChar { token }
24066+ LitChar {
24067+ repr: Box::new(LitRepr {
24068+ token,
24069+ suffix: Box::<str>::default(),
24070+ }),
24071+ }
24072 }
24073
24074 pub fn value(&self) -> char {
24075- value::parse_lit_char(&self.token.to_string())
24076+ let repr = self.repr.token.to_string();
24077+ let (value, _suffix) = value::parse_lit_char(&repr);
24078+ value
24079 }
24080
24081 pub fn span(&self) -> Span {
24082- self.token.span()
24083+ self.repr.token.span()
24084 }
24085
24086 pub fn set_span(&mut self, span: Span) {
24087- self.token.set_span(span)
24088+ self.repr.token.set_span(span)
24089+ }
24090+
24091+ pub fn suffix(&self) -> &str {
24092+ &self.repr.suffix
24093 }
24094 }
24095
24096 impl LitInt {
24097 pub fn new(repr: &str, span: Span) -> Self {
24098- if let Some((digits, suffix)) = value::parse_lit_int(repr) {
24099- let mut token = value::to_literal(repr);
24100- token.set_span(span);
24101- LitInt {
24102- repr: Box::new(LitIntRepr {
24103- token,
24104- digits,
24105- suffix,
24106- }),
24107- }
24108- } else {
24109- panic!("Not an integer literal: `{}`", repr);
24110+ let (digits, suffix) = match value::parse_lit_int(repr) {
24111+ Some(parse) => parse,
24112+ None => panic!("Not an integer literal: `{}`", repr),
24113+ };
24114+
24115+ let mut token = match value::to_literal(repr, &digits, &suffix) {
24116+ Some(token) => token,
24117+ None => panic!("Unsupported integer literal: `{}`", repr),
24118+ };
24119+
24120+ token.set_span(span);
24121+ LitInt {
24122+ repr: Box::new(LitIntRepr {
24123+ token,
24124+ digits,
24125+ suffix,
24126+ }),
24127 }
24128 }
24129
24130 pub fn base10_digits(&self) -> &str {
24131 &self.repr.digits
24132 }
24133
24134 /// Parses the literal into a selected number type.
24135@@ -487,28 +436,33 @@ impl From<Literal> for LitInt {
24136 impl Display for LitInt {
24137 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
24138 self.repr.token.fmt(formatter)
24139 }
24140 }
24141
24142 impl LitFloat {
24143 pub fn new(repr: &str, span: Span) -> Self {
24144- if let Some((digits, suffix)) = value::parse_lit_float(repr) {
24145- let mut token = value::to_literal(repr);
24146- token.set_span(span);
24147- LitFloat {
24148- repr: Box::new(LitFloatRepr {
24149- token,
24150- digits,
24151- suffix,
24152- }),
24153- }
24154- } else {
24155- panic!("Not a float literal: `{}`", repr);
24156+ let (digits, suffix) = match value::parse_lit_float(repr) {
24157+ Some(parse) => parse,
24158+ None => panic!("Not a float literal: `{}`", repr),
24159+ };
24160+
24161+ let mut token = match value::to_literal(repr, &digits, &suffix) {
24162+ Some(token) => token,
24163+ None => panic!("Unsupported float literal: `{}`", repr),
24164+ };
24165+
24166+ token.set_span(span);
24167+ LitFloat {
24168+ repr: Box::new(LitFloatRepr {
24169+ token,
24170+ digits,
24171+ suffix,
24172+ }),
24173 }
24174 }
24175
24176 pub fn base10_digits(&self) -> &str {
24177 &self.repr.digits
24178 }
24179
24180 pub fn base10_parse<N>(&self) -> Result<N>
24181@@ -570,35 +524,35 @@ mod debug_impls {
24182 .finish()
24183 }
24184 }
24185
24186 impl Debug for LitByteStr {
24187 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
24188 formatter
24189 .debug_struct("LitByteStr")
24190- .field("token", &format_args!("{}", self.token))
24191+ .field("token", &format_args!("{}", self.repr.token))
24192 .finish()
24193 }
24194 }
24195
24196 impl Debug for LitByte {
24197 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
24198 formatter
24199 .debug_struct("LitByte")
24200- .field("token", &format_args!("{}", self.token))
24201+ .field("token", &format_args!("{}", self.repr.token))
24202 .finish()
24203 }
24204 }
24205
24206 impl Debug for LitChar {
24207 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
24208 formatter
24209 .debug_struct("LitChar")
24210- .field("token", &format_args!("{}", self.token))
24211+ .field("token", &format_args!("{}", self.repr.token))
24212 .finish()
24213 }
24214 }
24215
24216 impl Debug for LitInt {
24217 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
24218 formatter
24219 .debug_struct("LitInt")
24220@@ -621,61 +575,102 @@ mod debug_impls {
24221 formatter
24222 .debug_struct("LitBool")
24223 .field("value", &self.value)
24224 .finish()
24225 }
24226 }
24227 }
24228
24229+#[cfg(feature = "clone-impls")]
24230+impl Clone for LitRepr {
24231+ fn clone(&self) -> Self {
24232+ LitRepr {
24233+ token: self.token.clone(),
24234+ suffix: self.suffix.clone(),
24235+ }
24236+ }
24237+}
24238+
24239+#[cfg(feature = "clone-impls")]
24240+impl Clone for LitIntRepr {
24241+ fn clone(&self) -> Self {
24242+ LitIntRepr {
24243+ token: self.token.clone(),
24244+ digits: self.digits.clone(),
24245+ suffix: self.suffix.clone(),
24246+ }
24247+ }
24248+}
24249+
24250+#[cfg(feature = "clone-impls")]
24251+impl Clone for LitFloatRepr {
24252+ fn clone(&self) -> Self {
24253+ LitFloatRepr {
24254+ token: self.token.clone(),
24255+ digits: self.digits.clone(),
24256+ suffix: self.suffix.clone(),
24257+ }
24258+ }
24259+}
24260+
24261 macro_rules! lit_extra_traits {
24262- ($ty:ident, $($field:ident).+) => {
24263- #[cfg(feature = "extra-traits")]
24264- impl Eq for $ty {}
24265+ ($ty:ident) => {
24266+ #[cfg(feature = "clone-impls")]
24267+ impl Clone for $ty {
24268+ fn clone(&self) -> Self {
24269+ $ty {
24270+ repr: self.repr.clone(),
24271+ }
24272+ }
24273+ }
24274
24275 #[cfg(feature = "extra-traits")]
24276 impl PartialEq for $ty {
24277 fn eq(&self, other: &Self) -> bool {
24278- self.$($field).+.to_string() == other.$($field).+.to_string()
24279+ self.repr.token.to_string() == other.repr.token.to_string()
24280 }
24281 }
24282
24283 #[cfg(feature = "extra-traits")]
24284 impl Hash for $ty {
24285 fn hash<H>(&self, state: &mut H)
24286 where
24287 H: Hasher,
24288 {
24289- self.$($field).+.to_string().hash(state);
24290+ self.repr.token.to_string().hash(state);
24291 }
24292 }
24293
24294 #[cfg(feature = "parsing")]
24295 #[doc(hidden)]
24296 #[allow(non_snake_case)]
24297 pub fn $ty(marker: lookahead::TokenMarker) -> $ty {
24298 match marker {}
24299 }
24300 };
24301 }
24302
24303-lit_extra_traits!(LitStr, repr.token);
24304-lit_extra_traits!(LitByteStr, token);
24305-lit_extra_traits!(LitByte, token);
24306-lit_extra_traits!(LitChar, token);
24307-lit_extra_traits!(LitInt, repr.token);
24308-lit_extra_traits!(LitFloat, repr.token);
24309-lit_extra_traits!(LitBool, value);
24310+lit_extra_traits!(LitStr);
24311+lit_extra_traits!(LitByteStr);
24312+lit_extra_traits!(LitByte);
24313+lit_extra_traits!(LitChar);
24314+lit_extra_traits!(LitInt);
24315+lit_extra_traits!(LitFloat);
24316+
24317+#[cfg(feature = "parsing")]
24318+#[doc(hidden)]
24319+#[allow(non_snake_case)]
24320+pub fn LitBool(marker: lookahead::TokenMarker) -> LitBool {
24321+ match marker {}
24322+}
24323
24324 ast_enum! {
24325 /// The style of a string literal, either plain quoted or a raw string like
24326 /// `r##"data"##`.
24327- ///
24328- /// *This type is available if Syn is built with the `"derive"` or `"full"`
24329- /// feature.*
24330 pub enum StrStyle #no_visit {
24331 /// An ordinary string like `"data"`.
24332 Cooked,
24333 /// A raw string like `r##"data"##`.
24334 ///
24335 /// The unsigned integer is the number of `#` symbols used.
24336 Raw(usize),
24337 }
24338@@ -686,43 +681,93 @@ ast_enum! {
24339 #[allow(non_snake_case)]
24340 pub fn Lit(marker: lookahead::TokenMarker) -> Lit {
24341 match marker {}
24342 }
24343
24344 #[cfg(feature = "parsing")]
24345 pub mod parsing {
24346 use super::*;
24347+ use crate::buffer::Cursor;
24348 use crate::parse::{Parse, ParseStream, Result};
24349+ use proc_macro2::Punct;
24350
24351 impl Parse for Lit {
24352 fn parse(input: ParseStream) -> Result<Self> {
24353 input.step(|cursor| {
24354 if let Some((lit, rest)) = cursor.literal() {
24355 return Ok((Lit::new(lit), rest));
24356 }
24357- while let Some((ident, rest)) = cursor.ident() {
24358- let value = if ident == "true" {
24359- true
24360- } else if ident == "false" {
24361- false
24362- } else {
24363- break;
24364- };
24365- let lit_bool = LitBool {
24366- value,
24367- span: ident.span(),
24368- };
24369- return Ok((Lit::Bool(lit_bool), rest));
24370+
24371+ if let Some((ident, rest)) = cursor.ident() {
24372+ let value = ident == "true";
24373+ if value || ident == "false" {
24374+ let lit_bool = LitBool {
24375+ value,
24376+ span: ident.span(),
24377+ };
24378+ return Ok((Lit::Bool(lit_bool), rest));
24379+ }
24380 }
24381+
24382+ if let Some((punct, rest)) = cursor.punct() {
24383+ if punct.as_char() == '-' {
24384+ if let Some((lit, rest)) = parse_negative_lit(punct, rest) {
24385+ return Ok((lit, rest));
24386+ }
24387+ }
24388+ }
24389+
24390 Err(cursor.error("expected literal"))
24391 })
24392 }
24393 }
24394
24395+ fn parse_negative_lit(neg: Punct, cursor: Cursor) -> Option<(Lit, Cursor)> {
24396+ let (lit, rest) = cursor.literal()?;
24397+
24398+ let mut span = neg.span();
24399+ span = span.join(lit.span()).unwrap_or(span);
24400+
24401+ let mut repr = lit.to_string();
24402+ repr.insert(0, '-');
24403+
24404+ if !(repr.ends_with("f32") || repr.ends_with("f64")) {
24405+ if let Some((digits, suffix)) = value::parse_lit_int(&repr) {
24406+ if let Some(mut token) = value::to_literal(&repr, &digits, &suffix) {
24407+ token.set_span(span);
24408+ return Some((
24409+ Lit::Int(LitInt {
24410+ repr: Box::new(LitIntRepr {
24411+ token,
24412+ digits,
24413+ suffix,
24414+ }),
24415+ }),
24416+ rest,
24417+ ));
24418+ }
24419+ }
24420+ }
24421+
24422+ let (digits, suffix) = value::parse_lit_float(&repr)?;
24423+ let mut token = value::to_literal(&repr, &digits, &suffix)?;
24424+ token.set_span(span);
24425+ Some((
24426+ Lit::Float(LitFloat {
24427+ repr: Box::new(LitFloatRepr {
24428+ token,
24429+ digits,
24430+ suffix,
24431+ }),
24432+ }),
24433+ rest,
24434+ ))
24435+ }
24436+
24437 impl Parse for LitStr {
24438 fn parse(input: ParseStream) -> Result<Self> {
24439 let head = input.fork();
24440 match input.parse()? {
24441 Lit::Str(lit) => Ok(lit),
24442 _ => Err(head.error("expected string literal")),
24443 }
24444 }
24445@@ -798,29 +843,29 @@ mod printing {
24446 impl ToTokens for LitStr {
24447 fn to_tokens(&self, tokens: &mut TokenStream) {
24448 self.repr.token.to_tokens(tokens);
24449 }
24450 }
24451
24452 impl ToTokens for LitByteStr {
24453 fn to_tokens(&self, tokens: &mut TokenStream) {
24454- self.token.to_tokens(tokens);
24455+ self.repr.token.to_tokens(tokens);
24456 }
24457 }
24458
24459 impl ToTokens for LitByte {
24460 fn to_tokens(&self, tokens: &mut TokenStream) {
24461- self.token.to_tokens(tokens);
24462+ self.repr.token.to_tokens(tokens);
24463 }
24464 }
24465
24466 impl ToTokens for LitChar {
24467 fn to_tokens(&self, tokens: &mut TokenStream) {
24468- self.token.to_tokens(tokens);
24469+ self.repr.token.to_tokens(tokens);
24470 }
24471 }
24472
24473 impl ToTokens for LitInt {
24474 fn to_tokens(&self, tokens: &mut TokenStream) {
24475 self.repr.token.to_tokens(tokens);
24476 }
24477 }
24478@@ -850,30 +895,39 @@ mod value {
24479 /// Interpret a Syn literal from a proc-macro2 literal.
24480 pub fn new(token: Literal) -> Self {
24481 let repr = token.to_string();
24482
24483 match byte(&repr, 0) {
24484 b'"' | b'r' => {
24485 let (_, suffix) = parse_lit_str(&repr);
24486 return Lit::Str(LitStr {
24487- repr: Box::new(LitStrRepr { token, suffix }),
24488+ repr: Box::new(LitRepr { token, suffix }),
24489 });
24490 }
24491 b'b' => match byte(&repr, 1) {
24492 b'"' | b'r' => {
24493- return Lit::ByteStr(LitByteStr { token });
24494+ let (_, suffix) = parse_lit_byte_str(&repr);
24495+ return Lit::ByteStr(LitByteStr {
24496+ repr: Box::new(LitRepr { token, suffix }),
24497+ });
24498 }
24499 b'\'' => {
24500- return Lit::Byte(LitByte { token });
24501+ let (_, suffix) = parse_lit_byte(&repr);
24502+ return Lit::Byte(LitByte {
24503+ repr: Box::new(LitRepr { token, suffix }),
24504+ });
24505 }
24506 _ => {}
24507 },
24508 b'\'' => {
24509- return Lit::Char(LitChar { token });
24510+ let (_, suffix) = parse_lit_char(&repr);
24511+ return Lit::Char(LitChar {
24512+ repr: Box::new(LitRepr { token, suffix }),
24513+ });
24514 }
24515 b'0'..=b'9' | b'-' => {
24516 if !(repr.ends_with("f32") || repr.ends_with("f64")) {
24517 if let Some((digits, suffix)) = parse_lit_int(&repr) {
24518 return Lit::Int(LitInt {
24519 repr: Box::new(LitIntRepr {
24520 token,
24521 digits,
24522@@ -900,16 +954,54 @@ mod value {
24523 });
24524 }
24525 }
24526 _ => {}
24527 }
24528
24529 panic!("Unrecognized literal: `{}`", repr);
24530 }
24531+
24532+ pub fn suffix(&self) -> &str {
24533+ match self {
24534+ Lit::Str(lit) => lit.suffix(),
24535+ Lit::ByteStr(lit) => lit.suffix(),
24536+ Lit::Byte(lit) => lit.suffix(),
24537+ Lit::Char(lit) => lit.suffix(),
24538+ Lit::Int(lit) => lit.suffix(),
24539+ Lit::Float(lit) => lit.suffix(),
24540+ Lit::Bool(_) | Lit::Verbatim(_) => "",
24541+ }
24542+ }
24543+
24544+ pub fn span(&self) -> Span {
24545+ match self {
24546+ Lit::Str(lit) => lit.span(),
24547+ Lit::ByteStr(lit) => lit.span(),
24548+ Lit::Byte(lit) => lit.span(),
24549+ Lit::Char(lit) => lit.span(),
24550+ Lit::Int(lit) => lit.span(),
24551+ Lit::Float(lit) => lit.span(),
24552+ Lit::Bool(lit) => lit.span,
24553+ Lit::Verbatim(lit) => lit.span(),
24554+ }
24555+ }
24556+
24557+ pub fn set_span(&mut self, span: Span) {
24558+ match self {
24559+ Lit::Str(lit) => lit.set_span(span),
24560+ Lit::ByteStr(lit) => lit.set_span(span),
24561+ Lit::Byte(lit) => lit.set_span(span),
24562+ Lit::Char(lit) => lit.set_span(span),
24563+ Lit::Int(lit) => lit.set_span(span),
24564+ Lit::Float(lit) => lit.set_span(span),
24565+ Lit::Bool(lit) => lit.span = span,
24566+ Lit::Verbatim(lit) => lit.set_span(span),
24567+ }
24568+ }
24569 }
24570
24571 /// Get the byte at offset idx, or a default of `b'\0'` if we're looking
24572 /// past the end of the input buffer.
24573 pub fn byte<S: AsRef<[u8]> + ?Sized>(s: &S, idx: usize) -> u8 {
24574 let s = s.as_ref();
24575 if idx < s.len() {
24576 s[idx]
24577@@ -999,140 +1091,144 @@ mod value {
24578 assert_eq!(byte(s, 0), b'r');
24579 s = &s[1..];
24580
24581 let mut pounds = 0;
24582 while byte(s, pounds) == b'#' {
24583 pounds += 1;
24584 }
24585 assert_eq!(byte(s, pounds), b'"');
24586- assert_eq!(byte(s, s.len() - pounds - 1), b'"');
24587- for end in s[s.len() - pounds..].bytes() {
24588+ let close = s.rfind('"').unwrap();
24589+ for end in s[close + 1..close + 1 + pounds].bytes() {
24590 assert_eq!(end, b'#');
24591 }
24592
24593- let content = s[pounds + 1..s.len() - pounds - 1]
24594- .to_owned()
24595- .into_boxed_str();
24596- let suffix = Box::<str>::default(); // todo
24597+ let content = s[pounds + 1..close].to_owned().into_boxed_str();
24598+ let suffix = s[close + 1 + pounds..].to_owned().into_boxed_str();
24599 (content, suffix)
24600 }
24601
24602- pub fn parse_lit_byte_str(s: &str) -> Vec<u8> {
24603+ // Returns (content, suffix).
24604+ pub fn parse_lit_byte_str(s: &str) -> (Vec<u8>, Box<str>) {
24605 assert_eq!(byte(s, 0), b'b');
24606 match byte(s, 1) {
24607 b'"' => parse_lit_byte_str_cooked(s),
24608 b'r' => parse_lit_byte_str_raw(s),
24609 _ => unreachable!(),
24610 }
24611 }
24612
24613 // Clippy false positive
24614 // https://github.com/rust-lang-nursery/rust-clippy/issues/2329
24615 #[allow(clippy::needless_continue)]
24616- fn parse_lit_byte_str_cooked(mut s: &str) -> Vec<u8> {
24617+ fn parse_lit_byte_str_cooked(mut s: &str) -> (Vec<u8>, Box<str>) {
24618 assert_eq!(byte(s, 0), b'b');
24619 assert_eq!(byte(s, 1), b'"');
24620 s = &s[2..];
24621
24622 // We're going to want to have slices which don't respect codepoint boundaries.
24623- let mut s = s.as_bytes();
24624+ let mut v = s.as_bytes();
24625
24626 let mut out = Vec::new();
24627 'outer: loop {
24628- let byte = match byte(s, 0) {
24629+ let byte = match byte(v, 0) {
24630 b'"' => break,
24631 b'\\' => {
24632- let b = byte(s, 1);
24633- s = &s[2..];
24634+ let b = byte(v, 1);
24635+ v = &v[2..];
24636 match b {
24637 b'x' => {
24638- let (b, rest) = backslash_x(s);
24639- s = rest;
24640+ let (b, rest) = backslash_x(v);
24641+ v = rest;
24642 b
24643 }
24644 b'n' => b'\n',
24645 b'r' => b'\r',
24646 b't' => b'\t',
24647 b'\\' => b'\\',
24648 b'0' => b'\0',
24649 b'\'' => b'\'',
24650 b'"' => b'"',
24651 b'\r' | b'\n' => loop {
24652- let byte = byte(s, 0);
24653+ let byte = byte(v, 0);
24654 let ch = char::from_u32(u32::from(byte)).unwrap();
24655 if ch.is_whitespace() {
24656- s = &s[1..];
24657+ v = &v[1..];
24658 } else {
24659 continue 'outer;
24660 }
24661 },
24662 b => panic!("unexpected byte {:?} after \\ character in byte literal", b),
24663 }
24664 }
24665 b'\r' => {
24666- assert_eq!(byte(s, 1), b'\n', "Bare CR not allowed in string");
24667- s = &s[2..];
24668+ assert_eq!(byte(v, 1), b'\n', "Bare CR not allowed in string");
24669+ v = &v[2..];
24670 b'\n'
24671 }
24672 b => {
24673- s = &s[1..];
24674+ v = &v[1..];
24675 b
24676 }
24677 };
24678 out.push(byte);
24679 }
24680
24681- assert_eq!(s, b"\"");
24682- out
24683+ assert_eq!(byte(v, 0), b'"');
24684+ let suffix = s[s.len() - v.len() + 1..].to_owned().into_boxed_str();
24685+ (out, suffix)
24686 }
24687
24688- fn parse_lit_byte_str_raw(s: &str) -> Vec<u8> {
24689+ fn parse_lit_byte_str_raw(s: &str) -> (Vec<u8>, Box<str>) {
24690 assert_eq!(byte(s, 0), b'b');
24691- String::from(parse_lit_str_raw(&s[1..]).0).into_bytes()
24692+ let (value, suffix) = parse_lit_str_raw(&s[1..]);
24693+ (String::from(value).into_bytes(), suffix)
24694 }
24695
24696- pub fn parse_lit_byte(s: &str) -> u8 {
24697+ // Returns (value, suffix).
24698+ pub fn parse_lit_byte(s: &str) -> (u8, Box<str>) {
24699 assert_eq!(byte(s, 0), b'b');
24700 assert_eq!(byte(s, 1), b'\'');
24701
24702 // We're going to want to have slices which don't respect codepoint boundaries.
24703- let mut s = s[2..].as_bytes();
24704+ let mut v = s[2..].as_bytes();
24705
24706- let b = match byte(s, 0) {
24707+ let b = match byte(v, 0) {
24708 b'\\' => {
24709- let b = byte(s, 1);
24710- s = &s[2..];
24711+ let b = byte(v, 1);
24712+ v = &v[2..];
24713 match b {
24714 b'x' => {
24715- let (b, rest) = backslash_x(s);
24716- s = rest;
24717+ let (b, rest) = backslash_x(v);
24718+ v = rest;
24719 b
24720 }
24721 b'n' => b'\n',
24722 b'r' => b'\r',
24723 b't' => b'\t',
24724 b'\\' => b'\\',
24725 b'0' => b'\0',
24726 b'\'' => b'\'',
24727 b'"' => b'"',
24728 b => panic!("unexpected byte {:?} after \\ character in byte literal", b),
24729 }
24730 }
24731 b => {
24732- s = &s[1..];
24733+ v = &v[1..];
24734 b
24735 }
24736 };
24737
24738- assert_eq!(byte(s, 0), b'\'');
24739- b
24740+ assert_eq!(byte(v, 0), b'\'');
24741+ let suffix = s[s.len() - v.len() + 1..].to_owned().into_boxed_str();
24742+ (b, suffix)
24743 }
24744
24745- pub fn parse_lit_char(mut s: &str) -> char {
24746+ // Returns (value, suffix).
24747+ pub fn parse_lit_char(mut s: &str) -> (char, Box<str>) {
24748 assert_eq!(byte(s, 0), b'\'');
24749 s = &s[1..];
24750
24751 let ch = match byte(s, 0) {
24752 b'\\' => {
24753 let b = byte(s, 1);
24754 s = &s[2..];
24755 match b {
24756@@ -1158,18 +1254,19 @@ mod value {
24757 }
24758 }
24759 _ => {
24760 let ch = next_chr(s);
24761 s = &s[ch.len_utf8()..];
24762 ch
24763 }
24764 };
24765- assert_eq!(s, "\'", "Expected end of char literal");
24766- ch
24767+ assert_eq!(byte(s, 0), b'\'');
24768+ let suffix = s[1..].to_owned().into_boxed_str();
24769+ (ch, suffix)
24770 }
24771
24772 fn backslash_x<S>(s: &S) -> (u8, &S)
24773 where
24774 S: Index<RangeFrom<usize>, Output = S> + AsRef<[u8]> + ?Sized,
24775 {
24776 let mut ch = 0;
24777 let b0 = byte(s, 0);
24778@@ -1329,17 +1426,21 @@ mod value {
24779 if has_e || has_dot {
24780 return None;
24781 }
24782 has_dot = true;
24783 bytes[write] = b'.';
24784 }
24785 b'e' | b'E' => {
24786 if has_e {
24787- return None;
24788+ if has_exponent {
24789+ break;
24790+ } else {
24791+ return None;
24792+ }
24793 }
24794 has_e = true;
24795 bytes[write] = b'e';
24796 }
24797 b'-' | b'+' => {
24798 if has_sign || has_exponent || !has_e {
24799 return None;
24800 }
24801@@ -1367,16 +1468,38 @@ mod value {
24802 digits.truncate(write);
24803 if suffix.is_empty() || crate::ident::xid_ok(&suffix) {
24804 Some((digits.into_boxed_str(), suffix.into_boxed_str()))
24805 } else {
24806 None
24807 }
24808 }
24809
24810- pub fn to_literal(s: &str) -> Literal {
24811- let stream = s.parse::<TokenStream>().unwrap();
24812- match stream.into_iter().next().unwrap() {
24813- TokenTree::Literal(l) => l,
24814- _ => unreachable!(),
24815+ pub fn to_literal(repr: &str, digits: &str, suffix: &str) -> Option<Literal> {
24816+ if repr.starts_with('-') {
24817+ if suffix == "f64" {
24818+ digits.parse().ok().map(Literal::f64_suffixed)
24819+ } else if suffix == "f32" {
24820+ digits.parse().ok().map(Literal::f32_suffixed)
24821+ } else if suffix == "i64" {
24822+ digits.parse().ok().map(Literal::i64_suffixed)
24823+ } else if suffix == "i32" {
24824+ digits.parse().ok().map(Literal::i32_suffixed)
24825+ } else if suffix == "i16" {
24826+ digits.parse().ok().map(Literal::i16_suffixed)
24827+ } else if suffix == "i8" {
24828+ digits.parse().ok().map(Literal::i8_suffixed)
24829+ } else if !suffix.is_empty() {
24830+ None
24831+ } else if digits.contains('.') {
24832+ digits.parse().ok().map(Literal::f64_unsuffixed)
24833+ } else {
24834+ digits.parse().ok().map(Literal::i64_unsuffixed)
24835+ }
24836+ } else {
24837+ let stream = repr.parse::<TokenStream>().unwrap();
24838+ match stream.into_iter().next().unwrap() {
24839+ TokenTree::Literal(l) => Some(l),
24840+ _ => unreachable!(),
24841+ }
24842 }
24843 }
24844 }
24845diff --git a/third_party/rust/syn/src/mac.rs b/third_party/rust/syn/src/mac.rs
24846--- a/third_party/rust/syn/src/mac.rs
24847+++ b/third_party/rust/syn/src/mac.rs
24848@@ -1,79 +1,56 @@
24849 use super::*;
24850 use crate::token::{Brace, Bracket, Paren};
24851 use proc_macro2::TokenStream;
24852 #[cfg(feature = "parsing")]
24853-use proc_macro2::{Delimiter, Span, TokenTree};
24854+use proc_macro2::{Delimiter, Group, Span, TokenTree};
24855
24856 #[cfg(feature = "parsing")]
24857 use crate::parse::{Parse, ParseStream, Parser, Result};
24858-#[cfg(feature = "extra-traits")]
24859-use crate::tt::TokenStreamHelper;
24860-#[cfg(feature = "extra-traits")]
24861-use std::hash::{Hash, Hasher};
24862
24863 ast_struct! {
24864 /// A macro invocation: `println!("{}", mac)`.
24865 ///
24866- /// *This type is available if Syn is built with the `"derive"` or `"full"`
24867+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
24868 /// feature.*
24869- pub struct Macro #manual_extra_traits {
24870+ pub struct Macro {
24871 pub path: Path,
24872 pub bang_token: Token![!],
24873 pub delimiter: MacroDelimiter,
24874 pub tokens: TokenStream,
24875 }
24876 }
24877
24878 ast_enum! {
24879 /// A grouping token that surrounds a macro body: `m!(...)` or `m!{...}` or `m![...]`.
24880 ///
24881- /// *This type is available if Syn is built with the `"derive"` or `"full"`
24882+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
24883 /// feature.*
24884 pub enum MacroDelimiter {
24885 Paren(Paren),
24886 Brace(Brace),
24887 Bracket(Bracket),
24888 }
24889 }
24890
24891-#[cfg(feature = "extra-traits")]
24892-impl Eq for Macro {}
24893-
24894-#[cfg(feature = "extra-traits")]
24895-impl PartialEq for Macro {
24896- fn eq(&self, other: &Self) -> bool {
24897- self.path == other.path
24898- && self.bang_token == other.bang_token
24899- && self.delimiter == other.delimiter
24900- && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens)
24901- }
24902-}
24903-
24904-#[cfg(feature = "extra-traits")]
24905-impl Hash for Macro {
24906- fn hash<H>(&self, state: &mut H)
24907- where
24908- H: Hasher,
24909- {
24910- self.path.hash(state);
24911- self.bang_token.hash(state);
24912- self.delimiter.hash(state);
24913- TokenStreamHelper(&self.tokens).hash(state);
24914- }
24915-}
24916-
24917 #[cfg(feature = "parsing")]
24918-fn delimiter_span(delimiter: &MacroDelimiter) -> Span {
24919- match delimiter {
24920+fn delimiter_span_close(macro_delimiter: &MacroDelimiter) -> Span {
24921+ let delimiter = match macro_delimiter {
24922+ MacroDelimiter::Paren(_) => Delimiter::Parenthesis,
24923+ MacroDelimiter::Brace(_) => Delimiter::Brace,
24924+ MacroDelimiter::Bracket(_) => Delimiter::Bracket,
24925+ };
24926+ let mut group = Group::new(delimiter, TokenStream::new());
24927+ group.set_span(match macro_delimiter {
24928 MacroDelimiter::Paren(token) => token.span,
24929 MacroDelimiter::Brace(token) => token.span,
24930 MacroDelimiter::Bracket(token) => token.span,
24931- }
24932+ });
24933+ group.span_close()
24934 }
24935
24936 impl Macro {
24937 /// Parse the tokens within the macro invocation's delimiters into a syntax
24938 /// tree.
24939 ///
24940 /// This is equivalent to `syn::parse2::<T>(mac.tokens)` except that it
24941 /// produces a more useful span when `tokens` is empty.
24942@@ -158,19 +135,17 @@ impl Macro {
24943 pub fn parse_body<T: Parse>(&self) -> Result<T> {
24944 self.parse_body_with(T::parse)
24945 }
24946
24947 /// Parse the tokens within the macro invocation's delimiters using the
24948 /// given parser.
24949 #[cfg(feature = "parsing")]
24950 pub fn parse_body_with<F: Parser>(&self, parser: F) -> Result<F::Output> {
24951- // TODO: see if we can get a group.span_close() span in here as the
24952- // scope, rather than the span of the whole group.
24953- let scope = delimiter_span(&self.delimiter);
24954+ let scope = delimiter_span_close(&self.delimiter);
24955 crate::parse::parse_scoped(parser, scope, self.tokens.clone())
24956 }
24957 }
24958
24959 #[cfg(feature = "parsing")]
24960 pub fn parse_delimiter(input: ParseStream) -> Result<(MacroDelimiter, TokenStream)> {
24961 input.step(|cursor| {
24962 if let Some((TokenTree::Group(g), rest)) = cursor.token_tree() {
24963diff --git a/third_party/rust/syn/src/macros.rs b/third_party/rust/syn/src/macros.rs
24964--- a/third_party/rust/syn/src/macros.rs
24965+++ b/third_party/rust/syn/src/macros.rs
24966@@ -1,56 +1,33 @@
24967 macro_rules! ast_struct {
24968 (
24969 [$($attrs_pub:tt)*]
24970 struct $name:ident #full $($rest:tt)*
24971 ) => {
24972 #[cfg(feature = "full")]
24973- #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
24974- #[cfg_attr(feature = "clone-impls", derive(Clone))]
24975 $($attrs_pub)* struct $name $($rest)*
24976
24977 #[cfg(not(feature = "full"))]
24978- #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
24979- #[cfg_attr(feature = "clone-impls", derive(Clone))]
24980 $($attrs_pub)* struct $name {
24981- _noconstruct: (),
24982+ _noconstruct: ::std::marker::PhantomData<::proc_macro2::Span>,
24983 }
24984
24985 #[cfg(all(not(feature = "full"), feature = "printing"))]
24986 impl ::quote::ToTokens for $name {
24987 fn to_tokens(&self, _: &mut ::proc_macro2::TokenStream) {
24988 unreachable!()
24989 }
24990 }
24991 };
24992
24993 (
24994 [$($attrs_pub:tt)*]
24995- struct $name:ident #manual_extra_traits $($rest:tt)*
24996- ) => {
24997- #[cfg_attr(feature = "extra-traits", derive(Debug))]
24998- #[cfg_attr(feature = "clone-impls", derive(Clone))]
24999- $($attrs_pub)* struct $name $($rest)*
25000- };
25001-
25002- (
25003- [$($attrs_pub:tt)*]
25004- struct $name:ident #manual_extra_traits_debug $($rest:tt)*
25005- ) => {
25006- #[cfg_attr(feature = "clone-impls", derive(Clone))]
25007- $($attrs_pub)* struct $name $($rest)*
25008- };
25009-
25010- (
25011- [$($attrs_pub:tt)*]
25012 struct $name:ident $($rest:tt)*
25013 ) => {
25014- #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
25015- #[cfg_attr(feature = "clone-impls", derive(Clone))]
25016 $($attrs_pub)* struct $name $($rest)*
25017 };
25018
25019 ($($t:tt)*) => {
25020 strip_attrs_pub!(ast_struct!($($t)*));
25021 };
25022 }
25023
25024@@ -60,29 +37,18 @@ macro_rules! ast_enum {
25025 [$($attrs_pub:tt)*]
25026 enum $name:ident #no_visit $($rest:tt)*
25027 ) => (
25028 ast_enum!([$($attrs_pub)*] enum $name $($rest)*);
25029 );
25030
25031 (
25032 [$($attrs_pub:tt)*]
25033- enum $name:ident #manual_extra_traits $($rest:tt)*
25034- ) => (
25035- #[cfg_attr(feature = "extra-traits", derive(Debug))]
25036- #[cfg_attr(feature = "clone-impls", derive(Clone))]
25037- $($attrs_pub)* enum $name $($rest)*
25038- );
25039-
25040- (
25041- [$($attrs_pub:tt)*]
25042 enum $name:ident $($rest:tt)*
25043 ) => (
25044- #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
25045- #[cfg_attr(feature = "clone-impls", derive(Clone))]
25046 $($attrs_pub)* enum $name $($rest)*
25047 );
25048
25049 ($($t:tt)*) => {
25050 strip_attrs_pub!(ast_enum!($($t)*));
25051 };
25052 }
25053
25054@@ -115,36 +81,43 @@ macro_rules! ast_enum_of_structs_impl {
25055 )*
25056 }
25057
25058 $($remaining:tt)*
25059 ) => {
25060 check_keyword_matches!(pub $pub);
25061 check_keyword_matches!(enum $enum);
25062
25063- $(
25064- $(
25065- impl From<$member> for $name {
25066- fn from(e: $member) -> $name {
25067- $name::$variant(e)
25068- }
25069- }
25070- )*
25071- )*
25072+ $($(
25073+ ast_enum_from_struct!($name::$variant, $member);
25074+ )*)*
25075
25076 #[cfg(feature = "printing")]
25077 generate_to_tokens! {
25078 $($remaining)*
25079 ()
25080 tokens
25081 $name { $($variant $($member)*,)* }
25082 }
25083 };
25084 }
25085
25086+macro_rules! ast_enum_from_struct {
25087+ // No From<TokenStream> for verbatim variants.
25088+ ($name:ident::Verbatim, $member:ident) => {};
25089+
25090+ ($name:ident::$variant:ident, $member:ident) => {
25091+ impl From<$member> for $name {
25092+ fn from(e: $member) -> $name {
25093+ $name::$variant(e)
25094+ }
25095+ }
25096+ };
25097+}
25098+
25099 #[cfg(feature = "printing")]
25100 macro_rules! generate_to_tokens {
25101 (do_not_generate_to_tokens $($foo:tt)*) => ();
25102
25103 (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident, $($next:tt)*}) => {
25104 generate_to_tokens!(
25105 ($($arms)* $name::$variant => {})
25106 $tokens $name { $($next)* }
25107diff --git a/third_party/rust/syn/src/op.rs b/third_party/rust/syn/src/op.rs
25108--- a/third_party/rust/syn/src/op.rs
25109+++ b/third_party/rust/syn/src/op.rs
25110@@ -1,14 +1,13 @@
25111 ast_enum! {
25112 /// A binary operator: `+`, `+=`, `&`.
25113 ///
25114- /// *This type is available if Syn is built with the `"derive"` or `"full"`
25115+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
25116 /// feature.*
25117- #[cfg_attr(feature = "clone-impls", derive(Copy))]
25118 pub enum BinOp {
25119 /// The `+` operator (addition)
25120 Add(Token![+]),
25121 /// The `-` operator (subtraction)
25122 Sub(Token![-]),
25123 /// The `*` operator (multiplication)
25124 Mul(Token![*]),
25125 /// The `/` operator (division)
25126@@ -62,19 +61,18 @@ ast_enum! {
25127 /// The `>>=` operator
25128 ShrEq(Token![>>=]),
25129 }
25130 }
25131
25132 ast_enum! {
25133 /// A unary operator: `*`, `!`, `-`.
25134 ///
25135- /// *This type is available if Syn is built with the `"derive"` or `"full"`
25136+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
25137 /// feature.*
25138- #[cfg_attr(feature = "clone-impls", derive(Copy))]
25139 pub enum UnOp {
25140 /// The `*` operator for dereferencing
25141 Deref(Token![*]),
25142 /// The `!` operator for logical inversion
25143 Not(Token![!]),
25144 /// The `-` operator for negation
25145 Neg(Token![-]),
25146 }
25147diff --git a/third_party/rust/syn/src/parse.rs b/third_party/rust/syn/src/parse.rs
25148--- a/third_party/rust/syn/src/parse.rs
25149+++ b/third_party/rust/syn/src/parse.rs
25150@@ -21,18 +21,18 @@
25151 //! procedural macro through [`parse_macro_input!`] as shown at the bottom of
25152 //! the snippet. If the caller provides syntactically invalid input to the
25153 //! procedural macro, they will receive a helpful compiler error message
25154 //! pointing out the exact token that triggered the failure to parse.
25155 //!
25156 //! [`parse_macro_input!`]: ../macro.parse_macro_input.html
25157 //!
25158 //! ```
25159-//! extern crate proc_macro;
25160-//!
25161+//! # extern crate proc_macro;
25162+//! #
25163 //! use proc_macro::TokenStream;
25164 //! use syn::{braced, parse_macro_input, token, Field, Ident, Result, Token};
25165 //! use syn::parse::{Parse, ParseStream};
25166 //! use syn::punctuated::Punctuated;
25167 //!
25168 //! enum Item {
25169 //! Struct(ItemStruct),
25170 //! Enum(ItemEnum),
25171@@ -104,19 +104,17 @@
25172 //! ```
25173 //! use syn::Type;
25174 //!
25175 //! # fn run_parser() -> syn::Result<()> {
25176 //! let t: Type = syn::parse_str("std::collections::HashMap<String, Value>")?;
25177 //! # Ok(())
25178 //! # }
25179 //! #
25180-//! # fn main() {
25181-//! # run_parser().unwrap();
25182-//! # }
25183+//! # run_parser().unwrap();
25184 //! ```
25185 //!
25186 //! The [`parse_quote!`] macro also uses this approach.
25187 //!
25188 //! [`parse_quote!`]: ../macro.parse_quote.html
25189 //!
25190 //! # The `Parser` trait
25191 //!
25192@@ -150,18 +148,18 @@
25193 //!
25194 //! In these cases the types provide a choice of parser functions rather than a
25195 //! single `Parse` implementation, and those parser functions can be invoked
25196 //! through the [`Parser`] trait.
25197 //!
25198 //! [`Parser`]: trait.Parser.html
25199 //!
25200 //! ```
25201-//! extern crate proc_macro;
25202-//!
25203+//! # extern crate proc_macro;
25204+//! #
25205 //! use proc_macro::TokenStream;
25206 //! use syn::parse::Parser;
25207 //! use syn::punctuated::Punctuated;
25208 //! use syn::{Attribute, Expr, PathSegment, Result, Token};
25209 //!
25210 //! fn call_some_parser_methods(input: TokenStream) -> Result<()> {
25211 //! // Parse a nonempty sequence of path segments separated by `::` punctuation
25212 //! // with no trailing punctuation.
25213@@ -181,17 +179,17 @@
25214 //! let _attrs = parser.parse(tokens)?;
25215 //!
25216 //! Ok(())
25217 //! }
25218 //! ```
25219 //!
25220 //! ---
25221 //!
25222-//! *This module is available if Syn is built with the `"parsing"` feature.*
25223+//! *This module is available only if Syn is built with the `"parsing"` feature.*
25224
25225 #[path = "discouraged.rs"]
25226 pub mod discouraged;
25227
25228 use std::cell::Cell;
25229 use std::fmt::{self, Debug, Display};
25230 use std::marker::PhantomData;
25231 use std::mem;
25232@@ -212,16 +210,21 @@ use crate::lookahead;
25233 use crate::punctuated::Punctuated;
25234 use crate::token::Token;
25235
25236 pub use crate::error::{Error, Result};
25237 pub use crate::lookahead::{Lookahead1, Peek};
25238
25239 /// Parsing interface implemented by all types that can be parsed in a default
25240 /// way from a token stream.
25241+///
25242+/// Refer to the [module documentation] for details about implementing and using
25243+/// the `Parse` trait.
25244+///
25245+/// [module documentation]: self
25246 pub trait Parse: Sized {
25247 fn parse(input: ParseStream) -> Result<Self>;
25248 }
25249
25250 /// Input to a Syn parser function.
25251 ///
25252 /// See the methods of this type under the documentation of [`ParseBuffer`]. For
25253 /// an overview of parsing in Syn, refer to the [module documentation].
25254@@ -258,23 +261,26 @@ pub struct ParseBuffer<'a> {
25255 // ParseBuffer<'a>, upcast to ParseBuffer<'short> for some lifetime shorter
25256 // than 'a, and then assign a Cursor<'short> into the Cell.
25257 //
25258 // By extension, it would not be safe to expose an API that accepts a
25259 // Cursor<'a> and trusts that it lives as long as the cursor currently in
25260 // the cell.
25261 cell: Cell<Cursor<'static>>,
25262 marker: PhantomData<Cursor<'a>>,
25263- unexpected: Rc<Cell<Option<Span>>>,
25264+ unexpected: Cell<Option<Rc<Cell<Unexpected>>>>,
25265 }
25266
25267 impl<'a> Drop for ParseBuffer<'a> {
25268 fn drop(&mut self) {
25269- if !self.is_empty() && self.unexpected.get().is_none() {
25270- self.unexpected.set(Some(self.cursor().span()));
25271+ if let Some(unexpected_span) = span_of_unexpected_ignoring_nones(self.cursor()) {
25272+ let (inner, old_span) = inner_unexpected(self);
25273+ if old_span.is_none() {
25274+ inner.set(Unexpected::Some(unexpected_span));
25275+ }
25276 }
25277 }
25278 }
25279
25280 impl<'a> Display for ParseBuffer<'a> {
25281 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
25282 Display::fmt(&self.cursor().token_stream(), f)
25283 }
25284@@ -319,25 +325,22 @@ impl<'a> Debug for ParseBuffer<'a> {
25285 /// #
25286 /// # fn remainder_after_skipping_past_next_at(
25287 /// # input: ParseStream,
25288 /// # ) -> Result<proc_macro2::TokenStream> {
25289 /// # skip_past_next_at(input)?;
25290 /// # input.parse()
25291 /// # }
25292 /// #
25293-/// # fn main() {
25294-/// # use syn::parse::Parser;
25295-/// # let remainder = remainder_after_skipping_past_next_at
25296-/// # .parse_str("a @ b c")
25297-/// # .unwrap();
25298-/// # assert_eq!(remainder.to_string(), "b c");
25299-/// # }
25300+/// # use syn::parse::Parser;
25301+/// # let remainder = remainder_after_skipping_past_next_at
25302+/// # .parse_str("a @ b c")
25303+/// # .unwrap();
25304+/// # assert_eq!(remainder.to_string(), "b c");
25305 /// ```
25306-#[derive(Copy, Clone)]
25307 pub struct StepCursor<'c, 'a> {
25308 scope: Span,
25309 // This field is covariant in 'c.
25310 cursor: Cursor<'c>,
25311 // This field is contravariant in 'c. Together these make StepCursor
25312 // invariant in 'c. Also covariant in 'a. The user cannot cast 'c to a
25313 // different lifetime but can upcast into a StepCursor with a shorter
25314 // lifetime 'a.
25315@@ -351,16 +354,24 @@ pub struct StepCursor<'c, 'a> {
25316 impl<'c, 'a> Deref for StepCursor<'c, 'a> {
25317 type Target = Cursor<'c>;
25318
25319 fn deref(&self) -> &Self::Target {
25320 &self.cursor
25321 }
25322 }
25323
25324+impl<'c, 'a> Copy for StepCursor<'c, 'a> {}
25325+
25326+impl<'c, 'a> Clone for StepCursor<'c, 'a> {
25327+ fn clone(&self) -> Self {
25328+ *self
25329+ }
25330+}
25331+
25332 impl<'c, 'a> StepCursor<'c, 'a> {
25333 /// Triggers an error at the current position of the parse stream.
25334 ///
25335 /// The `ParseStream::step` invocation will return this same error without
25336 /// advancing the stream state.
25337 pub fn error<T: Display>(self, message: T) -> Error {
25338 error::new_at(self.scope, self.cursor, message)
25339 }
25340@@ -370,46 +381,91 @@ pub(crate) fn advance_step_cursor<'c, 'a
25341 // Refer to the comments within the StepCursor definition. We use the
25342 // fact that a StepCursor<'c, 'a> exists as proof that 'c outlives 'a.
25343 // Cursor is covariant in its lifetime parameter so we can cast a
25344 // Cursor<'c> to one with the shorter lifetime Cursor<'a>.
25345 let _ = proof;
25346 unsafe { mem::transmute::<Cursor<'c>, Cursor<'a>>(to) }
25347 }
25348
25349-fn skip(input: ParseStream) -> bool {
25350- input
25351- .step(|cursor| {
25352- if let Some((_lifetime, rest)) = cursor.lifetime() {
25353- Ok((true, rest))
25354- } else if let Some((_token, rest)) = cursor.token_tree() {
25355- Ok((true, rest))
25356- } else {
25357- Ok((false, *cursor))
25358- }
25359- })
25360- .unwrap()
25361-}
25362-
25363 pub(crate) fn new_parse_buffer(
25364 scope: Span,
25365 cursor: Cursor,
25366- unexpected: Rc<Cell<Option<Span>>>,
25367+ unexpected: Rc<Cell<Unexpected>>,
25368 ) -> ParseBuffer {
25369 ParseBuffer {
25370 scope,
25371 // See comment on `cell` in the struct definition.
25372 cell: Cell::new(unsafe { mem::transmute::<Cursor, Cursor<'static>>(cursor) }),
25373 marker: PhantomData,
25374- unexpected,
25375+ unexpected: Cell::new(Some(unexpected)),
25376+ }
25377+}
25378+
25379+pub(crate) enum Unexpected {
25380+ None,
25381+ Some(Span),
25382+ Chain(Rc<Cell<Unexpected>>),
25383+}
25384+
25385+impl Default for Unexpected {
25386+ fn default() -> Self {
25387+ Unexpected::None
25388+ }
25389+}
25390+
25391+impl Clone for Unexpected {
25392+ fn clone(&self) -> Self {
25393+ match self {
25394+ Unexpected::None => Unexpected::None,
25395+ Unexpected::Some(span) => Unexpected::Some(*span),
25396+ Unexpected::Chain(next) => Unexpected::Chain(next.clone()),
25397+ }
25398 }
25399 }
25400
25401-pub(crate) fn get_unexpected(buffer: &ParseBuffer) -> Rc<Cell<Option<Span>>> {
25402- buffer.unexpected.clone()
25403+// We call this on Cell<Unexpected> and Cell<Option<T>> where temporarily
25404+// swapping in a None is cheap.
25405+fn cell_clone<T: Default + Clone>(cell: &Cell<T>) -> T {
25406+ let prev = cell.take();
25407+ let ret = prev.clone();
25408+ cell.set(prev);
25409+ ret
25410+}
25411+
25412+fn inner_unexpected(buffer: &ParseBuffer) -> (Rc<Cell<Unexpected>>, Option<Span>) {
25413+ let mut unexpected = get_unexpected(buffer);
25414+ loop {
25415+ match cell_clone(&unexpected) {
25416+ Unexpected::None => return (unexpected, None),
25417+ Unexpected::Some(span) => return (unexpected, Some(span)),
25418+ Unexpected::Chain(next) => unexpected = next,
25419+ }
25420+ }
25421+}
25422+
25423+pub(crate) fn get_unexpected(buffer: &ParseBuffer) -> Rc<Cell<Unexpected>> {
25424+ cell_clone(&buffer.unexpected).unwrap()
25425+}
25426+
25427+fn span_of_unexpected_ignoring_nones(mut cursor: Cursor) -> Option<Span> {
25428+ if cursor.eof() {
25429+ return None;
25430+ }
25431+ while let Some((inner, _span, rest)) = cursor.group(Delimiter::None) {
25432+ if let Some(unexpected) = span_of_unexpected_ignoring_nones(inner) {
25433+ return Some(unexpected);
25434+ }
25435+ cursor = rest;
25436+ }
25437+ if cursor.eof() {
25438+ None
25439+ } else {
25440+ Some(cursor.span())
25441+ }
25442 }
25443
25444 impl<'a> ParseBuffer<'a> {
25445 /// Parses a syntax tree node of type `T`, advancing the position of our
25446 /// parse stream past it.
25447 pub fn parse<T: Parse>(&self) -> Result<T> {
25448 T::parse(self)
25449 }
25450@@ -561,24 +617,27 @@ impl<'a> ParseBuffer<'a> {
25451 /// input.parse().map(UnionOrMacro::Union)
25452 /// } else {
25453 /// input.parse().map(UnionOrMacro::Macro)
25454 /// }
25455 /// }
25456 /// }
25457 /// ```
25458 pub fn peek2<T: Peek>(&self, token: T) -> bool {
25459- let ahead = self.fork();
25460- skip(&ahead) && ahead.peek(token)
25461+ let _ = token;
25462+ self.cursor().skip().map_or(false, T::Token::peek)
25463 }
25464
25465 /// Looks at the third-next token in the parse stream.
25466 pub fn peek3<T: Peek>(&self, token: T) -> bool {
25467- let ahead = self.fork();
25468- skip(&ahead) && skip(&ahead) && ahead.peek(token)
25469+ let _ = token;
25470+ self.cursor()
25471+ .skip()
25472+ .and_then(Cursor::skip)
25473+ .map_or(false, T::Token::peek)
25474 }
25475
25476 /// Parses zero or more occurrences of `T` separated by punctuation of type
25477 /// `P`, with optional trailing punctuation.
25478 ///
25479 /// Parsing continues until the end of this parse stream. The entire content
25480 /// of this parse stream must consist of `T` and `P`.
25481 ///
25482@@ -610,22 +669,20 @@ impl<'a> ParseBuffer<'a> {
25483 /// ident: input.parse()?,
25484 /// paren_token: parenthesized!(content in input),
25485 /// fields: content.parse_terminated(Type::parse)?,
25486 /// semi_token: input.parse()?,
25487 /// })
25488 /// }
25489 /// }
25490 /// #
25491- /// # fn main() {
25492- /// # let input = quote! {
25493- /// # struct S(A, B);
25494- /// # };
25495- /// # syn::parse2::<TupleStruct>(input).unwrap();
25496- /// # }
25497+ /// # let input = quote! {
25498+ /// # struct S(A, B);
25499+ /// # };
25500+ /// # syn::parse2::<TupleStruct>(input).unwrap();
25501 /// ```
25502 pub fn parse_terminated<T, P: Parse>(
25503 &self,
25504 parser: fn(ParseStream) -> Result<T>,
25505 ) -> Result<Punctuated<T, P>> {
25506 Punctuated::parse_terminated_with(self, parser)
25507 }
25508
25509@@ -842,18 +899,18 @@ impl<'a> ParseBuffer<'a> {
25510 /// }
25511 /// ```
25512 pub fn fork(&self) -> Self {
25513 ParseBuffer {
25514 scope: self.scope,
25515 cell: self.cell.clone(),
25516 marker: PhantomData,
25517 // Not the parent's unexpected. Nothing cares whether the clone
25518- // parses all the way.
25519- unexpected: Rc::new(Cell::new(None)),
25520+ // parses all the way unless we `advance_to`.
25521+ unexpected: Cell::new(Some(Rc::new(Cell::new(Unexpected::None)))),
25522 }
25523 }
25524
25525 /// Triggers an error at the current position of the parse stream.
25526 ///
25527 /// # Example
25528 ///
25529 /// ```
25530@@ -918,23 +975,21 @@ impl<'a> ParseBuffer<'a> {
25531 /// #
25532 /// # fn remainder_after_skipping_past_next_at(
25533 /// # input: ParseStream,
25534 /// # ) -> Result<proc_macro2::TokenStream> {
25535 /// # skip_past_next_at(input)?;
25536 /// # input.parse()
25537 /// # }
25538 /// #
25539- /// # fn main() {
25540- /// # use syn::parse::Parser;
25541- /// # let remainder = remainder_after_skipping_past_next_at
25542- /// # .parse_str("a @ b c")
25543- /// # .unwrap();
25544- /// # assert_eq!(remainder.to_string(), "b c");
25545- /// # }
25546+ /// # use syn::parse::Parser;
25547+ /// # let remainder = remainder_after_skipping_past_next_at
25548+ /// # .parse_str("a @ b c")
25549+ /// # .unwrap();
25550+ /// # assert_eq!(remainder.to_string(), "b c");
25551 /// ```
25552 pub fn step<F, R>(&self, function: F) -> Result<R>
25553 where
25554 F: for<'c> FnOnce(StepCursor<'c, 'a>) -> Result<(R, Cursor<'c>)>,
25555 {
25556 // Since the user's function is required to work for any 'c, we know
25557 // that the Cursor<'c> they return is either derived from the input
25558 // StepCursor<'c, 'a> or from a Cursor<'static>.
25559@@ -956,27 +1011,39 @@ impl<'a> ParseBuffer<'a> {
25560 scope: self.scope,
25561 cursor: self.cell.get(),
25562 marker: PhantomData,
25563 })?;
25564 self.cell.set(rest);
25565 Ok(node)
25566 }
25567
25568+ /// Returns the `Span` of the next token in the parse stream, or
25569+ /// `Span::call_site()` if this parse stream has completely exhausted its
25570+ /// input `TokenStream`.
25571+ pub fn span(&self) -> Span {
25572+ let cursor = self.cursor();
25573+ if cursor.eof() {
25574+ self.scope
25575+ } else {
25576+ crate::buffer::open_span_of_group(cursor)
25577+ }
25578+ }
25579+
25580 /// Provides low-level access to the token representation underlying this
25581 /// parse stream.
25582 ///
25583 /// Cursors are immutable so no operations you perform against the cursor
25584 /// will affect the state of this parse stream.
25585 pub fn cursor(&self) -> Cursor<'a> {
25586 self.cell.get()
25587 }
25588
25589 fn check_unexpected(&self) -> Result<()> {
25590- match self.unexpected.get() {
25591+ match inner_unexpected(self).1 {
25592 Some(span) => Err(Error::new(span, "unexpected token")),
25593 None => Ok(()),
25594 }
25595 }
25596 }
25597
25598 impl<T: Parse> Parse for Box<T> {
25599 fn parse(input: ParseStream) -> Result<Self> {
25600@@ -1043,32 +1110,32 @@ impl Parse for Literal {
25601 }
25602
25603 /// Parser that can parse Rust tokens into a particular syntax tree node.
25604 ///
25605 /// Refer to the [module documentation] for details about parsing in Syn.
25606 ///
25607 /// [module documentation]: self
25608 ///
25609-/// *This trait is available if Syn is built with the `"parsing"` feature.*
25610+/// *This trait is available only if Syn is built with the `"parsing"` feature.*
25611 pub trait Parser: Sized {
25612 type Output;
25613
25614 /// Parse a proc-macro2 token stream into the chosen syntax tree node.
25615 ///
25616 /// This function will check that the input is fully parsed. If there are
25617 /// any unparsed tokens at the end of the stream, an error is returned.
25618 fn parse2(self, tokens: TokenStream) -> Result<Self::Output>;
25619
25620 /// Parse tokens of source code into the chosen syntax tree node.
25621 ///
25622 /// This function will check that the input is fully parsed. If there are
25623 /// any unparsed tokens at the end of the stream, an error is returned.
25624 ///
25625- /// *This method is available if Syn is built with both the `"parsing"` and
25626+ /// *This method is available only if Syn is built with both the `"parsing"` and
25627 /// `"proc-macro"` features.*
25628 #[cfg(all(
25629 not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
25630 feature = "proc-macro"
25631 ))]
25632 fn parse(self, tokens: proc_macro::TokenStream) -> Result<Self::Output> {
25633 self.parse2(proc_macro2::TokenStream::from(tokens))
25634 }
25635@@ -1083,90 +1150,96 @@ pub trait Parser: Sized {
25636 /// Every span in the resulting syntax tree will be set to resolve at the
25637 /// macro call site.
25638 fn parse_str(self, s: &str) -> Result<Self::Output> {
25639 self.parse2(proc_macro2::TokenStream::from_str(s)?)
25640 }
25641
25642 // Not public API.
25643 #[doc(hidden)]
25644+ #[cfg(any(feature = "full", feature = "derive"))]
25645 fn __parse_scoped(self, scope: Span, tokens: TokenStream) -> Result<Self::Output> {
25646 let _ = scope;
25647 self.parse2(tokens)
25648 }
25649
25650 // Not public API.
25651 #[doc(hidden)]
25652+ #[cfg(any(feature = "full", feature = "derive"))]
25653 fn __parse_stream(self, input: ParseStream) -> Result<Self::Output> {
25654 input.parse().and_then(|tokens| self.parse2(tokens))
25655 }
25656 }
25657
25658 fn tokens_to_parse_buffer(tokens: &TokenBuffer) -> ParseBuffer {
25659 let scope = Span::call_site();
25660 let cursor = tokens.begin();
25661- let unexpected = Rc::new(Cell::new(None));
25662+ let unexpected = Rc::new(Cell::new(Unexpected::None));
25663 new_parse_buffer(scope, cursor, unexpected)
25664 }
25665
25666 impl<F, T> Parser for F
25667 where
25668 F: FnOnce(ParseStream) -> Result<T>,
25669 {
25670 type Output = T;
25671
25672 fn parse2(self, tokens: TokenStream) -> Result<T> {
25673 let buf = TokenBuffer::new2(tokens);
25674 let state = tokens_to_parse_buffer(&buf);
25675 let node = self(&state)?;
25676 state.check_unexpected()?;
25677- if state.is_empty() {
25678+ if let Some(unexpected_span) = span_of_unexpected_ignoring_nones(state.cursor()) {
25679+ Err(Error::new(unexpected_span, "unexpected token"))
25680+ } else {
25681 Ok(node)
25682- } else {
25683- Err(state.error("unexpected token"))
25684 }
25685 }
25686
25687 #[doc(hidden)]
25688+ #[cfg(any(feature = "full", feature = "derive"))]
25689 fn __parse_scoped(self, scope: Span, tokens: TokenStream) -> Result<Self::Output> {
25690 let buf = TokenBuffer::new2(tokens);
25691 let cursor = buf.begin();
25692- let unexpected = Rc::new(Cell::new(None));
25693+ let unexpected = Rc::new(Cell::new(Unexpected::None));
25694 let state = new_parse_buffer(scope, cursor, unexpected);
25695 let node = self(&state)?;
25696 state.check_unexpected()?;
25697- if state.is_empty() {
25698+ if let Some(unexpected_span) = span_of_unexpected_ignoring_nones(state.cursor()) {
25699+ Err(Error::new(unexpected_span, "unexpected token"))
25700+ } else {
25701 Ok(node)
25702- } else {
25703- Err(state.error("unexpected token"))
25704 }
25705 }
25706
25707 #[doc(hidden)]
25708+ #[cfg(any(feature = "full", feature = "derive"))]
25709 fn __parse_stream(self, input: ParseStream) -> Result<Self::Output> {
25710 self(input)
25711 }
25712 }
25713
25714+#[cfg(any(feature = "full", feature = "derive"))]
25715 pub(crate) fn parse_scoped<F: Parser>(f: F, scope: Span, tokens: TokenStream) -> Result<F::Output> {
25716 f.__parse_scoped(scope, tokens)
25717 }
25718
25719+#[cfg(any(feature = "full", feature = "derive"))]
25720 pub(crate) fn parse_stream<F: Parser>(f: F, input: ParseStream) -> Result<F::Output> {
25721 f.__parse_stream(input)
25722 }
25723
25724 /// An empty syntax tree node that consumes no tokens when parsed.
25725 ///
25726 /// This is useful for attribute macros that want to ensure they are not
25727 /// provided any attribute args.
25728 ///
25729 /// ```
25730-/// extern crate proc_macro;
25731-///
25732+/// # extern crate proc_macro;
25733+/// #
25734 /// use proc_macro::TokenStream;
25735 /// use syn::parse_macro_input;
25736 /// use syn::parse::Nothing;
25737 ///
25738 /// # const IGNORE: &str = stringify! {
25739 /// #[proc_macro_attribute]
25740 /// # };
25741 /// pub fn my_attr(args: TokenStream, input: TokenStream) -> TokenStream {
25742diff --git a/third_party/rust/syn/src/parse_macro_input.rs b/third_party/rust/syn/src/parse_macro_input.rs
25743--- a/third_party/rust/syn/src/parse_macro_input.rs
25744+++ b/third_party/rust/syn/src/parse_macro_input.rs
25745@@ -11,18 +11,18 @@
25746 /// # Intended usage
25747 ///
25748 /// This macro must be called from a function that returns
25749 /// `proc_macro::TokenStream`. Usually this will be your proc macro entry point,
25750 /// the function that has the #\[proc_macro\] / #\[proc_macro_derive\] /
25751 /// #\[proc_macro_attribute\] attribute.
25752 ///
25753 /// ```
25754-/// extern crate proc_macro;
25755-///
25756+/// # extern crate proc_macro;
25757+/// #
25758 /// use proc_macro::TokenStream;
25759 /// use syn::{parse_macro_input, Result};
25760 /// use syn::parse::{Parse, ParseStream};
25761 ///
25762 /// struct MyMacroInput {
25763 /// /* ... */
25764 /// }
25765 ///
25766@@ -38,28 +38,52 @@
25767 /// # };
25768 /// pub fn my_macro(tokens: TokenStream) -> TokenStream {
25769 /// let input = parse_macro_input!(tokens as MyMacroInput);
25770 ///
25771 /// /* ... */
25772 /// # "".parse().unwrap()
25773 /// }
25774 /// ```
25775-#[macro_export(local_inner_macros)]
25776+///
25777+/// <br>
25778+///
25779+/// # Expansion
25780+///
25781+/// `parse_macro_input!($variable as $Type)` expands to something like:
25782+///
25783+/// ```no_run
25784+/// # extern crate proc_macro;
25785+/// #
25786+/// # macro_rules! doc_test {
25787+/// # ($variable:ident as $Type:ty) => {
25788+/// match syn::parse::<$Type>($variable) {
25789+/// Ok(syntax_tree) => syntax_tree,
25790+/// Err(err) => return proc_macro::TokenStream::from(err.to_compile_error()),
25791+/// }
25792+/// # };
25793+/// # }
25794+/// #
25795+/// # fn test(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
25796+/// # let _ = doc_test!(input as syn::Ident);
25797+/// # proc_macro::TokenStream::new()
25798+/// # }
25799+/// ```
25800+#[macro_export]
25801 macro_rules! parse_macro_input {
25802 ($tokenstream:ident as $ty:ty) => {
25803 match $crate::parse_macro_input::parse::<$ty>($tokenstream) {
25804 $crate::export::Ok(data) => data,
25805 $crate::export::Err(err) => {
25806 return $crate::export::TokenStream::from(err.to_compile_error());
25807 }
25808 }
25809 };
25810 ($tokenstream:ident) => {
25811- parse_macro_input!($tokenstream as _)
25812+ $crate::parse_macro_input!($tokenstream as _)
25813 };
25814 }
25815
25816 ////////////////////////////////////////////////////////////////////////////////
25817 // Can parse any type that implements Parse.
25818
25819 use crate::parse::{Parse, ParseStream, Parser, Result};
25820 use proc_macro::TokenStream;
25821diff --git a/third_party/rust/syn/src/parse_quote.rs b/third_party/rust/syn/src/parse_quote.rs
25822--- a/third_party/rust/syn/src/parse_quote.rs
25823+++ b/third_party/rust/syn/src/parse_quote.rs
25824@@ -19,17 +19,17 @@
25825 /// let stmt: Stmt = parse_quote! {
25826 /// let #name: #ty = Default::default();
25827 /// };
25828 ///
25829 /// println!("{:#?}", stmt);
25830 /// }
25831 /// ```
25832 ///
25833-/// *This macro is available if Syn is built with the `"parsing"` feature,
25834+/// *This macro is available only if Syn is built with the `"parsing"` feature,
25835 /// although interpolation of syntax tree nodes into the quoted tokens is only
25836 /// supported if Syn is built with the `"printing"` feature as well.*
25837 ///
25838 /// # Example
25839 ///
25840 /// The following helper function adds a bound `T: HeapSize` to every type
25841 /// parameter `T` in the input generics.
25842 ///
25843@@ -51,28 +51,30 @@
25844 ///
25845 /// This macro can parse the following additional types as a special case even
25846 /// though they do not implement the `Parse` trait.
25847 ///
25848 /// - [`Attribute`] — parses one attribute, allowing either outer like `#[...]`
25849 /// or inner like `#![...]`
25850 /// - [`Punctuated<T, P>`] — parses zero or more `T` separated by punctuation
25851 /// `P` with optional trailing punctuation
25852+/// - [`Vec<Stmt>`] — parses the same as `Block::parse_within`
25853 ///
25854 /// [`Punctuated<T, P>`]: punctuated::Punctuated
25855+/// [`Vec<Stmt>`]: Block::parse_within
25856 ///
25857 /// # Panics
25858 ///
25859 /// Panics if the tokens fail to parse as the expected syntax tree type. The
25860 /// caller is responsible for ensuring that the input tokens are syntactically
25861 /// valid.
25862 //
25863 // TODO: allow Punctuated to be inferred as intra doc link, currently blocked on
25864 // https://github.com/rust-lang/rust/issues/62834
25865-#[macro_export(local_inner_macros)]
25866+#[macro_export]
25867 macro_rules! parse_quote {
25868 ($($tt:tt)*) => {
25869 $crate::parse_quote::parse(
25870 $crate::export::From::from(
25871 $crate::export::quote::quote!($($tt)*)
25872 )
25873 )
25874 };
25875@@ -107,16 +109,18 @@ impl<T: Parse> ParseQuote for T {
25876 }
25877
25878 ////////////////////////////////////////////////////////////////////////////////
25879 // Any other types that we want `parse_quote!` to be able to parse.
25880
25881 use crate::punctuated::Punctuated;
25882 #[cfg(any(feature = "full", feature = "derive"))]
25883 use crate::{attr, Attribute};
25884+#[cfg(feature = "full")]
25885+use crate::{Block, Stmt};
25886
25887 #[cfg(any(feature = "full", feature = "derive"))]
25888 impl ParseQuote for Attribute {
25889 fn parse(input: ParseStream) -> Result<Self> {
25890 if input.peek(Token![#]) && input.peek2(Token![!]) {
25891 attr::parsing::single_parse_inner(input)
25892 } else {
25893 attr::parsing::single_parse_outer(input)
25894@@ -124,8 +128,15 @@ impl ParseQuote for Attribute {
25895 }
25896 }
25897
25898 impl<T: Parse, P: Parse> ParseQuote for Punctuated<T, P> {
25899 fn parse(input: ParseStream) -> Result<Self> {
25900 Self::parse_terminated(input)
25901 }
25902 }
25903+
25904+#[cfg(feature = "full")]
25905+impl ParseQuote for Vec<Stmt> {
25906+ fn parse(input: ParseStream) -> Result<Self> {
25907+ Block::parse_within(input)
25908+ }
25909+}
25910diff --git a/third_party/rust/syn/src/pat.rs b/third_party/rust/syn/src/pat.rs
25911--- a/third_party/rust/syn/src/pat.rs
25912+++ b/third_party/rust/syn/src/pat.rs
25913@@ -1,31 +1,27 @@
25914 use super::*;
25915 use crate::punctuated::Punctuated;
25916-#[cfg(feature = "extra-traits")]
25917-use crate::tt::TokenStreamHelper;
25918 use proc_macro2::TokenStream;
25919-#[cfg(feature = "extra-traits")]
25920-use std::hash::{Hash, Hasher};
25921
25922 ast_enum_of_structs! {
25923 /// A pattern in a local binding, function signature, match expression, or
25924 /// various other places.
25925 ///
25926- /// *This type is available if Syn is built with the `"full"` feature.*
25927+ /// *This type is available only if Syn is built with the `"full"` feature.*
25928 ///
25929 /// # Syntax tree enum
25930 ///
25931 /// This type is a [syntax tree enum].
25932 ///
25933 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
25934 //
25935 // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
25936 // blocked on https://github.com/rust-lang/rust/issues/62833
25937- pub enum Pat #manual_extra_traits {
25938+ pub enum Pat {
25939 /// A box pattern: `box v`.
25940 Box(PatBox),
25941
25942 /// A pattern that binds a new variable: `ref mut binding @ SUBPATTERN`.
25943 Ident(PatIdent),
25944
25945 /// A literal pattern: `0`.
25946 ///
25947@@ -81,321 +77,219 @@ ast_enum_of_structs! {
25948 #[doc(hidden)]
25949 __Nonexhaustive,
25950 }
25951 }
25952
25953 ast_struct! {
25954 /// A box pattern: `box v`.
25955 ///
25956- /// *This type is available if Syn is built with the `"full"` feature.*
25957+ /// *This type is available only if Syn is built with the `"full"` feature.*
25958 pub struct PatBox {
25959 pub attrs: Vec<Attribute>,
25960 pub box_token: Token![box],
25961 pub pat: Box<Pat>,
25962 }
25963 }
25964
25965 ast_struct! {
25966 /// A pattern that binds a new variable: `ref mut binding @ SUBPATTERN`.
25967 ///
25968- /// *This type is available if Syn is built with the `"full"` feature.*
25969+ /// It may also be a unit struct or struct variant (e.g. `None`), or a
25970+ /// constant; these cannot be distinguished syntactically.
25971+ ///
25972+ /// *This type is available only if Syn is built with the `"full"` feature.*
25973 pub struct PatIdent {
25974 pub attrs: Vec<Attribute>,
25975 pub by_ref: Option<Token![ref]>,
25976 pub mutability: Option<Token![mut]>,
25977 pub ident: Ident,
25978 pub subpat: Option<(Token![@], Box<Pat>)>,
25979 }
25980 }
25981
25982 ast_struct! {
25983 /// A literal pattern: `0`.
25984 ///
25985 /// This holds an `Expr` rather than a `Lit` because negative numbers
25986 /// are represented as an `Expr::Unary`.
25987 ///
25988- /// *This type is available if Syn is built with the `"full"` feature.*
25989+ /// *This type is available only if Syn is built with the `"full"` feature.*
25990 pub struct PatLit {
25991 pub attrs: Vec<Attribute>,
25992 pub expr: Box<Expr>,
25993 }
25994 }
25995
25996 ast_struct! {
25997 /// A macro in pattern position.
25998 ///
25999- /// *This type is available if Syn is built with the `"full"` feature.*
26000+ /// *This type is available only if Syn is built with the `"full"` feature.*
26001 pub struct PatMacro {
26002 pub attrs: Vec<Attribute>,
26003 pub mac: Macro,
26004 }
26005 }
26006
26007 ast_struct! {
26008 /// A pattern that matches any one of a set of cases.
26009 ///
26010- /// *This type is available if Syn is built with the `"full"` feature.*
26011+ /// *This type is available only if Syn is built with the `"full"` feature.*
26012 pub struct PatOr {
26013 pub attrs: Vec<Attribute>,
26014 pub leading_vert: Option<Token![|]>,
26015 pub cases: Punctuated<Pat, Token![|]>,
26016 }
26017 }
26018
26019 ast_struct! {
26020 /// A path pattern like `Color::Red`, optionally qualified with a
26021 /// self-type.
26022 ///
26023 /// Unqualified path patterns can legally refer to variants, structs,
26024 /// constants or associated constants. Qualified path patterns like
26025 /// `<A>::B::C` and `<A as Trait>::B::C` can only legally refer to
26026 /// associated constants.
26027 ///
26028- /// *This type is available if Syn is built with the `"full"` feature.*
26029+ /// *This type is available only if Syn is built with the `"full"` feature.*
26030 pub struct PatPath {
26031 pub attrs: Vec<Attribute>,
26032 pub qself: Option<QSelf>,
26033 pub path: Path,
26034 }
26035 }
26036
26037 ast_struct! {
26038 /// A range pattern: `1..=2`.
26039 ///
26040- /// *This type is available if Syn is built with the `"full"` feature.*
26041+ /// *This type is available only if Syn is built with the `"full"` feature.*
26042 pub struct PatRange {
26043 pub attrs: Vec<Attribute>,
26044 pub lo: Box<Expr>,
26045 pub limits: RangeLimits,
26046 pub hi: Box<Expr>,
26047 }
26048 }
26049
26050 ast_struct! {
26051 /// A reference pattern: `&mut var`.
26052 ///
26053- /// *This type is available if Syn is built with the `"full"` feature.*
26054+ /// *This type is available only if Syn is built with the `"full"` feature.*
26055 pub struct PatReference {
26056 pub attrs: Vec<Attribute>,
26057 pub and_token: Token![&],
26058 pub mutability: Option<Token![mut]>,
26059 pub pat: Box<Pat>,
26060 }
26061 }
26062
26063 ast_struct! {
26064 /// The dots in a tuple or slice pattern: `[0, 1, ..]`
26065 ///
26066- /// *This type is available if Syn is built with the `"full"` feature.*
26067+ /// *This type is available only if Syn is built with the `"full"` feature.*
26068 pub struct PatRest {
26069 pub attrs: Vec<Attribute>,
26070 pub dot2_token: Token![..],
26071 }
26072 }
26073
26074 ast_struct! {
26075 /// A dynamically sized slice pattern: `[a, b, ref i @ .., y, z]`.
26076 ///
26077- /// *This type is available if Syn is built with the `"full"` feature.*
26078+ /// *This type is available only if Syn is built with the `"full"` feature.*
26079 pub struct PatSlice {
26080 pub attrs: Vec<Attribute>,
26081 pub bracket_token: token::Bracket,
26082 pub elems: Punctuated<Pat, Token![,]>,
26083 }
26084 }
26085
26086 ast_struct! {
26087 /// A struct or struct variant pattern: `Variant { x, y, .. }`.
26088 ///
26089- /// *This type is available if Syn is built with the `"full"` feature.*
26090+ /// *This type is available only if Syn is built with the `"full"` feature.*
26091 pub struct PatStruct {
26092 pub attrs: Vec<Attribute>,
26093 pub path: Path,
26094 pub brace_token: token::Brace,
26095 pub fields: Punctuated<FieldPat, Token![,]>,
26096 pub dot2_token: Option<Token![..]>,
26097 }
26098 }
26099
26100 ast_struct! {
26101 /// A tuple pattern: `(a, b)`.
26102 ///
26103- /// *This type is available if Syn is built with the `"full"` feature.*
26104+ /// *This type is available only if Syn is built with the `"full"` feature.*
26105 pub struct PatTuple {
26106 pub attrs: Vec<Attribute>,
26107 pub paren_token: token::Paren,
26108 pub elems: Punctuated<Pat, Token![,]>,
26109 }
26110 }
26111
26112 ast_struct! {
26113 /// A tuple struct or tuple variant pattern: `Variant(x, y, .., z)`.
26114 ///
26115- /// *This type is available if Syn is built with the `"full"` feature.*
26116+ /// *This type is available only if Syn is built with the `"full"` feature.*
26117 pub struct PatTupleStruct {
26118 pub attrs: Vec<Attribute>,
26119 pub path: Path,
26120 pub pat: PatTuple,
26121 }
26122 }
26123
26124 ast_struct! {
26125 /// A type ascription pattern: `foo: f64`.
26126 ///
26127- /// *This type is available if Syn is built with the `"full"` feature.*
26128+ /// *This type is available only if Syn is built with the `"full"` feature.*
26129 pub struct PatType {
26130 pub attrs: Vec<Attribute>,
26131 pub pat: Box<Pat>,
26132 pub colon_token: Token![:],
26133 pub ty: Box<Type>,
26134 }
26135 }
26136
26137 ast_struct! {
26138 /// A pattern that matches any value: `_`.
26139 ///
26140- /// *This type is available if Syn is built with the `"full"` feature.*
26141+ /// *This type is available only if Syn is built with the `"full"` feature.*
26142 pub struct PatWild {
26143 pub attrs: Vec<Attribute>,
26144 pub underscore_token: Token![_],
26145 }
26146 }
26147
26148 ast_struct! {
26149 /// A single field in a struct pattern.
26150 ///
26151 /// Patterns like the fields of Foo `{ x, ref y, ref mut z }` are treated
26152 /// the same as `x: x, y: ref y, z: ref mut z` but there is no colon token.
26153 ///
26154- /// *This type is available if Syn is built with the `"full"` feature.*
26155+ /// *This type is available only if Syn is built with the `"full"` feature.*
26156 pub struct FieldPat {
26157 pub attrs: Vec<Attribute>,
26158 pub member: Member,
26159 pub colon_token: Option<Token![:]>,
26160 pub pat: Box<Pat>,
26161 }
26162 }
26163
26164-#[cfg(feature = "extra-traits")]
26165-impl Eq for Pat {}
26166-
26167-#[cfg(feature = "extra-traits")]
26168-impl PartialEq for Pat {
26169- fn eq(&self, other: &Self) -> bool {
26170- match (self, other) {
26171- (Pat::Box(this), Pat::Box(other)) => this == other,
26172- (Pat::Ident(this), Pat::Ident(other)) => this == other,
26173- (Pat::Lit(this), Pat::Lit(other)) => this == other,
26174- (Pat::Macro(this), Pat::Macro(other)) => this == other,
26175- (Pat::Or(this), Pat::Or(other)) => this == other,
26176- (Pat::Path(this), Pat::Path(other)) => this == other,
26177- (Pat::Range(this), Pat::Range(other)) => this == other,
26178- (Pat::Reference(this), Pat::Reference(other)) => this == other,
26179- (Pat::Rest(this), Pat::Rest(other)) => this == other,
26180- (Pat::Slice(this), Pat::Slice(other)) => this == other,
26181- (Pat::Struct(this), Pat::Struct(other)) => this == other,
26182- (Pat::Tuple(this), Pat::Tuple(other)) => this == other,
26183- (Pat::TupleStruct(this), Pat::TupleStruct(other)) => this == other,
26184- (Pat::Type(this), Pat::Type(other)) => this == other,
26185- (Pat::Verbatim(this), Pat::Verbatim(other)) => {
26186- TokenStreamHelper(this) == TokenStreamHelper(other)
26187- }
26188- (Pat::Wild(this), Pat::Wild(other)) => this == other,
26189- _ => false,
26190- }
26191- }
26192-}
26193-
26194-#[cfg(feature = "extra-traits")]
26195-impl Hash for Pat {
26196- fn hash<H>(&self, hash: &mut H)
26197- where
26198- H: Hasher,
26199- {
26200- match self {
26201- Pat::Box(pat) => {
26202- hash.write_u8(0);
26203- pat.hash(hash);
26204- }
26205- Pat::Ident(pat) => {
26206- hash.write_u8(1);
26207- pat.hash(hash);
26208- }
26209- Pat::Lit(pat) => {
26210- hash.write_u8(2);
26211- pat.hash(hash);
26212- }
26213- Pat::Macro(pat) => {
26214- hash.write_u8(3);
26215- pat.hash(hash);
26216- }
26217- Pat::Or(pat) => {
26218- hash.write_u8(4);
26219- pat.hash(hash);
26220- }
26221- Pat::Path(pat) => {
26222- hash.write_u8(5);
26223- pat.hash(hash);
26224- }
26225- Pat::Range(pat) => {
26226- hash.write_u8(6);
26227- pat.hash(hash);
26228- }
26229- Pat::Reference(pat) => {
26230- hash.write_u8(7);
26231- pat.hash(hash);
26232- }
26233- Pat::Rest(pat) => {
26234- hash.write_u8(8);
26235- pat.hash(hash);
26236- }
26237- Pat::Slice(pat) => {
26238- hash.write_u8(9);
26239- pat.hash(hash);
26240- }
26241- Pat::Struct(pat) => {
26242- hash.write_u8(10);
26243- pat.hash(hash);
26244- }
26245- Pat::Tuple(pat) => {
26246- hash.write_u8(11);
26247- pat.hash(hash);
26248- }
26249- Pat::TupleStruct(pat) => {
26250- hash.write_u8(12);
26251- pat.hash(hash);
26252- }
26253- Pat::Type(pat) => {
26254- hash.write_u8(13);
26255- pat.hash(hash);
26256- }
26257- Pat::Verbatim(pat) => {
26258- hash.write_u8(14);
26259- TokenStreamHelper(pat).hash(hash);
26260- }
26261- Pat::Wild(pat) => {
26262- hash.write_u8(15);
26263- pat.hash(hash);
26264- }
26265- Pat::__Nonexhaustive => unreachable!(),
26266- }
26267- }
26268-}
26269-
26270 #[cfg(feature = "parsing")]
26271-mod parsing {
26272+pub mod parsing {
26273 use super::*;
26274
26275 use crate::ext::IdentExt;
26276- use crate::parse::{Parse, ParseStream, Result};
26277+ use crate::parse::{Parse, ParseBuffer, ParseStream, Result};
26278 use crate::path;
26279
26280 impl Parse for Pat {
26281 fn parse(input: ParseStream) -> Result<Self> {
26282+ let begin = input.fork();
26283 let lookahead = input.lookahead1();
26284 if lookahead.peek(Ident)
26285 && ({
26286 input.peek2(Token![::])
26287 || input.peek2(Token![!])
26288 || input.peek2(token::Brace)
26289 || input.peek2(token::Paren)
26290 || input.peek2(Token![..])
26291@@ -406,17 +300,16 @@ mod parsing {
26292 ahead.is_empty() || ahead.peek(Token![,])
26293 }
26294 })
26295 || input.peek(Token![self]) && input.peek2(Token![::])
26296 || lookahead.peek(Token![::])
26297 || lookahead.peek(Token![<])
26298 || input.peek(Token![Self])
26299 || input.peek(Token![super])
26300- || input.peek(Token![extern])
26301 || input.peek(Token![crate])
26302 {
26303 pat_path_or_macro_or_struct_or_range(input)
26304 } else if lookahead.peek(Token![_]) {
26305 input.call(pat_wild).map(Pat::Wild)
26306 } else if input.peek(Token![box]) {
26307 input.call(pat_box).map(Pat::Box)
26308 } else if input.peek(Token![-]) || lookahead.peek(Lit) {
26309@@ -429,28 +322,29 @@ mod parsing {
26310 input.call(pat_ident).map(Pat::Ident)
26311 } else if lookahead.peek(Token![&]) {
26312 input.call(pat_reference).map(Pat::Reference)
26313 } else if lookahead.peek(token::Paren) {
26314 input.call(pat_tuple).map(Pat::Tuple)
26315 } else if lookahead.peek(token::Bracket) {
26316 input.call(pat_slice).map(Pat::Slice)
26317 } else if lookahead.peek(Token![..]) && !input.peek(Token![...]) {
26318- input.call(pat_rest).map(Pat::Rest)
26319+ pat_range_half_open(input, begin)
26320 } else {
26321 Err(lookahead.error())
26322 }
26323 }
26324 }
26325
26326 fn pat_path_or_macro_or_struct_or_range(input: ParseStream) -> Result<Pat> {
26327+ let begin = input.fork();
26328 let (qself, path) = path::parsing::qpath(input, true)?;
26329
26330 if input.peek(Token![..]) {
26331- return pat_range(input, qself, path).map(Pat::Range);
26332+ return pat_range(input, begin, qself, path);
26333 }
26334
26335 if qself.is_some() {
26336 return Ok(Pat::Path(PatPath {
26337 attrs: Vec::new(),
26338 qself,
26339 path,
26340 }));
26341@@ -482,17 +376,17 @@ mod parsing {
26342 }
26343 }
26344
26345 if input.peek(token::Brace) {
26346 pat_struct(input, path).map(Pat::Struct)
26347 } else if input.peek(token::Paren) {
26348 pat_tuple_struct(input, path).map(Pat::TupleStruct)
26349 } else if input.peek(Token![..]) {
26350- pat_range(input, qself, path).map(Pat::Range)
26351+ pat_range(input, begin, qself, path)
26352 } else {
26353 Ok(Pat::Path(PatPath {
26354 attrs: Vec::new(),
26355 qself,
26356 path,
26357 }))
26358 }
26359 }
26360@@ -541,17 +435,17 @@ mod parsing {
26361 fn pat_struct(input: ParseStream, path: Path) -> Result<PatStruct> {
26362 let content;
26363 let brace_token = braced!(content in input);
26364
26365 let mut fields = Punctuated::new();
26366 while !content.is_empty() && !content.peek(Token![..]) {
26367 let value = content.call(field_pat)?;
26368 fields.push_value(value);
26369- if !content.peek(Token![,]) {
26370+ if content.is_empty() {
26371 break;
26372 }
26373 let punct: Token![,] = content.parse()?;
26374 fields.push_punct(punct);
26375 }
26376
26377 let dot2_token = if fields.empty_or_trailing() && content.peek(Token![..]) {
26378 Some(content.parse()?)
26379@@ -573,29 +467,30 @@ mod parsing {
26380 match *self {
26381 Member::Named(_) => false,
26382 Member::Unnamed(_) => true,
26383 }
26384 }
26385 }
26386
26387 fn field_pat(input: ParseStream) -> Result<FieldPat> {
26388+ let attrs = input.call(Attribute::parse_outer)?;
26389 let boxed: Option<Token![box]> = input.parse()?;
26390 let by_ref: Option<Token![ref]> = input.parse()?;
26391 let mutability: Option<Token![mut]> = input.parse()?;
26392 let member: Member = input.parse()?;
26393
26394 if boxed.is_none() && by_ref.is_none() && mutability.is_none() && input.peek(Token![:])
26395 || member.is_unnamed()
26396 {
26397 return Ok(FieldPat {
26398- attrs: Vec::new(),
26399+ attrs,
26400 member,
26401 colon_token: input.parse()?,
26402- pat: input.parse()?,
26403+ pat: Box::new(multi_pat(input)?),
26404 });
26405 }
26406
26407 let ident = match member {
26408 Member::Named(ident) => ident,
26409 Member::Unnamed(_) => unreachable!(),
26410 };
26411
26412@@ -605,49 +500,76 @@ mod parsing {
26413 mutability,
26414 ident: ident.clone(),
26415 subpat: None,
26416 });
26417
26418 if let Some(boxed) = boxed {
26419 pat = Pat::Box(PatBox {
26420 attrs: Vec::new(),
26421+ box_token: boxed,
26422 pat: Box::new(pat),
26423- box_token: boxed,
26424 });
26425 }
26426
26427 Ok(FieldPat {
26428+ attrs,
26429 member: Member::Named(ident),
26430+ colon_token: None,
26431 pat: Box::new(pat),
26432- attrs: Vec::new(),
26433- colon_token: None,
26434 })
26435 }
26436
26437- fn pat_range(input: ParseStream, qself: Option<QSelf>, path: Path) -> Result<PatRange> {
26438- Ok(PatRange {
26439- attrs: Vec::new(),
26440- lo: Box::new(Expr::Path(ExprPath {
26441+ fn pat_range(
26442+ input: ParseStream,
26443+ begin: ParseBuffer,
26444+ qself: Option<QSelf>,
26445+ path: Path,
26446+ ) -> Result<Pat> {
26447+ let limits: RangeLimits = input.parse()?;
26448+ let hi = input.call(pat_lit_expr)?;
26449+ if let Some(hi) = hi {
26450+ Ok(Pat::Range(PatRange {
26451 attrs: Vec::new(),
26452- qself,
26453- path,
26454- })),
26455- limits: input.parse()?,
26456- hi: input.call(pat_lit_expr)?,
26457- })
26458+ lo: Box::new(Expr::Path(ExprPath {
26459+ attrs: Vec::new(),
26460+ qself,
26461+ path,
26462+ })),
26463+ limits,
26464+ hi,
26465+ }))
26466+ } else {
26467+ Ok(Pat::Verbatim(verbatim::between(begin, input)))
26468+ }
26469+ }
26470+
26471+ fn pat_range_half_open(input: ParseStream, begin: ParseBuffer) -> Result<Pat> {
26472+ let limits: RangeLimits = input.parse()?;
26473+ let hi = input.call(pat_lit_expr)?;
26474+ if hi.is_some() {
26475+ Ok(Pat::Verbatim(verbatim::between(begin, input)))
26476+ } else {
26477+ match limits {
26478+ RangeLimits::HalfOpen(dot2_token) => Ok(Pat::Rest(PatRest {
26479+ attrs: Vec::new(),
26480+ dot2_token,
26481+ })),
26482+ RangeLimits::Closed(_) => Err(input.error("expected range upper bound")),
26483+ }
26484+ }
26485 }
26486
26487 fn pat_tuple(input: ParseStream) -> Result<PatTuple> {
26488 let content;
26489 let paren_token = parenthesized!(content in input);
26490
26491 let mut elems = Punctuated::new();
26492 while !content.is_empty() {
26493- let value: Pat = content.parse()?;
26494+ let value = multi_pat(&content)?;
26495 elems.push_value(value);
26496 if content.is_empty() {
26497 break;
26498 }
26499 let punct = content.parse()?;
26500 elems.push_punct(punct);
26501 }
26502
26503@@ -663,225 +585,280 @@ mod parsing {
26504 attrs: Vec::new(),
26505 and_token: input.parse()?,
26506 mutability: input.parse()?,
26507 pat: input.parse()?,
26508 })
26509 }
26510
26511 fn pat_lit_or_range(input: ParseStream) -> Result<Pat> {
26512- let lo = input.call(pat_lit_expr)?;
26513+ let begin = input.fork();
26514+ let lo = input.call(pat_lit_expr)?.unwrap();
26515 if input.peek(Token![..]) {
26516- Ok(Pat::Range(PatRange {
26517- attrs: Vec::new(),
26518- lo,
26519- limits: input.parse()?,
26520- hi: input.call(pat_lit_expr)?,
26521- }))
26522+ let limits: RangeLimits = input.parse()?;
26523+ let hi = input.call(pat_lit_expr)?;
26524+ if let Some(hi) = hi {
26525+ Ok(Pat::Range(PatRange {
26526+ attrs: Vec::new(),
26527+ lo,
26528+ limits,
26529+ hi,
26530+ }))
26531+ } else {
26532+ Ok(Pat::Verbatim(verbatim::between(begin, input)))
26533+ }
26534 } else {
26535 Ok(Pat::Lit(PatLit {
26536 attrs: Vec::new(),
26537 expr: lo,
26538 }))
26539 }
26540 }
26541
26542- fn pat_lit_expr(input: ParseStream) -> Result<Box<Expr>> {
26543+ fn pat_lit_expr(input: ParseStream) -> Result<Option<Box<Expr>>> {
26544+ if input.is_empty()
26545+ || input.peek(Token![|])
26546+ || input.peek(Token![=>])
26547+ || input.peek(Token![:]) && !input.peek(Token![::])
26548+ || input.peek(Token![,])
26549+ || input.peek(Token![;])
26550+ {
26551+ return Ok(None);
26552+ }
26553+
26554 let neg: Option<Token![-]> = input.parse()?;
26555
26556 let lookahead = input.lookahead1();
26557 let expr = if lookahead.peek(Lit) {
26558 Expr::Lit(input.parse()?)
26559 } else if lookahead.peek(Ident)
26560 || lookahead.peek(Token![::])
26561 || lookahead.peek(Token![<])
26562 || lookahead.peek(Token![self])
26563 || lookahead.peek(Token![Self])
26564 || lookahead.peek(Token![super])
26565- || lookahead.peek(Token![extern])
26566 || lookahead.peek(Token![crate])
26567 {
26568 Expr::Path(input.parse()?)
26569 } else {
26570 return Err(lookahead.error());
26571 };
26572
26573- Ok(Box::new(if let Some(neg) = neg {
26574+ Ok(Some(Box::new(if let Some(neg) = neg {
26575 Expr::Unary(ExprUnary {
26576 attrs: Vec::new(),
26577 op: UnOp::Neg(neg),
26578 expr: Box::new(expr),
26579 })
26580 } else {
26581 expr
26582- }))
26583+ })))
26584 }
26585
26586 fn pat_slice(input: ParseStream) -> Result<PatSlice> {
26587 let content;
26588 let bracket_token = bracketed!(content in input);
26589
26590 let mut elems = Punctuated::new();
26591 while !content.is_empty() {
26592- let value: Pat = content.parse()?;
26593+ let value = multi_pat(&content)?;
26594 elems.push_value(value);
26595 if content.is_empty() {
26596 break;
26597 }
26598 let punct = content.parse()?;
26599 elems.push_punct(punct);
26600 }
26601
26602 Ok(PatSlice {
26603 attrs: Vec::new(),
26604 bracket_token,
26605 elems,
26606 })
26607 }
26608
26609- fn pat_rest(input: ParseStream) -> Result<PatRest> {
26610- Ok(PatRest {
26611- attrs: Vec::new(),
26612- dot2_token: input.parse()?,
26613- })
26614+ pub fn multi_pat(input: ParseStream) -> Result<Pat> {
26615+ multi_pat_impl(input, None)
26616+ }
26617+
26618+ pub fn multi_pat_with_leading_vert(input: ParseStream) -> Result<Pat> {
26619+ let leading_vert: Option<Token![|]> = input.parse()?;
26620+ multi_pat_impl(input, leading_vert)
26621+ }
26622+
26623+ fn multi_pat_impl(input: ParseStream, leading_vert: Option<Token![|]>) -> Result<Pat> {
26624+ let mut pat: Pat = input.parse()?;
26625+ if leading_vert.is_some()
26626+ || input.peek(Token![|]) && !input.peek(Token![||]) && !input.peek(Token![|=])
26627+ {
26628+ let mut cases = Punctuated::new();
26629+ cases.push_value(pat);
26630+ while input.peek(Token![|]) && !input.peek(Token![||]) && !input.peek(Token![|=]) {
26631+ let punct = input.parse()?;
26632+ cases.push_punct(punct);
26633+ let pat: Pat = input.parse()?;
26634+ cases.push_value(pat);
26635+ }
26636+ pat = Pat::Or(PatOr {
26637+ attrs: Vec::new(),
26638+ leading_vert,
26639+ cases,
26640+ });
26641+ }
26642+ Ok(pat)
26643 }
26644 }
26645
26646 #[cfg(feature = "printing")]
26647 mod printing {
26648 use super::*;
26649
26650 use proc_macro2::TokenStream;
26651 use quote::{ToTokens, TokenStreamExt};
26652
26653 use crate::attr::FilterAttrs;
26654
26655 impl ToTokens for PatWild {
26656 fn to_tokens(&self, tokens: &mut TokenStream) {
26657+ tokens.append_all(self.attrs.outer());
26658 self.underscore_token.to_tokens(tokens);
26659 }
26660 }
26661
26662 impl ToTokens for PatIdent {
26663 fn to_tokens(&self, tokens: &mut TokenStream) {
26664+ tokens.append_all(self.attrs.outer());
26665 self.by_ref.to_tokens(tokens);
26666 self.mutability.to_tokens(tokens);
26667 self.ident.to_tokens(tokens);
26668 if let Some((at_token, subpat)) = &self.subpat {
26669 at_token.to_tokens(tokens);
26670 subpat.to_tokens(tokens);
26671 }
26672 }
26673 }
26674
26675 impl ToTokens for PatStruct {
26676 fn to_tokens(&self, tokens: &mut TokenStream) {
26677+ tokens.append_all(self.attrs.outer());
26678 self.path.to_tokens(tokens);
26679 self.brace_token.surround(tokens, |tokens| {
26680 self.fields.to_tokens(tokens);
26681 // NOTE: We need a comma before the dot2 token if it is present.
26682 if !self.fields.empty_or_trailing() && self.dot2_token.is_some() {
26683 <Token![,]>::default().to_tokens(tokens);
26684 }
26685 self.dot2_token.to_tokens(tokens);
26686 });
26687 }
26688 }
26689
26690 impl ToTokens for PatTupleStruct {
26691 fn to_tokens(&self, tokens: &mut TokenStream) {
26692+ tokens.append_all(self.attrs.outer());
26693 self.path.to_tokens(tokens);
26694 self.pat.to_tokens(tokens);
26695 }
26696 }
26697
26698 impl ToTokens for PatType {
26699 fn to_tokens(&self, tokens: &mut TokenStream) {
26700 tokens.append_all(self.attrs.outer());
26701 self.pat.to_tokens(tokens);
26702 self.colon_token.to_tokens(tokens);
26703 self.ty.to_tokens(tokens);
26704 }
26705 }
26706
26707 impl ToTokens for PatPath {
26708 fn to_tokens(&self, tokens: &mut TokenStream) {
26709+ tokens.append_all(self.attrs.outer());
26710 private::print_path(tokens, &self.qself, &self.path);
26711 }
26712 }
26713
26714 impl ToTokens for PatTuple {
26715 fn to_tokens(&self, tokens: &mut TokenStream) {
26716+ tokens.append_all(self.attrs.outer());
26717 self.paren_token.surround(tokens, |tokens| {
26718 self.elems.to_tokens(tokens);
26719 });
26720 }
26721 }
26722
26723 impl ToTokens for PatBox {
26724 fn to_tokens(&self, tokens: &mut TokenStream) {
26725+ tokens.append_all(self.attrs.outer());
26726 self.box_token.to_tokens(tokens);
26727 self.pat.to_tokens(tokens);
26728 }
26729 }
26730
26731 impl ToTokens for PatReference {
26732 fn to_tokens(&self, tokens: &mut TokenStream) {
26733+ tokens.append_all(self.attrs.outer());
26734 self.and_token.to_tokens(tokens);
26735 self.mutability.to_tokens(tokens);
26736 self.pat.to_tokens(tokens);
26737 }
26738 }
26739
26740 impl ToTokens for PatRest {
26741 fn to_tokens(&self, tokens: &mut TokenStream) {
26742+ tokens.append_all(self.attrs.outer());
26743 self.dot2_token.to_tokens(tokens);
26744 }
26745 }
26746
26747 impl ToTokens for PatLit {
26748 fn to_tokens(&self, tokens: &mut TokenStream) {
26749+ tokens.append_all(self.attrs.outer());
26750 self.expr.to_tokens(tokens);
26751 }
26752 }
26753
26754 impl ToTokens for PatRange {
26755 fn to_tokens(&self, tokens: &mut TokenStream) {
26756+ tokens.append_all(self.attrs.outer());
26757 self.lo.to_tokens(tokens);
26758 match &self.limits {
26759 RangeLimits::HalfOpen(t) => t.to_tokens(tokens),
26760 RangeLimits::Closed(t) => t.to_tokens(tokens),
26761 }
26762 self.hi.to_tokens(tokens);
26763 }
26764 }
26765
26766 impl ToTokens for PatSlice {
26767 fn to_tokens(&self, tokens: &mut TokenStream) {
26768+ tokens.append_all(self.attrs.outer());
26769 self.bracket_token.surround(tokens, |tokens| {
26770 self.elems.to_tokens(tokens);
26771 });
26772 }
26773 }
26774
26775 impl ToTokens for PatMacro {
26776 fn to_tokens(&self, tokens: &mut TokenStream) {
26777+ tokens.append_all(self.attrs.outer());
26778 self.mac.to_tokens(tokens);
26779 }
26780 }
26781
26782 impl ToTokens for PatOr {
26783 fn to_tokens(&self, tokens: &mut TokenStream) {
26784+ tokens.append_all(self.attrs.outer());
26785 self.leading_vert.to_tokens(tokens);
26786 self.cases.to_tokens(tokens);
26787 }
26788 }
26789
26790 impl ToTokens for FieldPat {
26791 fn to_tokens(&self, tokens: &mut TokenStream) {
26792+ tokens.append_all(self.attrs.outer());
26793 if let Some(colon_token) = &self.colon_token {
26794 self.member.to_tokens(tokens);
26795 colon_token.to_tokens(tokens);
26796 }
26797 self.pat.to_tokens(tokens);
26798 }
26799 }
26800 }
26801diff --git a/third_party/rust/syn/src/path.rs b/third_party/rust/syn/src/path.rs
26802--- a/third_party/rust/syn/src/path.rs
26803+++ b/third_party/rust/syn/src/path.rs
26804@@ -1,15 +1,15 @@
26805 use super::*;
26806 use crate::punctuated::Punctuated;
26807
26808 ast_struct! {
26809- /// A path at which a named item is exported: `std::collections::HashMap`.
26810+ /// A path at which a named item is exported (e.g. `std::collections::HashMap`).
26811 ///
26812- /// *This type is available if Syn is built with the `"derive"` or `"full"`
26813+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
26814 /// feature.*
26815 pub struct Path {
26816 pub leading_colon: Option<Token![::]>,
26817 pub segments: Punctuated<PathSegment, Token![::]>,
26818 }
26819 }
26820
26821 impl<T> From<T> for Path
26822@@ -24,17 +24,17 @@ where
26823 path.segments.push_value(segment.into());
26824 path
26825 }
26826 }
26827
26828 ast_struct! {
26829 /// A segment of a path together with any path arguments on that segment.
26830 ///
26831- /// *This type is available if Syn is built with the `"derive"` or `"full"`
26832+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
26833 /// feature.*
26834 pub struct PathSegment {
26835 pub ident: Ident,
26836 pub arguments: PathArguments,
26837 }
26838 }
26839
26840 impl<T> From<T> for PathSegment
26841@@ -47,17 +47,17 @@ where
26842 arguments: PathArguments::None,
26843 }
26844 }
26845 }
26846
26847 ast_enum! {
26848 /// Angle bracketed or parenthesized arguments of a path segment.
26849 ///
26850- /// *This type is available if Syn is built with the `"derive"` or `"full"`
26851+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
26852 /// feature.*
26853 ///
26854 /// ## Angle bracketed
26855 ///
26856 /// The `<'a, T>` in `std::slice::iter<'a, T>`.
26857 ///
26858 /// ## Parenthesized
26859 ///
26860@@ -93,17 +93,17 @@ impl PathArguments {
26861 PathArguments::AngleBracketed(_) | PathArguments::Parenthesized(_) => false,
26862 }
26863 }
26864 }
26865
26866 ast_enum! {
26867 /// An individual generic argument, like `'a`, `T`, or `Item = T`.
26868 ///
26869- /// *This type is available if Syn is built with the `"derive"` or `"full"`
26870+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
26871 /// feature.*
26872 pub enum GenericArgument {
26873 /// A lifetime argument.
26874 Lifetime(Lifetime),
26875 /// A type argument.
26876 Type(Type),
26877 /// A binding (equality constraint) on an associated type: the `Item =
26878 /// u8` in `Iterator<Item = u8>`.
26879@@ -117,55 +117,55 @@ ast_enum! {
26880 Const(Expr),
26881 }
26882 }
26883
26884 ast_struct! {
26885 /// Angle bracketed arguments of a path segment: the `<K, V>` in `HashMap<K,
26886 /// V>`.
26887 ///
26888- /// *This type is available if Syn is built with the `"derive"` or `"full"`
26889+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
26890 /// feature.*
26891 pub struct AngleBracketedGenericArguments {
26892 pub colon2_token: Option<Token![::]>,
26893 pub lt_token: Token![<],
26894 pub args: Punctuated<GenericArgument, Token![,]>,
26895 pub gt_token: Token![>],
26896 }
26897 }
26898
26899 ast_struct! {
26900 /// A binding (equality constraint) on an associated type: `Item = u8`.
26901 ///
26902- /// *This type is available if Syn is built with the `"derive"` or `"full"`
26903+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
26904 /// feature.*
26905 pub struct Binding {
26906 pub ident: Ident,
26907 pub eq_token: Token![=],
26908 pub ty: Type,
26909 }
26910 }
26911
26912 ast_struct! {
26913 /// An associated type bound: `Iterator<Item: Display>`.
26914 ///
26915- /// *This type is available if Syn is built with the `"derive"` or `"full"`
26916+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
26917 /// feature.*
26918 pub struct Constraint {
26919 pub ident: Ident,
26920 pub colon_token: Token![:],
26921 pub bounds: Punctuated<TypeParamBound, Token![+]>,
26922 }
26923 }
26924
26925 ast_struct! {
26926 /// Arguments of a function path segment: the `(A, B) -> C` in `Fn(A,B) ->
26927 /// C`.
26928 ///
26929- /// *This type is available if Syn is built with the `"derive"` or `"full"`
26930+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
26931 /// feature.*
26932 pub struct ParenthesizedGenericArguments {
26933 pub paren_token: token::Paren,
26934 /// `(A, B)`
26935 pub inputs: Punctuated<Type, Token![,]>,
26936 /// `C`
26937 pub output: ReturnType,
26938 }
26939@@ -184,17 +184,17 @@ ast_struct! {
26940 /// ^~~~~~ ~~~~~~~~~~~~~~^
26941 /// ty position = 3
26942 ///
26943 /// <Vec<T>>::AssociatedItem
26944 /// ^~~~~~ ^
26945 /// ty position = 0
26946 /// ```
26947 ///
26948- /// *This type is available if Syn is built with the `"derive"` or `"full"`
26949+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
26950 /// feature.*
26951 pub struct QSelf {
26952 pub lt_token: Token![<],
26953 pub ty: Box<Type>,
26954 pub position: usize,
26955 pub as_token: Option<Token![as]>,
26956 pub gt_token: Token![>],
26957 }
26958@@ -286,21 +286,17 @@ pub mod parsing {
26959 impl Parse for PathSegment {
26960 fn parse(input: ParseStream) -> Result<Self> {
26961 Self::parse_helper(input, false)
26962 }
26963 }
26964
26965 impl PathSegment {
26966 fn parse_helper(input: ParseStream, expr_style: bool) -> Result<Self> {
26967- if input.peek(Token![super])
26968- || input.peek(Token![self])
26969- || input.peek(Token![crate])
26970- || input.peek(Token![extern])
26971- {
26972+ if input.peek(Token![super]) || input.peek(Token![self]) || input.peek(Token![crate]) {
26973 let ident = input.call(Ident::parse_any)?;
26974 return Ok(PathSegment::from(ident));
26975 }
26976
26977 let ident = if input.peek(Token![Self]) {
26978 input.call(Ident::parse_any)?
26979 } else {
26980 input.parse()?
26981@@ -353,17 +349,17 @@ pub mod parsing {
26982 },
26983 })
26984 }
26985 }
26986
26987 impl Path {
26988 /// Parse a `Path` containing no path arguments on any of its segments.
26989 ///
26990- /// *This function is available if Syn is built with the `"parsing"`
26991+ /// *This function is available only if Syn is built with the `"parsing"`
26992 /// feature.*
26993 ///
26994 /// # Example
26995 ///
26996 /// ```
26997 /// use syn::{Path, Result, Token};
26998 /// use syn::parse::{Parse, ParseStream};
26999 ///
27000@@ -395,17 +391,16 @@ pub mod parsing {
27001 segments: {
27002 let mut segments = Punctuated::new();
27003 loop {
27004 if !input.peek(Ident)
27005 && !input.peek(Token![super])
27006 && !input.peek(Token![self])
27007 && !input.peek(Token![Self])
27008 && !input.peek(Token![crate])
27009- && !input.peek(Token![extern])
27010 {
27011 break;
27012 }
27013 let ident = Ident::parse_any(input)?;
27014 segments.push_value(PathSegment::from(ident));
27015 if !input.peek(Token![::]) {
27016 break;
27017 }
27018@@ -428,17 +423,17 @@ pub mod parsing {
27019 /// For them to compare equal, it must be the case that:
27020 ///
27021 /// - the path has no leading colon,
27022 /// - the number of path segments is 1,
27023 /// - the first path segment has no angle bracketed or parenthesized
27024 /// path arguments, and
27025 /// - the ident of the first path segment is equal to the given one.
27026 ///
27027- /// *This function is available if Syn is built with the `"parsing"`
27028+ /// *This function is available only if Syn is built with the `"parsing"`
27029 /// feature.*
27030 ///
27031 /// # Example
27032 ///
27033 /// ```
27034 /// use syn::{Attribute, Error, Meta, NestedMeta, Result};
27035 /// # use std::iter::FromIterator;
27036 ///
27037@@ -467,17 +462,17 @@ pub mod parsing {
27038 ///
27039 /// A path is considered an ident if:
27040 ///
27041 /// - the path has no leading colon,
27042 /// - the number of path segments is 1, and
27043 /// - the first path segment has no angle bracketed or parenthesized
27044 /// path arguments.
27045 ///
27046- /// *This function is available if Syn is built with the `"parsing"`
27047+ /// *This function is available only if Syn is built with the `"parsing"`
27048 /// feature.*
27049 pub fn get_ident(&self) -> Option<&Ident> {
27050 if self.leading_colon.is_none()
27051 && self.segments.len() == 1
27052 && self.segments[0].arguments.is_none()
27053 {
27054 Some(&self.segments[0].ident)
27055 } else {
27056diff --git a/third_party/rust/syn/src/punctuated.rs b/third_party/rust/syn/src/punctuated.rs
27057--- a/third_party/rust/syn/src/punctuated.rs
27058+++ b/third_party/rust/syn/src/punctuated.rs
27059@@ -17,16 +17,18 @@
27060 //!
27061 //! ```text
27062 //! a_function_call(arg1, arg2, arg3);
27063 //! ~~~~^ ~~~~^ ~~~~
27064 //! ```
27065
27066 #[cfg(feature = "extra-traits")]
27067 use std::fmt::{self, Debug};
27068+#[cfg(feature = "extra-traits")]
27069+use std::hash::{Hash, Hasher};
27070 #[cfg(any(feature = "full", feature = "derive"))]
27071 use std::iter;
27072 use std::iter::FromIterator;
27073 use std::ops::{Index, IndexMut};
27074 use std::option;
27075 use std::slice;
27076 use std::vec;
27077
27078@@ -36,18 +38,16 @@ use crate::parse::{Parse, ParseStream, R
27079 use crate::token::Token;
27080
27081 /// A punctuated sequence of syntax tree nodes of type `T` separated by
27082 /// punctuation of type `P`.
27083 ///
27084 /// Refer to the [module documentation] for details about punctuated sequences.
27085 ///
27086 /// [module documentation]: self
27087-#[cfg_attr(feature = "extra-traits", derive(Eq, PartialEq, Hash))]
27088-#[cfg_attr(feature = "clone-impls", derive(Clone))]
27089 pub struct Punctuated<T, P> {
27090 inner: Vec<(T, P)>,
27091 last: Option<Box<T>>,
27092 }
27093
27094 impl<T, P> Punctuated<T, P> {
27095 /// Creates an empty punctuated sequence.
27096 pub fn new() -> Punctuated<T, P> {
27097@@ -71,32 +71,29 @@ impl<T, P> Punctuated<T, P> {
27098 self.inner.len() + if self.last.is_some() { 1 } else { 0 }
27099 }
27100
27101 /// Borrows the first element in this sequence.
27102 pub fn first(&self) -> Option<&T> {
27103 self.iter().next()
27104 }
27105
27106+ /// Mutably borrows the first element in this sequence.
27107+ pub fn first_mut(&mut self) -> Option<&mut T> {
27108+ self.iter_mut().next()
27109+ }
27110+
27111 /// Borrows the last element in this sequence.
27112 pub fn last(&self) -> Option<&T> {
27113- if self.last.is_some() {
27114- self.last.as_ref().map(Box::as_ref)
27115- } else {
27116- self.inner.last().map(|pair| &pair.0)
27117- }
27118+ self.iter().next_back()
27119 }
27120
27121 /// Mutably borrows the last element in this sequence.
27122 pub fn last_mut(&mut self) -> Option<&mut T> {
27123- if self.last.is_some() {
27124- self.last.as_mut().map(Box::as_mut)
27125- } else {
27126- self.inner.last_mut().map(|pair| &mut pair.0)
27127- }
27128+ self.iter_mut().next_back()
27129 }
27130
27131 /// Returns an iterator over borrowed syntax tree nodes of type `&T`.
27132 pub fn iter(&self) -> Iter<T> {
27133 Iter {
27134 inner: Box::new(PrivateIter {
27135 inner: self.inner.iter(),
27136 last: self.last.as_ref().map(Box::as_ref).into_iter(),
27137@@ -225,23 +222,29 @@ impl<T, P> Punctuated<T, P> {
27138
27139 if index == self.len() {
27140 self.push(value);
27141 } else {
27142 self.inner.insert(index, (value, Default::default()));
27143 }
27144 }
27145
27146+ /// Clears the sequence of all values and punctuation, making it empty.
27147+ pub fn clear(&mut self) {
27148+ self.inner.clear();
27149+ self.last = None;
27150+ }
27151+
27152 /// Parses zero or more occurrences of `T` separated by punctuation of type
27153 /// `P`, with optional trailing punctuation.
27154 ///
27155 /// Parsing continues until the end of this parse stream. The entire content
27156 /// of this parse stream must consist of `T` and `P`.
27157 ///
27158- /// *This function is available if Syn is built with the `"parsing"`
27159+ /// *This function is available only if Syn is built with the `"parsing"`
27160 /// feature.*
27161 #[cfg(feature = "parsing")]
27162 pub fn parse_terminated(input: ParseStream) -> Result<Self>
27163 where
27164 T: Parse,
27165 P: Parse,
27166 {
27167 Self::parse_terminated_with(input, T::parse)
27168@@ -251,17 +254,17 @@ impl<T, P> Punctuated<T, P> {
27169 /// separated by punctuation of type `P`, with optional trailing
27170 /// punctuation.
27171 ///
27172 /// Like [`parse_terminated`], the entire content of this stream is expected
27173 /// to be parsed.
27174 ///
27175 /// [`parse_terminated`]: Punctuated::parse_terminated
27176 ///
27177- /// *This function is available if Syn is built with the `"parsing"`
27178+ /// *This function is available only if Syn is built with the `"parsing"`
27179 /// feature.*
27180 #[cfg(feature = "parsing")]
27181 pub fn parse_terminated_with(
27182 input: ParseStream,
27183 parser: fn(ParseStream) -> Result<T>,
27184 ) -> Result<Self>
27185 where
27186 P: Parse,
27187@@ -287,17 +290,17 @@ impl<T, P> Punctuated<T, P> {
27188 /// Parses one or more occurrences of `T` separated by punctuation of type
27189 /// `P`, not accepting trailing punctuation.
27190 ///
27191 /// Parsing continues as long as punctuation `P` is present at the head of
27192 /// the stream. This method returns upon parsing a `T` and observing that it
27193 /// is not followed by a `P`, even if there are remaining tokens in the
27194 /// stream.
27195 ///
27196- /// *This function is available if Syn is built with the `"parsing"`
27197+ /// *This function is available only if Syn is built with the `"parsing"`
27198 /// feature.*
27199 #[cfg(feature = "parsing")]
27200 pub fn parse_separated_nonempty(input: ParseStream) -> Result<Self>
27201 where
27202 T: Parse,
27203 P: Token + Parse,
27204 {
27205 Self::parse_separated_nonempty_with(input, T::parse)
27206@@ -307,17 +310,17 @@ impl<T, P> Punctuated<T, P> {
27207 /// separated by punctuation of type `P`, not accepting trailing
27208 /// punctuation.
27209 ///
27210 /// Like [`parse_separated_nonempty`], may complete early without parsing
27211 /// the entire content of this stream.
27212 ///
27213 /// [`parse_separated_nonempty`]: Punctuated::parse_separated_nonempty
27214 ///
27215- /// *This function is available if Syn is built with the `"parsing"`
27216+ /// *This function is available only if Syn is built with the `"parsing"`
27217 /// feature.*
27218 #[cfg(feature = "parsing")]
27219 pub fn parse_separated_nonempty_with(
27220 input: ParseStream,
27221 parser: fn(ParseStream) -> Result<T>,
27222 ) -> Result<Self>
27223 where
27224 P: Token + Parse,
27225@@ -333,16 +336,63 @@ impl<T, P> Punctuated<T, P> {
27226 let punct = input.parse()?;
27227 punctuated.push_punct(punct);
27228 }
27229
27230 Ok(punctuated)
27231 }
27232 }
27233
27234+#[cfg(feature = "clone-impls")]
27235+impl<T, P> Clone for Punctuated<T, P>
27236+where
27237+ T: Clone,
27238+ P: Clone,
27239+{
27240+ fn clone(&self) -> Self {
27241+ Punctuated {
27242+ inner: self.inner.clone(),
27243+ last: self.last.clone(),
27244+ }
27245+ }
27246+}
27247+
27248+#[cfg(feature = "extra-traits")]
27249+impl<T, P> Eq for Punctuated<T, P>
27250+where
27251+ T: Eq,
27252+ P: Eq,
27253+{
27254+}
27255+
27256+#[cfg(feature = "extra-traits")]
27257+impl<T, P> PartialEq for Punctuated<T, P>
27258+where
27259+ T: PartialEq,
27260+ P: PartialEq,
27261+{
27262+ fn eq(&self, other: &Self) -> bool {
27263+ let Punctuated { inner, last } = self;
27264+ *inner == other.inner && *last == other.last
27265+ }
27266+}
27267+
27268+#[cfg(feature = "extra-traits")]
27269+impl<T, P> Hash for Punctuated<T, P>
27270+where
27271+ T: Hash,
27272+ P: Hash,
27273+{
27274+ fn hash<H: Hasher>(&self, state: &mut H) {
27275+ let Punctuated { inner, last } = self;
27276+ inner.hash(state);
27277+ last.hash(state);
27278+ }
27279+}
27280+
27281 #[cfg(feature = "extra-traits")]
27282 impl<T: Debug, P: Debug> Debug for Punctuated<T, P> {
27283 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
27284 let mut list = f.debug_list();
27285 for (t, p) in &self.inner {
27286 list.entry(t);
27287 list.entry(p);
27288 }
27289@@ -531,17 +581,16 @@ impl<'a, T, P> ExactSizeIterator for Pai
27290 }
27291 }
27292
27293 /// An iterator over owned pairs of type `Pair<T, P>`.
27294 ///
27295 /// Refer to the [module documentation] for details about punctuated sequences.
27296 ///
27297 /// [module documentation]: self
27298-#[derive(Clone)]
27299 pub struct IntoPairs<T, P> {
27300 inner: vec::IntoIter<(T, P)>,
27301 last: option::IntoIter<T>,
27302 }
27303
27304 impl<T, P> Iterator for IntoPairs<T, P> {
27305 type Item = Pair<T, P>;
27306
27307@@ -567,22 +616,34 @@ impl<T, P> DoubleEndedIterator for IntoP
27308 }
27309
27310 impl<T, P> ExactSizeIterator for IntoPairs<T, P> {
27311 fn len(&self) -> usize {
27312 self.inner.len() + self.last.len()
27313 }
27314 }
27315
27316+impl<T, P> Clone for IntoPairs<T, P>
27317+where
27318+ T: Clone,
27319+ P: Clone,
27320+{
27321+ fn clone(&self) -> Self {
27322+ IntoPairs {
27323+ inner: self.inner.clone(),
27324+ last: self.last.clone(),
27325+ }
27326+ }
27327+}
27328+
27329 /// An iterator over owned values of type `T`.
27330 ///
27331 /// Refer to the [module documentation] for details about punctuated sequences.
27332 ///
27333 /// [module documentation]: self
27334-#[derive(Clone)]
27335 pub struct IntoIter<T> {
27336 inner: vec::IntoIter<T>,
27337 }
27338
27339 impl<T> Iterator for IntoIter<T> {
27340 type Item = T;
27341
27342 fn next(&mut self) -> Option<Self::Item> {
27343@@ -601,16 +662,27 @@ impl<T> DoubleEndedIterator for IntoIter
27344 }
27345
27346 impl<T> ExactSizeIterator for IntoIter<T> {
27347 fn len(&self) -> usize {
27348 self.inner.len()
27349 }
27350 }
27351
27352+impl<T> Clone for IntoIter<T>
27353+where
27354+ T: Clone,
27355+{
27356+ fn clone(&self) -> Self {
27357+ IntoIter {
27358+ inner: self.inner.clone(),
27359+ }
27360+ }
27361+}
27362+
27363 /// An iterator over borrowed values of type `&T`.
27364 ///
27365 /// Refer to the [module documentation] for details about punctuated sequences.
27366 ///
27367 /// [module documentation]: self
27368 pub struct Iter<'a, T: 'a> {
27369 // The `Item = &'a T` needs to be specified to support rustc 1.31 and older.
27370 // On modern compilers we would be able to write just IterTrait<'a, T> where
27371@@ -794,17 +866,16 @@ impl<'a, T: 'a, I: 'a> IterMutTrait<'a,
27372 }
27373
27374 /// A single syntax tree node of type `T` followed by its trailing punctuation
27375 /// of type `P` if any.
27376 ///
27377 /// Refer to the [module documentation] for details about punctuated sequences.
27378 ///
27379 /// [module documentation]: self
27380-#[cfg_attr(feature = "clone-impls", derive(Clone))]
27381 pub enum Pair<T, P> {
27382 Punctuated(T, P),
27383 End(T),
27384 }
27385
27386 impl<T, P> Pair<T, P> {
27387 /// Extracts the syntax tree node from this punctuated pair, discarding the
27388 /// following punctuation.
27389@@ -851,16 +922,30 @@ impl<T, P> Pair<T, P> {
27390 pub fn into_tuple(self) -> (T, Option<P>) {
27391 match self {
27392 Pair::Punctuated(t, d) => (t, Some(d)),
27393 Pair::End(t) => (t, None),
27394 }
27395 }
27396 }
27397
27398+#[cfg(feature = "clone-impls")]
27399+impl<T, P> Clone for Pair<T, P>
27400+where
27401+ T: Clone,
27402+ P: Clone,
27403+{
27404+ fn clone(&self) -> Self {
27405+ match self {
27406+ Pair::Punctuated(t, p) => Pair::Punctuated(t.clone(), p.clone()),
27407+ Pair::End(t) => Pair::End(t.clone()),
27408+ }
27409+ }
27410+}
27411+
27412 impl<T, P> Index<usize> for Punctuated<T, P> {
27413 type Output = T;
27414
27415 fn index(&self, index: usize) -> &Self::Output {
27416 if index == self.len() - 1 {
27417 match &self.last {
27418 Some(t) => t,
27419 None => &self.inner[index].0,
27420diff --git a/third_party/rust/syn/src/reserved.rs b/third_party/rust/syn/src/reserved.rs
27421new file mode 100644
27422--- /dev/null
27423+++ b/third_party/rust/syn/src/reserved.rs
27424@@ -0,0 +1,42 @@
27425+// Type for a syntax tree node that is reserved for future use.
27426+//
27427+// For example ExprReference contains a field `raw` of type Reserved. If `&raw
27428+// place` syntax becomes a thing as per https://github.com/rust-lang/rfcs/pull/2582,
27429+// we can backward compatibly change `raw`'s type to Option<Token![raw]> without
27430+// the possibility of breaking any code.
27431+
27432+use proc_macro2::Span;
27433+use std::marker::PhantomData;
27434+
27435+#[cfg(feature = "extra-traits")]
27436+use std::fmt::{self, Debug};
27437+
27438+ast_struct! {
27439+ pub struct Reserved {
27440+ _private: PhantomData<Span>,
27441+ }
27442+}
27443+
27444+impl Default for Reserved {
27445+ fn default() -> Self {
27446+ Reserved {
27447+ _private: PhantomData,
27448+ }
27449+ }
27450+}
27451+
27452+#[cfg(feature = "clone-impls")]
27453+impl Clone for Reserved {
27454+ fn clone(&self) -> Self {
27455+ Reserved {
27456+ _private: self._private,
27457+ }
27458+ }
27459+}
27460+
27461+#[cfg(feature = "extra-traits")]
27462+impl Debug for Reserved {
27463+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
27464+ formatter.debug_struct("Reserved").finish()
27465+ }
27466+}
27467diff --git a/third_party/rust/syn/src/spanned.rs b/third_party/rust/syn/src/spanned.rs
27468--- a/third_party/rust/syn/src/spanned.rs
27469+++ b/third_party/rust/syn/src/spanned.rs
27470@@ -1,12 +1,12 @@
27471 //! A trait that can provide the `Span` of the complete contents of a syntax
27472 //! tree node.
27473 //!
27474-//! *This module is available if Syn is built with both the `"parsing"` and
27475+//! *This module is available only if Syn is built with both the `"parsing"` and
27476 //! `"printing"` features.*
27477 //!
27478 //! <br>
27479 //!
27480 //! # Example
27481 //!
27482 //! Suppose in a procedural macro we have a [`Type`] that we want to assert
27483 //! implements the [`Sync`] trait. Maybe this is the type of one of the fields
27484@@ -92,17 +92,17 @@ use quote::spanned::Spanned as ToTokens;
27485 /// [`ToTokens`] from the `quote` crate, as well as for `Span` itself.
27486 ///
27487 /// [`ToTokens`]: quote::ToTokens
27488 ///
27489 /// See the [module documentation] for an example.
27490 ///
27491 /// [module documentation]: self
27492 ///
27493-/// *This trait is available if Syn is built with both the `"parsing"` and
27494+/// *This trait is available only if Syn is built with both the `"parsing"` and
27495 /// `"printing"` features.*
27496 pub trait Spanned {
27497 /// Returns a `Span` covering the complete contents of this syntax tree
27498 /// node, or [`Span::call_site()`] if this node is empty.
27499 ///
27500 /// [`Span::call_site()`]: proc_macro2::Span::call_site
27501 fn span(&self) -> Span;
27502 }
27503diff --git a/third_party/rust/syn/src/stmt.rs b/third_party/rust/syn/src/stmt.rs
27504--- a/third_party/rust/syn/src/stmt.rs
27505+++ b/third_party/rust/syn/src/stmt.rs
27506@@ -1,25 +1,25 @@
27507 use super::*;
27508
27509 ast_struct! {
27510 /// A braced block containing Rust statements.
27511 ///
27512- /// *This type is available if Syn is built with the `"full"` feature.*
27513+ /// *This type is available only if Syn is built with the `"full"` feature.*
27514 pub struct Block {
27515 pub brace_token: token::Brace,
27516 /// Statements in a block
27517 pub stmts: Vec<Stmt>,
27518 }
27519 }
27520
27521 ast_enum! {
27522 /// A statement, usually ending in a semicolon.
27523 ///
27524- /// *This type is available if Syn is built with the `"full"` feature.*
27525+ /// *This type is available only if Syn is built with the `"full"` feature.*
27526 pub enum Stmt {
27527 /// A local (let) binding.
27528 Local(Local),
27529
27530 /// An item definition.
27531 Item(Item),
27532
27533 /// Expr without trailing semicolon.
27534@@ -28,38 +28,39 @@ ast_enum! {
27535 /// Expression with trailing semicolon.
27536 Semi(Expr, Token![;]),
27537 }
27538 }
27539
27540 ast_struct! {
27541 /// A local `let` binding: `let x: u64 = s.parse()?`.
27542 ///
27543- /// *This type is available if Syn is built with the `"full"` feature.*
27544+ /// *This type is available only if Syn is built with the `"full"` feature.*
27545 pub struct Local {
27546 pub attrs: Vec<Attribute>,
27547 pub let_token: Token![let],
27548 pub pat: Pat,
27549 pub init: Option<(Token![=], Box<Expr>)>,
27550 pub semi_token: Token![;],
27551 }
27552 }
27553
27554 #[cfg(feature = "parsing")]
27555 pub mod parsing {
27556 use super::*;
27557
27558+ use crate::parse::discouraged::Speculative;
27559 use crate::parse::{Parse, ParseStream, Result};
27560- use crate::punctuated::Punctuated;
27561+ use proc_macro2::TokenStream;
27562
27563 impl Block {
27564 /// Parse the body of a block as zero or more statements, possibly
27565 /// including one trailing expression.
27566 ///
27567- /// *This function is available if Syn is built with the `"parsing"`
27568+ /// *This function is available only if Syn is built with the `"parsing"`
27569 /// feature.*
27570 ///
27571 /// # Example
27572 ///
27573 /// ```
27574 /// use syn::{braced, token, Attribute, Block, Ident, Result, Stmt, Token};
27575 /// use syn::parse::{Parse, ParseStream};
27576 ///
27577@@ -101,18 +102,18 @@ pub mod parsing {
27578 /// stmts,
27579 /// })
27580 /// }
27581 /// }
27582 /// ```
27583 pub fn parse_within(input: ParseStream) -> Result<Vec<Stmt>> {
27584 let mut stmts = Vec::new();
27585 loop {
27586- while input.peek(Token![;]) {
27587- input.parse::<Token![;]>()?;
27588+ while let Some(semi) = input.parse::<Option<Token![;]>>()? {
27589+ stmts.push(Stmt::Semi(Expr::Verbatim(TokenStream::new()), semi));
27590 }
27591 if input.is_empty() {
27592 break;
27593 }
27594 let s = parse_stmt(input, true)?;
27595 let requires_semicolon = if let Stmt::Expr(s) = &s {
27596 expr::requires_terminator(s)
27597 } else {
27598@@ -141,65 +142,65 @@ pub mod parsing {
27599
27600 impl Parse for Stmt {
27601 fn parse(input: ParseStream) -> Result<Self> {
27602 parse_stmt(input, false)
27603 }
27604 }
27605
27606 fn parse_stmt(input: ParseStream, allow_nosemi: bool) -> Result<Stmt> {
27607- // TODO: optimize using advance_to
27608+ let mut attrs = input.call(Attribute::parse_outer)?;
27609+
27610+ // brace-style macros; paren and bracket macros get parsed as
27611+ // expression statements.
27612 let ahead = input.fork();
27613- ahead.call(Attribute::parse_outer)?;
27614+ if let Ok(path) = ahead.call(Path::parse_mod_style) {
27615+ if ahead.peek(Token![!]) && (ahead.peek2(token::Brace) || ahead.peek2(Ident)) {
27616+ input.advance_to(&ahead);
27617+ return stmt_mac(input, attrs, path);
27618+ }
27619+ }
27620
27621- if {
27622- let ahead = ahead.fork();
27623- // Only parse braces here; paren and bracket will get parsed as
27624- // expression statements
27625- ahead.call(Path::parse_mod_style).is_ok()
27626- && ahead.parse::<Token![!]>().is_ok()
27627- && (ahead.peek(token::Brace) || ahead.peek(Ident))
27628- } {
27629- stmt_mac(input)
27630- } else if ahead.peek(Token![let]) {
27631- stmt_local(input).map(Stmt::Local)
27632- } else if ahead.peek(Token![pub])
27633- || ahead.peek(Token![crate]) && !ahead.peek2(Token![::])
27634- || ahead.peek(Token![extern]) && !ahead.peek2(Token![::])
27635- || ahead.peek(Token![use])
27636- || ahead.peek(Token![static]) && (ahead.peek2(Token![mut]) || ahead.peek2(Ident))
27637- || ahead.peek(Token![const])
27638- || ahead.peek(Token![unsafe]) && !ahead.peek2(token::Brace)
27639- || ahead.peek(Token![async])
27640- && (ahead.peek2(Token![unsafe])
27641- || ahead.peek2(Token![extern])
27642- || ahead.peek2(Token![fn]))
27643- || ahead.peek(Token![fn])
27644- || ahead.peek(Token![mod])
27645- || ahead.peek(Token![type])
27646- || ahead.peek(item::parsing::existential) && ahead.peek2(Token![type])
27647- || ahead.peek(Token![struct])
27648- || ahead.peek(Token![enum])
27649- || ahead.peek(Token![union]) && ahead.peek2(Ident)
27650- || ahead.peek(Token![auto]) && ahead.peek2(Token![trait])
27651- || ahead.peek(Token![trait])
27652- || ahead.peek(Token![default])
27653- && (ahead.peek2(Token![unsafe]) || ahead.peek2(Token![impl]))
27654- || ahead.peek(Token![impl])
27655- || ahead.peek(Token![macro])
27656+ if input.peek(Token![let]) {
27657+ stmt_local(input, attrs).map(Stmt::Local)
27658+ } else if input.peek(Token![pub])
27659+ || input.peek(Token![crate]) && !input.peek2(Token![::])
27660+ || input.peek(Token![extern])
27661+ || input.peek(Token![use])
27662+ || input.peek(Token![static]) && (input.peek2(Token![mut]) || input.peek2(Ident))
27663+ || input.peek(Token![const])
27664+ || input.peek(Token![unsafe]) && !input.peek2(token::Brace)
27665+ || input.peek(Token![async])
27666+ && (input.peek2(Token![unsafe])
27667+ || input.peek2(Token![extern])
27668+ || input.peek2(Token![fn]))
27669+ || input.peek(Token![fn])
27670+ || input.peek(Token![mod])
27671+ || input.peek(Token![type])
27672+ || input.peek(item::parsing::existential) && input.peek2(Token![type])
27673+ || input.peek(Token![struct])
27674+ || input.peek(Token![enum])
27675+ || input.peek(Token![union]) && input.peek2(Ident)
27676+ || input.peek(Token![auto]) && input.peek2(Token![trait])
27677+ || input.peek(Token![trait])
27678+ || input.peek(Token![default])
27679+ && (input.peek2(Token![unsafe]) || input.peek2(Token![impl]))
27680+ || input.peek(Token![impl])
27681+ || input.peek(Token![macro])
27682 {
27683- input.parse().map(Stmt::Item)
27684+ let mut item: Item = input.parse()?;
27685+ attrs.extend(item.replace_attrs(Vec::new()));
27686+ item.replace_attrs(attrs);
27687+ Ok(Stmt::Item(item))
27688 } else {
27689- stmt_expr(input, allow_nosemi)
27690+ stmt_expr(input, allow_nosemi, attrs)
27691 }
27692 }
27693
27694- fn stmt_mac(input: ParseStream) -> Result<Stmt> {
27695- let attrs = input.call(Attribute::parse_outer)?;
27696- let path = input.call(Path::parse_mod_style)?;
27697+ fn stmt_mac(input: ParseStream, attrs: Vec<Attribute>, path: Path) -> Result<Stmt> {
27698 let bang_token: Token![!] = input.parse()?;
27699 let ident: Option<Ident> = input.parse()?;
27700 let (delimiter, tokens) = mac::parse_delimiter(input)?;
27701 let semi_token: Option<Token![;]> = input.parse()?;
27702
27703 Ok(Stmt::Item(Item::Macro(ItemMacro {
27704 attrs,
27705 ident,
27706@@ -208,43 +209,22 @@ pub mod parsing {
27707 bang_token,
27708 delimiter,
27709 tokens,
27710 },
27711 semi_token,
27712 })))
27713 }
27714
27715- fn stmt_local(input: ParseStream) -> Result<Local> {
27716+ fn stmt_local(input: ParseStream, attrs: Vec<Attribute>) -> Result<Local> {
27717 Ok(Local {
27718- attrs: input.call(Attribute::parse_outer)?,
27719+ attrs,
27720 let_token: input.parse()?,
27721 pat: {
27722- let leading_vert: Option<Token![|]> = input.parse()?;
27723- let mut pat: Pat = input.parse()?;
27724- if leading_vert.is_some()
27725- || input.peek(Token![|]) && !input.peek(Token![||]) && !input.peek(Token![|=])
27726- {
27727- let mut cases = Punctuated::new();
27728- cases.push_value(pat);
27729- while input.peek(Token![|])
27730- && !input.peek(Token![||])
27731- && !input.peek(Token![|=])
27732- {
27733- let punct = input.parse()?;
27734- cases.push_punct(punct);
27735- let pat: Pat = input.parse()?;
27736- cases.push_value(pat);
27737- }
27738- pat = Pat::Or(PatOr {
27739- attrs: Vec::new(),
27740- leading_vert,
27741- cases,
27742- });
27743- }
27744+ let mut pat: Pat = pat::parsing::multi_pat_with_leading_vert(input)?;
27745 if input.peek(Token![:]) {
27746 let colon_token: Token![:] = input.parse()?;
27747 let ty: Type = input.parse()?;
27748 pat = Pat::Type(PatType {
27749 attrs: Vec::new(),
27750 pat: Box::new(pat),
27751 colon_token,
27752 ty: Box::new(ty),
27753@@ -260,22 +240,29 @@ pub mod parsing {
27754 } else {
27755 None
27756 }
27757 },
27758 semi_token: input.parse()?,
27759 })
27760 }
27761
27762- fn stmt_expr(input: ParseStream, allow_nosemi: bool) -> Result<Stmt> {
27763- let mut attrs = input.call(Attribute::parse_outer)?;
27764+ fn stmt_expr(
27765+ input: ParseStream,
27766+ allow_nosemi: bool,
27767+ mut attrs: Vec<Attribute>,
27768+ ) -> Result<Stmt> {
27769 let mut e = expr::parsing::expr_early(input)?;
27770
27771- attrs.extend(e.replace_attrs(Vec::new()));
27772- e.replace_attrs(attrs);
27773+ let mut attr_target = &mut e;
27774+ while let Expr::Binary(e) = attr_target {
27775+ attr_target = &mut e.left;
27776+ }
27777+ attrs.extend(attr_target.replace_attrs(Vec::new()));
27778+ attr_target.replace_attrs(attrs);
27779
27780 if input.peek(Token![;]) {
27781 return Ok(Stmt::Semi(e, input.parse()?));
27782 }
27783
27784 if allow_nosemi || !expr::requires_terminator(&e) {
27785 Ok(Stmt::Expr(e))
27786 } else {
27787diff --git a/third_party/rust/syn/src/token.rs b/third_party/rust/syn/src/token.rs
27788--- a/third_party/rust/syn/src/token.rs
27789+++ b/third_party/rust/syn/src/token.rs
27790@@ -83,44 +83,41 @@
27791 //!
27792 //! - Field access to its span — `let sp = the_token.span`
27793 //!
27794 //! [Peeking]: ../parse/struct.ParseBuffer.html#method.peek
27795 //! [Parsing]: ../parse/struct.ParseBuffer.html#method.parse
27796 //! [Printing]: https://docs.rs/quote/1.0/quote/trait.ToTokens.html
27797 //! [`Span`]: https://docs.rs/proc-macro2/1.0/proc_macro2/struct.Span.html
27798
27799-use std;
27800 #[cfg(feature = "extra-traits")]
27801 use std::cmp;
27802 #[cfg(feature = "extra-traits")]
27803 use std::fmt::{self, Debug};
27804 #[cfg(feature = "extra-traits")]
27805 use std::hash::{Hash, Hasher};
27806 use std::ops::{Deref, DerefMut};
27807
27808-#[cfg(feature = "parsing")]
27809-use proc_macro2::Delimiter;
27810 #[cfg(any(feature = "parsing", feature = "printing"))]
27811 use proc_macro2::Ident;
27812 use proc_macro2::Span;
27813 #[cfg(feature = "printing")]
27814 use proc_macro2::TokenStream;
27815+#[cfg(feature = "parsing")]
27816+use proc_macro2::{Delimiter, Literal, Punct, TokenTree};
27817 #[cfg(feature = "printing")]
27818 use quote::{ToTokens, TokenStreamExt};
27819
27820 use self::private::WithSpan;
27821 #[cfg(feature = "parsing")]
27822 use crate::buffer::Cursor;
27823 #[cfg(feature = "parsing")]
27824 use crate::error::Result;
27825-#[cfg(any(feature = "full", feature = "derive"))]
27826 #[cfg(feature = "parsing")]
27827 use crate::lifetime::Lifetime;
27828-#[cfg(any(feature = "full", feature = "derive"))]
27829 #[cfg(feature = "parsing")]
27830 use crate::lit::{Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr};
27831 #[cfg(feature = "parsing")]
27832 use crate::lookahead;
27833 #[cfg(feature = "parsing")]
27834 use crate::parse::{Parse, ParseStream};
27835 use crate::span::IntoSpans;
27836
27837@@ -150,31 +147,30 @@ mod private {
27838 pub struct WithSpan {
27839 pub span: Span,
27840 }
27841 }
27842
27843 #[cfg(feature = "parsing")]
27844 impl private::Sealed for Ident {}
27845
27846-#[cfg(any(feature = "full", feature = "derive"))]
27847 #[cfg(feature = "parsing")]
27848 fn peek_impl(cursor: Cursor, peek: fn(ParseStream) -> bool) -> bool {
27849+ use crate::parse::Unexpected;
27850 use std::cell::Cell;
27851 use std::rc::Rc;
27852
27853 let scope = Span::call_site();
27854- let unexpected = Rc::new(Cell::new(None));
27855+ let unexpected = Rc::new(Cell::new(Unexpected::None));
27856 let buffer = crate::parse::new_parse_buffer(scope, cursor, unexpected);
27857 peek(&buffer)
27858 }
27859
27860-#[cfg(any(feature = "full", feature = "derive"))]
27861 macro_rules! impl_token {
27862- ($name:ident $display:expr) => {
27863+ ($display:tt $name:ty) => {
27864 #[cfg(feature = "parsing")]
27865 impl Token for $name {
27866 fn peek(cursor: Cursor) -> bool {
27867 fn peek(input: ParseStream) -> bool {
27868 <$name as Parse>::parse(input).is_ok()
27869 }
27870 peek_impl(cursor, peek)
27871 }
27872@@ -184,34 +180,48 @@ macro_rules! impl_token {
27873 }
27874 }
27875
27876 #[cfg(feature = "parsing")]
27877 impl private::Sealed for $name {}
27878 };
27879 }
27880
27881-#[cfg(any(feature = "full", feature = "derive"))]
27882-impl_token!(Lifetime "lifetime");
27883-#[cfg(any(feature = "full", feature = "derive"))]
27884-impl_token!(Lit "literal");
27885-#[cfg(any(feature = "full", feature = "derive"))]
27886-impl_token!(LitStr "string literal");
27887-#[cfg(any(feature = "full", feature = "derive"))]
27888-impl_token!(LitByteStr "byte string literal");
27889-#[cfg(any(feature = "full", feature = "derive"))]
27890-impl_token!(LitByte "byte literal");
27891-#[cfg(any(feature = "full", feature = "derive"))]
27892-impl_token!(LitChar "character literal");
27893-#[cfg(any(feature = "full", feature = "derive"))]
27894-impl_token!(LitInt "integer literal");
27895-#[cfg(any(feature = "full", feature = "derive"))]
27896-impl_token!(LitFloat "floating point literal");
27897-#[cfg(any(feature = "full", feature = "derive"))]
27898-impl_token!(LitBool "boolean literal");
27899+impl_token!("lifetime" Lifetime);
27900+impl_token!("literal" Lit);
27901+impl_token!("string literal" LitStr);
27902+impl_token!("byte string literal" LitByteStr);
27903+impl_token!("byte literal" LitByte);
27904+impl_token!("character literal" LitChar);
27905+impl_token!("integer literal" LitInt);
27906+impl_token!("floating point literal" LitFloat);
27907+impl_token!("boolean literal" LitBool);
27908+impl_token!("group token" proc_macro2::Group);
27909+
27910+macro_rules! impl_low_level_token {
27911+ ($display:tt $ty:ident $get:ident) => {
27912+ #[cfg(feature = "parsing")]
27913+ impl Token for $ty {
27914+ fn peek(cursor: Cursor) -> bool {
27915+ cursor.$get().is_some()
27916+ }
27917+
27918+ fn display() -> &'static str {
27919+ $display
27920+ }
27921+ }
27922+
27923+ #[cfg(feature = "parsing")]
27924+ impl private::Sealed for $ty {}
27925+ };
27926+}
27927+
27928+impl_low_level_token!("punctuation token" Punct punct);
27929+impl_low_level_token!("literal" Literal literal);
27930+impl_low_level_token!("token" TokenTree token_tree);
27931
27932 // Not public API.
27933 #[doc(hidden)]
27934 #[cfg(feature = "parsing")]
27935 pub trait CustomToken {
27936 fn peek(cursor: Cursor) -> bool;
27937 fn display() -> &'static str;
27938 }
27939@@ -228,17 +238,16 @@ impl<T: CustomToken> Token for T {
27940 fn display() -> &'static str {
27941 <Self as CustomToken>::display()
27942 }
27943 }
27944
27945 macro_rules! define_keywords {
27946 ($($token:tt pub struct $name:ident #[$doc:meta])*) => {
27947 $(
27948- #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))]
27949 #[$doc]
27950 ///
27951 /// Don't try to remember the name of this type &mdash; use the
27952 /// [`Token!`] macro instead.
27953 ///
27954 /// [`Token!`]: crate::token
27955 pub struct $name {
27956 pub span: Span,
27957@@ -255,16 +264,26 @@ macro_rules! define_keywords {
27958 impl std::default::Default for $name {
27959 fn default() -> Self {
27960 $name {
27961 span: Span::call_site(),
27962 }
27963 }
27964 }
27965
27966+ #[cfg(feature = "clone-impls")]
27967+ impl Copy for $name {}
27968+
27969+ #[cfg(feature = "clone-impls")]
27970+ impl Clone for $name {
27971+ fn clone(&self) -> Self {
27972+ *self
27973+ }
27974+ }
27975+
27976 #[cfg(feature = "extra-traits")]
27977 impl Debug for $name {
27978 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
27979 f.write_str(stringify!($name))
27980 }
27981 }
27982
27983 #[cfg(feature = "extra-traits")]
27984@@ -333,17 +352,16 @@ macro_rules! impl_deref_if_len_is_1 {
27985 };
27986
27987 ($name:ident/$len:tt) => {};
27988 }
27989
27990 macro_rules! define_punctuation_structs {
27991 ($($token:tt pub struct $name:ident/$len:tt #[$doc:meta])*) => {
27992 $(
27993- #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))]
27994 #[repr(C)]
27995 #[$doc]
27996 ///
27997 /// Don't try to remember the name of this type &mdash; use the
27998 /// [`Token!`] macro instead.
27999 ///
28000 /// [`Token!`]: crate::token
28001 pub struct $name {
28002@@ -361,16 +379,26 @@ macro_rules! define_punctuation_structs
28003 impl std::default::Default for $name {
28004 fn default() -> Self {
28005 $name {
28006 spans: [Span::call_site(); $len],
28007 }
28008 }
28009 }
28010
28011+ #[cfg(feature = "clone-impls")]
28012+ impl Copy for $name {}
28013+
28014+ #[cfg(feature = "clone-impls")]
28015+ impl Clone for $name {
28016+ fn clone(&self) -> Self {
28017+ *self
28018+ }
28019+ }
28020+
28021 #[cfg(feature = "extra-traits")]
28022 impl Debug for $name {
28023 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28024 f.write_str(stringify!($name))
28025 }
28026 }
28027
28028 #[cfg(feature = "extra-traits")]
28029@@ -431,17 +459,16 @@ macro_rules! define_punctuation {
28030 impl private::Sealed for $name {}
28031 )*
28032 };
28033 }
28034
28035 macro_rules! define_delimiters {
28036 ($($token:tt pub struct $name:ident #[$doc:meta])*) => {
28037 $(
28038- #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))]
28039 #[$doc]
28040 pub struct $name {
28041 pub span: Span,
28042 }
28043
28044 #[doc(hidden)]
28045 #[allow(non_snake_case)]
28046 pub fn $name<S: IntoSpans<[Span; 1]>>(span: S) -> $name {
28047@@ -453,16 +480,26 @@ macro_rules! define_delimiters {
28048 impl std::default::Default for $name {
28049 fn default() -> Self {
28050 $name {
28051 span: Span::call_site(),
28052 }
28053 }
28054 }
28055
28056+ #[cfg(feature = "clone-impls")]
28057+ impl Copy for $name {}
28058+
28059+ #[cfg(feature = "clone-impls")]
28060+ impl Clone for $name {
28061+ fn clone(&self) -> Self {
28062+ *self
28063+ }
28064+ }
28065+
28066 #[cfg(feature = "extra-traits")]
28067 impl Debug for $name {
28068 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28069 f.write_str(stringify!($name))
28070 }
28071 }
28072
28073 #[cfg(feature = "extra-traits")]
28074@@ -850,17 +887,17 @@ pub mod parsing {
28075 if let Some((ident, _rest)) = cursor.ident() {
28076 ident == token
28077 } else {
28078 false
28079 }
28080 }
28081
28082 pub fn punct<S: FromSpans>(input: ParseStream, token: &str) -> Result<S> {
28083- let mut spans = [input.cursor().span(); 3];
28084+ let mut spans = [input.span(); 3];
28085 punct_helper(input, token, &mut spans)?;
28086 Ok(S::from_spans(&spans))
28087 }
28088
28089 fn punct_helper(input: ParseStream, token: &str, spans: &mut [Span; 3]) -> Result<()> {
28090 input.step(|cursor| {
28091 let mut cursor = *cursor;
28092 assert!(token.len() <= spans.len());
28093diff --git a/third_party/rust/syn/src/tt.rs b/third_party/rust/syn/src/tt.rs
28094--- a/third_party/rust/syn/src/tt.rs
28095+++ b/third_party/rust/syn/src/tt.rs
28096@@ -13,18 +13,18 @@ impl<'a> PartialEq for TokenTreeHelper<'
28097 match (g1.delimiter(), g2.delimiter()) {
28098 (Delimiter::Parenthesis, Delimiter::Parenthesis)
28099 | (Delimiter::Brace, Delimiter::Brace)
28100 | (Delimiter::Bracket, Delimiter::Bracket)
28101 | (Delimiter::None, Delimiter::None) => {}
28102 _ => return false,
28103 }
28104
28105- let s1 = g1.stream().clone().into_iter();
28106- let mut s2 = g2.stream().clone().into_iter();
28107+ let s1 = g1.stream().into_iter();
28108+ let mut s2 = g2.stream().into_iter();
28109
28110 for item1 in s1 {
28111 let item2 = match s2.next() {
28112 Some(item) => item,
28113 None => return false,
28114 };
28115 if TokenTreeHelper(&item1) != TokenTreeHelper(&item2) {
28116 return false;
28117@@ -55,17 +55,17 @@ impl<'a> Hash for TokenTreeHelper<'a> {
28118 0u8.hash(h);
28119 match g.delimiter() {
28120 Delimiter::Parenthesis => 0u8.hash(h),
28121 Delimiter::Brace => 1u8.hash(h),
28122 Delimiter::Bracket => 2u8.hash(h),
28123 Delimiter::None => 3u8.hash(h),
28124 }
28125
28126- for item in g.stream().clone() {
28127+ for item in g.stream() {
28128 TokenTreeHelper(&item).hash(h);
28129 }
28130 0xffu8.hash(h); // terminator w/ a variant we don't normally hash
28131 }
28132 TokenTree::Punct(op) => {
28133 1u8.hash(h);
28134 op.as_char().hash(h);
28135 match op.spacing() {
28136diff --git a/third_party/rust/syn/src/ty.rs b/third_party/rust/syn/src/ty.rs
28137--- a/third_party/rust/syn/src/ty.rs
28138+++ b/third_party/rust/syn/src/ty.rs
28139@@ -1,31 +1,27 @@
28140 use super::*;
28141 use crate::punctuated::Punctuated;
28142-#[cfg(feature = "extra-traits")]
28143-use crate::tt::TokenStreamHelper;
28144 use proc_macro2::TokenStream;
28145-#[cfg(feature = "extra-traits")]
28146-use std::hash::{Hash, Hasher};
28147
28148 ast_enum_of_structs! {
28149 /// The possible types that a Rust value could have.
28150 ///
28151- /// *This type is available if Syn is built with the `"derive"` or `"full"`
28152+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
28153 /// feature.*
28154 ///
28155 /// # Syntax tree enum
28156 ///
28157 /// This type is a [syntax tree enum].
28158 ///
28159 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
28160 //
28161 // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
28162 // blocked on https://github.com/rust-lang/rust/issues/62833
28163- pub enum Type #manual_extra_traits {
28164+ pub enum Type {
28165 /// A fixed size array type: `[T; n]`.
28166 Array(TypeArray),
28167
28168 /// A bare function type: `fn(usize) -> bool`.
28169 BareFn(TypeBareFn),
28170
28171 /// A type contained within invisible delimiters.
28172 Group(TypeGroup),
28173@@ -72,295 +68,194 @@ ast_enum_of_structs! {
28174 #[doc(hidden)]
28175 __Nonexhaustive,
28176 }
28177 }
28178
28179 ast_struct! {
28180 /// A fixed size array type: `[T; n]`.
28181 ///
28182- /// *This type is available if Syn is built with the `"derive"` or
28183+ /// *This type is available only if Syn is built with the `"derive"` or
28184 /// `"full"` feature.*
28185 pub struct TypeArray {
28186 pub bracket_token: token::Bracket,
28187 pub elem: Box<Type>,
28188 pub semi_token: Token![;],
28189 pub len: Expr,
28190 }
28191 }
28192
28193 ast_struct! {
28194 /// A bare function type: `fn(usize) -> bool`.
28195 ///
28196- /// *This type is available if Syn is built with the `"derive"` or
28197+ /// *This type is available only if Syn is built with the `"derive"` or
28198 /// `"full"` feature.*
28199 pub struct TypeBareFn {
28200 pub lifetimes: Option<BoundLifetimes>,
28201 pub unsafety: Option<Token![unsafe]>,
28202 pub abi: Option<Abi>,
28203 pub fn_token: Token![fn],
28204 pub paren_token: token::Paren,
28205 pub inputs: Punctuated<BareFnArg, Token![,]>,
28206 pub variadic: Option<Variadic>,
28207 pub output: ReturnType,
28208 }
28209 }
28210
28211 ast_struct! {
28212 /// A type contained within invisible delimiters.
28213 ///
28214- /// *This type is available if Syn is built with the `"derive"` or
28215+ /// *This type is available only if Syn is built with the `"derive"` or
28216 /// `"full"` feature.*
28217 pub struct TypeGroup {
28218 pub group_token: token::Group,
28219 pub elem: Box<Type>,
28220 }
28221 }
28222
28223 ast_struct! {
28224 /// An `impl Bound1 + Bound2 + Bound3` type where `Bound` is a trait or
28225 /// a lifetime.
28226 ///
28227- /// *This type is available if Syn is built with the `"derive"` or
28228+ /// *This type is available only if Syn is built with the `"derive"` or
28229 /// `"full"` feature.*
28230 pub struct TypeImplTrait {
28231 pub impl_token: Token![impl],
28232 pub bounds: Punctuated<TypeParamBound, Token![+]>,
28233 }
28234 }
28235
28236 ast_struct! {
28237 /// Indication that a type should be inferred by the compiler: `_`.
28238 ///
28239- /// *This type is available if Syn is built with the `"derive"` or
28240+ /// *This type is available only if Syn is built with the `"derive"` or
28241 /// `"full"` feature.*
28242 pub struct TypeInfer {
28243 pub underscore_token: Token![_],
28244 }
28245 }
28246
28247 ast_struct! {
28248 /// A macro in the type position.
28249 ///
28250- /// *This type is available if Syn is built with the `"derive"` or
28251+ /// *This type is available only if Syn is built with the `"derive"` or
28252 /// `"full"` feature.*
28253 pub struct TypeMacro {
28254 pub mac: Macro,
28255 }
28256 }
28257
28258 ast_struct! {
28259 /// The never type: `!`.
28260 ///
28261- /// *This type is available if Syn is built with the `"derive"` or
28262+ /// *This type is available only if Syn is built with the `"derive"` or
28263 /// `"full"` feature.*
28264 pub struct TypeNever {
28265 pub bang_token: Token![!],
28266 }
28267 }
28268
28269 ast_struct! {
28270 /// A parenthesized type equivalent to the inner type.
28271 ///
28272- /// *This type is available if Syn is built with the `"derive"` or
28273+ /// *This type is available only if Syn is built with the `"derive"` or
28274 /// `"full"` feature.*
28275 pub struct TypeParen {
28276 pub paren_token: token::Paren,
28277 pub elem: Box<Type>,
28278 }
28279 }
28280
28281 ast_struct! {
28282 /// A path like `std::slice::Iter`, optionally qualified with a
28283 /// self-type as in `<Vec<T> as SomeTrait>::Associated`.
28284 ///
28285- /// *This type is available if Syn is built with the `"derive"` or
28286+ /// *This type is available only if Syn is built with the `"derive"` or
28287 /// `"full"` feature.*
28288 pub struct TypePath {
28289 pub qself: Option<QSelf>,
28290 pub path: Path,
28291 }
28292 }
28293
28294 ast_struct! {
28295 /// A raw pointer type: `*const T` or `*mut T`.
28296 ///
28297- /// *This type is available if Syn is built with the `"derive"` or
28298+ /// *This type is available only if Syn is built with the `"derive"` or
28299 /// `"full"` feature.*
28300 pub struct TypePtr {
28301 pub star_token: Token![*],
28302 pub const_token: Option<Token![const]>,
28303 pub mutability: Option<Token![mut]>,
28304 pub elem: Box<Type>,
28305 }
28306 }
28307
28308 ast_struct! {
28309 /// A reference type: `&'a T` or `&'a mut T`.
28310 ///
28311- /// *This type is available if Syn is built with the `"derive"` or
28312+ /// *This type is available only if Syn is built with the `"derive"` or
28313 /// `"full"` feature.*
28314 pub struct TypeReference {
28315 pub and_token: Token![&],
28316 pub lifetime: Option<Lifetime>,
28317 pub mutability: Option<Token![mut]>,
28318 pub elem: Box<Type>,
28319 }
28320 }
28321
28322 ast_struct! {
28323 /// A dynamically sized slice type: `[T]`.
28324 ///
28325- /// *This type is available if Syn is built with the `"derive"` or
28326+ /// *This type is available only if Syn is built with the `"derive"` or
28327 /// `"full"` feature.*
28328 pub struct TypeSlice {
28329 pub bracket_token: token::Bracket,
28330 pub elem: Box<Type>,
28331 }
28332 }
28333
28334 ast_struct! {
28335 /// A trait object type `Bound1 + Bound2 + Bound3` where `Bound` is a
28336 /// trait or a lifetime.
28337 ///
28338- /// *This type is available if Syn is built with the `"derive"` or
28339+ /// *This type is available only if Syn is built with the `"derive"` or
28340 /// `"full"` feature.*
28341 pub struct TypeTraitObject {
28342 pub dyn_token: Option<Token![dyn]>,
28343 pub bounds: Punctuated<TypeParamBound, Token![+]>,
28344 }
28345 }
28346
28347 ast_struct! {
28348 /// A tuple type: `(A, B, C, String)`.
28349 ///
28350- /// *This type is available if Syn is built with the `"derive"` or
28351+ /// *This type is available only if Syn is built with the `"derive"` or
28352 /// `"full"` feature.*
28353 pub struct TypeTuple {
28354 pub paren_token: token::Paren,
28355 pub elems: Punctuated<Type, Token![,]>,
28356 }
28357 }
28358
28359-#[cfg(feature = "extra-traits")]
28360-impl Eq for Type {}
28361-
28362-#[cfg(feature = "extra-traits")]
28363-impl PartialEq for Type {
28364- fn eq(&self, other: &Self) -> bool {
28365- match (self, other) {
28366- (Type::Array(this), Type::Array(other)) => this == other,
28367- (Type::BareFn(this), Type::BareFn(other)) => this == other,
28368- (Type::Group(this), Type::Group(other)) => this == other,
28369- (Type::ImplTrait(this), Type::ImplTrait(other)) => this == other,
28370- (Type::Infer(this), Type::Infer(other)) => this == other,
28371- (Type::Macro(this), Type::Macro(other)) => this == other,
28372- (Type::Never(this), Type::Never(other)) => this == other,
28373- (Type::Paren(this), Type::Paren(other)) => this == other,
28374- (Type::Path(this), Type::Path(other)) => this == other,
28375- (Type::Ptr(this), Type::Ptr(other)) => this == other,
28376- (Type::Reference(this), Type::Reference(other)) => this == other,
28377- (Type::Slice(this), Type::Slice(other)) => this == other,
28378- (Type::TraitObject(this), Type::TraitObject(other)) => this == other,
28379- (Type::Tuple(this), Type::Tuple(other)) => this == other,
28380- (Type::Verbatim(this), Type::Verbatim(other)) => {
28381- TokenStreamHelper(this) == TokenStreamHelper(other)
28382- }
28383- _ => false,
28384- }
28385- }
28386-}
28387-
28388-#[cfg(feature = "extra-traits")]
28389-impl Hash for Type {
28390- fn hash<H>(&self, hash: &mut H)
28391- where
28392- H: Hasher,
28393- {
28394- match self {
28395- Type::Array(ty) => {
28396- hash.write_u8(0);
28397- ty.hash(hash);
28398- }
28399- Type::BareFn(ty) => {
28400- hash.write_u8(1);
28401- ty.hash(hash);
28402- }
28403- Type::Group(ty) => {
28404- hash.write_u8(2);
28405- ty.hash(hash);
28406- }
28407- Type::ImplTrait(ty) => {
28408- hash.write_u8(3);
28409- ty.hash(hash);
28410- }
28411- Type::Infer(ty) => {
28412- hash.write_u8(4);
28413- ty.hash(hash);
28414- }
28415- Type::Macro(ty) => {
28416- hash.write_u8(5);
28417- ty.hash(hash);
28418- }
28419- Type::Never(ty) => {
28420- hash.write_u8(6);
28421- ty.hash(hash);
28422- }
28423- Type::Paren(ty) => {
28424- hash.write_u8(7);
28425- ty.hash(hash);
28426- }
28427- Type::Path(ty) => {
28428- hash.write_u8(8);
28429- ty.hash(hash);
28430- }
28431- Type::Ptr(ty) => {
28432- hash.write_u8(9);
28433- ty.hash(hash);
28434- }
28435- Type::Reference(ty) => {
28436- hash.write_u8(10);
28437- ty.hash(hash);
28438- }
28439- Type::Slice(ty) => {
28440- hash.write_u8(11);
28441- ty.hash(hash);
28442- }
28443- Type::TraitObject(ty) => {
28444- hash.write_u8(12);
28445- ty.hash(hash);
28446- }
28447- Type::Tuple(ty) => {
28448- hash.write_u8(13);
28449- ty.hash(hash);
28450- }
28451- Type::Verbatim(ty) => {
28452- hash.write_u8(14);
28453- TokenStreamHelper(ty).hash(hash);
28454- }
28455- Type::__Nonexhaustive => unreachable!(),
28456- }
28457- }
28458-}
28459-
28460 ast_struct! {
28461 /// The binary interface of a function: `extern "C"`.
28462 ///
28463- /// *This type is available if Syn is built with the `"derive"` or `"full"`
28464+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
28465 /// feature.*
28466 pub struct Abi {
28467 pub extern_token: Token![extern],
28468 pub name: Option<LitStr>,
28469 }
28470 }
28471
28472 ast_struct! {
28473 /// An argument in a function type: the `usize` in `fn(usize) -> bool`.
28474 ///
28475- /// *This type is available if Syn is built with the `"derive"` or `"full"`
28476+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
28477 /// feature.*
28478 pub struct BareFnArg {
28479 pub attrs: Vec<Attribute>,
28480 pub name: Option<(Ident, Token![:])>,
28481 pub ty: Type,
28482 }
28483 }
28484
28485@@ -372,28 +267,28 @@ ast_struct! {
28486 /// # struct c_int;
28487 /// #
28488 /// extern "C" {
28489 /// fn printf(format: *const c_char, ...) -> c_int;
28490 /// // ^^^
28491 /// }
28492 /// ```
28493 ///
28494- /// *This type is available if Syn is built with the `"derive"` or `"full"`
28495+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
28496 /// feature.*
28497 pub struct Variadic {
28498 pub attrs: Vec<Attribute>,
28499 pub dots: Token![...],
28500 }
28501 }
28502
28503 ast_enum! {
28504 /// Return type of a function signature.
28505 ///
28506- /// *This type is available if Syn is built with the `"derive"` or `"full"`
28507+ /// *This type is available only if Syn is built with the `"derive"` or `"full"`
28508 /// feature.*
28509 pub enum ReturnType {
28510 /// Return type is not specified.
28511 ///
28512 /// Functions default to `()` and closures default to type inference.
28513 Default,
28514 /// A particular type is returned.
28515 Type(Token![->], Box<Type>),
28516@@ -402,39 +297,44 @@ ast_enum! {
28517
28518 #[cfg(feature = "parsing")]
28519 pub mod parsing {
28520 use super::*;
28521
28522 use crate::ext::IdentExt;
28523 use crate::parse::{Parse, ParseStream, Result};
28524 use crate::path;
28525+ use proc_macro2::{Punct, Spacing, TokenTree};
28526+ use std::iter::FromIterator;
28527
28528 impl Parse for Type {
28529 fn parse(input: ParseStream) -> Result<Self> {
28530- ambig_ty(input, true)
28531+ let allow_plus = true;
28532+ ambig_ty(input, allow_plus)
28533 }
28534 }
28535
28536 impl Type {
28537 /// In some positions, types may not contain the `+` character, to
28538 /// disambiguate them. For example in the expression `1 as T`, T may not
28539 /// contain a `+` character.
28540 ///
28541 /// This parser does not allow a `+`, while the default parser does.
28542 pub fn without_plus(input: ParseStream) -> Result<Self> {
28543- ambig_ty(input, false)
28544+ let allow_plus = false;
28545+ ambig_ty(input, allow_plus)
28546 }
28547 }
28548
28549 fn ambig_ty(input: ParseStream, allow_plus: bool) -> Result<Type> {
28550- if input.peek(token::Group) {
28551+ if input.peek(token::Group) && !input.peek2(Token![::]) && !input.peek2(Token![<]) {
28552 return input.parse().map(Type::Group);
28553 }
28554
28555+ let begin = input.fork();
28556 let mut lifetimes = None::<BoundLifetimes>;
28557 let mut lookahead = input.lookahead1();
28558 if lookahead.peek(Token![for]) {
28559 lifetimes = input.parse()?;
28560 lookahead = input.lookahead1();
28561 if !lookahead.peek(Ident)
28562 && !lookahead.peek(Token![fn])
28563 && !lookahead.peek(Token![unsafe])
28564@@ -519,17 +419,17 @@ pub mod parsing {
28565 }
28566 match bounds.into_iter().next().unwrap() {
28567 TypeParamBound::Trait(trait_bound) => {
28568 TypeParamBound::Trait(TraitBound {
28569 paren_token: Some(paren_token),
28570 ..trait_bound
28571 })
28572 }
28573- other => other,
28574+ other @ TypeParamBound::Lifetime(_) => other,
28575 }
28576 }
28577 _ => break,
28578 };
28579 return Ok(Type::TraitObject(TypeTraitObject {
28580 dyn_token: None,
28581 bounds: {
28582 let mut bounds = Punctuated::new();
28583@@ -544,27 +444,30 @@ pub mod parsing {
28584 }
28585 }
28586 Ok(Type::Paren(TypeParen {
28587 paren_token,
28588 elem: Box::new(first),
28589 }))
28590 } else if lookahead.peek(Token![fn])
28591 || lookahead.peek(Token![unsafe])
28592- || lookahead.peek(Token![extern]) && !input.peek2(Token![::])
28593+ || lookahead.peek(Token![extern])
28594 {
28595- let mut bare_fn: TypeBareFn = input.parse()?;
28596- bare_fn.lifetimes = lifetimes;
28597- Ok(Type::BareFn(bare_fn))
28598+ let allow_mut_self = true;
28599+ if let Some(mut bare_fn) = parse_bare_fn(input, allow_mut_self)? {
28600+ bare_fn.lifetimes = lifetimes;
28601+ Ok(Type::BareFn(bare_fn))
28602+ } else {
28603+ Ok(Type::Verbatim(verbatim::between(begin, input)))
28604+ }
28605 } else if lookahead.peek(Ident)
28606 || input.peek(Token![super])
28607 || input.peek(Token![self])
28608 || input.peek(Token![Self])
28609 || input.peek(Token![crate])
28610- || input.peek(Token![extern])
28611 || lookahead.peek(Token![::])
28612 || lookahead.peek(Token![<])
28613 {
28614 if input.peek(Token![dyn]) {
28615 let mut trait_object: TypeTraitObject = input.parse()?;
28616 if lifetimes.is_some() {
28617 match trait_object.bounds.iter_mut().next().unwrap() {
28618 TypeParamBound::Trait(trait_bound) => {
28619@@ -717,48 +620,68 @@ pub mod parsing {
28620 // & binds tighter than +, so we don't allow + here.
28621 elem: Box::new(input.call(Type::without_plus)?),
28622 })
28623 }
28624 }
28625
28626 impl Parse for TypeBareFn {
28627 fn parse(input: ParseStream) -> Result<Self> {
28628- let args;
28629- let allow_variadic;
28630- Ok(TypeBareFn {
28631- lifetimes: input.parse()?,
28632- unsafety: input.parse()?,
28633- abi: input.parse()?,
28634- fn_token: input.parse()?,
28635- paren_token: parenthesized!(args in input),
28636- inputs: {
28637- let mut inputs = Punctuated::new();
28638- while !args.is_empty() && !args.peek(Token![...]) {
28639- inputs.push_value(args.parse()?);
28640- if args.is_empty() {
28641- break;
28642- }
28643- inputs.push_punct(args.parse()?);
28644+ let allow_mut_self = false;
28645+ parse_bare_fn(input, allow_mut_self).map(Option::unwrap)
28646+ }
28647+ }
28648+
28649+ fn parse_bare_fn(input: ParseStream, allow_mut_self: bool) -> Result<Option<TypeBareFn>> {
28650+ let args;
28651+ let mut variadic = None;
28652+ let mut has_mut_self = false;
28653+
28654+ let bare_fn = TypeBareFn {
28655+ lifetimes: input.parse()?,
28656+ unsafety: input.parse()?,
28657+ abi: input.parse()?,
28658+ fn_token: input.parse()?,
28659+ paren_token: parenthesized!(args in input),
28660+ inputs: {
28661+ let mut inputs = Punctuated::new();
28662+
28663+ while !args.is_empty() {
28664+ let attrs = args.call(Attribute::parse_outer)?;
28665+
28666+ if inputs.empty_or_trailing() && args.peek(Token![...]) {
28667+ variadic = Some(Variadic {
28668+ attrs,
28669+ dots: args.parse()?,
28670+ });
28671+ break;
28672 }
28673- allow_variadic = inputs.empty_or_trailing();
28674- inputs
28675- },
28676- variadic: {
28677- if allow_variadic && args.peek(Token![...]) {
28678- Some(Variadic {
28679- attrs: Vec::new(),
28680- dots: args.parse()?,
28681- })
28682+
28683+ if let Some(arg) = parse_bare_fn_arg(&args, allow_mut_self)? {
28684+ inputs.push_value(BareFnArg { attrs, ..arg });
28685 } else {
28686- None
28687+ has_mut_self = true;
28688+ }
28689+ if args.is_empty() {
28690+ break;
28691 }
28692- },
28693- output: input.call(ReturnType::without_plus)?,
28694- })
28695+
28696+ inputs.push_punct(args.parse()?);
28697+ }
28698+
28699+ inputs
28700+ },
28701+ variadic,
28702+ output: input.call(ReturnType::without_plus)?,
28703+ };
28704+
28705+ if has_mut_self {
28706+ Ok(None)
28707+ } else {
28708+ Ok(Some(bare_fn))
28709 }
28710 }
28711
28712 impl Parse for TypeNever {
28713 fn parse(input: ParseStream) -> Result<Self> {
28714 Ok(TypeNever {
28715 bang_token: input.parse()?,
28716 })
28717@@ -771,19 +694,37 @@ pub mod parsing {
28718 underscore_token: input.parse()?,
28719 })
28720 }
28721 }
28722
28723 impl Parse for TypeTuple {
28724 fn parse(input: ParseStream) -> Result<Self> {
28725 let content;
28726+ let paren_token = parenthesized!(content in input);
28727+
28728+ if content.is_empty() {
28729+ return Ok(TypeTuple {
28730+ paren_token,
28731+ elems: Punctuated::new(),
28732+ });
28733+ }
28734+
28735+ let first: Type = content.parse()?;
28736 Ok(TypeTuple {
28737- paren_token: parenthesized!(content in input),
28738- elems: content.parse_terminated(Type::parse)?,
28739+ paren_token,
28740+ elems: {
28741+ let mut elems = Punctuated::new();
28742+ elems.push_value(first);
28743+ elems.push_punct(content.parse()?);
28744+ let rest: Punctuated<Type, Token![,]> =
28745+ content.parse_terminated(Parse::parse)?;
28746+ elems.extend(rest);
28747+ elems
28748+ },
28749 })
28750 }
28751 }
28752
28753 impl Parse for TypeMacro {
28754 fn parse(input: ParseStream) -> Result<Self> {
28755 Ok(TypeMacro {
28756 mac: input.parse()?,
28757@@ -802,19 +743,21 @@ pub mod parsing {
28758 }
28759
28760 Ok(TypePath { qself, path })
28761 }
28762 }
28763
28764 impl ReturnType {
28765 pub fn without_plus(input: ParseStream) -> Result<Self> {
28766- Self::parse(input, false)
28767+ let allow_plus = false;
28768+ Self::parse(input, allow_plus)
28769 }
28770
28771+ #[doc(hidden)]
28772 pub fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
28773 if input.peek(Token![->]) {
28774 let arrow = input.parse()?;
28775 let ty = ambig_ty(input, allow_plus)?;
28776 Ok(ReturnType::Type(arrow, Box::new(ty)))
28777 } else {
28778 Ok(ReturnType::Default)
28779 }
28780@@ -839,20 +782,22 @@ pub mod parsing {
28781 return true;
28782 }
28783 }
28784 false
28785 }
28786
28787 impl TypeTraitObject {
28788 pub fn without_plus(input: ParseStream) -> Result<Self> {
28789- Self::parse(input, false)
28790+ let allow_plus = false;
28791+ Self::parse(input, allow_plus)
28792 }
28793
28794 // Only allow multiple trait references if allow_plus is true.
28795+ #[doc(hidden)]
28796 pub fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
28797 Ok(TypeTraitObject {
28798 dyn_token: input.parse()?,
28799 bounds: {
28800 let mut bounds = Punctuated::new();
28801 if allow_plus {
28802 loop {
28803 bounds.push_value(input.parse()?);
28804@@ -905,48 +850,99 @@ pub mod parsing {
28805 group_token: group.token,
28806 elem: group.content.parse()?,
28807 })
28808 }
28809 }
28810
28811 impl Parse for TypeParen {
28812 fn parse(input: ParseStream) -> Result<Self> {
28813- Self::parse(input, false)
28814+ let allow_plus = false;
28815+ Self::parse(input, allow_plus)
28816 }
28817 }
28818
28819 impl TypeParen {
28820 fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
28821 let content;
28822 Ok(TypeParen {
28823 paren_token: parenthesized!(content in input),
28824 elem: Box::new(ambig_ty(&content, allow_plus)?),
28825 })
28826 }
28827 }
28828
28829 impl Parse for BareFnArg {
28830 fn parse(input: ParseStream) -> Result<Self> {
28831- Ok(BareFnArg {
28832- attrs: input.call(Attribute::parse_outer)?,
28833- name: {
28834- if (input.peek(Ident) || input.peek(Token![_]))
28835- && input.peek2(Token![:])
28836- && !input.peek2(Token![::])
28837- {
28838- let name = input.call(Ident::parse_any)?;
28839- let colon: Token![:] = input.parse()?;
28840- Some((name, colon))
28841- } else {
28842- None
28843- }
28844- },
28845- ty: input.parse()?,
28846- })
28847+ let allow_mut_self = false;
28848+ parse_bare_fn_arg(input, allow_mut_self).map(Option::unwrap)
28849+ }
28850+ }
28851+
28852+ fn parse_bare_fn_arg(
28853+ input: ParseStream,
28854+ mut allow_mut_self: bool,
28855+ ) -> Result<Option<BareFnArg>> {
28856+ let mut has_mut_self = false;
28857+ let arg = BareFnArg {
28858+ attrs: input.call(Attribute::parse_outer)?,
28859+ name: {
28860+ if (input.peek(Ident) || input.peek(Token![_]) || input.peek(Token![self]))
28861+ && input.peek2(Token![:])
28862+ && !input.peek2(Token![::])
28863+ {
28864+ let name = input.call(Ident::parse_any)?;
28865+ let colon: Token![:] = input.parse()?;
28866+ Some((name, colon))
28867+ } else if allow_mut_self
28868+ && input.peek(Token![mut])
28869+ && input.peek2(Token![self])
28870+ && input.peek3(Token![:])
28871+ && !input.peek3(Token![::])
28872+ {
28873+ has_mut_self = true;
28874+ allow_mut_self = false;
28875+ input.parse::<Token![mut]>()?;
28876+ input.parse::<Token![self]>()?;
28877+ input.parse::<Token![:]>()?;
28878+ None
28879+ } else {
28880+ None
28881+ }
28882+ },
28883+ ty: if !has_mut_self && input.peek(Token![...]) {
28884+ let dot3 = input.parse::<Token![...]>()?;
28885+ let args = vec![
28886+ TokenTree::Punct(Punct::new('.', Spacing::Joint)),
28887+ TokenTree::Punct(Punct::new('.', Spacing::Joint)),
28888+ TokenTree::Punct(Punct::new('.', Spacing::Alone)),
28889+ ];
28890+ let tokens = TokenStream::from_iter(args.into_iter().zip(&dot3.spans).map(
28891+ |(mut arg, span)| {
28892+ arg.set_span(*span);
28893+ arg
28894+ },
28895+ ));
28896+ Type::Verbatim(tokens)
28897+ } else if allow_mut_self && input.peek(Token![mut]) && input.peek2(Token![self]) {
28898+ has_mut_self = true;
28899+ input.parse::<Token![mut]>()?;
28900+ Type::Path(TypePath {
28901+ qself: None,
28902+ path: input.parse::<Token![self]>()?.into(),
28903+ })
28904+ } else {
28905+ input.parse()?
28906+ },
28907+ };
28908+
28909+ if has_mut_self {
28910+ Ok(None)
28911+ } else {
28912+ Ok(Some(arg))
28913 }
28914 }
28915
28916 impl Parse for Abi {
28917 fn parse(input: ParseStream) -> Result<Self> {
28918 Ok(Abi {
28919 extern_token: input.parse()?,
28920 name: input.parse()?,
28921diff --git a/third_party/rust/syn/src/verbatim.rs b/third_party/rust/syn/src/verbatim.rs
28922new file mode 100644
28923--- /dev/null
28924+++ b/third_party/rust/syn/src/verbatim.rs
28925@@ -0,0 +1,15 @@
28926+use crate::parse::{ParseBuffer, ParseStream};
28927+use proc_macro2::TokenStream;
28928+use std::iter;
28929+
28930+pub fn between<'a>(begin: ParseBuffer<'a>, end: ParseStream<'a>) -> TokenStream {
28931+ let end = end.cursor();
28932+ let mut cursor = begin.cursor();
28933+ let mut tokens = TokenStream::new();
28934+ while cursor != end {
28935+ let (tt, next) = cursor.token_tree().unwrap();
28936+ tokens.extend(iter::once(tt));
28937+ cursor = next;
28938+ }
28939+ tokens
28940+}
28941diff --git a/third_party/rust/syn/src/whitespace.rs b/third_party/rust/syn/src/whitespace.rs
28942new file mode 100644
28943--- /dev/null
28944+++ b/third_party/rust/syn/src/whitespace.rs
28945@@ -0,0 +1,65 @@
28946+pub fn skip(mut s: &str) -> &str {
28947+ 'skip: while !s.is_empty() {
28948+ let byte = s.as_bytes()[0];
28949+ if byte == b'/' {
28950+ if s.starts_with("//")
28951+ && (!s.starts_with("///") || s.starts_with("////"))
28952+ && !s.starts_with("//!")
28953+ {
28954+ if let Some(i) = s.find('\n') {
28955+ s = &s[i + 1..];
28956+ continue;
28957+ } else {
28958+ return "";
28959+ }
28960+ } else if s.starts_with("/**/") {
28961+ s = &s[4..];
28962+ continue;
28963+ } else if s.starts_with("/*")
28964+ && (!s.starts_with("/**") || s.starts_with("/***"))
28965+ && !s.starts_with("/*!")
28966+ {
28967+ let mut depth = 0;
28968+ let bytes = s.as_bytes();
28969+ let mut i = 0;
28970+ let upper = bytes.len() - 1;
28971+ while i < upper {
28972+ if bytes[i] == b'/' && bytes[i + 1] == b'*' {
28973+ depth += 1;
28974+ i += 1; // eat '*'
28975+ } else if bytes[i] == b'*' && bytes[i + 1] == b'/' {
28976+ depth -= 1;
28977+ if depth == 0 {
28978+ s = &s[i + 2..];
28979+ continue 'skip;
28980+ }
28981+ i += 1; // eat '/'
28982+ }
28983+ i += 1;
28984+ }
28985+ return s;
28986+ }
28987+ }
28988+ match byte {
28989+ b' ' | 0x09..=0x0d => {
28990+ s = &s[1..];
28991+ continue;
28992+ }
28993+ b if b <= 0x7f => {}
28994+ _ => {
28995+ let ch = s.chars().next().unwrap();
28996+ if is_whitespace(ch) {
28997+ s = &s[ch.len_utf8()..];
28998+ continue;
28999+ }
29000+ }
29001+ }
29002+ return s;
29003+ }
29004+ s
29005+}
29006+
29007+fn is_whitespace(ch: char) -> bool {
29008+ // Rust treats left-to-right mark and right-to-left mark as whitespace
29009+ ch.is_whitespace() || ch == '\u{200e}' || ch == '\u{200f}'
29010+}
29011diff --git a/third_party/rust/syn/tests/.gitignore b/third_party/rust/syn/tests/.gitignore
29012new file mode 100644
29013--- /dev/null
29014+++ b/third_party/rust/syn/tests/.gitignore
29015@@ -0,0 +1,1 @@
29016+/*.pending-snap
29017diff --git a/third_party/rust/syn/tests/clone.sh b/third_party/rust/syn/tests/clone.sh
29018deleted file mode 100755
29019--- a/third_party/rust/syn/tests/clone.sh
29020+++ /dev/null
29021@@ -1,16 +0,0 @@
29022-#!/bin/bash
29023-
29024-REV=4560cb830fce63fcffdc4558f4281aaac6a3a1ba
29025-
29026-set -euo pipefail
29027-cd "$(dirname "${BASH_SOURCE[0]}")"
29028-mkdir -p rust
29029-touch rust/COMMIT
29030-
29031-if [ "$(cat rust/COMMIT)" != "$REV" ]; then
29032- rm -rf rust
29033- mkdir rust
29034- curl -L "https://github.com/rust-lang/rust/archive/${REV}.tar.gz" \
29035- | tar xz --directory rust --strip-components 1
29036- echo "$REV" > rust/COMMIT
29037-fi
29038diff --git a/third_party/rust/syn/tests/common/eq.rs b/third_party/rust/syn/tests/common/eq.rs
29039--- a/third_party/rust/syn/tests/common/eq.rs
29040+++ b/third_party/rust/syn/tests/common/eq.rs
29041@@ -1,41 +1,40 @@
29042+extern crate rustc_ast;
29043 extern crate rustc_data_structures;
29044+extern crate rustc_span;
29045 extern crate rustc_target;
29046-extern crate syntax;
29047-extern crate syntax_pos;
29048
29049 use std::mem;
29050
29051-use self::rustc_data_structures::sync::Lrc;
29052-use self::rustc_data_structures::thin_vec::ThinVec;
29053-use self::rustc_target::abi::FloatTy;
29054-use self::rustc_target::spec::abi::Abi;
29055-use self::syntax::ast::{
29056- AngleBracketedArgs, AnonConst, Arg, Arm, AsmDialect, AssocTyConstraint, AssocTyConstraintKind,
29057- AttrId, AttrStyle, Attribute, BareFnTy, BinOpKind, BindingMode, Block, BlockCheckMode,
29058- CaptureBy, Constness, Crate, CrateSugar, Defaultness, EnumDef, Expr, ExprKind, Field, FieldPat,
29059- FnDecl, FnHeader, ForeignItem, ForeignItemKind, ForeignMod, FunctionRetTy, GenericArg,
29060- GenericArgs, GenericBound, GenericParam, GenericParamKind, Generics, GlobalAsm, Ident,
29061- ImplItem, ImplItemKind, ImplPolarity, InlineAsm, InlineAsmOutput, IntTy, IsAsync, IsAuto, Item,
29062- ItemKind, Label, Lifetime, Lit, LitIntType, LitKind, Local, Mac, MacDelimiter, MacStmtStyle,
29063- MacroDef, MethodSig, Mod, Movability, MutTy, Mutability, NodeId, ParenthesizedArgs, Pat,
29064- PatKind, Path, PathSegment, PolyTraitRef, QSelf, RangeEnd, RangeLimits, RangeSyntax, Stmt,
29065- StmtKind, StrStyle, StructField, TraitBoundModifier, TraitItem, TraitItemKind,
29066- TraitObjectSyntax, TraitRef, Ty, TyKind, UintTy, UnOp, UnsafeSource, Unsafety, UseTree,
29067- UseTreeKind, Variant, VariantData, VisibilityKind, WhereBoundPredicate, WhereClause,
29068- WhereEqPredicate, WherePredicate, WhereRegionPredicate,
29069+use rustc_ast::ast::{
29070+ AngleBracketedArg, AngleBracketedArgs, AnonConst, Arm, AssocItemKind, AssocTyConstraint,
29071+ AssocTyConstraintKind, Async, AttrId, AttrItem, AttrKind, AttrStyle, Attribute, BareFnTy,
29072+ BinOpKind, BindingMode, Block, BlockCheckMode, BorrowKind, CaptureBy, Const, Crate, CrateSugar,
29073+ Defaultness, EnumDef, Expr, ExprKind, Extern, Field, FieldPat, FloatTy, FnDecl, FnHeader,
29074+ FnRetTy, FnSig, ForeignItemKind, ForeignMod, GenericArg, GenericArgs, GenericBound,
29075+ GenericParam, GenericParamKind, Generics, GlobalAsm, ImplPolarity, InlineAsm, InlineAsmOperand,
29076+ InlineAsmOptions, InlineAsmRegOrRegClass, InlineAsmTemplatePiece, IntTy, IsAuto, Item,
29077+ ItemKind, Label, Lifetime, Lit, LitFloatType, LitIntType, LitKind, LlvmAsmDialect,
29078+ LlvmInlineAsm, LlvmInlineAsmOutput, Local, MacArgs, MacCall, MacCallStmt, MacDelimiter,
29079+ MacStmtStyle, MacroDef, Mod, Movability, MutTy, Mutability, NodeId, Param, ParenthesizedArgs,
29080+ Pat, PatKind, Path, PathSegment, PolyTraitRef, QSelf, RangeEnd, RangeLimits, RangeSyntax, Stmt,
29081+ StmtKind, StrLit, StrStyle, StructField, TraitBoundModifier, TraitObjectSyntax, TraitRef, Ty,
29082+ TyKind, UintTy, UnOp, Unsafe, UnsafeSource, UseTree, UseTreeKind, Variant, VariantData,
29083+ VisibilityKind, WhereBoundPredicate, WhereClause, WhereEqPredicate, WherePredicate,
29084+ WhereRegionPredicate,
29085 };
29086-use self::syntax::parse::lexer::comments;
29087-use self::syntax::parse::token::{self, DelimToken, Token, TokenKind};
29088-use self::syntax::ptr::P;
29089-use self::syntax::source_map::Spanned;
29090-use self::syntax::symbol::{sym, Symbol};
29091-use self::syntax::tokenstream::{DelimSpan, TokenStream, TokenTree};
29092-use self::syntax_pos::{Span, SyntaxContext, DUMMY_SP};
29093+use rustc_ast::ptr::P;
29094+use rustc_ast::token::{self, CommentKind, DelimToken, Token, TokenKind};
29095+use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
29096+use rustc_data_structures::sync::Lrc;
29097+use rustc_data_structures::thin_vec::ThinVec;
29098+use rustc_span::source_map::Spanned;
29099+use rustc_span::symbol::Ident;
29100+use rustc_span::{Span, Symbol, SyntaxContext};
29101
29102 pub trait SpanlessEq {
29103 fn eq(&self, other: &Self) -> bool;
29104 }
29105
29106 impl<T: SpanlessEq> SpanlessEq for P<T> {
29107 fn eq(&self, other: &Self) -> bool {
29108 SpanlessEq::eq(&**self, &**other)
29109@@ -81,24 +80,16 @@ impl<T: SpanlessEq> SpanlessEq for Spann
29110 }
29111
29112 impl<A: SpanlessEq, B: SpanlessEq> SpanlessEq for (A, B) {
29113 fn eq(&self, other: &Self) -> bool {
29114 SpanlessEq::eq(&self.0, &other.0) && SpanlessEq::eq(&self.1, &other.1)
29115 }
29116 }
29117
29118-impl<A: SpanlessEq, B: SpanlessEq, C: SpanlessEq> SpanlessEq for (A, B, C) {
29119- fn eq(&self, other: &Self) -> bool {
29120- SpanlessEq::eq(&self.0, &other.0)
29121- && SpanlessEq::eq(&self.1, &other.1)
29122- && SpanlessEq::eq(&self.2, &other.2)
29123- }
29124-}
29125-
29126 macro_rules! spanless_eq_true {
29127 ($name:ident) => {
29128 impl SpanlessEq for $name {
29129 fn eq(&self, _other: &Self) -> bool {
29130 true
29131 }
29132 }
29133 };
29134@@ -121,60 +112,62 @@ macro_rules! spanless_eq_partial_eq {
29135 }
29136
29137 spanless_eq_partial_eq!(bool);
29138 spanless_eq_partial_eq!(u8);
29139 spanless_eq_partial_eq!(u16);
29140 spanless_eq_partial_eq!(u128);
29141 spanless_eq_partial_eq!(usize);
29142 spanless_eq_partial_eq!(char);
29143+spanless_eq_partial_eq!(String);
29144 spanless_eq_partial_eq!(Symbol);
29145-spanless_eq_partial_eq!(Abi);
29146+spanless_eq_partial_eq!(CommentKind);
29147 spanless_eq_partial_eq!(DelimToken);
29148+spanless_eq_partial_eq!(InlineAsmOptions);
29149
29150 macro_rules! spanless_eq_struct {
29151 {
29152- $name:ident;
29153+ $name:ident $(<$param:ident>)?;
29154 $([$field:ident $other:ident])*
29155 $(![$ignore:ident])*
29156 } => {
29157- impl SpanlessEq for $name {
29158+ impl $(<$param: SpanlessEq>)* SpanlessEq for $name $(<$param>)* {
29159 fn eq(&self, other: &Self) -> bool {
29160 let $name { $($field,)* $($ignore: _,)* } = self;
29161 let $name { $($field: $other,)* $($ignore: _,)* } = other;
29162 $(SpanlessEq::eq($field, $other))&&*
29163 }
29164 }
29165 };
29166
29167 {
29168- $name:ident;
29169+ $name:ident $(<$param:ident>)?;
29170 $([$field:ident $other:ident])*
29171 $next:ident
29172 $($rest:ident)*
29173 $(!$ignore:ident)*
29174 } => {
29175 spanless_eq_struct! {
29176- $name;
29177+ $name $(<$param>)*;
29178 $([$field $other])*
29179 [$next other]
29180 $($rest)*
29181 $(!$ignore)*
29182 }
29183 };
29184
29185 {
29186- $name:ident;
29187+ $name:ident $(<$param:ident>)?;
29188 $([$field:ident $other:ident])*
29189 $(![$ignore:ident])*
29190 !$next:ident
29191 $(!$rest:ident)*
29192 } => {
29193 spanless_eq_struct! {
29194- $name;
29195+ $name $(<$param>)*;
29196 $([$field $other])*
29197 $(![$ignore])*
29198 ![$next]
29199 $(!$rest)*
29200 }
29201 };
29202 }
29203
29204@@ -258,129 +251,141 @@ macro_rules! spanless_eq_enum {
29205 $name;
29206 $([$variant $($fields)*])*
29207 [$next]
29208 $($rest)*
29209 }
29210 };
29211 }
29212
29213-spanless_eq_struct!(AngleBracketedArgs; span args constraints);
29214+spanless_eq_struct!(AngleBracketedArgs; span args);
29215 spanless_eq_struct!(AnonConst; id value);
29216-spanless_eq_struct!(Arg; attrs ty pat id span);
29217-spanless_eq_struct!(Arm; attrs pats guard body span id);
29218+spanless_eq_struct!(Arm; attrs pat guard body span id is_placeholder);
29219 spanless_eq_struct!(AssocTyConstraint; id ident kind span);
29220-spanless_eq_struct!(Attribute; id style path tokens span !is_sugared_doc);
29221-spanless_eq_struct!(BareFnTy; unsafety abi generic_params decl);
29222+spanless_eq_struct!(AttrItem; path args);
29223+spanless_eq_struct!(Attribute; kind id style span);
29224+spanless_eq_struct!(BareFnTy; unsafety ext generic_params decl);
29225 spanless_eq_struct!(Block; stmts id rules span);
29226-spanless_eq_struct!(Crate; module attrs span);
29227+spanless_eq_struct!(Crate; module attrs span proc_macros);
29228 spanless_eq_struct!(EnumDef; variants);
29229-spanless_eq_struct!(Expr; id node span attrs);
29230-spanless_eq_struct!(Field; ident expr span is_shorthand attrs id);
29231-spanless_eq_struct!(FieldPat; ident pat is_shorthand attrs id span);
29232-spanless_eq_struct!(FnDecl; inputs output c_variadic);
29233-spanless_eq_struct!(FnHeader; constness asyncness unsafety abi);
29234-spanless_eq_struct!(ForeignItem; ident attrs node id span vis);
29235+spanless_eq_struct!(Expr; id kind span attrs !tokens);
29236+spanless_eq_struct!(Field; attrs id span ident expr is_shorthand is_placeholder);
29237+spanless_eq_struct!(FieldPat; ident pat is_shorthand attrs id span is_placeholder);
29238+spanless_eq_struct!(FnDecl; inputs output);
29239+spanless_eq_struct!(FnHeader; constness asyncness unsafety ext);
29240+spanless_eq_struct!(FnSig; header decl span);
29241 spanless_eq_struct!(ForeignMod; abi items);
29242-spanless_eq_struct!(GenericParam; id ident attrs bounds kind);
29243+spanless_eq_struct!(GenericParam; id ident attrs bounds is_placeholder kind);
29244 spanless_eq_struct!(Generics; params where_clause span);
29245 spanless_eq_struct!(GlobalAsm; asm);
29246-spanless_eq_struct!(ImplItem; id ident vis defaultness attrs generics node span !tokens);
29247-spanless_eq_struct!(InlineAsm; asm asm_str_style outputs inputs clobbers volatile alignstack dialect);
29248-spanless_eq_struct!(InlineAsmOutput; constraint expr is_rw is_indirect);
29249-spanless_eq_struct!(Item; ident attrs id node vis span !tokens);
29250+spanless_eq_struct!(InlineAsm; template operands options line_spans);
29251+spanless_eq_struct!(Item<K>; attrs id span vis ident kind !tokens);
29252 spanless_eq_struct!(Label; ident);
29253 spanless_eq_struct!(Lifetime; id ident);
29254-spanless_eq_struct!(Lit; token node span);
29255+spanless_eq_struct!(Lit; token kind span);
29256+spanless_eq_struct!(LlvmInlineAsm; asm asm_str_style outputs inputs clobbers volatile alignstack dialect);
29257+spanless_eq_struct!(LlvmInlineAsmOutput; constraint expr is_rw is_indirect);
29258 spanless_eq_struct!(Local; pat ty init id span attrs);
29259-spanless_eq_struct!(Mac; path delim tts span prior_type_ascription);
29260-spanless_eq_struct!(MacroDef; tokens legacy);
29261-spanless_eq_struct!(MethodSig; header decl);
29262+spanless_eq_struct!(MacCall; path args prior_type_ascription);
29263+spanless_eq_struct!(MacCallStmt; mac style attrs);
29264+spanless_eq_struct!(MacroDef; body macro_rules);
29265 spanless_eq_struct!(Mod; inner items inline);
29266 spanless_eq_struct!(MutTy; ty mutbl);
29267+spanless_eq_struct!(Param; attrs ty pat id span is_placeholder);
29268 spanless_eq_struct!(ParenthesizedArgs; span inputs output);
29269-spanless_eq_struct!(Pat; id node span);
29270+spanless_eq_struct!(Pat; id kind span tokens);
29271 spanless_eq_struct!(Path; span segments);
29272 spanless_eq_struct!(PathSegment; ident id args);
29273 spanless_eq_struct!(PolyTraitRef; bound_generic_params trait_ref span);
29274 spanless_eq_struct!(QSelf; ty path_span position);
29275-spanless_eq_struct!(Stmt; id node span);
29276-spanless_eq_struct!(StructField; span ident vis id ty attrs);
29277+spanless_eq_struct!(Stmt; id kind span);
29278+spanless_eq_struct!(StrLit; style symbol suffix span symbol_unescaped);
29279+spanless_eq_struct!(StructField; attrs id span vis ident ty is_placeholder);
29280 spanless_eq_struct!(Token; kind span);
29281-spanless_eq_struct!(TraitItem; id ident attrs generics node span !tokens);
29282 spanless_eq_struct!(TraitRef; path ref_id);
29283-spanless_eq_struct!(Ty; id node span);
29284+spanless_eq_struct!(Ty; id kind span);
29285 spanless_eq_struct!(UseTree; prefix kind span);
29286-spanless_eq_struct!(Variant; ident attrs id data disr_expr span);
29287+spanless_eq_struct!(Variant; attrs id span vis ident data disr_expr is_placeholder);
29288 spanless_eq_struct!(WhereBoundPredicate; span bound_generic_params bounded_ty bounds);
29289-spanless_eq_struct!(WhereClause; predicates span);
29290+spanless_eq_struct!(WhereClause; has_where_token predicates span);
29291 spanless_eq_struct!(WhereEqPredicate; id span lhs_ty rhs_ty);
29292 spanless_eq_struct!(WhereRegionPredicate; span lifetime bounds);
29293-spanless_eq_enum!(AsmDialect; Att Intel);
29294+spanless_eq_enum!(AngleBracketedArg; Arg(0) Constraint(0));
29295+spanless_eq_enum!(AssocItemKind; Const(0 1 2) Fn(0 1 2 3) TyAlias(0 1 2 3) MacCall(0));
29296 spanless_eq_enum!(AssocTyConstraintKind; Equality(ty) Bound(bounds));
29297+spanless_eq_enum!(Async; Yes(span closure_id return_impl_trait_id) No);
29298+spanless_eq_enum!(AttrKind; Normal(0) DocComment(0 1));
29299 spanless_eq_enum!(AttrStyle; Outer Inner);
29300 spanless_eq_enum!(BinOpKind; Add Sub Mul Div Rem And Or BitXor BitAnd BitOr Shl Shr Eq Lt Le Ne Ge Gt);
29301 spanless_eq_enum!(BindingMode; ByRef(0) ByValue(0));
29302 spanless_eq_enum!(BlockCheckMode; Default Unsafe(0));
29303+spanless_eq_enum!(BorrowKind; Ref Raw);
29304 spanless_eq_enum!(CaptureBy; Value Ref);
29305-spanless_eq_enum!(Constness; Const NotConst);
29306+spanless_eq_enum!(Const; Yes(0) No);
29307 spanless_eq_enum!(CrateSugar; PubCrate JustCrate);
29308-spanless_eq_enum!(Defaultness; Default Final);
29309+spanless_eq_enum!(Defaultness; Default(0) Final);
29310+spanless_eq_enum!(Extern; None Implicit Explicit(0));
29311 spanless_eq_enum!(FloatTy; F32 F64);
29312-spanless_eq_enum!(ForeignItemKind; Fn(0 1) Static(0 1) Ty Macro(0));
29313-spanless_eq_enum!(FunctionRetTy; Default(0) Ty(0));
29314+spanless_eq_enum!(FnRetTy; Default(0) Ty(0));
29315+spanless_eq_enum!(ForeignItemKind; Static(0 1 2) Fn(0 1 2 3) TyAlias(0 1 2 3) MacCall(0));
29316 spanless_eq_enum!(GenericArg; Lifetime(0) Type(0) Const(0));
29317 spanless_eq_enum!(GenericArgs; AngleBracketed(0) Parenthesized(0));
29318 spanless_eq_enum!(GenericBound; Trait(0 1) Outlives(0));
29319-spanless_eq_enum!(GenericParamKind; Lifetime Type(default) Const(ty));
29320-spanless_eq_enum!(ImplItemKind; Const(0 1) Method(0 1) TyAlias(0) OpaqueTy(0) Macro(0));
29321-spanless_eq_enum!(ImplPolarity; Positive Negative);
29322+spanless_eq_enum!(GenericParamKind; Lifetime Type(default) Const(ty kw_span));
29323+spanless_eq_enum!(ImplPolarity; Positive Negative(0));
29324+spanless_eq_enum!(InlineAsmRegOrRegClass; Reg(0) RegClass(0));
29325+spanless_eq_enum!(InlineAsmTemplatePiece; String(0) Placeholder(operand_idx modifier span));
29326 spanless_eq_enum!(IntTy; Isize I8 I16 I32 I64 I128);
29327-spanless_eq_enum!(IsAsync; Async(closure_id return_impl_trait_id) NotAsync);
29328 spanless_eq_enum!(IsAuto; Yes No);
29329+spanless_eq_enum!(LitFloatType; Suffixed(0) Unsuffixed);
29330 spanless_eq_enum!(LitIntType; Signed(0) Unsigned(0) Unsuffixed);
29331+spanless_eq_enum!(LlvmAsmDialect; Att Intel);
29332+spanless_eq_enum!(MacArgs; Empty Delimited(0 1 2) Eq(0 1));
29333 spanless_eq_enum!(MacDelimiter; Parenthesis Bracket Brace);
29334 spanless_eq_enum!(MacStmtStyle; Semicolon Braces NoBraces);
29335 spanless_eq_enum!(Movability; Static Movable);
29336-spanless_eq_enum!(Mutability; Mutable Immutable);
29337+spanless_eq_enum!(Mutability; Mut Not);
29338 spanless_eq_enum!(RangeEnd; Included(0) Excluded);
29339 spanless_eq_enum!(RangeLimits; HalfOpen Closed);
29340-spanless_eq_enum!(StmtKind; Local(0) Item(0) Expr(0) Semi(0) Mac(0));
29341+spanless_eq_enum!(StmtKind; Local(0) Item(0) Expr(0) Semi(0) Empty MacCall(0));
29342 spanless_eq_enum!(StrStyle; Cooked Raw(0));
29343 spanless_eq_enum!(TokenTree; Token(0) Delimited(0 1 2));
29344-spanless_eq_enum!(TraitBoundModifier; None Maybe);
29345-spanless_eq_enum!(TraitItemKind; Const(0 1) Method(0 1) Type(0 1) Macro(0));
29346+spanless_eq_enum!(TraitBoundModifier; None Maybe MaybeConst MaybeConstMaybe);
29347 spanless_eq_enum!(TraitObjectSyntax; Dyn None);
29348 spanless_eq_enum!(UintTy; Usize U8 U16 U32 U64 U128);
29349 spanless_eq_enum!(UnOp; Deref Not Neg);
29350+spanless_eq_enum!(Unsafe; Yes(0) No);
29351 spanless_eq_enum!(UnsafeSource; CompilerGenerated UserProvided);
29352-spanless_eq_enum!(Unsafety; Unsafe Normal);
29353 spanless_eq_enum!(UseTreeKind; Simple(0 1 2) Nested(0) Glob);
29354 spanless_eq_enum!(VariantData; Struct(0 1) Tuple(0 1) Unit(0));
29355 spanless_eq_enum!(VisibilityKind; Public Crate(0) Restricted(path id) Inherited);
29356 spanless_eq_enum!(WherePredicate; BoundPredicate(0) RegionPredicate(0) EqPredicate(0));
29357-spanless_eq_enum!(ExprKind; Box(0) Array(0) Call(0 1) MethodCall(0 1) Tup(0)
29358+spanless_eq_enum!(ExprKind; Box(0) Array(0) Call(0 1) MethodCall(0 1 2) Tup(0)
29359 Binary(0 1 2) Unary(0 1) Lit(0) Cast(0 1) Type(0 1) Let(0 1) If(0 1 2)
29360 While(0 1 2) ForLoop(0 1 2 3) Loop(0 1) Match(0 1) Closure(0 1 2 3 4 5)
29361- Block(0 1) Async(0 1 2) Await(0) TryBlock(0) Assign(0 1) AssignOp(0 1 2)
29362- Field(0 1) Index(0 1) Range(0 1 2) Path(0 1) AddrOf(0 1) Break(0 1)
29363- Continue(0) Ret(0) InlineAsm(0) Mac(0) Struct(0 1 2) Repeat(0 1) Paren(0)
29364- Try(0) Yield(0) Err);
29365-spanless_eq_enum!(ItemKind; ExternCrate(0) Use(0) Static(0 1 2) Const(0 1)
29366- Fn(0 1 2 3) Mod(0) ForeignMod(0) GlobalAsm(0) TyAlias(0 1) OpaqueTy(0 1)
29367- Enum(0 1) Struct(0 1) Union(0 1) Trait(0 1 2 3 4) TraitAlias(0 1)
29368- Impl(0 1 2 3 4 5 6) Mac(0) MacroDef(0));
29369+ Block(0 1) Async(0 1 2) Await(0) TryBlock(0) Assign(0 1 2) AssignOp(0 1 2)
29370+ Field(0 1) Index(0 1) Range(0 1 2) Path(0 1) AddrOf(0 1 2) Break(0 1)
29371+ Continue(0) Ret(0) InlineAsm(0) LlvmInlineAsm(0) MacCall(0) Struct(0 1 2)
29372+ Repeat(0 1) Paren(0) Try(0) Yield(0) Err);
29373+spanless_eq_enum!(InlineAsmOperand; In(reg expr) Out(reg late expr)
29374+ InOut(reg late expr) SplitInOut(reg late in_expr out_expr) Const(expr)
29375+ Sym(expr));
29376+spanless_eq_enum!(ItemKind; ExternCrate(0) Use(0) Static(0 1 2) Const(0 1 2)
29377+ Fn(0 1 2 3) Mod(0) ForeignMod(0) GlobalAsm(0) TyAlias(0 1 2 3) Enum(0 1)
29378+ Struct(0 1) Union(0 1) Trait(0 1 2 3 4) TraitAlias(0 1)
29379+ Impl(unsafety polarity defaultness constness generics of_trait self_ty items)
29380+ MacCall(0) MacroDef(0));
29381 spanless_eq_enum!(LitKind; Str(0 1) ByteStr(0) Byte(0) Char(0) Int(0 1)
29382- Float(0 1) FloatUnsuffixed(0) Bool(0) Err(0));
29383+ Float(0 1) Bool(0) Err(0));
29384 spanless_eq_enum!(PatKind; Wild Ident(0 1 2) Struct(0 1 2) TupleStruct(0 1)
29385 Or(0) Path(0 1) Tuple(0) Box(0) Ref(0 1) Lit(0) Range(0 1 2) Slice(0) Rest
29386- Paren(0) Mac(0));
29387+ Paren(0) MacCall(0));
29388 spanless_eq_enum!(TyKind; Slice(0) Array(0 1) Ptr(0) Rptr(0 1) BareFn(0) Never
29389 Tup(0) Path(0 1) TraitObject(0 1) ImplTrait(0 1) Paren(0) Typeof(0) Infer
29390- ImplicitSelf Mac(0) Err CVarArgs);
29391+ ImplicitSelf MacCall(0) Err CVarArgs);
29392
29393 impl SpanlessEq for Ident {
29394 fn eq(&self, other: &Self) -> bool {
29395 self.as_str() == other.as_str()
29396 }
29397 }
29398
29399 // Give up on comparing literals inside of macros because there are so many
29400@@ -409,49 +414,25 @@ impl SpanlessEq for TokenKind {
29401 },
29402 _ => self == other,
29403 }
29404 }
29405 }
29406
29407 impl SpanlessEq for TokenStream {
29408 fn eq(&self, other: &Self) -> bool {
29409- SpanlessEq::eq(&expand_tts(self), &expand_tts(other))
29410+ let mut this = self.clone().into_trees();
29411+ let mut other = other.clone().into_trees();
29412+ loop {
29413+ let this = match this.next() {
29414+ None => return other.next().is_none(),
29415+ Some(val) => val,
29416+ };
29417+ let other = match other.next() {
29418+ None => return false,
29419+ Some(val) => val,
29420+ };
29421+ if !SpanlessEq::eq(&this, &other) {
29422+ return false;
29423+ }
29424+ }
29425 }
29426 }
29427-
29428-fn expand_tts(tts: &TokenStream) -> Vec<TokenTree> {
29429- let mut tokens = Vec::new();
29430- for tt in tts.clone().into_trees() {
29431- let c = match tt {
29432- TokenTree::Token(Token {
29433- kind: TokenKind::DocComment(c),
29434- ..
29435- }) => c,
29436- _ => {
29437- tokens.push(tt);
29438- continue;
29439- }
29440- };
29441- let contents = comments::strip_doc_comment_decoration(&c.as_str());
29442- let style = comments::doc_comment_style(&c.as_str());
29443- tokens.push(TokenTree::token(TokenKind::Pound, DUMMY_SP));
29444- if style == AttrStyle::Inner {
29445- tokens.push(TokenTree::token(TokenKind::Not, DUMMY_SP));
29446- }
29447- let lit = token::Lit {
29448- kind: token::LitKind::Str,
29449- symbol: Symbol::intern(&contents),
29450- suffix: None,
29451- };
29452- let tts = vec![
29453- TokenTree::token(TokenKind::Ident(sym::doc, false), DUMMY_SP),
29454- TokenTree::token(TokenKind::Eq, DUMMY_SP),
29455- TokenTree::token(TokenKind::Literal(lit), DUMMY_SP),
29456- ];
29457- tokens.push(TokenTree::Delimited(
29458- DelimSpan::dummy(),
29459- DelimToken::Bracket,
29460- tts.into_iter().collect::<TokenStream>().into(),
29461- ));
29462- }
29463- tokens
29464-}
29465diff --git a/third_party/rust/syn/tests/common/mod.rs b/third_party/rust/syn/tests/common/mod.rs
29466--- a/third_party/rust/syn/tests/common/mod.rs
29467+++ b/third_party/rust/syn/tests/common/mod.rs
29468@@ -1,14 +1,27 @@
29469 #![allow(dead_code)]
29470
29471+use rayon::ThreadPoolBuilder;
29472 use std::env;
29473
29474 pub mod eq;
29475 pub mod parse;
29476
29477 /// Read the `ABORT_AFTER_FAILURE` environment variable, and parse it.
29478 pub fn abort_after() -> usize {
29479 match env::var("ABORT_AFTER_FAILURE") {
29480 Ok(s) => s.parse().expect("failed to parse ABORT_AFTER_FAILURE"),
29481 Err(_) => usize::max_value(),
29482 }
29483 }
29484+
29485+/// Configure Rayon threadpool.
29486+pub fn rayon_init() {
29487+ let stack_size = match env::var("RUST_MIN_STACK") {
29488+ Ok(s) => s.parse().expect("failed to parse RUST_MIN_STACK"),
29489+ Err(_) => 20 * 1024 * 1024,
29490+ };
29491+ ThreadPoolBuilder::new()
29492+ .stack_size(stack_size)
29493+ .build_global()
29494+ .unwrap();
29495+}
29496diff --git a/third_party/rust/syn/tests/common/parse.rs b/third_party/rust/syn/tests/common/parse.rs
29497--- a/third_party/rust/syn/tests/common/parse.rs
29498+++ b/third_party/rust/syn/tests/common/parse.rs
29499@@ -1,25 +1,25 @@
29500-extern crate proc_macro2;
29501-extern crate syn;
29502-extern crate syntax;
29503-extern crate syntax_pos;
29504+extern crate rustc_ast;
29505+extern crate rustc_expand;
29506+extern crate rustc_parse as parse;
29507+extern crate rustc_session;
29508+extern crate rustc_span;
29509
29510-use self::syntax::ast;
29511-use self::syntax::parse::{self, ParseSess};
29512-use self::syntax::ptr::P;
29513-use self::syntax::source_map::FilePathMapping;
29514-use self::syntax_pos::FileName;
29515+use rustc_ast::ast;
29516+use rustc_ast::ptr::P;
29517+use rustc_session::parse::ParseSess;
29518+use rustc_span::source_map::FilePathMapping;
29519+use rustc_span::FileName;
29520
29521 use std::panic;
29522
29523-pub fn libsyntax_expr(input: &str) -> Option<P<ast::Expr>> {
29524+pub fn librustc_expr(input: &str) -> Option<P<ast::Expr>> {
29525 match panic::catch_unwind(|| {
29526 let sess = ParseSess::new(FilePathMapping::empty());
29527- sess.span_diagnostic.set_continue_after_error(false);
29528 let e = parse::new_parser_from_source_str(
29529 &sess,
29530 FileName::Custom("test_precedence".to_string()),
29531 input.to_string(),
29532 )
29533 .parse_expr();
29534 match e {
29535 Ok(expr) => Some(expr),
29536@@ -27,17 +27,17 @@ pub fn libsyntax_expr(input: &str) -> Op
29537 diagnostic.emit();
29538 None
29539 }
29540 }
29541 }) {
29542 Ok(Some(e)) => Some(e),
29543 Ok(None) => None,
29544 Err(_) => {
29545- errorf!("libsyntax panicked\n");
29546+ errorf!("librustc panicked\n");
29547 None
29548 }
29549 }
29550 }
29551
29552 pub fn syn_expr(input: &str) -> Option<syn::Expr> {
29553 match syn::parse_str(input) {
29554 Ok(e) => Some(e),
29555diff --git a/third_party/rust/syn/tests/debug/gen.rs b/third_party/rust/syn/tests/debug/gen.rs
29556--- a/third_party/rust/syn/tests/debug/gen.rs
29557+++ b/third_party/rust/syn/tests/debug/gen.rs
29558@@ -1,13 +1,13 @@
29559 // This file is @generated by syn-internal-codegen.
29560 // It is not intended for manual editing.
29561
29562 use super::{Lite, RefCast};
29563-use std::fmt::{self, Debug};
29564+use std::fmt::{self, Debug, Display};
29565 impl Debug for Lite<syn::Abi> {
29566 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29567 let _val = &self.value;
29568 let mut formatter = formatter.debug_struct("Abi");
29569 if let Some(val) = &_val.name {
29570 #[derive(RefCast)]
29571 #[repr(transparent)]
29572 struct Print(syn::LitStr);
29573@@ -1034,19 +1034,19 @@ impl Debug for Lite<syn::Expr> {
29574 if !_val.attrs.is_empty() {
29575 formatter.field("attrs", Lite(&_val.attrs));
29576 }
29577 formatter.field("block", Lite(&_val.block));
29578 formatter.finish()
29579 }
29580 syn::Expr::Verbatim(_val) => {
29581 formatter.write_str("Verbatim")?;
29582- formatter.write_str("(")?;
29583- Debug::fmt(Lite(_val), formatter)?;
29584- formatter.write_str(")")?;
29585+ formatter.write_str("(`")?;
29586+ Display::fmt(_val, formatter)?;
29587+ formatter.write_str("`)")?;
29588 Ok(())
29589 }
29590 syn::Expr::While(_val) => {
29591 let mut formatter = formatter.debug_struct("Expr::While");
29592 if !_val.attrs.is_empty() {
29593 formatter.field("attrs", Lite(&_val.attrs));
29594 }
29595 if let Some(val) = &_val.label {
29596@@ -2111,19 +2111,19 @@ impl Debug for Lite<syn::ForeignItem> {
29597 }
29598 }
29599 formatter.field("semi_token", Print::ref_cast(val));
29600 }
29601 formatter.finish()
29602 }
29603 syn::ForeignItem::Verbatim(_val) => {
29604 formatter.write_str("Verbatim")?;
29605- formatter.write_str("(")?;
29606- Debug::fmt(Lite(_val), formatter)?;
29607- formatter.write_str(")")?;
29608+ formatter.write_str("(`")?;
29609+ Display::fmt(_val, formatter)?;
29610+ formatter.write_str("`)")?;
29611 Ok(())
29612 }
29613 _ => unreachable!(),
29614 }
29615 }
29616 }
29617 impl Debug for Lite<syn::ForeignItemFn> {
29618 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29619@@ -2427,19 +2427,19 @@ impl Debug for Lite<syn::ImplItem> {
29620 }
29621 }
29622 formatter.field("semi_token", Print::ref_cast(val));
29623 }
29624 formatter.finish()
29625 }
29626 syn::ImplItem::Verbatim(_val) => {
29627 formatter.write_str("Verbatim")?;
29628- formatter.write_str("(")?;
29629- Debug::fmt(Lite(_val), formatter)?;
29630- formatter.write_str(")")?;
29631+ formatter.write_str("(`")?;
29632+ Display::fmt(_val, formatter)?;
29633+ formatter.write_str("`)")?;
29634 Ok(())
29635 }
29636 _ => unreachable!(),
29637 }
29638 }
29639 }
29640 impl Debug for Lite<syn::ImplItemConst> {
29641 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29642@@ -2935,19 +2935,19 @@ impl Debug for Lite<syn::Item> {
29643 }
29644 formatter.field("leading_colon", Print::ref_cast(val));
29645 }
29646 formatter.field("tree", Lite(&_val.tree));
29647 formatter.finish()
29648 }
29649 syn::Item::Verbatim(_val) => {
29650 formatter.write_str("Verbatim")?;
29651- formatter.write_str("(")?;
29652- Debug::fmt(Lite(_val), formatter)?;
29653- formatter.write_str(")")?;
29654+ formatter.write_str("(`")?;
29655+ Display::fmt(_val, formatter)?;
29656+ formatter.write_str("`)")?;
29657 Ok(())
29658 }
29659 _ => unreachable!(),
29660 }
29661 }
29662 }
29663 impl Debug for Lite<syn::ItemConst> {
29664 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29665@@ -3432,19 +3432,19 @@ impl Debug for Lite<syn::Lit> {
29666 syn::Lit::Float(_val) => write!(formatter, "{}", _val),
29667 syn::Lit::Bool(_val) => {
29668 let mut formatter = formatter.debug_struct("Lit::Bool");
29669 formatter.field("value", Lite(&_val.value));
29670 formatter.finish()
29671 }
29672 syn::Lit::Verbatim(_val) => {
29673 formatter.write_str("Verbatim")?;
29674- formatter.write_str("(")?;
29675- Debug::fmt(Lite(_val), formatter)?;
29676- formatter.write_str(")")?;
29677+ formatter.write_str("(`")?;
29678+ Display::fmt(_val, formatter)?;
29679+ formatter.write_str("`)")?;
29680 Ok(())
29681 }
29682 }
29683 }
29684 }
29685 impl Debug for Lite<syn::LitBool> {
29686 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29687 let _val = &self.value;
29688@@ -3873,19 +3873,19 @@ impl Debug for Lite<syn::Pat> {
29689 formatter.field("attrs", Lite(&_val.attrs));
29690 }
29691 formatter.field("pat", Lite(&_val.pat));
29692 formatter.field("ty", Lite(&_val.ty));
29693 formatter.finish()
29694 }
29695 syn::Pat::Verbatim(_val) => {
29696 formatter.write_str("Verbatim")?;
29697- formatter.write_str("(")?;
29698- Debug::fmt(Lite(_val), formatter)?;
29699- formatter.write_str(")")?;
29700+ formatter.write_str("(`")?;
29701+ Display::fmt(_val, formatter)?;
29702+ formatter.write_str("`)")?;
29703 Ok(())
29704 }
29705 syn::Pat::Wild(_val) => {
29706 let mut formatter = formatter.debug_struct("Pat::Wild");
29707 if !_val.attrs.is_empty() {
29708 formatter.field("attrs", Lite(&_val.attrs));
29709 }
29710 formatter.finish()
29711@@ -4669,19 +4669,19 @@ impl Debug for Lite<syn::TraitItem> {
29712 }
29713 }
29714 formatter.field("semi_token", Print::ref_cast(val));
29715 }
29716 formatter.finish()
29717 }
29718 syn::TraitItem::Verbatim(_val) => {
29719 formatter.write_str("Verbatim")?;
29720- formatter.write_str("(")?;
29721- Debug::fmt(Lite(_val), formatter)?;
29722- formatter.write_str(")")?;
29723+ formatter.write_str("(`")?;
29724+ Display::fmt(_val, formatter)?;
29725+ formatter.write_str("`)")?;
29726 Ok(())
29727 }
29728 _ => unreachable!(),
29729 }
29730 }
29731 }
29732 impl Debug for Lite<syn::TraitItemConst> {
29733 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29734@@ -5035,19 +5035,19 @@ impl Debug for Lite<syn::Type> {
29735 let mut formatter = formatter.debug_struct("Type::Tuple");
29736 if !_val.elems.is_empty() {
29737 formatter.field("elems", Lite(&_val.elems));
29738 }
29739 formatter.finish()
29740 }
29741 syn::Type::Verbatim(_val) => {
29742 formatter.write_str("Verbatim")?;
29743- formatter.write_str("(")?;
29744- Debug::fmt(Lite(_val), formatter)?;
29745- formatter.write_str(")")?;
29746+ formatter.write_str("(`")?;
29747+ Display::fmt(_val, formatter)?;
29748+ formatter.write_str("`)")?;
29749 Ok(())
29750 }
29751 _ => unreachable!(),
29752 }
29753 }
29754 }
29755 impl Debug for Lite<syn::TypeArray> {
29756 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29757diff --git a/third_party/rust/syn/tests/debug/mod.rs b/third_party/rust/syn/tests/debug/mod.rs
29758--- a/third_party/rust/syn/tests/debug/mod.rs
29759+++ b/third_party/rust/syn/tests/debug/mod.rs
29760@@ -1,15 +1,12 @@
29761-extern crate proc_macro2;
29762-extern crate ref_cast;
29763-
29764 mod gen;
29765
29766-use self::proc_macro2::{Ident, Literal, TokenStream};
29767-use self::ref_cast::RefCast;
29768+use proc_macro2::{Ident, Literal, TokenStream};
29769+use ref_cast::RefCast;
29770 use std::fmt::{self, Debug};
29771 use std::ops::Deref;
29772 use syn::punctuated::Punctuated;
29773
29774 #[derive(RefCast)]
29775 #[repr(transparent)]
29776 pub struct Lite<T: ?Sized> {
29777 value: T,
29778@@ -61,17 +58,25 @@ impl Debug for Lite<Ident> {
29779 impl Debug for Lite<Literal> {
29780 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29781 write!(formatter, "{}", self.value)
29782 }
29783 }
29784
29785 impl Debug for Lite<TokenStream> {
29786 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29787- write!(formatter, "`{}`", self.value)
29788+ let string = self.value.to_string();
29789+ if string.len() <= 80 {
29790+ write!(formatter, "TokenStream(`{}`)", self.value)
29791+ } else {
29792+ formatter
29793+ .debug_tuple("TokenStream")
29794+ .field(&format_args!("`{}`", string))
29795+ .finish()
29796+ }
29797 }
29798 }
29799
29800 impl<'a, T> Debug for Lite<&'a T>
29801 where
29802 Lite<T>: Debug,
29803 {
29804 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29805diff --git a/third_party/rust/syn/tests/features/error.rs b/third_party/rust/syn/tests/features/error.rs
29806deleted file mode 100644
29807--- a/third_party/rust/syn/tests/features/error.rs
29808+++ /dev/null
29809@@ -1,1 +0,0 @@
29810-"Hello! You want: cargo test --release --all-features"
29811diff --git a/third_party/rust/syn/tests/features/mod.rs b/third_party/rust/syn/tests/features/mod.rs
29812deleted file mode 100644
29813--- a/third_party/rust/syn/tests/features/mod.rs
29814+++ /dev/null
29815@@ -1,22 +0,0 @@
29816-#[allow(unused_macros)]
29817-macro_rules! hide_from_rustfmt {
29818- ($mod:item) => {
29819- $mod
29820- };
29821-}
29822-
29823-#[cfg(not(all(
29824- feature = "derive",
29825- feature = "full",
29826- feature = "parsing",
29827- feature = "printing",
29828- feature = "visit",
29829- feature = "visit-mut",
29830- feature = "fold",
29831- feature = "clone-impls",
29832- feature = "extra-traits",
29833- feature = "proc-macro",
29834-)))]
29835-hide_from_rustfmt! {
29836- mod error;
29837-}
29838diff --git a/third_party/rust/syn/tests/macros/mod.rs b/third_party/rust/syn/tests/macros/mod.rs
29839--- a/third_party/rust/syn/tests/macros/mod.rs
29840+++ b/third_party/rust/syn/tests/macros/mod.rs
29841@@ -1,10 +1,8 @@
29842-extern crate proc_macro2;
29843-
29844 #[path = "../debug/mod.rs"]
29845 pub mod debug;
29846
29847 use syn;
29848 use syn::parse::{Parse, Result};
29849
29850 #[macro_export]
29851 macro_rules! errorf {
29852@@ -37,28 +35,28 @@ macro_rules! snapshot {
29853 };
29854 }
29855
29856 #[macro_export]
29857 macro_rules! snapshot_impl {
29858 (($expr:ident) as $t:ty, @$snapshot:literal) => {
29859 let $expr = crate::macros::Tokens::parse::<$t>($expr).unwrap();
29860 let debug = crate::macros::debug::Lite(&$expr);
29861- insta::assert_debug_snapshot_matches!(debug, @$snapshot);
29862+ insta::assert_debug_snapshot!(debug, @$snapshot);
29863 };
29864 (($($expr:tt)*) as $t:ty, @$snapshot:literal) => {{
29865 let syntax_tree = crate::macros::Tokens::parse::<$t>($($expr)*).unwrap();
29866 let debug = crate::macros::debug::Lite(&syntax_tree);
29867- insta::assert_debug_snapshot_matches!(debug, @$snapshot);
29868+ insta::assert_debug_snapshot!(debug, @$snapshot);
29869 syntax_tree
29870 }};
29871 (($($expr:tt)*) , @$snapshot:literal) => {{
29872 let syntax_tree = $($expr)*;
29873 let debug = crate::macros::debug::Lite(&syntax_tree);
29874- insta::assert_debug_snapshot_matches!(debug, @$snapshot);
29875+ insta::assert_debug_snapshot!(debug, @$snapshot);
29876 syntax_tree
29877 }};
29878 (($($expr:tt)*) $next:tt $($rest:tt)*) => {
29879 snapshot_impl!(($($expr)* $next) $($rest)*)
29880 };
29881 }
29882
29883 pub trait Tokens {
29884diff --git a/third_party/rust/syn/tests/repo/mod.rs b/third_party/rust/syn/tests/repo/mod.rs
29885--- a/third_party/rust/syn/tests/repo/mod.rs
29886+++ b/third_party/rust/syn/tests/repo/mod.rs
29887@@ -1,60 +1,135 @@
29888-extern crate walkdir;
29889+mod progress;
29890+
29891+use self::progress::Progress;
29892+use anyhow::Result;
29893+use flate2::read::GzDecoder;
29894+use std::fs;
29895+use std::path::Path;
29896+use tar::Archive;
29897+use walkdir::DirEntry;
29898+
29899+const REVISION: &str = "792c645ca7d11a8d254df307d019c5bf01445c37";
29900+
29901+#[rustfmt::skip]
29902+static EXCLUDE: &[&str] = &[
29903+ // Compile-fail expr parameter in const generic position: f::<1 + 2>()
29904+ "test/ui/const-generics/const-expression-parameter.rs",
29905
29906-use std::process::Command;
29907+ // Deprecated anonymous parameter syntax in traits
29908+ "test/ui/issues/issue-13105.rs",
29909+ "test/ui/issues/issue-13775.rs",
29910+ "test/ui/issues/issue-34074.rs",
29911+ "test/ui/proc-macro/trait-fn-args-2015.rs",
29912
29913-use self::walkdir::DirEntry;
29914+ // Not actually test cases
29915+ "test/rustdoc-ui/test-compile-fail2.rs",
29916+ "test/rustdoc-ui/test-compile-fail3.rs",
29917+ "test/ui/include-single-expr-helper.rs",
29918+ "test/ui/include-single-expr-helper-1.rs",
29919+ "test/ui/issues/auxiliary/issue-21146-inc.rs",
29920+ "test/ui/json-bom-plus-crlf-multifile-aux.rs",
29921+ "test/ui/lint/expansion-time-include.rs",
29922+ "test/ui/macros/auxiliary/macro-comma-support.rs",
29923+ "test/ui/macros/auxiliary/macro-include-items-expr.rs",
29924+];
29925
29926 pub fn base_dir_filter(entry: &DirEntry) -> bool {
29927 let path = entry.path();
29928 if path.is_dir() {
29929 return true; // otherwise walkdir does not visit the files
29930 }
29931 if path.extension().map(|e| e != "rs").unwrap_or(true) {
29932 return false;
29933 }
29934- let path_string = path.to_string_lossy();
29935- let path_string = if cfg!(windows) {
29936- path_string.replace('\\', "/").into()
29937+
29938+ let mut path_string = path.to_string_lossy();
29939+ if cfg!(windows) {
29940+ path_string = path_string.replace('\\', "/").into();
29941+ }
29942+ let path = if let Some(path) = path_string.strip_prefix("tests/rust/src/") {
29943+ path
29944+ } else if let Some(path) = path_string.strip_prefix("tests/rust/library/") {
29945+ path
29946 } else {
29947- path_string
29948+ panic!("unexpected path in Rust dist: {}", path_string);
29949 };
29950+
29951 // TODO assert that parsing fails on the parse-fail cases
29952- if path_string.starts_with("tests/rust/src/test/parse-fail")
29953- || path_string.starts_with("tests/rust/src/test/compile-fail")
29954- || path_string.starts_with("tests/rust/src/test/rustfix")
29955+ if path.starts_with("test/parse-fail")
29956+ || path.starts_with("test/compile-fail")
29957+ || path.starts_with("test/rustfix")
29958 {
29959 return false;
29960 }
29961
29962- if path_string.starts_with("tests/rust/src/test/ui") {
29963- let stderr_path = path.with_extension("stderr");
29964+ if path.starts_with("test/ui") {
29965+ let stderr_path = entry.path().with_extension("stderr");
29966 if stderr_path.exists() {
29967 // Expected to fail in some way
29968 return false;
29969 }
29970 }
29971
29972- match path_string.as_ref() {
29973- // Deprecated placement syntax
29974- "tests/rust/src/test/ui/obsolete-in-place/bad.rs" |
29975- // Deprecated anonymous parameter syntax in traits
29976- "tests/rust/src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs" |
29977- "tests/rust/src/test/ui/issues/issue-13105.rs" |
29978- "tests/rust/src/test/ui/issues/issue-13775.rs" |
29979- "tests/rust/src/test/ui/issues/issue-34074.rs" |
29980- // Deprecated await macro syntax
29981- "tests/rust/src/test/ui/async-await/await-macro.rs" |
29982- // 2015-style dyn that libsyntax rejects
29983- "tests/rust/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs" |
29984- // not actually test cases
29985- "tests/rust/src/test/ui/macros/auxiliary/macro-comma-support.rs" |
29986- "tests/rust/src/test/ui/macros/auxiliary/macro-include-items-expr.rs" |
29987- "tests/rust/src/test/ui/issues/auxiliary/issue-21146-inc.rs" => false,
29988- _ => true,
29989+ !EXCLUDE.contains(&path)
29990+}
29991+
29992+#[allow(dead_code)]
29993+pub fn edition(path: &Path) -> &'static str {
29994+ if path.ends_with("dyn-2015-no-warnings-without-lints.rs") {
29995+ "2015"
29996+ } else {
29997+ "2018"
29998 }
29999 }
30000
30001 pub fn clone_rust() {
30002- let result = Command::new("tests/clone.sh").status().unwrap();
30003- assert!(result.success());
30004+ let needs_clone = match fs::read_to_string("tests/rust/COMMIT") {
30005+ Err(_) => true,
30006+ Ok(contents) => contents.trim() != REVISION,
30007+ };
30008+ if needs_clone {
30009+ download_and_unpack().unwrap();
30010+ }
30011+ let mut missing = String::new();
30012+ let test_src = Path::new("tests/rust/src");
30013+ for exclude in EXCLUDE {
30014+ if !test_src.join(exclude).exists() {
30015+ missing += "\ntests/rust/src/";
30016+ missing += exclude;
30017+ }
30018+ }
30019+ if !missing.is_empty() {
30020+ panic!("excluded test file does not exist:{}\n", missing);
30021+ }
30022 }
30023+
30024+fn download_and_unpack() -> Result<()> {
30025+ let url = format!(
30026+ "https://github.com/rust-lang/rust/archive/{}.tar.gz",
30027+ REVISION
30028+ );
30029+ let response = reqwest::blocking::get(&url)?.error_for_status()?;
30030+ let progress = Progress::new(response);
30031+ let decoder = GzDecoder::new(progress);
30032+ let mut archive = Archive::new(decoder);
30033+ let prefix = format!("rust-{}", REVISION);
30034+
30035+ let tests_rust = Path::new("tests/rust");
30036+ if tests_rust.exists() {
30037+ fs::remove_dir_all(tests_rust)?;
30038+ }
30039+
30040+ for entry in archive.entries()? {
30041+ let mut entry = entry?;
30042+ let path = entry.path()?;
30043+ if path == Path::new("pax_global_header") {
30044+ continue;
30045+ }
30046+ let relative = path.strip_prefix(&prefix)?;
30047+ let out = tests_rust.join(relative);
30048+ entry.unpack(&out)?;
30049+ }
30050+
30051+ fs::write("tests/rust/COMMIT", REVISION)?;
30052+ Ok(())
30053+}
30054diff --git a/third_party/rust/syn/tests/repo/progress.rs b/third_party/rust/syn/tests/repo/progress.rs
30055new file mode 100644
30056--- /dev/null
30057+++ b/third_party/rust/syn/tests/repo/progress.rs
30058@@ -0,0 +1,37 @@
30059+use std::io::{Read, Result};
30060+use std::time::{Duration, Instant};
30061+
30062+pub struct Progress<R> {
30063+ bytes: usize,
30064+ tick: Instant,
30065+ stream: R,
30066+}
30067+
30068+impl<R> Progress<R> {
30069+ pub fn new(stream: R) -> Self {
30070+ Progress {
30071+ bytes: 0,
30072+ tick: Instant::now() + Duration::from_millis(2000),
30073+ stream,
30074+ }
30075+ }
30076+}
30077+
30078+impl<R: Read> Read for Progress<R> {
30079+ fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
30080+ let num = self.stream.read(buf)?;
30081+ self.bytes += num;
30082+ let now = Instant::now();
30083+ if now > self.tick {
30084+ self.tick = now + Duration::from_millis(500);
30085+ errorf!("downloading... {} bytes\n", self.bytes);
30086+ }
30087+ Ok(num)
30088+ }
30089+}
30090+
30091+impl<R> Drop for Progress<R> {
30092+ fn drop(&mut self) {
30093+ errorf!("done ({} bytes)\n", self.bytes);
30094+ }
30095+}
30096diff --git a/third_party/rust/syn/tests/test_asyncness.rs b/third_party/rust/syn/tests/test_asyncness.rs
30097--- a/third_party/rust/syn/tests/test_asyncness.rs
30098+++ b/third_party/rust/syn/tests/test_asyncness.rs
30099@@ -1,41 +1,37 @@
30100-extern crate syn;
30101-
30102-mod features;
30103-
30104 #[macro_use]
30105 mod macros;
30106
30107 use syn::{Expr, Item};
30108
30109 #[test]
30110 fn test_async_fn() {
30111 let input = "async fn process() {}";
30112
30113 snapshot!(input as Item, @r###"
30114- ⋮Item::Fn {
30115- ⋮ vis: Inherited,
30116- ⋮ sig: Signature {
30117- ⋮ asyncness: Some,
30118- ⋮ ident: "process",
30119- ⋮ generics: Generics,
30120- ⋮ output: Default,
30121- ⋮ },
30122- ⋮ block: Block,
30123- ⋮}
30124+ Item::Fn {
30125+ vis: Inherited,
30126+ sig: Signature {
30127+ asyncness: Some,
30128+ ident: "process",
30129+ generics: Generics,
30130+ output: Default,
30131+ },
30132+ block: Block,
30133+ }
30134 "###);
30135 }
30136
30137 #[test]
30138 fn test_async_closure() {
30139 let input = "async || {}";
30140
30141 snapshot!(input as Expr, @r###"
30142- ⋮Expr::Closure {
30143- ⋮ asyncness: Some,
30144- ⋮ output: Default,
30145- ⋮ body: Expr::Block {
30146- ⋮ block: Block,
30147- ⋮ },
30148- ⋮}
30149+ Expr::Closure {
30150+ asyncness: Some,
30151+ output: Default,
30152+ body: Expr::Block {
30153+ block: Block,
30154+ },
30155+ }
30156 "###);
30157 }
30158diff --git a/third_party/rust/syn/tests/test_attribute.rs b/third_party/rust/syn/tests/test_attribute.rs
30159--- a/third_party/rust/syn/tests/test_attribute.rs
30160+++ b/third_party/rust/syn/tests/test_attribute.rs
30161@@ -1,295 +1,333 @@
30162-extern crate syn;
30163-
30164-mod features;
30165-
30166 #[macro_use]
30167 mod macros;
30168
30169 use syn::parse::Parser;
30170 use syn::{Attribute, Meta};
30171
30172 #[test]
30173 fn test_meta_item_word() {
30174 let meta = test("#[foo]");
30175
30176 snapshot!(meta, @r###"
30177- ⋮Path(Path {
30178- ⋮ segments: [
30179- ⋮ PathSegment {
30180- ⋮ ident: "foo",
30181- ⋮ arguments: None,
30182- ⋮ },
30183- ⋮ ],
30184- ⋮})
30185+ Path(Path {
30186+ segments: [
30187+ PathSegment {
30188+ ident: "foo",
30189+ arguments: None,
30190+ },
30191+ ],
30192+ })
30193 "###);
30194 }
30195
30196 #[test]
30197 fn test_meta_item_name_value() {
30198 let meta = test("#[foo = 5]");
30199
30200 snapshot!(meta, @r###"
30201- ⋮Meta::NameValue {
30202- ⋮ path: Path {
30203- ⋮ segments: [
30204- ⋮ PathSegment {
30205- ⋮ ident: "foo",
30206- ⋮ arguments: None,
30207- ⋮ },
30208- ⋮ ],
30209- ⋮ },
30210- ⋮ lit: 5,
30211- ⋮}
30212+ Meta::NameValue {
30213+ path: Path {
30214+ segments: [
30215+ PathSegment {
30216+ ident: "foo",
30217+ arguments: None,
30218+ },
30219+ ],
30220+ },
30221+ lit: 5,
30222+ }
30223 "###);
30224 }
30225
30226 #[test]
30227 fn test_meta_item_bool_value() {
30228 let meta = test("#[foo = true]");
30229
30230 snapshot!(meta, @r###"
30231- ⋮Meta::NameValue {
30232- ⋮ path: Path {
30233- ⋮ segments: [
30234- ⋮ PathSegment {
30235- ⋮ ident: "foo",
30236- ⋮ arguments: None,
30237- ⋮ },
30238- ⋮ ],
30239- ⋮ },
30240- ⋮ lit: Lit::Bool {
30241- ⋮ value: true,
30242- ⋮ },
30243- ⋮}
30244+ Meta::NameValue {
30245+ path: Path {
30246+ segments: [
30247+ PathSegment {
30248+ ident: "foo",
30249+ arguments: None,
30250+ },
30251+ ],
30252+ },
30253+ lit: Lit::Bool {
30254+ value: true,
30255+ },
30256+ }
30257 "###);
30258
30259 let meta = test("#[foo = false]");
30260
30261 snapshot!(meta, @r###"
30262- ⋮Meta::NameValue {
30263- ⋮ path: Path {
30264- ⋮ segments: [
30265- ⋮ PathSegment {
30266- ⋮ ident: "foo",
30267- ⋮ arguments: None,
30268- ⋮ },
30269- ⋮ ],
30270- ⋮ },
30271- ⋮ lit: Lit::Bool {
30272- ⋮ value: false,
30273- ⋮ },
30274- ⋮}
30275+ Meta::NameValue {
30276+ path: Path {
30277+ segments: [
30278+ PathSegment {
30279+ ident: "foo",
30280+ arguments: None,
30281+ },
30282+ ],
30283+ },
30284+ lit: Lit::Bool {
30285+ value: false,
30286+ },
30287+ }
30288 "###);
30289 }
30290
30291 #[test]
30292 fn test_meta_item_list_lit() {
30293 let meta = test("#[foo(5)]");
30294
30295 snapshot!(meta, @r###"
30296- ⋮Meta::List {
30297- ⋮ path: Path {
30298- ⋮ segments: [
30299- ⋮ PathSegment {
30300- ⋮ ident: "foo",
30301- ⋮ arguments: None,
30302- ⋮ },
30303- ⋮ ],
30304- ⋮ },
30305- ⋮ nested: [
30306- ⋮ Lit(5),
30307- ⋮ ],
30308- ⋮}
30309+ Meta::List {
30310+ path: Path {
30311+ segments: [
30312+ PathSegment {
30313+ ident: "foo",
30314+ arguments: None,
30315+ },
30316+ ],
30317+ },
30318+ nested: [
30319+ Lit(5),
30320+ ],
30321+ }
30322 "###);
30323 }
30324
30325 #[test]
30326 fn test_meta_item_list_word() {
30327 let meta = test("#[foo(bar)]");
30328
30329 snapshot!(meta, @r###"
30330- ⋮Meta::List {
30331- ⋮ path: Path {
30332- ⋮ segments: [
30333- ⋮ PathSegment {
30334- ⋮ ident: "foo",
30335- ⋮ arguments: None,
30336- ⋮ },
30337- ⋮ ],
30338- ⋮ },
30339- ⋮ nested: [
30340- ⋮ Meta(Path(Path {
30341- ⋮ segments: [
30342- ⋮ PathSegment {
30343- ⋮ ident: "bar",
30344- ⋮ arguments: None,
30345- ⋮ },
30346- ⋮ ],
30347- ⋮ })),
30348- ⋮ ],
30349- ⋮}
30350+ Meta::List {
30351+ path: Path {
30352+ segments: [
30353+ PathSegment {
30354+ ident: "foo",
30355+ arguments: None,
30356+ },
30357+ ],
30358+ },
30359+ nested: [
30360+ Meta(Path(Path {
30361+ segments: [
30362+ PathSegment {
30363+ ident: "bar",
30364+ arguments: None,
30365+ },
30366+ ],
30367+ })),
30368+ ],
30369+ }
30370 "###);
30371 }
30372
30373 #[test]
30374 fn test_meta_item_list_name_value() {
30375 let meta = test("#[foo(bar = 5)]");
30376
30377 snapshot!(meta, @r###"
30378- ⋮Meta::List {
30379- ⋮ path: Path {
30380- ⋮ segments: [
30381- ⋮ PathSegment {
30382- ⋮ ident: "foo",
30383- ⋮ arguments: None,
30384- ⋮ },
30385- ⋮ ],
30386- ⋮ },
30387- ⋮ nested: [
30388- ⋮ Meta(Meta::NameValue {
30389- ⋮ path: Path {
30390- ⋮ segments: [
30391- ⋮ PathSegment {
30392- ⋮ ident: "bar",
30393- ⋮ arguments: None,
30394- ⋮ },
30395- ⋮ ],
30396- ⋮ },
30397- ⋮ lit: 5,
30398- ⋮ }),
30399- ⋮ ],
30400- ⋮}
30401+ Meta::List {
30402+ path: Path {
30403+ segments: [
30404+ PathSegment {
30405+ ident: "foo",
30406+ arguments: None,
30407+ },
30408+ ],
30409+ },
30410+ nested: [
30411+ Meta(Meta::NameValue {
30412+ path: Path {
30413+ segments: [
30414+ PathSegment {
30415+ ident: "bar",
30416+ arguments: None,
30417+ },
30418+ ],
30419+ },
30420+ lit: 5,
30421+ }),
30422+ ],
30423+ }
30424 "###);
30425 }
30426
30427 #[test]
30428 fn test_meta_item_list_bool_value() {
30429 let meta = test("#[foo(bar = true)]");
30430
30431 snapshot!(meta, @r###"
30432- ⋮Meta::List {
30433- ⋮ path: Path {
30434- ⋮ segments: [
30435- ⋮ PathSegment {
30436- ⋮ ident: "foo",
30437- ⋮ arguments: None,
30438- ⋮ },
30439- ⋮ ],
30440- ⋮ },
30441- ⋮ nested: [
30442- ⋮ Meta(Meta::NameValue {
30443- ⋮ path: Path {
30444- ⋮ segments: [
30445- ⋮ PathSegment {
30446- ⋮ ident: "bar",
30447- ⋮ arguments: None,
30448- ⋮ },
30449- ⋮ ],
30450- ⋮ },
30451- ⋮ lit: Lit::Bool {
30452- ⋮ value: true,
30453- ⋮ },
30454- ⋮ }),
30455- ⋮ ],
30456- ⋮}
30457+ Meta::List {
30458+ path: Path {
30459+ segments: [
30460+ PathSegment {
30461+ ident: "foo",
30462+ arguments: None,
30463+ },
30464+ ],
30465+ },
30466+ nested: [
30467+ Meta(Meta::NameValue {
30468+ path: Path {
30469+ segments: [
30470+ PathSegment {
30471+ ident: "bar",
30472+ arguments: None,
30473+ },
30474+ ],
30475+ },
30476+ lit: Lit::Bool {
30477+ value: true,
30478+ },
30479+ }),
30480+ ],
30481+ }
30482 "###);
30483 }
30484
30485 #[test]
30486 fn test_meta_item_multiple() {
30487 let meta = test("#[foo(word, name = 5, list(name2 = 6), word2)]");
30488
30489 snapshot!(meta, @r###"
30490- ⋮Meta::List {
30491- ⋮ path: Path {
30492- ⋮ segments: [
30493- ⋮ PathSegment {
30494- ⋮ ident: "foo",
30495- ⋮ arguments: None,
30496- ⋮ },
30497- ⋮ ],
30498- ⋮ },
30499- ⋮ nested: [
30500- ⋮ Meta(Path(Path {
30501- ⋮ segments: [
30502- ⋮ PathSegment {
30503- ⋮ ident: "word",
30504- ⋮ arguments: None,
30505- ⋮ },
30506- ⋮ ],
30507- ⋮ })),
30508- ⋮ Meta(Meta::NameValue {
30509- ⋮ path: Path {
30510- ⋮ segments: [
30511- ⋮ PathSegment {
30512- ⋮ ident: "name",
30513- ⋮ arguments: None,
30514- ⋮ },
30515- ⋮ ],
30516- ⋮ },
30517- ⋮ lit: 5,
30518- ⋮ }),
30519- ⋮ Meta(Meta::List {
30520- ⋮ path: Path {
30521- ⋮ segments: [
30522- ⋮ PathSegment {
30523- ⋮ ident: "list",
30524- ⋮ arguments: None,
30525- ⋮ },
30526- ⋮ ],
30527- ⋮ },
30528- ⋮ nested: [
30529- ⋮ Meta(Meta::NameValue {
30530- ⋮ path: Path {
30531- ⋮ segments: [
30532- ⋮ PathSegment {
30533- ⋮ ident: "name2",
30534- ⋮ arguments: None,
30535- ⋮ },
30536- ⋮ ],
30537- ⋮ },
30538- ⋮ lit: 6,
30539- ⋮ }),
30540- ⋮ ],
30541- ⋮ }),
30542- ⋮ Meta(Path(Path {
30543- ⋮ segments: [
30544- ⋮ PathSegment {
30545- ⋮ ident: "word2",
30546- ⋮ arguments: None,
30547- ⋮ },
30548- ⋮ ],
30549- ⋮ })),
30550- ⋮ ],
30551- ⋮}
30552+ Meta::List {
30553+ path: Path {
30554+ segments: [
30555+ PathSegment {
30556+ ident: "foo",
30557+ arguments: None,
30558+ },
30559+ ],
30560+ },
30561+ nested: [
30562+ Meta(Path(Path {
30563+ segments: [
30564+ PathSegment {
30565+ ident: "word",
30566+ arguments: None,
30567+ },
30568+ ],
30569+ })),
30570+ Meta(Meta::NameValue {
30571+ path: Path {
30572+ segments: [
30573+ PathSegment {
30574+ ident: "name",
30575+ arguments: None,
30576+ },
30577+ ],
30578+ },
30579+ lit: 5,
30580+ }),
30581+ Meta(Meta::List {
30582+ path: Path {
30583+ segments: [
30584+ PathSegment {
30585+ ident: "list",
30586+ arguments: None,
30587+ },
30588+ ],
30589+ },
30590+ nested: [
30591+ Meta(Meta::NameValue {
30592+ path: Path {
30593+ segments: [
30594+ PathSegment {
30595+ ident: "name2",
30596+ arguments: None,
30597+ },
30598+ ],
30599+ },
30600+ lit: 6,
30601+ }),
30602+ ],
30603+ }),
30604+ Meta(Path(Path {
30605+ segments: [
30606+ PathSegment {
30607+ ident: "word2",
30608+ arguments: None,
30609+ },
30610+ ],
30611+ })),
30612+ ],
30613+ }
30614 "###);
30615 }
30616
30617 #[test]
30618 fn test_bool_lit() {
30619 let meta = test("#[foo(true)]");
30620
30621 snapshot!(meta, @r###"
30622- ⋮Meta::List {
30623- ⋮ path: Path {
30624- ⋮ segments: [
30625- ⋮ PathSegment {
30626- ⋮ ident: "foo",
30627- ⋮ arguments: None,
30628- ⋮ },
30629- ⋮ ],
30630- ⋮ },
30631- ⋮ nested: [
30632- ⋮ Lit(Lit::Bool {
30633- ⋮ value: true,
30634- ⋮ }),
30635- ⋮ ],
30636- ⋮}
30637+ Meta::List {
30638+ path: Path {
30639+ segments: [
30640+ PathSegment {
30641+ ident: "foo",
30642+ arguments: None,
30643+ },
30644+ ],
30645+ },
30646+ nested: [
30647+ Lit(Lit::Bool {
30648+ value: true,
30649+ }),
30650+ ],
30651+ }
30652+ "###);
30653+}
30654+
30655+#[test]
30656+fn test_negative_lit() {
30657+ let meta = test("#[form(min = -1, max = 200)]");
30658+
30659+ snapshot!(meta, @r###"
30660+ Meta::List {
30661+ path: Path {
30662+ segments: [
30663+ PathSegment {
30664+ ident: "form",
30665+ arguments: None,
30666+ },
30667+ ],
30668+ },
30669+ nested: [
30670+ Meta(Meta::NameValue {
30671+ path: Path {
30672+ segments: [
30673+ PathSegment {
30674+ ident: "min",
30675+ arguments: None,
30676+ },
30677+ ],
30678+ },
30679+ lit: -1,
30680+ }),
30681+ Meta(Meta::NameValue {
30682+ path: Path {
30683+ segments: [
30684+ PathSegment {
30685+ ident: "max",
30686+ arguments: None,
30687+ },
30688+ ],
30689+ },
30690+ lit: 200,
30691+ }),
30692+ ],
30693+ }
30694 "###);
30695 }
30696
30697 fn test(input: &str) -> Meta {
30698 let attrs = Attribute::parse_outer.parse_str(input).unwrap();
30699
30700 assert_eq!(attrs.len(), 1);
30701 let attr = attrs.into_iter().next().unwrap();
30702diff --git a/third_party/rust/syn/tests/test_derive_input.rs b/third_party/rust/syn/tests/test_derive_input.rs
30703--- a/third_party/rust/syn/tests/test_derive_input.rs
30704+++ b/third_party/rust/syn/tests/test_derive_input.rs
30705@@ -1,201 +1,196 @@
30706-extern crate quote;
30707-extern crate syn;
30708-
30709-mod features;
30710-
30711 #[macro_use]
30712 mod macros;
30713
30714 use quote::quote;
30715 use syn::{Data, DeriveInput};
30716
30717 #[test]
30718 fn test_unit() {
30719 let input = quote! {
30720 struct Unit;
30721 };
30722
30723 snapshot!(input as DeriveInput, @r###"
30724- ⋮DeriveInput {
30725- ⋮ vis: Inherited,
30726- ⋮ ident: "Unit",
30727- ⋮ generics: Generics,
30728- ⋮ data: Data::Struct {
30729- ⋮ fields: Unit,
30730- ⋮ semi_token: Some,
30731- ⋮ },
30732- ⋮}
30733+ DeriveInput {
30734+ vis: Inherited,
30735+ ident: "Unit",
30736+ generics: Generics,
30737+ data: Data::Struct {
30738+ fields: Unit,
30739+ semi_token: Some,
30740+ },
30741+ }
30742 "###);
30743 }
30744
30745 #[test]
30746 fn test_struct() {
30747 let input = quote! {
30748 #[derive(Debug, Clone)]
30749 pub struct Item {
30750 pub ident: Ident,
30751 pub attrs: Vec<Attribute>
30752 }
30753 };
30754
30755 snapshot!(input as DeriveInput, @r###"
30756- ⋮DeriveInput {
30757- ⋮ attrs: [
30758- ⋮ Attribute {
30759- ⋮ style: Outer,
30760- ⋮ path: Path {
30761- ⋮ segments: [
30762- ⋮ PathSegment {
30763- ⋮ ident: "derive",
30764- ⋮ arguments: None,
30765- ⋮ },
30766- ⋮ ],
30767- ⋮ },
30768- ⋮ tokens: `( Debug , Clone )`,
30769- ⋮ },
30770- ⋮ ],
30771- ⋮ vis: Visibility::Public,
30772- ⋮ ident: "Item",
30773- ⋮ generics: Generics,
30774- ⋮ data: Data::Struct {
30775- ⋮ fields: Fields::Named {
30776- ⋮ named: [
30777- ⋮ Field {
30778- ⋮ vis: Visibility::Public,
30779- ⋮ ident: Some("ident"),
30780- ⋮ colon_token: Some,
30781- ⋮ ty: Type::Path {
30782- ⋮ path: Path {
30783- ⋮ segments: [
30784- ⋮ PathSegment {
30785- ⋮ ident: "Ident",
30786- ⋮ arguments: None,
30787- ⋮ },
30788- ⋮ ],
30789- ⋮ },
30790- ⋮ },
30791- ⋮ },
30792- ⋮ Field {
30793- ⋮ vis: Visibility::Public,
30794- ⋮ ident: Some("attrs"),
30795- ⋮ colon_token: Some,
30796- ⋮ ty: Type::Path {
30797- ⋮ path: Path {
30798- ⋮ segments: [
30799- ⋮ PathSegment {
30800- ⋮ ident: "Vec",
30801- ⋮ arguments: PathArguments::AngleBracketed {
30802- ⋮ args: [
30803- ⋮ Type(Type::Path {
30804- ⋮ path: Path {
30805- ⋮ segments: [
30806- ⋮ PathSegment {
30807- ⋮ ident: "Attribute",
30808- ⋮ arguments: None,
30809- ⋮ },
30810- ⋮ ],
30811- ⋮ },
30812- ⋮ }),
30813- ⋮ ],
30814- ⋮ },
30815- ⋮ },
30816- ⋮ ],
30817- ⋮ },
30818- ⋮ },
30819- ⋮ },
30820- ⋮ ],
30821- ⋮ },
30822- ⋮ },
30823- ⋮}
30824+ DeriveInput {
30825+ attrs: [
30826+ Attribute {
30827+ style: Outer,
30828+ path: Path {
30829+ segments: [
30830+ PathSegment {
30831+ ident: "derive",
30832+ arguments: None,
30833+ },
30834+ ],
30835+ },
30836+ tokens: TokenStream(`(Debug , Clone)`),
30837+ },
30838+ ],
30839+ vis: Visibility::Public,
30840+ ident: "Item",
30841+ generics: Generics,
30842+ data: Data::Struct {
30843+ fields: Fields::Named {
30844+ named: [
30845+ Field {
30846+ vis: Visibility::Public,
30847+ ident: Some("ident"),
30848+ colon_token: Some,
30849+ ty: Type::Path {
30850+ path: Path {
30851+ segments: [
30852+ PathSegment {
30853+ ident: "Ident",
30854+ arguments: None,
30855+ },
30856+ ],
30857+ },
30858+ },
30859+ },
30860+ Field {
30861+ vis: Visibility::Public,
30862+ ident: Some("attrs"),
30863+ colon_token: Some,
30864+ ty: Type::Path {
30865+ path: Path {
30866+ segments: [
30867+ PathSegment {
30868+ ident: "Vec",
30869+ arguments: PathArguments::AngleBracketed {
30870+ args: [
30871+ Type(Type::Path {
30872+ path: Path {
30873+ segments: [
30874+ PathSegment {
30875+ ident: "Attribute",
30876+ arguments: None,
30877+ },
30878+ ],
30879+ },
30880+ }),
30881+ ],
30882+ },
30883+ },
30884+ ],
30885+ },
30886+ },
30887+ },
30888+ ],
30889+ },
30890+ },
30891+ }
30892 "###);
30893
30894 snapshot!(input.attrs[0].parse_meta().unwrap(), @r###"
30895- ⋮Meta::List {
30896- ⋮ path: Path {
30897- ⋮ segments: [
30898- ⋮ PathSegment {
30899- ⋮ ident: "derive",
30900- ⋮ arguments: None,
30901- ⋮ },
30902- ⋮ ],
30903- ⋮ },
30904- ⋮ nested: [
30905- ⋮ Meta(Path(Path {
30906- ⋮ segments: [
30907- ⋮ PathSegment {
30908- ⋮ ident: "Debug",
30909- ⋮ arguments: None,
30910- ⋮ },
30911- ⋮ ],
30912- ⋮ })),
30913- ⋮ Meta(Path(Path {
30914- ⋮ segments: [
30915- ⋮ PathSegment {
30916- ⋮ ident: "Clone",
30917- ⋮ arguments: None,
30918- ⋮ },
30919- ⋮ ],
30920- ⋮ })),
30921- ⋮ ],
30922- ⋮}
30923+ Meta::List {
30924+ path: Path {
30925+ segments: [
30926+ PathSegment {
30927+ ident: "derive",
30928+ arguments: None,
30929+ },
30930+ ],
30931+ },
30932+ nested: [
30933+ Meta(Path(Path {
30934+ segments: [
30935+ PathSegment {
30936+ ident: "Debug",
30937+ arguments: None,
30938+ },
30939+ ],
30940+ })),
30941+ Meta(Path(Path {
30942+ segments: [
30943+ PathSegment {
30944+ ident: "Clone",
30945+ arguments: None,
30946+ },
30947+ ],
30948+ })),
30949+ ],
30950+ }
30951 "###);
30952 }
30953
30954 #[test]
30955 fn test_union() {
30956 let input = quote! {
30957 union MaybeUninit<T> {
30958 uninit: (),
30959 value: T
30960 }
30961 };
30962
30963 snapshot!(input as DeriveInput, @r###"
30964- ⋮DeriveInput {
30965- ⋮ vis: Inherited,
30966- ⋮ ident: "MaybeUninit",
30967- ⋮ generics: Generics {
30968- ⋮ lt_token: Some,
30969- ⋮ params: [
30970- ⋮ Type(TypeParam {
30971- ⋮ ident: "T",
30972- ⋮ }),
30973- ⋮ ],
30974- ⋮ gt_token: Some,
30975- ⋮ },
30976- ⋮ data: Data::Union {
30977- ⋮ fields: FieldsNamed {
30978- ⋮ named: [
30979- ⋮ Field {
30980- ⋮ vis: Inherited,
30981- ⋮ ident: Some("uninit"),
30982- ⋮ colon_token: Some,
30983- ⋮ ty: Type::Tuple,
30984- ⋮ },
30985- ⋮ Field {
30986- ⋮ vis: Inherited,
30987- ⋮ ident: Some("value"),
30988- ⋮ colon_token: Some,
30989- ⋮ ty: Type::Path {
30990- ⋮ path: Path {
30991- ⋮ segments: [
30992- ⋮ PathSegment {
30993- ⋮ ident: "T",
30994- ⋮ arguments: None,
30995- ⋮ },
30996- ⋮ ],
30997- ⋮ },
30998- ⋮ },
30999- ⋮ },
31000- ⋮ ],
31001- ⋮ },
31002- ⋮ },
31003- ⋮}
31004+ DeriveInput {
31005+ vis: Inherited,
31006+ ident: "MaybeUninit",
31007+ generics: Generics {
31008+ lt_token: Some,
31009+ params: [
31010+ Type(TypeParam {
31011+ ident: "T",
31012+ }),
31013+ ],
31014+ gt_token: Some,
31015+ },
31016+ data: Data::Union {
31017+ fields: FieldsNamed {
31018+ named: [
31019+ Field {
31020+ vis: Inherited,
31021+ ident: Some("uninit"),
31022+ colon_token: Some,
31023+ ty: Type::Tuple,
31024+ },
31025+ Field {
31026+ vis: Inherited,
31027+ ident: Some("value"),
31028+ colon_token: Some,
31029+ ty: Type::Path {
31030+ path: Path {
31031+ segments: [
31032+ PathSegment {
31033+ ident: "T",
31034+ arguments: None,
31035+ },
31036+ ],
31037+ },
31038+ },
31039+ },
31040+ ],
31041+ },
31042+ },
31043+ }
31044 "###);
31045 }
31046
31047 #[test]
31048 #[cfg(feature = "full")]
31049 fn test_enum() {
31050 let input = quote! {
31051 /// See the std::result module documentation for details.
31052@@ -207,472 +202,472 @@ fn test_enum() {
31053
31054 // Smuggling data into a proc_macro_derive,
31055 // in the style of https://github.com/dtolnay/proc-macro-hack
31056 ProcMacroHack = (0, "data").0
31057 }
31058 };
31059
31060 snapshot!(input as DeriveInput, @r###"
31061- ⋮DeriveInput {
31062- ⋮ attrs: [
31063- ⋮ Attribute {
31064- ⋮ style: Outer,
31065- ⋮ path: Path {
31066- ⋮ segments: [
31067- ⋮ PathSegment {
31068- ⋮ ident: "doc",
31069- ⋮ arguments: None,
31070- ⋮ },
31071- ⋮ ],
31072- ⋮ },
31073- ⋮ tokens: `= r" See the std::result module documentation for details."`,
31074- ⋮ },
31075- ⋮ Attribute {
31076- ⋮ style: Outer,
31077- ⋮ path: Path {
31078- ⋮ segments: [
31079- ⋮ PathSegment {
31080- ⋮ ident: "must_use",
31081- ⋮ arguments: None,
31082- ⋮ },
31083- ⋮ ],
31084- ⋮ },
31085- ⋮ tokens: ``,
31086- ⋮ },
31087- ⋮ ],
31088- ⋮ vis: Visibility::Public,
31089- ⋮ ident: "Result",
31090- ⋮ generics: Generics {
31091- ⋮ lt_token: Some,
31092- ⋮ params: [
31093- ⋮ Type(TypeParam {
31094- ⋮ ident: "T",
31095- ⋮ }),
31096- ⋮ Type(TypeParam {
31097- ⋮ ident: "E",
31098- ⋮ }),
31099- ⋮ ],
31100- ⋮ gt_token: Some,
31101- ⋮ },
31102- ⋮ data: Data::Enum {
31103- ⋮ variants: [
31104- ⋮ Variant {
31105- ⋮ ident: "Ok",
31106- ⋮ fields: Fields::Unnamed {
31107- ⋮ unnamed: [
31108- ⋮ Field {
31109- ⋮ vis: Inherited,
31110- ⋮ ty: Type::Path {
31111- ⋮ path: Path {
31112- ⋮ segments: [
31113- ⋮ PathSegment {
31114- ⋮ ident: "T",
31115- ⋮ arguments: None,
31116- ⋮ },
31117- ⋮ ],
31118- ⋮ },
31119- ⋮ },
31120- ⋮ },
31121- ⋮ ],
31122- ⋮ },
31123- ⋮ },
31124- ⋮ Variant {
31125- ⋮ ident: "Err",
31126- ⋮ fields: Fields::Unnamed {
31127- ⋮ unnamed: [
31128- ⋮ Field {
31129- ⋮ vis: Inherited,
31130- ⋮ ty: Type::Path {
31131- ⋮ path: Path {
31132- ⋮ segments: [
31133- ⋮ PathSegment {
31134- ⋮ ident: "E",
31135- ⋮ arguments: None,
31136- ⋮ },
31137- ⋮ ],
31138- ⋮ },
31139- ⋮ },
31140- ⋮ },
31141- ⋮ ],
31142- ⋮ },
31143- ⋮ },
31144- ⋮ Variant {
31145- ⋮ ident: "Surprise",
31146- ⋮ fields: Unit,
31147- ⋮ discriminant: Some(Expr::Lit {
31148- ⋮ lit: 0isize,
31149- ⋮ }),
31150- ⋮ },
31151- ⋮ Variant {
31152- ⋮ ident: "ProcMacroHack",
31153- ⋮ fields: Unit,
31154- ⋮ discriminant: Some(Expr::Field {
31155- ⋮ base: Expr::Tuple {
31156- ⋮ elems: [
31157- ⋮ Expr::Lit {
31158- ⋮ lit: 0,
31159- ⋮ },
31160- ⋮ Expr::Lit {
31161- ⋮ lit: "data",
31162- ⋮ },
31163- ⋮ ],
31164- ⋮ },
31165- ⋮ member: Unnamed(Index {
31166- ⋮ index: 0,
31167- ⋮ }),
31168- ⋮ }),
31169- ⋮ },
31170- ⋮ ],
31171- ⋮ },
31172- ⋮}
31173+ DeriveInput {
31174+ attrs: [
31175+ Attribute {
31176+ style: Outer,
31177+ path: Path {
31178+ segments: [
31179+ PathSegment {
31180+ ident: "doc",
31181+ arguments: None,
31182+ },
31183+ ],
31184+ },
31185+ tokens: TokenStream(`= r" See the std::result module documentation for details."`),
31186+ },
31187+ Attribute {
31188+ style: Outer,
31189+ path: Path {
31190+ segments: [
31191+ PathSegment {
31192+ ident: "must_use",
31193+ arguments: None,
31194+ },
31195+ ],
31196+ },
31197+ tokens: TokenStream(``),
31198+ },
31199+ ],
31200+ vis: Visibility::Public,
31201+ ident: "Result",
31202+ generics: Generics {
31203+ lt_token: Some,
31204+ params: [
31205+ Type(TypeParam {
31206+ ident: "T",
31207+ }),
31208+ Type(TypeParam {
31209+ ident: "E",
31210+ }),
31211+ ],
31212+ gt_token: Some,
31213+ },
31214+ data: Data::Enum {
31215+ variants: [
31216+ Variant {
31217+ ident: "Ok",
31218+ fields: Fields::Unnamed {
31219+ unnamed: [
31220+ Field {
31221+ vis: Inherited,
31222+ ty: Type::Path {
31223+ path: Path {
31224+ segments: [
31225+ PathSegment {
31226+ ident: "T",
31227+ arguments: None,
31228+ },
31229+ ],
31230+ },
31231+ },
31232+ },
31233+ ],
31234+ },
31235+ },
31236+ Variant {
31237+ ident: "Err",
31238+ fields: Fields::Unnamed {
31239+ unnamed: [
31240+ Field {
31241+ vis: Inherited,
31242+ ty: Type::Path {
31243+ path: Path {
31244+ segments: [
31245+ PathSegment {
31246+ ident: "E",
31247+ arguments: None,
31248+ },
31249+ ],
31250+ },
31251+ },
31252+ },
31253+ ],
31254+ },
31255+ },
31256+ Variant {
31257+ ident: "Surprise",
31258+ fields: Unit,
31259+ discriminant: Some(Expr::Lit {
31260+ lit: 0isize,
31261+ }),
31262+ },
31263+ Variant {
31264+ ident: "ProcMacroHack",
31265+ fields: Unit,
31266+ discriminant: Some(Expr::Field {
31267+ base: Expr::Tuple {
31268+ elems: [
31269+ Expr::Lit {
31270+ lit: 0,
31271+ },
31272+ Expr::Lit {
31273+ lit: "data",
31274+ },
31275+ ],
31276+ },
31277+ member: Unnamed(Index {
31278+ index: 0,
31279+ }),
31280+ }),
31281+ },
31282+ ],
31283+ },
31284+ }
31285 "###);
31286
31287 let meta_items: Vec<_> = input
31288 .attrs
31289 .into_iter()
31290 .map(|attr| attr.parse_meta().unwrap())
31291 .collect();
31292
31293 snapshot!(meta_items, @r###"
31294- ⋮[
31295- ⋮ Meta::NameValue {
31296- ⋮ path: Path {
31297- ⋮ segments: [
31298- ⋮ PathSegment {
31299- ⋮ ident: "doc",
31300- ⋮ arguments: None,
31301- ⋮ },
31302- ⋮ ],
31303- ⋮ },
31304- ⋮ lit: " See the std::result module documentation for details.",
31305- ⋮ },
31306- ⋮ Path(Path {
31307- ⋮ segments: [
31308- ⋮ PathSegment {
31309- ⋮ ident: "must_use",
31310- ⋮ arguments: None,
31311- ⋮ },
31312- ⋮ ],
31313- ⋮ }),
31314- ⋮]
31315+ [
31316+ Meta::NameValue {
31317+ path: Path {
31318+ segments: [
31319+ PathSegment {
31320+ ident: "doc",
31321+ arguments: None,
31322+ },
31323+ ],
31324+ },
31325+ lit: " See the std::result module documentation for details.",
31326+ },
31327+ Path(Path {
31328+ segments: [
31329+ PathSegment {
31330+ ident: "must_use",
31331+ arguments: None,
31332+ },
31333+ ],
31334+ }),
31335+ ]
31336 "###);
31337 }
31338
31339 #[test]
31340 fn test_attr_with_path() {
31341 let input = quote! {
31342 #[::attr_args::identity
31343 fn main() { assert_eq!(foo(), "Hello, world!"); }]
31344 struct Dummy;
31345 };
31346
31347 snapshot!(input as DeriveInput, @r###"
31348- ⋮DeriveInput {
31349- ⋮ attrs: [
31350- ⋮ Attribute {
31351- ⋮ style: Outer,
31352- ⋮ path: Path {
31353- ⋮ leading_colon: Some,
31354- ⋮ segments: [
31355- ⋮ PathSegment {
31356- ⋮ ident: "attr_args",
31357- ⋮ arguments: None,
31358- ⋮ },
31359- ⋮ PathSegment {
31360- ⋮ ident: "identity",
31361- ⋮ arguments: None,
31362- ⋮ },
31363- ⋮ ],
31364- ⋮ },
31365- ⋮ tokens: `fn main ( ) { assert_eq ! ( foo ( ) , "Hello, world!" ) ; }`,
31366- ⋮ },
31367- ⋮ ],
31368- ⋮ vis: Inherited,
31369- ⋮ ident: "Dummy",
31370- ⋮ generics: Generics,
31371- ⋮ data: Data::Struct {
31372- ⋮ fields: Unit,
31373- ⋮ semi_token: Some,
31374- ⋮ },
31375- ⋮}
31376+ DeriveInput {
31377+ attrs: [
31378+ Attribute {
31379+ style: Outer,
31380+ path: Path {
31381+ leading_colon: Some,
31382+ segments: [
31383+ PathSegment {
31384+ ident: "attr_args",
31385+ arguments: None,
31386+ },
31387+ PathSegment {
31388+ ident: "identity",
31389+ arguments: None,
31390+ },
31391+ ],
31392+ },
31393+ tokens: TokenStream(`fn main () { assert_eq ! (foo () , "Hello, world!") ; }`),
31394+ },
31395+ ],
31396+ vis: Inherited,
31397+ ident: "Dummy",
31398+ generics: Generics,
31399+ data: Data::Struct {
31400+ fields: Unit,
31401+ semi_token: Some,
31402+ },
31403+ }
31404 "###);
31405
31406 assert!(input.attrs[0].parse_meta().is_err());
31407 }
31408
31409 #[test]
31410 fn test_attr_with_non_mod_style_path() {
31411 let input = quote! {
31412 #[inert <T>]
31413 struct S;
31414 };
31415
31416 snapshot!(input as DeriveInput, @r###"
31417- ⋮DeriveInput {
31418- ⋮ attrs: [
31419- ⋮ Attribute {
31420- ⋮ style: Outer,
31421- ⋮ path: Path {
31422- ⋮ segments: [
31423- ⋮ PathSegment {
31424- ⋮ ident: "inert",
31425- ⋮ arguments: None,
31426- ⋮ },
31427- ⋮ ],
31428- ⋮ },
31429- ⋮ tokens: `< T >`,
31430- ⋮ },
31431- ⋮ ],
31432- ⋮ vis: Inherited,
31433- ⋮ ident: "S",
31434- ⋮ generics: Generics,
31435- ⋮ data: Data::Struct {
31436- ⋮ fields: Unit,
31437- ⋮ semi_token: Some,
31438- ⋮ },
31439- ⋮}
31440+ DeriveInput {
31441+ attrs: [
31442+ Attribute {
31443+ style: Outer,
31444+ path: Path {
31445+ segments: [
31446+ PathSegment {
31447+ ident: "inert",
31448+ arguments: None,
31449+ },
31450+ ],
31451+ },
31452+ tokens: TokenStream(`< T >`),
31453+ },
31454+ ],
31455+ vis: Inherited,
31456+ ident: "S",
31457+ generics: Generics,
31458+ data: Data::Struct {
31459+ fields: Unit,
31460+ semi_token: Some,
31461+ },
31462+ }
31463 "###);
31464
31465 assert!(input.attrs[0].parse_meta().is_err());
31466 }
31467
31468 #[test]
31469 fn test_attr_with_mod_style_path_with_self() {
31470 let input = quote! {
31471 #[foo::self]
31472 struct S;
31473 };
31474
31475 snapshot!(input as DeriveInput, @r###"
31476- ⋮DeriveInput {
31477- ⋮ attrs: [
31478- ⋮ Attribute {
31479- ⋮ style: Outer,
31480- ⋮ path: Path {
31481- ⋮ segments: [
31482- ⋮ PathSegment {
31483- ⋮ ident: "foo",
31484- ⋮ arguments: None,
31485- ⋮ },
31486- ⋮ PathSegment {
31487- ⋮ ident: "self",
31488- ⋮ arguments: None,
31489- ⋮ },
31490- ⋮ ],
31491- ⋮ },
31492- ⋮ tokens: ``,
31493- ⋮ },
31494- ⋮ ],
31495- ⋮ vis: Inherited,
31496- ⋮ ident: "S",
31497- ⋮ generics: Generics,
31498- ⋮ data: Data::Struct {
31499- ⋮ fields: Unit,
31500- ⋮ semi_token: Some,
31501- ⋮ },
31502- ⋮}
31503+ DeriveInput {
31504+ attrs: [
31505+ Attribute {
31506+ style: Outer,
31507+ path: Path {
31508+ segments: [
31509+ PathSegment {
31510+ ident: "foo",
31511+ arguments: None,
31512+ },
31513+ PathSegment {
31514+ ident: "self",
31515+ arguments: None,
31516+ },
31517+ ],
31518+ },
31519+ tokens: TokenStream(``),
31520+ },
31521+ ],
31522+ vis: Inherited,
31523+ ident: "S",
31524+ generics: Generics,
31525+ data: Data::Struct {
31526+ fields: Unit,
31527+ semi_token: Some,
31528+ },
31529+ }
31530 "###);
31531
31532 snapshot!(input.attrs[0].parse_meta().unwrap(), @r###"
31533- ⋮Path(Path {
31534- ⋮ segments: [
31535- ⋮ PathSegment {
31536- ⋮ ident: "foo",
31537- ⋮ arguments: None,
31538- ⋮ },
31539- ⋮ PathSegment {
31540- ⋮ ident: "self",
31541- ⋮ arguments: None,
31542- ⋮ },
31543- ⋮ ],
31544- ⋮})
31545+ Path(Path {
31546+ segments: [
31547+ PathSegment {
31548+ ident: "foo",
31549+ arguments: None,
31550+ },
31551+ PathSegment {
31552+ ident: "self",
31553+ arguments: None,
31554+ },
31555+ ],
31556+ })
31557 "###);
31558 }
31559
31560 #[test]
31561 fn test_pub_restricted() {
31562 // Taken from tests/rust/src/test/ui/resolve/auxiliary/privacy-struct-ctor.rs
31563 let input = quote! {
31564 pub(in m) struct Z(pub(in m::n) u8);
31565 };
31566
31567 snapshot!(input as DeriveInput, @r###"
31568- ⋮DeriveInput {
31569- ⋮ vis: Visibility::Restricted {
31570- ⋮ in_token: Some,
31571- ⋮ path: Path {
31572- ⋮ segments: [
31573- ⋮ PathSegment {
31574- ⋮ ident: "m",
31575- ⋮ arguments: None,
31576- ⋮ },
31577- ⋮ ],
31578- ⋮ },
31579- ⋮ },
31580- ⋮ ident: "Z",
31581- ⋮ generics: Generics,
31582- ⋮ data: Data::Struct {
31583- ⋮ fields: Fields::Unnamed {
31584- ⋮ unnamed: [
31585- ⋮ Field {
31586- ⋮ vis: Visibility::Restricted {
31587- ⋮ in_token: Some,
31588- ⋮ path: Path {
31589- ⋮ segments: [
31590- ⋮ PathSegment {
31591- ⋮ ident: "m",
31592- ⋮ arguments: None,
31593- ⋮ },
31594- ⋮ PathSegment {
31595- ⋮ ident: "n",
31596- ⋮ arguments: None,
31597- ⋮ },
31598- ⋮ ],
31599- ⋮ },
31600- ⋮ },
31601- ⋮ ty: Type::Path {
31602- ⋮ path: Path {
31603- ⋮ segments: [
31604- ⋮ PathSegment {
31605- ⋮ ident: "u8",
31606- ⋮ arguments: None,
31607- ⋮ },
31608- ⋮ ],
31609- ⋮ },
31610- ⋮ },
31611- ⋮ },
31612- ⋮ ],
31613- ⋮ },
31614- ⋮ semi_token: Some,
31615- ⋮ },
31616- ⋮}
31617+ DeriveInput {
31618+ vis: Visibility::Restricted {
31619+ in_token: Some,
31620+ path: Path {
31621+ segments: [
31622+ PathSegment {
31623+ ident: "m",
31624+ arguments: None,
31625+ },
31626+ ],
31627+ },
31628+ },
31629+ ident: "Z",
31630+ generics: Generics,
31631+ data: Data::Struct {
31632+ fields: Fields::Unnamed {
31633+ unnamed: [
31634+ Field {
31635+ vis: Visibility::Restricted {
31636+ in_token: Some,
31637+ path: Path {
31638+ segments: [
31639+ PathSegment {
31640+ ident: "m",
31641+ arguments: None,
31642+ },
31643+ PathSegment {
31644+ ident: "n",
31645+ arguments: None,
31646+ },
31647+ ],
31648+ },
31649+ },
31650+ ty: Type::Path {
31651+ path: Path {
31652+ segments: [
31653+ PathSegment {
31654+ ident: "u8",
31655+ arguments: None,
31656+ },
31657+ ],
31658+ },
31659+ },
31660+ },
31661+ ],
31662+ },
31663+ semi_token: Some,
31664+ },
31665+ }
31666 "###);
31667 }
31668
31669 #[test]
31670 fn test_vis_crate() {
31671 let input = quote! {
31672 crate struct S;
31673 };
31674
31675 snapshot!(input as DeriveInput, @r###"
31676- ⋮DeriveInput {
31677- ⋮ vis: Visibility::Crate,
31678- ⋮ ident: "S",
31679- ⋮ generics: Generics,
31680- ⋮ data: Data::Struct {
31681- ⋮ fields: Unit,
31682- ⋮ semi_token: Some,
31683- ⋮ },
31684- ⋮}
31685+ DeriveInput {
31686+ vis: Visibility::Crate,
31687+ ident: "S",
31688+ generics: Generics,
31689+ data: Data::Struct {
31690+ fields: Unit,
31691+ semi_token: Some,
31692+ },
31693+ }
31694 "###);
31695 }
31696
31697 #[test]
31698 fn test_pub_restricted_crate() {
31699 let input = quote! {
31700 pub(crate) struct S;
31701 };
31702
31703 snapshot!(input as DeriveInput, @r###"
31704- ⋮DeriveInput {
31705- ⋮ vis: Visibility::Restricted {
31706- ⋮ path: Path {
31707- ⋮ segments: [
31708- ⋮ PathSegment {
31709- ⋮ ident: "crate",
31710- ⋮ arguments: None,
31711- ⋮ },
31712- ⋮ ],
31713- ⋮ },
31714- ⋮ },
31715- ⋮ ident: "S",
31716- ⋮ generics: Generics,
31717- ⋮ data: Data::Struct {
31718- ⋮ fields: Unit,
31719- ⋮ semi_token: Some,
31720- ⋮ },
31721- ⋮}
31722+ DeriveInput {
31723+ vis: Visibility::Restricted {
31724+ path: Path {
31725+ segments: [
31726+ PathSegment {
31727+ ident: "crate",
31728+ arguments: None,
31729+ },
31730+ ],
31731+ },
31732+ },
31733+ ident: "S",
31734+ generics: Generics,
31735+ data: Data::Struct {
31736+ fields: Unit,
31737+ semi_token: Some,
31738+ },
31739+ }
31740 "###);
31741 }
31742
31743 #[test]
31744 fn test_pub_restricted_super() {
31745 let input = quote! {
31746 pub(super) struct S;
31747 };
31748
31749 snapshot!(input as DeriveInput, @r###"
31750- ⋮DeriveInput {
31751- ⋮ vis: Visibility::Restricted {
31752- ⋮ path: Path {
31753- ⋮ segments: [
31754- ⋮ PathSegment {
31755- ⋮ ident: "super",
31756- ⋮ arguments: None,
31757- ⋮ },
31758- ⋮ ],
31759- ⋮ },
31760- ⋮ },
31761- ⋮ ident: "S",
31762- ⋮ generics: Generics,
31763- ⋮ data: Data::Struct {
31764- ⋮ fields: Unit,
31765- ⋮ semi_token: Some,
31766- ⋮ },
31767- ⋮}
31768+ DeriveInput {
31769+ vis: Visibility::Restricted {
31770+ path: Path {
31771+ segments: [
31772+ PathSegment {
31773+ ident: "super",
31774+ arguments: None,
31775+ },
31776+ ],
31777+ },
31778+ },
31779+ ident: "S",
31780+ generics: Generics,
31781+ data: Data::Struct {
31782+ fields: Unit,
31783+ semi_token: Some,
31784+ },
31785+ }
31786 "###);
31787 }
31788
31789 #[test]
31790 fn test_pub_restricted_in_super() {
31791 let input = quote! {
31792 pub(in super) struct S;
31793 };
31794
31795 snapshot!(input as DeriveInput, @r###"
31796- ⋮DeriveInput {
31797- ⋮ vis: Visibility::Restricted {
31798- ⋮ in_token: Some,
31799- ⋮ path: Path {
31800- ⋮ segments: [
31801- ⋮ PathSegment {
31802- ⋮ ident: "super",
31803- ⋮ arguments: None,
31804- ⋮ },
31805- ⋮ ],
31806- ⋮ },
31807- ⋮ },
31808- ⋮ ident: "S",
31809- ⋮ generics: Generics,
31810- ⋮ data: Data::Struct {
31811- ⋮ fields: Unit,
31812- ⋮ semi_token: Some,
31813- ⋮ },
31814- ⋮}
31815+ DeriveInput {
31816+ vis: Visibility::Restricted {
31817+ in_token: Some,
31818+ path: Path {
31819+ segments: [
31820+ PathSegment {
31821+ ident: "super",
31822+ arguments: None,
31823+ },
31824+ ],
31825+ },
31826+ },
31827+ ident: "S",
31828+ generics: Generics,
31829+ data: Data::Struct {
31830+ fields: Unit,
31831+ semi_token: Some,
31832+ },
31833+ }
31834 "###);
31835 }
31836
31837 #[test]
31838 fn test_fields_on_unit_struct() {
31839 let input = quote! {
31840 struct S;
31841 };
31842
31843 snapshot!(input as DeriveInput, @r###"
31844- ⋮DeriveInput {
31845- ⋮ vis: Inherited,
31846- ⋮ ident: "S",
31847- ⋮ generics: Generics,
31848- ⋮ data: Data::Struct {
31849- ⋮ fields: Unit,
31850- ⋮ semi_token: Some,
31851- ⋮ },
31852- ⋮}
31853+ DeriveInput {
31854+ vis: Inherited,
31855+ ident: "S",
31856+ generics: Generics,
31857+ data: Data::Struct {
31858+ fields: Unit,
31859+ semi_token: Some,
31860+ },
31861+ }
31862 "###);
31863
31864 let data = match input.data {
31865 Data::Struct(data) => data,
31866 _ => panic!("expected a struct"),
31867 };
31868
31869 assert_eq!(0, data.fields.iter().count());
31870@@ -683,215 +678,215 @@ fn test_fields_on_named_struct() {
31871 let input = quote! {
31872 struct S {
31873 foo: i32,
31874 pub bar: String,
31875 }
31876 };
31877
31878 snapshot!(input as DeriveInput, @r###"
31879- ⋮DeriveInput {
31880- ⋮ vis: Inherited,
31881- ⋮ ident: "S",
31882- ⋮ generics: Generics,
31883- ⋮ data: Data::Struct {
31884- ⋮ fields: Fields::Named {
31885- ⋮ named: [
31886- ⋮ Field {
31887- ⋮ vis: Inherited,
31888- ⋮ ident: Some("foo"),
31889- ⋮ colon_token: Some,
31890- ⋮ ty: Type::Path {
31891- ⋮ path: Path {
31892- ⋮ segments: [
31893- ⋮ PathSegment {
31894- ⋮ ident: "i32",
31895- ⋮ arguments: None,
31896- ⋮ },
31897- ⋮ ],
31898- ⋮ },
31899- ⋮ },
31900- ⋮ },
31901- ⋮ Field {
31902- ⋮ vis: Visibility::Public,
31903- ⋮ ident: Some("bar"),
31904- ⋮ colon_token: Some,
31905- ⋮ ty: Type::Path {
31906- ⋮ path: Path {
31907- ⋮ segments: [
31908- ⋮ PathSegment {
31909- ⋮ ident: "String",
31910- ⋮ arguments: None,
31911- ⋮ },
31912- ⋮ ],
31913- ⋮ },
31914- ⋮ },
31915- ⋮ },
31916- ⋮ ],
31917- ⋮ },
31918- ⋮ },
31919- ⋮}
31920+ DeriveInput {
31921+ vis: Inherited,
31922+ ident: "S",
31923+ generics: Generics,
31924+ data: Data::Struct {
31925+ fields: Fields::Named {
31926+ named: [
31927+ Field {
31928+ vis: Inherited,
31929+ ident: Some("foo"),
31930+ colon_token: Some,
31931+ ty: Type::Path {
31932+ path: Path {
31933+ segments: [
31934+ PathSegment {
31935+ ident: "i32",
31936+ arguments: None,
31937+ },
31938+ ],
31939+ },
31940+ },
31941+ },
31942+ Field {
31943+ vis: Visibility::Public,
31944+ ident: Some("bar"),
31945+ colon_token: Some,
31946+ ty: Type::Path {
31947+ path: Path {
31948+ segments: [
31949+ PathSegment {
31950+ ident: "String",
31951+ arguments: None,
31952+ },
31953+ ],
31954+ },
31955+ },
31956+ },
31957+ ],
31958+ },
31959+ },
31960+ }
31961 "###);
31962
31963 let data = match input.data {
31964 Data::Struct(data) => data,
31965 _ => panic!("expected a struct"),
31966 };
31967
31968 snapshot!(data.fields.into_iter().collect::<Vec<_>>(), @r###"
31969- ⋮[
31970- ⋮ Field {
31971- ⋮ vis: Inherited,
31972- ⋮ ident: Some("foo"),
31973- ⋮ colon_token: Some,
31974- ⋮ ty: Type::Path {
31975- ⋮ path: Path {
31976- ⋮ segments: [
31977- ⋮ PathSegment {
31978- ⋮ ident: "i32",
31979- ⋮ arguments: None,
31980- ⋮ },
31981- ⋮ ],
31982- ⋮ },
31983- ⋮ },
31984- ⋮ },
31985- ⋮ Field {
31986- ⋮ vis: Visibility::Public,
31987- ⋮ ident: Some("bar"),
31988- ⋮ colon_token: Some,
31989- ⋮ ty: Type::Path {
31990- ⋮ path: Path {
31991- ⋮ segments: [
31992- ⋮ PathSegment {
31993- ⋮ ident: "String",
31994- ⋮ arguments: None,
31995- ⋮ },
31996- ⋮ ],
31997- ⋮ },
31998- ⋮ },
31999- ⋮ },
32000- ⋮]
32001+ [
32002+ Field {
32003+ vis: Inherited,
32004+ ident: Some("foo"),
32005+ colon_token: Some,
32006+ ty: Type::Path {
32007+ path: Path {
32008+ segments: [
32009+ PathSegment {
32010+ ident: "i32",
32011+ arguments: None,
32012+ },
32013+ ],
32014+ },
32015+ },
32016+ },
32017+ Field {
32018+ vis: Visibility::Public,
32019+ ident: Some("bar"),
32020+ colon_token: Some,
32021+ ty: Type::Path {
32022+ path: Path {
32023+ segments: [
32024+ PathSegment {
32025+ ident: "String",
32026+ arguments: None,
32027+ },
32028+ ],
32029+ },
32030+ },
32031+ },
32032+ ]
32033 "###);
32034 }
32035
32036 #[test]
32037 fn test_fields_on_tuple_struct() {
32038 let input = quote! {
32039 struct S(i32, pub String);
32040 };
32041
32042 snapshot!(input as DeriveInput, @r###"
32043- ⋮DeriveInput {
32044- ⋮ vis: Inherited,
32045- ⋮ ident: "S",
32046- ⋮ generics: Generics,
32047- ⋮ data: Data::Struct {
32048- ⋮ fields: Fields::Unnamed {
32049- ⋮ unnamed: [
32050- ⋮ Field {
32051- ⋮ vis: Inherited,
32052- ⋮ ty: Type::Path {
32053- ⋮ path: Path {
32054- ⋮ segments: [
32055- ⋮ PathSegment {
32056- ⋮ ident: "i32",
32057- ⋮ arguments: None,
32058- ⋮ },
32059- ⋮ ],
32060- ⋮ },
32061- ⋮ },
32062- ⋮ },
32063- ⋮ Field {
32064- ⋮ vis: Visibility::Public,
32065- ⋮ ty: Type::Path {
32066- ⋮ path: Path {
32067- ⋮ segments: [
32068- ⋮ PathSegment {
32069- ⋮ ident: "String",
32070- ⋮ arguments: None,
32071- ⋮ },
32072- ⋮ ],
32073- ⋮ },
32074- ⋮ },
32075- ⋮ },
32076- ⋮ ],
32077- ⋮ },
32078- ⋮ semi_token: Some,
32079- ⋮ },
32080- ⋮}
32081+ DeriveInput {
32082+ vis: Inherited,
32083+ ident: "S",
32084+ generics: Generics,
32085+ data: Data::Struct {
32086+ fields: Fields::Unnamed {
32087+ unnamed: [
32088+ Field {
32089+ vis: Inherited,
32090+ ty: Type::Path {
32091+ path: Path {
32092+ segments: [
32093+ PathSegment {
32094+ ident: "i32",
32095+ arguments: None,
32096+ },
32097+ ],
32098+ },
32099+ },
32100+ },
32101+ Field {
32102+ vis: Visibility::Public,
32103+ ty: Type::Path {
32104+ path: Path {
32105+ segments: [
32106+ PathSegment {
32107+ ident: "String",
32108+ arguments: None,
32109+ },
32110+ ],
32111+ },
32112+ },
32113+ },
32114+ ],
32115+ },
32116+ semi_token: Some,
32117+ },
32118+ }
32119 "###);
32120
32121 let data = match input.data {
32122 Data::Struct(data) => data,
32123 _ => panic!("expected a struct"),
32124 };
32125
32126 snapshot!(data.fields.iter().collect::<Vec<_>>(), @r###"
32127- ⋮[
32128- ⋮ Field {
32129- ⋮ vis: Inherited,
32130- ⋮ ty: Type::Path {
32131- ⋮ path: Path {
32132- ⋮ segments: [
32133- ⋮ PathSegment {
32134- ⋮ ident: "i32",
32135- ⋮ arguments: None,
32136- ⋮ },
32137- ⋮ ],
32138- ⋮ },
32139- ⋮ },
32140- ⋮ },
32141- ⋮ Field {
32142- ⋮ vis: Visibility::Public,
32143- ⋮ ty: Type::Path {
32144- ⋮ path: Path {
32145- ⋮ segments: [
32146- ⋮ PathSegment {
32147- ⋮ ident: "String",
32148- ⋮ arguments: None,
32149- ⋮ },
32150- ⋮ ],
32151- ⋮ },
32152- ⋮ },
32153- ⋮ },
32154- ⋮]
32155+ [
32156+ Field {
32157+ vis: Inherited,
32158+ ty: Type::Path {
32159+ path: Path {
32160+ segments: [
32161+ PathSegment {
32162+ ident: "i32",
32163+ arguments: None,
32164+ },
32165+ ],
32166+ },
32167+ },
32168+ },
32169+ Field {
32170+ vis: Visibility::Public,
32171+ ty: Type::Path {
32172+ path: Path {
32173+ segments: [
32174+ PathSegment {
32175+ ident: "String",
32176+ arguments: None,
32177+ },
32178+ ],
32179+ },
32180+ },
32181+ },
32182+ ]
32183 "###);
32184 }
32185
32186 #[test]
32187 fn test_ambiguous_crate() {
32188 let input = quote! {
32189 // The field type is `(crate::X)` not `crate (::X)`.
32190 struct S(crate::X);
32191 };
32192
32193 snapshot!(input as DeriveInput, @r###"
32194- ⋮DeriveInput {
32195- ⋮ vis: Inherited,
32196- ⋮ ident: "S",
32197- ⋮ generics: Generics,
32198- ⋮ data: Data::Struct {
32199- ⋮ fields: Fields::Unnamed {
32200- ⋮ unnamed: [
32201- ⋮ Field {
32202- ⋮ vis: Inherited,
32203- ⋮ ty: Type::Path {
32204- ⋮ path: Path {
32205- ⋮ segments: [
32206- ⋮ PathSegment {
32207- ⋮ ident: "crate",
32208- ⋮ arguments: None,
32209- ⋮ },
32210- ⋮ PathSegment {
32211- ⋮ ident: "X",
32212- ⋮ arguments: None,
32213- ⋮ },
32214- ⋮ ],
32215- ⋮ },
32216- ⋮ },
32217- ⋮ },
32218- ⋮ ],
32219- ⋮ },
32220- ⋮ semi_token: Some,
32221- ⋮ },
32222- ⋮}
32223+ DeriveInput {
32224+ vis: Inherited,
32225+ ident: "S",
32226+ generics: Generics,
32227+ data: Data::Struct {
32228+ fields: Fields::Unnamed {
32229+ unnamed: [
32230+ Field {
32231+ vis: Inherited,
32232+ ty: Type::Path {
32233+ path: Path {
32234+ segments: [
32235+ PathSegment {
32236+ ident: "crate",
32237+ arguments: None,
32238+ },
32239+ PathSegment {
32240+ ident: "X",
32241+ arguments: None,
32242+ },
32243+ ],
32244+ },
32245+ },
32246+ },
32247+ ],
32248+ },
32249+ semi_token: Some,
32250+ },
32251+ }
32252 "###);
32253 }
32254diff --git a/third_party/rust/syn/tests/test_expr.rs b/third_party/rust/syn/tests/test_expr.rs
32255--- a/third_party/rust/syn/tests/test_expr.rs
32256+++ b/third_party/rust/syn/tests/test_expr.rs
32257@@ -1,40 +1,302 @@
32258-extern crate proc_macro2;
32259-extern crate syn;
32260-
32261 #[macro_use]
32262 mod macros;
32263
32264-use std::str::FromStr;
32265-
32266-use proc_macro2::TokenStream;
32267+use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
32268+use quote::quote;
32269+use std::iter::FromIterator;
32270 use syn::{Expr, ExprRange};
32271
32272 #[test]
32273 fn test_expr_parse() {
32274- let code = "..100u32";
32275- let tt = TokenStream::from_str(code).unwrap();
32276- let expr: Expr = syn::parse2(tt.clone()).unwrap();
32277- let expr_range: ExprRange = syn::parse2(tt).unwrap();
32278- assert_eq!(expr, Expr::Range(expr_range));
32279+ let tokens = quote!(..100u32);
32280+ snapshot!(tokens as Expr, @r###"
32281+ Expr::Range {
32282+ limits: HalfOpen,
32283+ to: Some(Expr::Lit {
32284+ lit: 100u32,
32285+ }),
32286+ }
32287+ "###);
32288+
32289+ let tokens = quote!(..100u32);
32290+ snapshot!(tokens as ExprRange, @r###"
32291+ ExprRange {
32292+ limits: HalfOpen,
32293+ to: Some(Expr::Lit {
32294+ lit: 100u32,
32295+ }),
32296+ }
32297+ "###);
32298 }
32299
32300 #[test]
32301 fn test_await() {
32302 // Must not parse as Expr::Field.
32303- let expr = syn::parse_str::<Expr>("fut.await").unwrap();
32304+ let tokens = quote!(fut.await);
32305
32306- snapshot!(expr, @r###"
32307- ⋮Expr::Await {
32308- ⋮ base: Expr::Path {
32309- ⋮ path: Path {
32310- ⋮ segments: [
32311- ⋮ PathSegment {
32312- ⋮ ident: "fut",
32313- ⋮ arguments: None,
32314- ⋮ },
32315- ⋮ ],
32316- ⋮ },
32317- ⋮ },
32318- ⋮}
32319+ snapshot!(tokens as Expr, @r###"
32320+ Expr::Await {
32321+ base: Expr::Path {
32322+ path: Path {
32323+ segments: [
32324+ PathSegment {
32325+ ident: "fut",
32326+ arguments: None,
32327+ },
32328+ ],
32329+ },
32330+ },
32331+ }
32332 "###);
32333 }
32334+
32335+#[rustfmt::skip]
32336+#[test]
32337+fn test_tuple_multi_index() {
32338+ for &input in &[
32339+ "tuple.0.0",
32340+ "tuple .0.0",
32341+ "tuple. 0.0",
32342+ "tuple.0 .0",
32343+ "tuple.0. 0",
32344+ "tuple . 0 . 0",
32345+ ] {
32346+ snapshot!(input as Expr, @r###"
32347+ Expr::Field {
32348+ base: Expr::Field {
32349+ base: Expr::Path {
32350+ path: Path {
32351+ segments: [
32352+ PathSegment {
32353+ ident: "tuple",
32354+ arguments: None,
32355+ },
32356+ ],
32357+ },
32358+ },
32359+ member: Unnamed(Index {
32360+ index: 0,
32361+ }),
32362+ },
32363+ member: Unnamed(Index {
32364+ index: 0,
32365+ }),
32366+ }
32367+ "###);
32368+ }
32369+
32370+ for tokens in vec![
32371+ quote!(tuple.0.0),
32372+ quote!(tuple .0.0),
32373+ quote!(tuple. 0.0),
32374+ quote!(tuple.0 .0),
32375+ quote!(tuple.0. 0),
32376+ quote!(tuple . 0 . 0),
32377+ ] {
32378+ snapshot!(tokens as Expr, @r###"
32379+ Expr::Field {
32380+ base: Expr::Field {
32381+ base: Expr::Path {
32382+ path: Path {
32383+ segments: [
32384+ PathSegment {
32385+ ident: "tuple",
32386+ arguments: None,
32387+ },
32388+ ],
32389+ },
32390+ },
32391+ member: Unnamed(Index {
32392+ index: 0,
32393+ }),
32394+ },
32395+ member: Unnamed(Index {
32396+ index: 0,
32397+ }),
32398+ }
32399+ "###);
32400+ }
32401+}
32402+
32403+#[test]
32404+fn test_macro_variable_func() {
32405+ // mimics the token stream corresponding to `$fn()`
32406+ let tokens = TokenStream::from_iter(vec![
32407+ TokenTree::Group(Group::new(Delimiter::None, quote! { f })),
32408+ TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
32409+ ]);
32410+
32411+ snapshot!(tokens as Expr, @r###"
32412+ Expr::Call {
32413+ func: Expr::Group {
32414+ expr: Expr::Path {
32415+ path: Path {
32416+ segments: [
32417+ PathSegment {
32418+ ident: "f",
32419+ arguments: None,
32420+ },
32421+ ],
32422+ },
32423+ },
32424+ },
32425+ }
32426+ "###);
32427+
32428+ let tokens = TokenStream::from_iter(vec![
32429+ TokenTree::Punct(Punct::new('#', Spacing::Alone)),
32430+ TokenTree::Group(Group::new(Delimiter::Bracket, quote! { outside })),
32431+ TokenTree::Group(Group::new(Delimiter::None, quote! { #[inside] f })),
32432+ TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
32433+ ]);
32434+
32435+ snapshot!(tokens as Expr, @r###"
32436+ Expr::Call {
32437+ attrs: [
32438+ Attribute {
32439+ style: Outer,
32440+ path: Path {
32441+ segments: [
32442+ PathSegment {
32443+ ident: "outside",
32444+ arguments: None,
32445+ },
32446+ ],
32447+ },
32448+ tokens: TokenStream(``),
32449+ },
32450+ ],
32451+ func: Expr::Group {
32452+ expr: Expr::Path {
32453+ attrs: [
32454+ Attribute {
32455+ style: Outer,
32456+ path: Path {
32457+ segments: [
32458+ PathSegment {
32459+ ident: "inside",
32460+ arguments: None,
32461+ },
32462+ ],
32463+ },
32464+ tokens: TokenStream(``),
32465+ },
32466+ ],
32467+ path: Path {
32468+ segments: [
32469+ PathSegment {
32470+ ident: "f",
32471+ arguments: None,
32472+ },
32473+ ],
32474+ },
32475+ },
32476+ },
32477+ }
32478+ "###);
32479+}
32480+
32481+#[test]
32482+fn test_macro_variable_macro() {
32483+ // mimics the token stream corresponding to `$macro!()`
32484+ let tokens = TokenStream::from_iter(vec![
32485+ TokenTree::Group(Group::new(Delimiter::None, quote! { m })),
32486+ TokenTree::Punct(Punct::new('!', Spacing::Alone)),
32487+ TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
32488+ ]);
32489+
32490+ snapshot!(tokens as Expr, @r###"
32491+ Expr::Macro {
32492+ mac: Macro {
32493+ path: Path {
32494+ segments: [
32495+ PathSegment {
32496+ ident: "m",
32497+ arguments: None,
32498+ },
32499+ ],
32500+ },
32501+ delimiter: Paren,
32502+ tokens: TokenStream(``),
32503+ },
32504+ }
32505+ "###);
32506+}
32507+
32508+#[test]
32509+fn test_macro_variable_struct() {
32510+ // mimics the token stream corresponding to `$struct {}`
32511+ let tokens = TokenStream::from_iter(vec![
32512+ TokenTree::Group(Group::new(Delimiter::None, quote! { S })),
32513+ TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())),
32514+ ]);
32515+
32516+ snapshot!(tokens as Expr, @r###"
32517+ Expr::Struct {
32518+ path: Path {
32519+ segments: [
32520+ PathSegment {
32521+ ident: "S",
32522+ arguments: None,
32523+ },
32524+ ],
32525+ },
32526+ }
32527+ "###);
32528+}
32529+
32530+#[test]
32531+fn test_macro_variable_match_arm() {
32532+ // mimics the token stream corresponding to `match v { _ => $expr }`
32533+ let tokens = TokenStream::from_iter(vec![
32534+ TokenTree::Ident(Ident::new("match", Span::call_site())),
32535+ TokenTree::Ident(Ident::new("v", Span::call_site())),
32536+ TokenTree::Group(Group::new(
32537+ Delimiter::Brace,
32538+ TokenStream::from_iter(vec![
32539+ TokenTree::Punct(Punct::new('_', Spacing::Alone)),
32540+ TokenTree::Punct(Punct::new('=', Spacing::Joint)),
32541+ TokenTree::Punct(Punct::new('>', Spacing::Alone)),
32542+ TokenTree::Group(Group::new(Delimiter::None, quote! { #[a] () })),
32543+ ]),
32544+ )),
32545+ ]);
32546+
32547+ snapshot!(tokens as Expr, @r###"
32548+ Expr::Match {
32549+ expr: Expr::Path {
32550+ path: Path {
32551+ segments: [
32552+ PathSegment {
32553+ ident: "v",
32554+ arguments: None,
32555+ },
32556+ ],
32557+ },
32558+ },
32559+ arms: [
32560+ Arm {
32561+ pat: Pat::Wild,
32562+ body: Expr::Group {
32563+ expr: Expr::Tuple {
32564+ attrs: [
32565+ Attribute {
32566+ style: Outer,
32567+ path: Path {
32568+ segments: [
32569+ PathSegment {
32570+ ident: "a",
32571+ arguments: None,
32572+ },
32573+ ],
32574+ },
32575+ tokens: TokenStream(``),
32576+ },
32577+ ],
32578+ },
32579+ },
32580+ },
32581+ ],
32582+ }
32583+ "###);
32584+}
32585diff --git a/third_party/rust/syn/tests/test_generics.rs b/third_party/rust/syn/tests/test_generics.rs
32586--- a/third_party/rust/syn/tests/test_generics.rs
32587+++ b/third_party/rust/syn/tests/test_generics.rs
32588@@ -1,110 +1,105 @@
32589-extern crate quote;
32590-extern crate syn;
32591-
32592-mod features;
32593-
32594 #[macro_use]
32595 mod macros;
32596
32597 use quote::quote;
32598 use syn::{DeriveInput, ItemFn, TypeParamBound, WhereClause, WherePredicate};
32599
32600 #[test]
32601 fn test_split_for_impl() {
32602 let input = quote! {
32603 struct S<'a, 'b: 'a, #[may_dangle] T: 'a = ()> where T: Debug;
32604 };
32605
32606 snapshot!(input as DeriveInput, @r###"
32607- ⋮DeriveInput {
32608- ⋮ vis: Inherited,
32609- ⋮ ident: "S",
32610- ⋮ generics: Generics {
32611- ⋮ lt_token: Some,
32612- ⋮ params: [
32613- ⋮ Lifetime(LifetimeDef {
32614- ⋮ lifetime: Lifetime {
32615- ⋮ ident: "a",
32616- ⋮ },
32617- ⋮ }),
32618- ⋮ Lifetime(LifetimeDef {
32619- ⋮ lifetime: Lifetime {
32620- ⋮ ident: "b",
32621- ⋮ },
32622- ⋮ colon_token: Some,
32623- ⋮ bounds: [
32624- ⋮ Lifetime {
32625- ⋮ ident: "a",
32626- ⋮ },
32627- ⋮ ],
32628- ⋮ }),
32629- ⋮ Type(TypeParam {
32630- ⋮ attrs: [
32631- ⋮ Attribute {
32632- ⋮ style: Outer,
32633- ⋮ path: Path {
32634- ⋮ segments: [
32635- ⋮ PathSegment {
32636- ⋮ ident: "may_dangle",
32637- ⋮ arguments: None,
32638- ⋮ },
32639- ⋮ ],
32640- ⋮ },
32641- ⋮ tokens: ``,
32642- ⋮ },
32643- ⋮ ],
32644- ⋮ ident: "T",
32645- ⋮ colon_token: Some,
32646- ⋮ bounds: [
32647- ⋮ Lifetime(Lifetime {
32648- ⋮ ident: "a",
32649- ⋮ }),
32650- ⋮ ],
32651- ⋮ eq_token: Some,
32652- ⋮ default: Some(Type::Tuple),
32653- ⋮ }),
32654- ⋮ ],
32655- ⋮ gt_token: Some,
32656- ⋮ where_clause: Some(WhereClause {
32657- ⋮ predicates: [
32658- ⋮ Type(PredicateType {
32659- ⋮ bounded_ty: Type::Path {
32660- ⋮ path: Path {
32661- ⋮ segments: [
32662- ⋮ PathSegment {
32663- ⋮ ident: "T",
32664- ⋮ arguments: None,
32665- ⋮ },
32666- ⋮ ],
32667- ⋮ },
32668- ⋮ },
32669- ⋮ bounds: [
32670- ⋮ Trait(TraitBound {
32671- ⋮ modifier: None,
32672- ⋮ path: Path {
32673- ⋮ segments: [
32674- ⋮ PathSegment {
32675- ⋮ ident: "Debug",
32676- ⋮ arguments: None,
32677- ⋮ },
32678- ⋮ ],
32679- ⋮ },
32680- ⋮ }),
32681- ⋮ ],
32682- ⋮ }),
32683- ⋮ ],
32684- ⋮ }),
32685- ⋮ },
32686- ⋮ data: Data::Struct {
32687- ⋮ fields: Unit,
32688- ⋮ semi_token: Some,
32689- ⋮ },
32690- ⋮}
32691+ DeriveInput {
32692+ vis: Inherited,
32693+ ident: "S",
32694+ generics: Generics {
32695+ lt_token: Some,
32696+ params: [
32697+ Lifetime(LifetimeDef {
32698+ lifetime: Lifetime {
32699+ ident: "a",
32700+ },
32701+ }),
32702+ Lifetime(LifetimeDef {
32703+ lifetime: Lifetime {
32704+ ident: "b",
32705+ },
32706+ colon_token: Some,
32707+ bounds: [
32708+ Lifetime {
32709+ ident: "a",
32710+ },
32711+ ],
32712+ }),
32713+ Type(TypeParam {
32714+ attrs: [
32715+ Attribute {
32716+ style: Outer,
32717+ path: Path {
32718+ segments: [
32719+ PathSegment {
32720+ ident: "may_dangle",
32721+ arguments: None,
32722+ },
32723+ ],
32724+ },
32725+ tokens: TokenStream(``),
32726+ },
32727+ ],
32728+ ident: "T",
32729+ colon_token: Some,
32730+ bounds: [
32731+ Lifetime(Lifetime {
32732+ ident: "a",
32733+ }),
32734+ ],
32735+ eq_token: Some,
32736+ default: Some(Type::Tuple),
32737+ }),
32738+ ],
32739+ gt_token: Some,
32740+ where_clause: Some(WhereClause {
32741+ predicates: [
32742+ Type(PredicateType {
32743+ bounded_ty: Type::Path {
32744+ path: Path {
32745+ segments: [
32746+ PathSegment {
32747+ ident: "T",
32748+ arguments: None,
32749+ },
32750+ ],
32751+ },
32752+ },
32753+ bounds: [
32754+ Trait(TraitBound {
32755+ modifier: None,
32756+ path: Path {
32757+ segments: [
32758+ PathSegment {
32759+ ident: "Debug",
32760+ arguments: None,
32761+ },
32762+ ],
32763+ },
32764+ }),
32765+ ],
32766+ }),
32767+ ],
32768+ }),
32769+ },
32770+ data: Data::Struct {
32771+ fields: Unit,
32772+ semi_token: Some,
32773+ },
32774+ }
32775 "###);
32776
32777 let generics = input.generics;
32778 let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
32779
32780 let generated = quote! {
32781 impl #impl_generics MyTrait for Test #ty_generics #where_clause {}
32782 };
32783@@ -126,156 +121,156 @@ fn test_split_for_impl() {
32784 };
32785 assert_eq!(generated.to_string(), expected.to_string());
32786 }
32787
32788 #[test]
32789 fn test_ty_param_bound() {
32790 let tokens = quote!('a);
32791 snapshot!(tokens as TypeParamBound, @r###"
32792- ⋮Lifetime(Lifetime {
32793- ⋮ ident: "a",
32794- ⋮})
32795+ Lifetime(Lifetime {
32796+ ident: "a",
32797+ })
32798 "###);
32799
32800 let tokens = quote!('_);
32801 snapshot!(tokens as TypeParamBound, @r###"
32802- ⋮Lifetime(Lifetime {
32803- ⋮ ident: "_",
32804- ⋮})
32805+ Lifetime(Lifetime {
32806+ ident: "_",
32807+ })
32808 "###);
32809
32810 let tokens = quote!(Debug);
32811 snapshot!(tokens as TypeParamBound, @r###"
32812- ⋮Trait(TraitBound {
32813- ⋮ modifier: None,
32814- ⋮ path: Path {
32815- ⋮ segments: [
32816- ⋮ PathSegment {
32817- ⋮ ident: "Debug",
32818- ⋮ arguments: None,
32819- ⋮ },
32820- ⋮ ],
32821- ⋮ },
32822- ⋮})
32823+ Trait(TraitBound {
32824+ modifier: None,
32825+ path: Path {
32826+ segments: [
32827+ PathSegment {
32828+ ident: "Debug",
32829+ arguments: None,
32830+ },
32831+ ],
32832+ },
32833+ })
32834 "###);
32835
32836 let tokens = quote!(?Sized);
32837 snapshot!(tokens as TypeParamBound, @r###"
32838- ⋮Trait(TraitBound {
32839- ⋮ modifier: Maybe,
32840- ⋮ path: Path {
32841- ⋮ segments: [
32842- ⋮ PathSegment {
32843- ⋮ ident: "Sized",
32844- ⋮ arguments: None,
32845- ⋮ },
32846- ⋮ ],
32847- ⋮ },
32848- ⋮})
32849+ Trait(TraitBound {
32850+ modifier: Maybe,
32851+ path: Path {
32852+ segments: [
32853+ PathSegment {
32854+ ident: "Sized",
32855+ arguments: None,
32856+ },
32857+ ],
32858+ },
32859+ })
32860 "###);
32861 }
32862
32863 #[test]
32864 fn test_fn_precedence_in_where_clause() {
32865 // This should parse as two separate bounds, `FnOnce() -> i32` and `Send` - not
32866 // `FnOnce() -> (i32 + Send)`.
32867 let input = quote! {
32868 fn f<G>()
32869 where
32870 G: FnOnce() -> i32 + Send,
32871 {
32872 }
32873 };
32874
32875 snapshot!(input as ItemFn, @r###"
32876- ⋮ItemFn {
32877- ⋮ vis: Inherited,
32878- ⋮ sig: Signature {
32879- ⋮ ident: "f",
32880- ⋮ generics: Generics {
32881- ⋮ lt_token: Some,
32882- ⋮ params: [
32883- ⋮ Type(TypeParam {
32884- ⋮ ident: "G",
32885- ⋮ }),
32886- ⋮ ],
32887- ⋮ gt_token: Some,
32888- ⋮ where_clause: Some(WhereClause {
32889- ⋮ predicates: [
32890- ⋮ Type(PredicateType {
32891- ⋮ bounded_ty: Type::Path {
32892- ⋮ path: Path {
32893- ⋮ segments: [
32894- ⋮ PathSegment {
32895- ⋮ ident: "G",
32896- ⋮ arguments: None,
32897- ⋮ },
32898- ⋮ ],
32899- ⋮ },
32900- ⋮ },
32901- ⋮ bounds: [
32902- ⋮ Trait(TraitBound {
32903- ⋮ modifier: None,
32904- ⋮ path: Path {
32905- ⋮ segments: [
32906- ⋮ PathSegment {
32907- ⋮ ident: "FnOnce",
32908- ⋮ arguments: PathArguments::Parenthesized {
32909- ⋮ output: Type(
32910- ⋮ Type::Path {
32911- ⋮ path: Path {
32912- ⋮ segments: [
32913- ⋮ PathSegment {
32914- ⋮ ident: "i32",
32915- ⋮ arguments: None,
32916- ⋮ },
32917- ⋮ ],
32918- ⋮ },
32919- ⋮ },
32920- ⋮ ),
32921- ⋮ },
32922- ⋮ },
32923- ⋮ ],
32924- ⋮ },
32925- ⋮ }),
32926- ⋮ Trait(TraitBound {
32927- ⋮ modifier: None,
32928- ⋮ path: Path {
32929- ⋮ segments: [
32930- ⋮ PathSegment {
32931- ⋮ ident: "Send",
32932- ⋮ arguments: None,
32933- ⋮ },
32934- ⋮ ],
32935- ⋮ },
32936- ⋮ }),
32937- ⋮ ],
32938- ⋮ }),
32939- ⋮ ],
32940- ⋮ }),
32941- ⋮ },
32942- ⋮ output: Default,
32943- ⋮ },
32944- ⋮ block: Block,
32945- ⋮}
32946+ ItemFn {
32947+ vis: Inherited,
32948+ sig: Signature {
32949+ ident: "f",
32950+ generics: Generics {
32951+ lt_token: Some,
32952+ params: [
32953+ Type(TypeParam {
32954+ ident: "G",
32955+ }),
32956+ ],
32957+ gt_token: Some,
32958+ where_clause: Some(WhereClause {
32959+ predicates: [
32960+ Type(PredicateType {
32961+ bounded_ty: Type::Path {
32962+ path: Path {
32963+ segments: [
32964+ PathSegment {
32965+ ident: "G",
32966+ arguments: None,
32967+ },
32968+ ],
32969+ },
32970+ },
32971+ bounds: [
32972+ Trait(TraitBound {
32973+ modifier: None,
32974+ path: Path {
32975+ segments: [
32976+ PathSegment {
32977+ ident: "FnOnce",
32978+ arguments: PathArguments::Parenthesized {
32979+ output: Type(
32980+ Type::Path {
32981+ path: Path {
32982+ segments: [
32983+ PathSegment {
32984+ ident: "i32",
32985+ arguments: None,
32986+ },
32987+ ],
32988+ },
32989+ },
32990+ ),
32991+ },
32992+ },
32993+ ],
32994+ },
32995+ }),
32996+ Trait(TraitBound {
32997+ modifier: None,
32998+ path: Path {
32999+ segments: [
33000+ PathSegment {
33001+ ident: "Send",
33002+ arguments: None,
33003+ },
33004+ ],
33005+ },
33006+ }),
33007+ ],
33008+ }),
33009+ ],
33010+ }),
33011+ },
33012+ output: Default,
33013+ },
33014+ block: Block,
33015+ }
33016 "###);
33017
33018 let where_clause = input.sig.generics.where_clause.as_ref().unwrap();
33019 assert_eq!(where_clause.predicates.len(), 1);
33020
33021 let predicate = match &where_clause.predicates[0] {
33022 WherePredicate::Type(pred) => pred,
33023 _ => panic!("wrong predicate kind"),
33024 };
33025
33026 assert_eq!(predicate.bounds.len(), 2, "{:#?}", predicate.bounds);
33027
33028 let first_bound = &predicate.bounds[0];
33029- assert_eq!(quote!(#first_bound).to_string(), "FnOnce ( ) -> i32");
33030+ assert_eq!(quote!(#first_bound).to_string(), "FnOnce () -> i32");
33031
33032 let second_bound = &predicate.bounds[1];
33033 assert_eq!(quote!(#second_bound).to_string(), "Send");
33034 }
33035
33036 #[test]
33037 fn test_where_clause_at_end_of_input() {
33038 let input = quote! {
33039diff --git a/third_party/rust/syn/tests/test_grouping.rs b/third_party/rust/syn/tests/test_grouping.rs
33040--- a/third_party/rust/syn/tests/test_grouping.rs
33041+++ b/third_party/rust/syn/tests/test_grouping.rs
33042@@ -1,13 +1,8 @@
33043-extern crate proc_macro2;
33044-extern crate syn;
33045-
33046-mod features;
33047-
33048 #[macro_use]
33049 mod macros;
33050
33051 use proc_macro2::{Delimiter, Group, Literal, Punct, Spacing, TokenStream, TokenTree};
33052 use syn::Expr;
33053
33054 use std::iter::FromIterator;
33055
33056@@ -23,36 +18,36 @@ fn test_grouping() {
33057 TokenTree::Punct(Punct::new('+', Spacing::Alone)),
33058 TokenTree::Literal(Literal::i32_suffixed(3)),
33059 ]),
33060 )),
33061 TokenTree::Punct(Punct::new('*', Spacing::Alone)),
33062 TokenTree::Literal(Literal::i32_suffixed(4)),
33063 ]);
33064
33065- assert_eq!(tokens.to_string(), "1i32 + 2i32 + 3i32 * 4i32");
33066+ assert_eq!(tokens.to_string(), "1i32 + 2i32 + 3i32 * 4i32");
33067
33068 snapshot!(tokens as Expr, @r###"
33069- ⋮Expr::Binary {
33070- ⋮ left: Expr::Lit {
33071- ⋮ lit: 1i32,
33072- ⋮ },
33073- ⋮ op: Add,
33074- ⋮ right: Expr::Binary {
33075- ⋮ left: Expr::Group {
33076- ⋮ expr: Expr::Binary {
33077- ⋮ left: Expr::Lit {
33078- ⋮ lit: 2i32,
33079- ⋮ },
33080- ⋮ op: Add,
33081- ⋮ right: Expr::Lit {
33082- ⋮ lit: 3i32,
33083- ⋮ },
33084- ⋮ },
33085- ⋮ },
33086- ⋮ op: Mul,
33087- ⋮ right: Expr::Lit {
33088- ⋮ lit: 4i32,
33089- ⋮ },
33090- ⋮ },
33091- ⋮}
33092+ Expr::Binary {
33093+ left: Expr::Lit {
33094+ lit: 1i32,
33095+ },
33096+ op: Add,
33097+ right: Expr::Binary {
33098+ left: Expr::Group {
33099+ expr: Expr::Binary {
33100+ left: Expr::Lit {
33101+ lit: 2i32,
33102+ },
33103+ op: Add,
33104+ right: Expr::Lit {
33105+ lit: 3i32,
33106+ },
33107+ },
33108+ },
33109+ op: Mul,
33110+ right: Expr::Lit {
33111+ lit: 4i32,
33112+ },
33113+ },
33114+ }
33115 "###);
33116 }
33117diff --git a/third_party/rust/syn/tests/test_ident.rs b/third_party/rust/syn/tests/test_ident.rs
33118--- a/third_party/rust/syn/tests/test_ident.rs
33119+++ b/third_party/rust/syn/tests/test_ident.rs
33120@@ -1,13 +1,8 @@
33121-extern crate proc_macro2;
33122-extern crate syn;
33123-
33124-mod features;
33125-
33126 use proc_macro2::{Ident, Span, TokenStream};
33127 use std::str::FromStr;
33128 use syn::Result;
33129
33130 fn parse(s: &str) -> Result<Ident> {
33131 syn::parse2(TokenStream::from_str(s).unwrap())
33132 }
33133
33134diff --git a/third_party/rust/syn/tests/test_item.rs b/third_party/rust/syn/tests/test_item.rs
33135new file mode 100644
33136--- /dev/null
33137+++ b/third_party/rust/syn/tests/test_item.rs
33138@@ -0,0 +1,45 @@
33139+#[macro_use]
33140+mod macros;
33141+
33142+use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
33143+use quote::quote;
33144+use std::iter::FromIterator;
33145+use syn::Item;
33146+
33147+#[test]
33148+fn test_macro_variable_attr() {
33149+ // mimics the token stream corresponding to `$attr fn f() {}`
33150+ let tokens = TokenStream::from_iter(vec![
33151+ TokenTree::Group(Group::new(Delimiter::None, quote! { #[test] })),
33152+ TokenTree::Ident(Ident::new("fn", Span::call_site())),
33153+ TokenTree::Ident(Ident::new("f", Span::call_site())),
33154+ TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
33155+ TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())),
33156+ ]);
33157+
33158+ snapshot!(tokens as Item, @r###"
33159+ Item::Fn {
33160+ attrs: [
33161+ Attribute {
33162+ style: Outer,
33163+ path: Path {
33164+ segments: [
33165+ PathSegment {
33166+ ident: "test",
33167+ arguments: None,
33168+ },
33169+ ],
33170+ },
33171+ tokens: TokenStream(``),
33172+ },
33173+ ],
33174+ vis: Inherited,
33175+ sig: Signature {
33176+ ident: "f",
33177+ generics: Generics,
33178+ output: Default,
33179+ },
33180+ block: Block,
33181+ }
33182+ "###);
33183+}
33184diff --git a/third_party/rust/syn/tests/test_iterators.rs b/third_party/rust/syn/tests/test_iterators.rs
33185--- a/third_party/rust/syn/tests/test_iterators.rs
33186+++ b/third_party/rust/syn/tests/test_iterators.rs
33187@@ -1,15 +1,10 @@
33188 use syn::punctuated::{Pair, Punctuated};
33189-
33190-extern crate quote;
33191-#[macro_use]
33192-extern crate syn;
33193-
33194-mod features;
33195+use syn::Token;
33196
33197 #[macro_use]
33198 mod macros;
33199
33200 macro_rules! check_exact_size_iterator {
33201 ($iter:expr) => {{
33202 let iter = $iter;
33203 let size_hint = iter.size_hint();
33204diff --git a/third_party/rust/syn/tests/test_lit.rs b/third_party/rust/syn/tests/test_lit.rs
33205--- a/third_party/rust/syn/tests/test_lit.rs
33206+++ b/third_party/rust/syn/tests/test_lit.rs
33207@@ -1,18 +1,16 @@
33208-extern crate proc_macro2;
33209-extern crate quote;
33210-extern crate syn;
33211+#[macro_use]
33212+mod macros;
33213
33214-mod features;
33215-
33216-use proc_macro2::{TokenStream, TokenTree};
33217+use proc_macro2::{Delimiter, Group, Literal, Span, TokenStream, TokenTree};
33218 use quote::ToTokens;
33219+use std::iter::FromIterator;
33220 use std::str::FromStr;
33221-use syn::Lit;
33222+use syn::{Lit, LitFloat, LitInt};
33223
33224 fn lit(s: &str) -> Lit {
33225 match TokenStream::from_str(s)
33226 .unwrap()
33227 .into_iter()
33228 .next()
33229 .unwrap()
33230 {
33231@@ -45,16 +43,19 @@ fn strings() {
33232 test_string("\"'\"", "'");
33233 test_string("\"\"", "");
33234 test_string("\"\\u{1F415}\"", "\u{1F415}");
33235 test_string(
33236 "\"contains\nnewlines\\\nescaped newlines\"",
33237 "contains\nnewlinesescaped newlines",
33238 );
33239 test_string("r\"raw\nstring\\\nhere\"", "raw\nstring\\\nhere");
33240+ test_string("\"...\"q", "...");
33241+ test_string("r\"...\"q", "...");
33242+ test_string("r##\"...\"##q", "...");
33243 }
33244
33245 #[test]
33246 fn byte_strings() {
33247 fn test_byte_string(s: &str, value: &[u8]) {
33248 match lit(s) {
33249 Lit::ByteStr(lit) => {
33250 assert_eq!(lit.value(), value);
33251@@ -74,16 +75,19 @@ fn byte_strings() {
33252 test_byte_string("b\"\\\"\"", b"\"");
33253 test_byte_string("b\"'\"", b"'");
33254 test_byte_string("b\"\"", b"");
33255 test_byte_string(
33256 "b\"contains\nnewlines\\\nescaped newlines\"",
33257 b"contains\nnewlinesescaped newlines",
33258 );
33259 test_byte_string("br\"raw\nstring\\\nhere\"", b"raw\nstring\\\nhere");
33260+ test_byte_string("b\"...\"q", b"...");
33261+ test_byte_string("br\"...\"q", b"...");
33262+ test_byte_string("br##\"...\"##q", b"...");
33263 }
33264
33265 #[test]
33266 fn bytes() {
33267 fn test_byte(s: &str, value: u8) {
33268 match lit(s) {
33269 Lit::Byte(lit) => {
33270 assert_eq!(lit.value(), value);
33271@@ -95,16 +99,17 @@ fn bytes() {
33272 }
33273
33274 test_byte("b'a'", b'a');
33275 test_byte("b'\\n'", b'\n');
33276 test_byte("b'\\r'", b'\r');
33277 test_byte("b'\\t'", b'\t');
33278 test_byte("b'\\''", b'\'');
33279 test_byte("b'\"'", b'"');
33280+ test_byte("b'a'q", b'a');
33281 }
33282
33283 #[test]
33284 fn chars() {
33285 fn test_char(s: &str, value: char) {
33286 match lit(s) {
33287 Lit::Char(lit) => {
33288 assert_eq!(lit.value(), value);
33289@@ -120,16 +125,17 @@ fn chars() {
33290 test_char("'a'", 'a');
33291 test_char("'\\n'", '\n');
33292 test_char("'\\r'", '\r');
33293 test_char("'\\t'", '\t');
33294 test_char("'🐕'", '🐕'); // NOTE: This is an emoji
33295 test_char("'\\''", '\'');
33296 test_char("'\"'", '"');
33297 test_char("'\\u{1F415}'", '\u{1F415}');
33298+ test_char("'a'q", 'a');
33299 }
33300
33301 #[test]
33302 fn ints() {
33303 fn test_int(s: &str, value: u64, suffix: &str) {
33304 match lit(s) {
33305 Lit::Int(lit) => {
33306 assert_eq!(lit.base10_digits().parse::<u64>().unwrap(), value);
33307@@ -180,9 +186,64 @@ fn floats() {
33308 }
33309 }
33310
33311 test_float("5.5", 5.5, "");
33312 test_float("5.5E12", 5.5e12, "");
33313 test_float("5.5e12", 5.5e12, "");
33314 test_float("1.0__3e-12", 1.03e-12, "");
33315 test_float("1.03e+12", 1.03e12, "");
33316+ test_float("9e99e99", 9e99, "e99");
33317 }
33318+
33319+#[test]
33320+fn negative() {
33321+ let span = Span::call_site();
33322+ assert_eq!("-1", LitInt::new("-1", span).to_string());
33323+ assert_eq!("-1i8", LitInt::new("-1i8", span).to_string());
33324+ assert_eq!("-1i16", LitInt::new("-1i16", span).to_string());
33325+ assert_eq!("-1i32", LitInt::new("-1i32", span).to_string());
33326+ assert_eq!("-1i64", LitInt::new("-1i64", span).to_string());
33327+ assert_eq!("-1.5", LitFloat::new("-1.5", span).to_string());
33328+ assert_eq!("-1.5f32", LitFloat::new("-1.5f32", span).to_string());
33329+ assert_eq!("-1.5f64", LitFloat::new("-1.5f64", span).to_string());
33330+}
33331+
33332+#[test]
33333+fn suffix() {
33334+ fn get_suffix(token: &str) -> String {
33335+ let lit = syn::parse_str::<Lit>(token).unwrap();
33336+ match lit {
33337+ Lit::Str(lit) => lit.suffix().to_owned(),
33338+ Lit::ByteStr(lit) => lit.suffix().to_owned(),
33339+ Lit::Byte(lit) => lit.suffix().to_owned(),
33340+ Lit::Char(lit) => lit.suffix().to_owned(),
33341+ Lit::Int(lit) => lit.suffix().to_owned(),
33342+ Lit::Float(lit) => lit.suffix().to_owned(),
33343+ _ => unimplemented!(),
33344+ }
33345+ }
33346+
33347+ assert_eq!(get_suffix("\"\"s"), "s");
33348+ assert_eq!(get_suffix("r\"\"r"), "r");
33349+ assert_eq!(get_suffix("b\"\"b"), "b");
33350+ assert_eq!(get_suffix("br\"\"br"), "br");
33351+ assert_eq!(get_suffix("r#\"\"#r"), "r");
33352+ assert_eq!(get_suffix("'c'c"), "c");
33353+ assert_eq!(get_suffix("b'b'b"), "b");
33354+ assert_eq!(get_suffix("1i32"), "i32");
33355+ assert_eq!(get_suffix("1_i32"), "i32");
33356+ assert_eq!(get_suffix("1.0f32"), "f32");
33357+ assert_eq!(get_suffix("1.0_f32"), "f32");
33358+}
33359+
33360+#[test]
33361+fn test_deep_group_empty() {
33362+ let tokens = TokenStream::from_iter(vec![TokenTree::Group(Group::new(
33363+ Delimiter::None,
33364+ TokenStream::from_iter(vec![TokenTree::Group(Group::new(
33365+ Delimiter::None,
33366+ TokenStream::from_iter(vec![TokenTree::Literal(Literal::string("hi"))]),
33367+ ))]),
33368+ ))]);
33369+
33370+ snapshot!(tokens as Lit, @r#""hi""# );
33371+}
33372diff --git a/third_party/rust/syn/tests/test_meta.rs b/third_party/rust/syn/tests/test_meta.rs
33373--- a/third_party/rust/syn/tests/test_meta.rs
33374+++ b/third_party/rust/syn/tests/test_meta.rs
33375@@ -1,343 +1,339 @@
33376-extern crate syn;
33377-
33378-mod features;
33379-
33380 #[macro_use]
33381 mod macros;
33382
33383 use syn::{Meta, MetaList, MetaNameValue, NestedMeta};
33384
33385 #[test]
33386 fn test_parse_meta_item_word() {
33387 let input = "hello";
33388
33389 snapshot!(input as Meta, @r###"
33390- ⋮Path(Path {
33391- ⋮ segments: [
33392- ⋮ PathSegment {
33393- ⋮ ident: "hello",
33394- ⋮ arguments: None,
33395- ⋮ },
33396- ⋮ ],
33397- ⋮})
33398+ Path(Path {
33399+ segments: [
33400+ PathSegment {
33401+ ident: "hello",
33402+ arguments: None,
33403+ },
33404+ ],
33405+ })
33406 "###);
33407 }
33408
33409 #[test]
33410 fn test_parse_meta_name_value() {
33411 let input = "foo = 5";
33412 let (inner, meta) = (input, input);
33413
33414 snapshot!(inner as MetaNameValue, @r###"
33415- ⋮MetaNameValue {
33416- ⋮ path: Path {
33417- ⋮ segments: [
33418- ⋮ PathSegment {
33419- ⋮ ident: "foo",
33420- ⋮ arguments: None,
33421- ⋮ },
33422- ⋮ ],
33423- ⋮ },
33424- ⋮ lit: 5,
33425- ⋮}
33426+ MetaNameValue {
33427+ path: Path {
33428+ segments: [
33429+ PathSegment {
33430+ ident: "foo",
33431+ arguments: None,
33432+ },
33433+ ],
33434+ },
33435+ lit: 5,
33436+ }
33437 "###);
33438
33439 snapshot!(meta as Meta, @r###"
33440- ⋮Meta::NameValue {
33441- ⋮ path: Path {
33442- ⋮ segments: [
33443- ⋮ PathSegment {
33444- ⋮ ident: "foo",
33445- ⋮ arguments: None,
33446- ⋮ },
33447- ⋮ ],
33448- ⋮ },
33449- ⋮ lit: 5,
33450- ⋮}
33451+ Meta::NameValue {
33452+ path: Path {
33453+ segments: [
33454+ PathSegment {
33455+ ident: "foo",
33456+ arguments: None,
33457+ },
33458+ ],
33459+ },
33460+ lit: 5,
33461+ }
33462 "###);
33463
33464 assert_eq!(meta, inner.into());
33465 }
33466
33467 #[test]
33468 fn test_parse_meta_name_value_with_keyword() {
33469 let input = "static = 5";
33470 let (inner, meta) = (input, input);
33471
33472 snapshot!(inner as MetaNameValue, @r###"
33473- ⋮MetaNameValue {
33474- ⋮ path: Path {
33475- ⋮ segments: [
33476- ⋮ PathSegment {
33477- ⋮ ident: "static",
33478- ⋮ arguments: None,
33479- ⋮ },
33480- ⋮ ],
33481- ⋮ },
33482- ⋮ lit: 5,
33483- ⋮}
33484+ MetaNameValue {
33485+ path: Path {
33486+ segments: [
33487+ PathSegment {
33488+ ident: "static",
33489+ arguments: None,
33490+ },
33491+ ],
33492+ },
33493+ lit: 5,
33494+ }
33495 "###);
33496
33497 snapshot!(meta as Meta, @r###"
33498- ⋮Meta::NameValue {
33499- ⋮ path: Path {
33500- ⋮ segments: [
33501- ⋮ PathSegment {
33502- ⋮ ident: "static",
33503- ⋮ arguments: None,
33504- ⋮ },
33505- ⋮ ],
33506- ⋮ },
33507- ⋮ lit: 5,
33508- ⋮}
33509+ Meta::NameValue {
33510+ path: Path {
33511+ segments: [
33512+ PathSegment {
33513+ ident: "static",
33514+ arguments: None,
33515+ },
33516+ ],
33517+ },
33518+ lit: 5,
33519+ }
33520 "###);
33521
33522 assert_eq!(meta, inner.into());
33523 }
33524
33525 #[test]
33526 fn test_parse_meta_name_value_with_bool() {
33527 let input = "true = 5";
33528 let (inner, meta) = (input, input);
33529
33530 snapshot!(inner as MetaNameValue, @r###"
33531- ⋮MetaNameValue {
33532- ⋮ path: Path {
33533- ⋮ segments: [
33534- ⋮ PathSegment {
33535- ⋮ ident: "true",
33536- ⋮ arguments: None,
33537- ⋮ },
33538- ⋮ ],
33539- ⋮ },
33540- ⋮ lit: 5,
33541- ⋮}
33542+ MetaNameValue {
33543+ path: Path {
33544+ segments: [
33545+ PathSegment {
33546+ ident: "true",
33547+ arguments: None,
33548+ },
33549+ ],
33550+ },
33551+ lit: 5,
33552+ }
33553 "###);
33554
33555 snapshot!(meta as Meta, @r###"
33556- ⋮Meta::NameValue {
33557- ⋮ path: Path {
33558- ⋮ segments: [
33559- ⋮ PathSegment {
33560- ⋮ ident: "true",
33561- ⋮ arguments: None,
33562- ⋮ },
33563- ⋮ ],
33564- ⋮ },
33565- ⋮ lit: 5,
33566- ⋮}
33567+ Meta::NameValue {
33568+ path: Path {
33569+ segments: [
33570+ PathSegment {
33571+ ident: "true",
33572+ arguments: None,
33573+ },
33574+ ],
33575+ },
33576+ lit: 5,
33577+ }
33578 "###);
33579
33580 assert_eq!(meta, inner.into());
33581 }
33582
33583 #[test]
33584 fn test_parse_meta_item_list_lit() {
33585 let input = "foo(5)";
33586 let (inner, meta) = (input, input);
33587
33588 snapshot!(inner as MetaList, @r###"
33589- ⋮MetaList {
33590- ⋮ path: Path {
33591- ⋮ segments: [
33592- ⋮ PathSegment {
33593- ⋮ ident: "foo",
33594- ⋮ arguments: None,
33595- ⋮ },
33596- ⋮ ],
33597- ⋮ },
33598- ⋮ nested: [
33599- ⋮ Lit(5),
33600- ⋮ ],
33601- ⋮}
33602+ MetaList {
33603+ path: Path {
33604+ segments: [
33605+ PathSegment {
33606+ ident: "foo",
33607+ arguments: None,
33608+ },
33609+ ],
33610+ },
33611+ nested: [
33612+ Lit(5),
33613+ ],
33614+ }
33615 "###);
33616
33617 snapshot!(meta as Meta, @r###"
33618- ⋮Meta::List {
33619- ⋮ path: Path {
33620- ⋮ segments: [
33621- ⋮ PathSegment {
33622- ⋮ ident: "foo",
33623- ⋮ arguments: None,
33624- ⋮ },
33625- ⋮ ],
33626- ⋮ },
33627- ⋮ nested: [
33628- ⋮ Lit(5),
33629- ⋮ ],
33630- ⋮}
33631+ Meta::List {
33632+ path: Path {
33633+ segments: [
33634+ PathSegment {
33635+ ident: "foo",
33636+ arguments: None,
33637+ },
33638+ ],
33639+ },
33640+ nested: [
33641+ Lit(5),
33642+ ],
33643+ }
33644 "###);
33645
33646 assert_eq!(meta, inner.into());
33647 }
33648
33649 #[test]
33650 fn test_parse_meta_item_multiple() {
33651 let input = "foo(word, name = 5, list(name2 = 6), word2)";
33652 let (inner, meta) = (input, input);
33653
33654 snapshot!(inner as MetaList, @r###"
33655- ⋮MetaList {
33656- ⋮ path: Path {
33657- ⋮ segments: [
33658- ⋮ PathSegment {
33659- ⋮ ident: "foo",
33660- ⋮ arguments: None,
33661- ⋮ },
33662- ⋮ ],
33663- ⋮ },
33664- ⋮ nested: [
33665- ⋮ Meta(Path(Path {
33666- ⋮ segments: [
33667- ⋮ PathSegment {
33668- ⋮ ident: "word",
33669- ⋮ arguments: None,
33670- ⋮ },
33671- ⋮ ],
33672- ⋮ })),
33673- ⋮ Meta(Meta::NameValue {
33674- ⋮ path: Path {
33675- ⋮ segments: [
33676- ⋮ PathSegment {
33677- ⋮ ident: "name",
33678- ⋮ arguments: None,
33679- ⋮ },
33680- ⋮ ],
33681- ⋮ },
33682- ⋮ lit: 5,
33683- ⋮ }),
33684- ⋮ Meta(Meta::List {
33685- ⋮ path: Path {
33686- ⋮ segments: [
33687- ⋮ PathSegment {
33688- ⋮ ident: "list",
33689- ⋮ arguments: None,
33690- ⋮ },
33691- ⋮ ],
33692- ⋮ },
33693- ⋮ nested: [
33694- ⋮ Meta(Meta::NameValue {
33695- ⋮ path: Path {
33696- ⋮ segments: [
33697- ⋮ PathSegment {
33698- ⋮ ident: "name2",
33699- ⋮ arguments: None,
33700- ⋮ },
33701- ⋮ ],
33702- ⋮ },
33703- ⋮ lit: 6,
33704- ⋮ }),
33705- ⋮ ],
33706- ⋮ }),
33707- ⋮ Meta(Path(Path {
33708- ⋮ segments: [
33709- ⋮ PathSegment {
33710- ⋮ ident: "word2",
33711- ⋮ arguments: None,
33712- ⋮ },
33713- ⋮ ],
33714- ⋮ })),
33715- ⋮ ],
33716- ⋮}
33717+ MetaList {
33718+ path: Path {
33719+ segments: [
33720+ PathSegment {
33721+ ident: "foo",
33722+ arguments: None,
33723+ },
33724+ ],
33725+ },
33726+ nested: [
33727+ Meta(Path(Path {
33728+ segments: [
33729+ PathSegment {
33730+ ident: "word",
33731+ arguments: None,
33732+ },
33733+ ],
33734+ })),
33735+ Meta(Meta::NameValue {
33736+ path: Path {
33737+ segments: [
33738+ PathSegment {
33739+ ident: "name",
33740+ arguments: None,
33741+ },
33742+ ],
33743+ },
33744+ lit: 5,
33745+ }),
33746+ Meta(Meta::List {
33747+ path: Path {
33748+ segments: [
33749+ PathSegment {
33750+ ident: "list",
33751+ arguments: None,
33752+ },
33753+ ],
33754+ },
33755+ nested: [
33756+ Meta(Meta::NameValue {
33757+ path: Path {
33758+ segments: [
33759+ PathSegment {
33760+ ident: "name2",
33761+ arguments: None,
33762+ },
33763+ ],
33764+ },
33765+ lit: 6,
33766+ }),
33767+ ],
33768+ }),
33769+ Meta(Path(Path {
33770+ segments: [
33771+ PathSegment {
33772+ ident: "word2",
33773+ arguments: None,
33774+ },
33775+ ],
33776+ })),
33777+ ],
33778+ }
33779 "###);
33780
33781 snapshot!(meta as Meta, @r###"
33782- ⋮Meta::List {
33783- ⋮ path: Path {
33784- ⋮ segments: [
33785- ⋮ PathSegment {
33786- ⋮ ident: "foo",
33787- ⋮ arguments: None,
33788- ⋮ },
33789- ⋮ ],
33790- ⋮ },
33791- ⋮ nested: [
33792- ⋮ Meta(Path(Path {
33793- ⋮ segments: [
33794- ⋮ PathSegment {
33795- ⋮ ident: "word",
33796- ⋮ arguments: None,
33797- ⋮ },
33798- ⋮ ],
33799- ⋮ })),
33800- ⋮ Meta(Meta::NameValue {
33801- ⋮ path: Path {
33802- ⋮ segments: [
33803- ⋮ PathSegment {
33804- ⋮ ident: "name",
33805- ⋮ arguments: None,
33806- ⋮ },
33807- ⋮ ],
33808- ⋮ },
33809- ⋮ lit: 5,
33810- ⋮ }),
33811- ⋮ Meta(Meta::List {
33812- ⋮ path: Path {
33813- ⋮ segments: [
33814- ⋮ PathSegment {
33815- ⋮ ident: "list",
33816- ⋮ arguments: None,
33817- ⋮ },
33818- ⋮ ],
33819- ⋮ },
33820- ⋮ nested: [
33821- ⋮ Meta(Meta::NameValue {
33822- ⋮ path: Path {
33823- ⋮ segments: [
33824- ⋮ PathSegment {
33825- ⋮ ident: "name2",
33826- ⋮ arguments: None,
33827- ⋮ },
33828- ⋮ ],
33829- ⋮ },
33830- ⋮ lit: 6,
33831- ⋮ }),
33832- ⋮ ],
33833- ⋮ }),
33834- ⋮ Meta(Path(Path {
33835- ⋮ segments: [
33836- ⋮ PathSegment {
33837- ⋮ ident: "word2",
33838- ⋮ arguments: None,
33839- ⋮ },
33840- ⋮ ],
33841- ⋮ })),
33842- ⋮ ],
33843- ⋮}
33844+ Meta::List {
33845+ path: Path {
33846+ segments: [
33847+ PathSegment {
33848+ ident: "foo",
33849+ arguments: None,
33850+ },
33851+ ],
33852+ },
33853+ nested: [
33854+ Meta(Path(Path {
33855+ segments: [
33856+ PathSegment {
33857+ ident: "word",
33858+ arguments: None,
33859+ },
33860+ ],
33861+ })),
33862+ Meta(Meta::NameValue {
33863+ path: Path {
33864+ segments: [
33865+ PathSegment {
33866+ ident: "name",
33867+ arguments: None,
33868+ },
33869+ ],
33870+ },
33871+ lit: 5,
33872+ }),
33873+ Meta(Meta::List {
33874+ path: Path {
33875+ segments: [
33876+ PathSegment {
33877+ ident: "list",
33878+ arguments: None,
33879+ },
33880+ ],
33881+ },
33882+ nested: [
33883+ Meta(Meta::NameValue {
33884+ path: Path {
33885+ segments: [
33886+ PathSegment {
33887+ ident: "name2",
33888+ arguments: None,
33889+ },
33890+ ],
33891+ },
33892+ lit: 6,
33893+ }),
33894+ ],
33895+ }),
33896+ Meta(Path(Path {
33897+ segments: [
33898+ PathSegment {
33899+ ident: "word2",
33900+ arguments: None,
33901+ },
33902+ ],
33903+ })),
33904+ ],
33905+ }
33906 "###);
33907
33908 assert_eq!(meta, inner.into());
33909 }
33910
33911 #[test]
33912 fn test_parse_nested_meta() {
33913 let input = "5";
33914 snapshot!(input as NestedMeta, @"Lit(5)");
33915
33916 let input = "list(name2 = 6)";
33917 snapshot!(input as NestedMeta, @r###"
33918- ⋮Meta(Meta::List {
33919- ⋮ path: Path {
33920- ⋮ segments: [
33921- ⋮ PathSegment {
33922- ⋮ ident: "list",
33923- ⋮ arguments: None,
33924- ⋮ },
33925- ⋮ ],
33926- ⋮ },
33927- ⋮ nested: [
33928- ⋮ Meta(Meta::NameValue {
33929- ⋮ path: Path {
33930- ⋮ segments: [
33931- ⋮ PathSegment {
33932- ⋮ ident: "name2",
33933- ⋮ arguments: None,
33934- ⋮ },
33935- ⋮ ],
33936- ⋮ },
33937- ⋮ lit: 6,
33938- ⋮ }),
33939- ⋮ ],
33940- ⋮})
33941+ Meta(Meta::List {
33942+ path: Path {
33943+ segments: [
33944+ PathSegment {
33945+ ident: "list",
33946+ arguments: None,
33947+ },
33948+ ],
33949+ },
33950+ nested: [
33951+ Meta(Meta::NameValue {
33952+ path: Path {
33953+ segments: [
33954+ PathSegment {
33955+ ident: "name2",
33956+ arguments: None,
33957+ },
33958+ ],
33959+ },
33960+ lit: 6,
33961+ }),
33962+ ],
33963+ })
33964 "###);
33965 }
33966diff --git a/third_party/rust/syn/tests/test_parse_buffer.rs b/third_party/rust/syn/tests/test_parse_buffer.rs
33967--- a/third_party/rust/syn/tests/test_parse_buffer.rs
33968+++ b/third_party/rust/syn/tests/test_parse_buffer.rs
33969@@ -1,12 +1,12 @@
33970-#[macro_use]
33971-extern crate syn;
33972-
33973+use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenStream, TokenTree};
33974+use std::iter::FromIterator;
33975 use syn::parse::{discouraged::Speculative, Parse, ParseStream, Parser, Result};
33976+use syn::{parenthesized, Token};
33977
33978 #[test]
33979 #[should_panic(expected = "Fork was not derived from the advancing parse stream")]
33980 fn smuggled_speculative_cursor_between_sources() {
33981 struct BreakRules;
33982 impl Parse for BreakRules {
33983 fn parse(input1: ParseStream) -> Result<Self> {
33984 let nested = |input2: ParseStream| {
33985@@ -48,8 +48,43 @@ fn smuggled_speculative_cursor_into_brac
33986 parenthesized!(a in input);
33987 input.advance_to(&a);
33988 Ok(Self)
33989 }
33990 }
33991
33992 syn::parse_str::<BreakRules>("()").unwrap();
33993 }
33994+
33995+#[test]
33996+fn trailing_empty_none_group() {
33997+ fn parse(input: ParseStream) -> Result<()> {
33998+ input.parse::<Token![+]>()?;
33999+
34000+ let content;
34001+ parenthesized!(content in input);
34002+ content.parse::<Token![+]>()?;
34003+
34004+ Ok(())
34005+ }
34006+
34007+ // `+ ( + <Ø Ø> ) <Ø <Ø Ø> Ø>`
34008+ let tokens = TokenStream::from_iter(vec![
34009+ TokenTree::Punct(Punct::new('+', Spacing::Alone)),
34010+ TokenTree::Group(Group::new(
34011+ Delimiter::Parenthesis,
34012+ TokenStream::from_iter(vec![
34013+ TokenTree::Punct(Punct::new('+', Spacing::Alone)),
34014+ TokenTree::Group(Group::new(Delimiter::None, TokenStream::new())),
34015+ ]),
34016+ )),
34017+ TokenTree::Group(Group::new(Delimiter::None, TokenStream::new())),
34018+ TokenTree::Group(Group::new(
34019+ Delimiter::None,
34020+ TokenStream::from_iter(vec![TokenTree::Group(Group::new(
34021+ Delimiter::None,
34022+ TokenStream::new(),
34023+ ))]),
34024+ )),
34025+ ]);
34026+
34027+ parse.parse2(tokens).unwrap();
34028+}
34029diff --git a/third_party/rust/syn/tests/test_parse_stream.rs b/third_party/rust/syn/tests/test_parse_stream.rs
34030new file mode 100644
34031--- /dev/null
34032+++ b/third_party/rust/syn/tests/test_parse_stream.rs
34033@@ -0,0 +1,12 @@
34034+use syn::ext::IdentExt;
34035+use syn::parse::ParseStream;
34036+use syn::{Ident, Token};
34037+
34038+#[test]
34039+fn test_peek() {
34040+ let _ = |input: ParseStream| {
34041+ let _ = input.peek(Ident);
34042+ let _ = input.peek(Ident::peek_any);
34043+ let _ = input.peek(Token![::]);
34044+ };
34045+}
34046diff --git a/third_party/rust/syn/tests/test_pat.rs b/third_party/rust/syn/tests/test_pat.rs
34047--- a/third_party/rust/syn/tests/test_pat.rs
34048+++ b/third_party/rust/syn/tests/test_pat.rs
34049@@ -1,23 +1,38 @@
34050-extern crate quote;
34051-extern crate syn;
34052-
34053-mod features;
34054-
34055 use quote::quote;
34056-use syn::Pat;
34057+use syn::{Item, Pat, Stmt};
34058
34059 #[test]
34060 fn test_pat_ident() {
34061 match syn::parse2(quote!(self)).unwrap() {
34062 Pat::Ident(_) => (),
34063 value => panic!("expected PatIdent, got {:?}", value),
34064 }
34065 }
34066
34067 #[test]
34068 fn test_pat_path() {
34069 match syn::parse2(quote!(self::CONST)).unwrap() {
34070 Pat::Path(_) => (),
34071 value => panic!("expected PatPath, got {:?}", value),
34072 }
34073 }
34074+
34075+#[test]
34076+fn test_leading_vert() {
34077+ // https://github.com/rust-lang/rust/blob/1.43.0/src/test/ui/or-patterns/remove-leading-vert.rs
34078+
34079+ syn::parse_str::<Item>("fn f() {}").unwrap();
34080+ syn::parse_str::<Item>("fn fun1(| A: E) {}").unwrap_err();
34081+ syn::parse_str::<Item>("fn fun2(|| A: E) {}").unwrap_err();
34082+
34083+ syn::parse_str::<Stmt>("let | () = ();").unwrap();
34084+ syn::parse_str::<Stmt>("let (| A): E;").unwrap_err();
34085+ syn::parse_str::<Stmt>("let (|| A): (E);").unwrap_err();
34086+ syn::parse_str::<Stmt>("let (| A,): (E,);").unwrap_err();
34087+ syn::parse_str::<Stmt>("let [| A]: [E; 1];").unwrap_err();
34088+ syn::parse_str::<Stmt>("let [|| A]: [E; 1];").unwrap_err();
34089+ syn::parse_str::<Stmt>("let TS(| A): TS;").unwrap_err();
34090+ syn::parse_str::<Stmt>("let TS(|| A): TS;").unwrap_err();
34091+ syn::parse_str::<Stmt>("let NS { f: | A }: NS;").unwrap_err();
34092+ syn::parse_str::<Stmt>("let NS { f: || A }: NS;").unwrap_err();
34093+}
34094diff --git a/third_party/rust/syn/tests/test_path.rs b/third_party/rust/syn/tests/test_path.rs
34095new file mode 100644
34096--- /dev/null
34097+++ b/third_party/rust/syn/tests/test_path.rs
34098@@ -0,0 +1,52 @@
34099+#[macro_use]
34100+mod macros;
34101+
34102+use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
34103+use quote::quote;
34104+use std::iter::FromIterator;
34105+use syn::{Expr, Type};
34106+
34107+#[test]
34108+fn parse_interpolated_leading_component() {
34109+ // mimics the token stream corresponding to `$mod::rest`
34110+ let tokens = TokenStream::from_iter(vec![
34111+ TokenTree::Group(Group::new(Delimiter::None, quote! { first })),
34112+ TokenTree::Punct(Punct::new(':', Spacing::Joint)),
34113+ TokenTree::Punct(Punct::new(':', Spacing::Alone)),
34114+ TokenTree::Ident(Ident::new("rest", Span::call_site())),
34115+ ]);
34116+
34117+ snapshot!(tokens.clone() as Expr, @r###"
34118+ Expr::Path {
34119+ path: Path {
34120+ segments: [
34121+ PathSegment {
34122+ ident: "first",
34123+ arguments: None,
34124+ },
34125+ PathSegment {
34126+ ident: "rest",
34127+ arguments: None,
34128+ },
34129+ ],
34130+ },
34131+ }
34132+ "###);
34133+
34134+ snapshot!(tokens as Type, @r###"
34135+ Type::Path {
34136+ path: Path {
34137+ segments: [
34138+ PathSegment {
34139+ ident: "first",
34140+ arguments: None,
34141+ },
34142+ PathSegment {
34143+ ident: "rest",
34144+ arguments: None,
34145+ },
34146+ ],
34147+ },
34148+ }
34149+ "###);
34150+}
34151diff --git a/third_party/rust/syn/tests/test_precedence.rs b/third_party/rust/syn/tests/test_precedence.rs
34152--- a/third_party/rust/syn/tests/test_precedence.rs
34153+++ b/third_party/rust/syn/tests/test_precedence.rs
34154@@ -1,43 +1,34 @@
34155 #![cfg(not(syn_disable_nightly_tests))]
34156 #![recursion_limit = "1024"]
34157 #![feature(rustc_private)]
34158
34159 //! The tests in this module do the following:
34160 //!
34161-//! 1. Parse a given expression in both `syn` and `libsyntax`.
34162+//! 1. Parse a given expression in both `syn` and `librustc`.
34163 //! 2. Fold over the expression adding brackets around each subexpression (with
34164-//! some complications - see the `syn_brackets` and `libsyntax_brackets`
34165+//! some complications - see the `syn_brackets` and `librustc_brackets`
34166 //! methods).
34167 //! 3. Serialize the `syn` expression back into a string, and re-parse it with
34168-//! `libsyntax`.
34169+//! `librustc`.
34170 //! 4. Respan all of the expressions, replacing the spans with the default
34171 //! spans.
34172 //! 5. Compare the expressions with one another, if they are not equal fail.
34173
34174-extern crate quote;
34175-extern crate rayon;
34176-extern crate regex;
34177+extern crate rustc_ast;
34178 extern crate rustc_data_structures;
34179-extern crate smallvec;
34180-extern crate syn;
34181-extern crate syntax;
34182-extern crate syntax_pos;
34183-extern crate walkdir;
34184-
34185-mod features;
34186+extern crate rustc_span;
34187
34188 use quote::quote;
34189 use rayon::iter::{IntoParallelIterator, ParallelIterator};
34190 use regex::Regex;
34191-use smallvec::smallvec;
34192-use syntax::ast;
34193-use syntax::ptr::P;
34194-use syntax_pos::edition::Edition;
34195+use rustc_ast::ast;
34196+use rustc_ast::ptr::P;
34197+use rustc_span::edition::Edition;
34198 use walkdir::{DirEntry, WalkDir};
34199
34200 use std::fs::File;
34201 use std::io::Read;
34202 use std::process;
34203 use std::sync::atomic::{AtomicUsize, Ordering};
34204
34205 use common::eq::SpanlessEq;
34206@@ -68,17 +59,17 @@ fn test_simple_precedence() {
34207 for input in EXPRS {
34208 let expr = if let Some(expr) = parse::syn_expr(input) {
34209 expr
34210 } else {
34211 failed += 1;
34212 continue;
34213 };
34214
34215- let pf = match test_expressions(vec![expr]) {
34216+ let pf = match test_expressions(Edition::Edition2018, vec![expr]) {
34217 (1, 0) => "passed",
34218 (0, 1) => {
34219 failed += 1;
34220 "failed"
34221 }
34222 _ => unreachable!(),
34223 };
34224 errorf!("=== {}: {}\n", input, pf);
34225@@ -86,18 +77,18 @@ fn test_simple_precedence() {
34226
34227 if failed > 0 {
34228 panic!("Failed {} tests", failed);
34229 }
34230 }
34231
34232 /// Test expressions from rustc, like in `test_round_trip`.
34233 #[test]
34234-#[cfg_attr(target_os = "windows", ignore = "requires nix .sh")]
34235 fn test_rustc_precedence() {
34236+ common::rayon_init();
34237 repo::clone_rust();
34238 let abort_after = common::abort_after();
34239 if abort_after == 0 {
34240 panic!("Skipping all precedence tests");
34241 }
34242
34243 let passed = AtomicUsize::new(0);
34244 let failed = AtomicUsize::new(0);
34245@@ -113,34 +104,26 @@ fn test_rustc_precedence() {
34246 .unwrap()
34247 .into_par_iter()
34248 .for_each(|entry| {
34249 let path = entry.path();
34250 if path.is_dir() {
34251 return;
34252 }
34253
34254- // Our version of `libsyntax` can't parse this tests
34255- if path
34256- .to_str()
34257- .unwrap()
34258- .ends_with("optional_comma_in_match_arm.rs")
34259- {
34260- return;
34261- }
34262-
34263 let mut file = File::open(path).unwrap();
34264 let mut content = String::new();
34265 file.read_to_string(&mut content).unwrap();
34266 let content = edition_regex.replace_all(&content, "_$0");
34267
34268 let (l_passed, l_failed) = match syn::parse_file(&content) {
34269 Ok(file) => {
34270+ let edition = repo::edition(path).parse().unwrap();
34271 let exprs = collect_exprs(file);
34272- test_expressions(exprs)
34273+ test_expressions(edition, exprs)
34274 }
34275 Err(msg) => {
34276 errorf!("syn failed to parse\n{:?}\n", msg);
34277 (0, 1)
34278 }
34279 };
34280
34281 errorf!(
34282@@ -164,147 +147,182 @@ fn test_rustc_precedence() {
34283 errorf!("\n===== Precedence Test Results =====\n");
34284 errorf!("{} passed | {} failed\n", passed, failed);
34285
34286 if failed > 0 {
34287 panic!("{} failures", failed);
34288 }
34289 }
34290
34291-fn test_expressions(exprs: Vec<syn::Expr>) -> (usize, usize) {
34292+fn test_expressions(edition: Edition, exprs: Vec<syn::Expr>) -> (usize, usize) {
34293 let mut passed = 0;
34294 let mut failed = 0;
34295
34296- syntax::with_globals(Edition::Edition2018, || {
34297+ rustc_span::with_session_globals(edition, || {
34298 for expr in exprs {
34299 let raw = quote!(#expr).to_string();
34300
34301- let libsyntax_ast = if let Some(e) = libsyntax_parse_and_rewrite(&raw) {
34302+ let librustc_ast = if let Some(e) = librustc_parse_and_rewrite(&raw) {
34303 e
34304 } else {
34305 failed += 1;
34306- errorf!("\nFAIL - libsyntax failed to parse raw\n");
34307+ errorf!("\nFAIL - librustc failed to parse raw\n");
34308 continue;
34309 };
34310
34311 let syn_expr = syn_brackets(expr);
34312- let syn_ast = if let Some(e) = parse::libsyntax_expr(&quote!(#syn_expr).to_string()) {
34313+ let syn_ast = if let Some(e) = parse::librustc_expr(&quote!(#syn_expr).to_string()) {
34314 e
34315 } else {
34316 failed += 1;
34317- errorf!("\nFAIL - libsyntax failed to parse bracketed\n");
34318+ errorf!("\nFAIL - librustc failed to parse bracketed\n");
34319 continue;
34320 };
34321
34322- if SpanlessEq::eq(&syn_ast, &libsyntax_ast) {
34323+ if SpanlessEq::eq(&syn_ast, &librustc_ast) {
34324 passed += 1;
34325 } else {
34326 failed += 1;
34327- errorf!("\nFAIL\n{:?}\n!=\n{:?}\n", syn_ast, libsyntax_ast);
34328+ errorf!("\nFAIL\n{:?}\n!=\n{:?}\n", syn_ast, librustc_ast);
34329 }
34330 }
34331 });
34332
34333 (passed, failed)
34334 }
34335
34336-fn libsyntax_parse_and_rewrite(input: &str) -> Option<P<ast::Expr>> {
34337- parse::libsyntax_expr(input).and_then(libsyntax_brackets)
34338+fn librustc_parse_and_rewrite(input: &str) -> Option<P<ast::Expr>> {
34339+ parse::librustc_expr(input).and_then(librustc_brackets)
34340 }
34341
34342 /// Wrap every expression which is not already wrapped in parens with parens, to
34343 /// reveal the precidence of the parsed expressions, and produce a stringified
34344 /// form of the resulting expression.
34345 ///
34346-/// This method operates on libsyntax objects.
34347-fn libsyntax_brackets(mut libsyntax_expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
34348+/// This method operates on librustc objects.
34349+fn librustc_brackets(mut librustc_expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
34350+ use rustc_ast::ast::{
34351+ Block, BorrowKind, Expr, ExprKind, Field, GenericArg, MacCall, Pat, Stmt, StmtKind, Ty,
34352+ };
34353+ use rustc_ast::mut_visit::{noop_visit_generic_arg, MutVisitor};
34354+ use rustc_data_structures::map_in_place::MapInPlace;
34355 use rustc_data_structures::thin_vec::ThinVec;
34356- use smallvec::SmallVec;
34357+ use rustc_span::DUMMY_SP;
34358 use std::mem;
34359- use syntax::ast::{Expr, ExprKind, Field, Mac, Pat, Stmt, StmtKind, Ty};
34360- use syntax::mut_visit::{noop_visit_expr, MutVisitor};
34361- use syntax_pos::DUMMY_SP;
34362
34363 struct BracketsVisitor {
34364 failed: bool,
34365 };
34366
34367+ fn flat_map_field<T: MutVisitor>(mut f: Field, vis: &mut T) -> Vec<Field> {
34368+ if f.is_shorthand {
34369+ noop_visit_expr(&mut f.expr, vis);
34370+ } else {
34371+ vis.visit_expr(&mut f.expr);
34372+ }
34373+ vec![f]
34374+ }
34375+
34376+ fn flat_map_stmt<T: MutVisitor>(stmt: Stmt, vis: &mut T) -> Vec<Stmt> {
34377+ let kind = match stmt.kind {
34378+ // Don't wrap toplevel expressions in statements.
34379+ StmtKind::Expr(mut e) => {
34380+ noop_visit_expr(&mut e, vis);
34381+ StmtKind::Expr(e)
34382+ }
34383+ StmtKind::Semi(mut e) => {
34384+ noop_visit_expr(&mut e, vis);
34385+ StmtKind::Semi(e)
34386+ }
34387+ s => s,
34388+ };
34389+
34390+ vec![Stmt { kind, ..stmt }]
34391+ }
34392+
34393+ fn noop_visit_expr<T: MutVisitor>(e: &mut Expr, vis: &mut T) {
34394+ use rustc_ast::mut_visit::{noop_visit_expr, visit_opt, visit_thin_attrs};
34395+ match &mut e.kind {
34396+ ExprKind::AddrOf(BorrowKind::Raw, ..) => {}
34397+ ExprKind::Struct(path, fields, expr) => {
34398+ vis.visit_path(path);
34399+ fields.flat_map_in_place(|field| flat_map_field(field, vis));
34400+ visit_opt(expr, |expr| vis.visit_expr(expr));
34401+ vis.visit_id(&mut e.id);
34402+ vis.visit_span(&mut e.span);
34403+ visit_thin_attrs(&mut e.attrs, vis);
34404+ }
34405+ _ => noop_visit_expr(e, vis),
34406+ }
34407+ }
34408+
34409 impl MutVisitor for BracketsVisitor {
34410 fn visit_expr(&mut self, e: &mut P<Expr>) {
34411 noop_visit_expr(e, self);
34412- match e.node {
34413+ match e.kind {
34414 ExprKind::If(..) | ExprKind::Block(..) | ExprKind::Let(..) => {}
34415 _ => {
34416 let inner = mem::replace(
34417 e,
34418 P(Expr {
34419 id: ast::DUMMY_NODE_ID,
34420- node: ExprKind::Err,
34421+ kind: ExprKind::Err,
34422 span: DUMMY_SP,
34423 attrs: ThinVec::new(),
34424+ tokens: None,
34425 }),
34426 );
34427- e.node = ExprKind::Paren(inner);
34428+ e.kind = ExprKind::Paren(inner);
34429 }
34430 }
34431 }
34432
34433- fn flat_map_field(&mut self, mut f: Field) -> SmallVec<[Field; 1]> {
34434- if f.is_shorthand {
34435- noop_visit_expr(&mut f.expr, self);
34436- } else {
34437- self.visit_expr(&mut f.expr);
34438+ fn visit_generic_arg(&mut self, arg: &mut GenericArg) {
34439+ match arg {
34440+ // Don't wrap const generic arg as that's invalid syntax.
34441+ GenericArg::Const(arg) => noop_visit_expr(&mut arg.value, self),
34442+ _ => noop_visit_generic_arg(arg, self),
34443 }
34444- SmallVec::from([f])
34445+ }
34446+
34447+ fn visit_block(&mut self, block: &mut P<Block>) {
34448+ self.visit_id(&mut block.id);
34449+ block
34450+ .stmts
34451+ .flat_map_in_place(|stmt| flat_map_stmt(stmt, self));
34452+ self.visit_span(&mut block.span);
34453 }
34454
34455 // We don't want to look at expressions that might appear in patterns or
34456 // types yet. We'll look into comparing those in the future. For now
34457 // focus on expressions appearing in other places.
34458 fn visit_pat(&mut self, pat: &mut P<Pat>) {
34459 let _ = pat;
34460 }
34461
34462 fn visit_ty(&mut self, ty: &mut P<Ty>) {
34463 let _ = ty;
34464 }
34465
34466- fn flat_map_stmt(&mut self, stmt: Stmt) -> SmallVec<[Stmt; 1]> {
34467- let node = match stmt.node {
34468- // Don't wrap toplevel expressions in statements.
34469- StmtKind::Expr(mut e) => {
34470- noop_visit_expr(&mut e, self);
34471- StmtKind::Expr(e)
34472- }
34473- StmtKind::Semi(mut e) => {
34474- noop_visit_expr(&mut e, self);
34475- StmtKind::Semi(e)
34476- }
34477- s => s,
34478- };
34479-
34480- smallvec![Stmt { node, ..stmt }]
34481- }
34482-
34483- fn visit_mac(&mut self, mac: &mut Mac) {
34484- // By default when folding over macros, libsyntax panics. This is
34485+ fn visit_mac(&mut self, mac: &mut MacCall) {
34486+ // By default when folding over macros, librustc panics. This is
34487 // because it's usually not what you want, you want to run after
34488 // macro expansion. We do want to do that (syn doesn't do macro
34489 // expansion), so we implement visit_mac to just return the macro
34490 // unchanged.
34491 let _ = mac;
34492 }
34493 }
34494
34495 let mut folder = BracketsVisitor { failed: false };
34496- folder.visit_expr(&mut libsyntax_expr);
34497+ folder.visit_expr(&mut librustc_expr);
34498 if folder.failed {
34499 None
34500 } else {
34501- Some(libsyntax_expr)
34502+ Some(librustc_expr)
34503 }
34504 }
34505
34506 /// Wrap every expression which is not already wrapped in parens with parens, to
34507 /// reveal the precedence of the parsed expressions, and produce a stringified
34508 /// form of the resulting expression.
34509 fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr {
34510 use syn::fold::*;
34511@@ -313,24 +331,43 @@ fn syn_brackets(syn_expr: syn::Expr) ->
34512 struct ParenthesizeEveryExpr;
34513 impl Fold for ParenthesizeEveryExpr {
34514 fn fold_expr(&mut self, expr: Expr) -> Expr {
34515 match expr {
34516 Expr::Group(_) => unreachable!(),
34517 Expr::If(..) | Expr::Unsafe(..) | Expr::Block(..) | Expr::Let(..) => {
34518 fold_expr(self, expr)
34519 }
34520- node => Expr::Paren(ExprParen {
34521+ _ => Expr::Paren(ExprParen {
34522 attrs: Vec::new(),
34523- expr: Box::new(fold_expr(self, node)),
34524+ expr: Box::new(fold_expr(self, expr)),
34525 paren_token: token::Paren::default(),
34526 }),
34527 }
34528 }
34529
34530+ fn fold_generic_argument(&mut self, arg: GenericArgument) -> GenericArgument {
34531+ match arg {
34532+ // Don't wrap const generic arg as that's invalid syntax.
34533+ GenericArgument::Const(a) => GenericArgument::Const(fold_expr(self, a)),
34534+ _ => fold_generic_argument(self, arg),
34535+ }
34536+ }
34537+
34538+ fn fold_generic_method_argument(
34539+ &mut self,
34540+ arg: GenericMethodArgument,
34541+ ) -> GenericMethodArgument {
34542+ match arg {
34543+ // Don't wrap const generic arg as that's invalid syntax.
34544+ GenericMethodArgument::Const(a) => GenericMethodArgument::Const(fold_expr(self, a)),
34545+ _ => fold_generic_method_argument(self, arg),
34546+ }
34547+ }
34548+
34549 fn fold_stmt(&mut self, stmt: Stmt) -> Stmt {
34550 match stmt {
34551 // Don't wrap toplevel expressions in statements.
34552 Stmt::Expr(e) => Stmt::Expr(fold_expr(self, e)),
34553 Stmt::Semi(e, semi) => Stmt::Semi(fold_expr(self, e), semi),
34554 s => s,
34555 }
34556 }
34557@@ -355,17 +392,20 @@ fn syn_brackets(syn_expr: syn::Expr) ->
34558 fn collect_exprs(file: syn::File) -> Vec<syn::Expr> {
34559 use syn::fold::*;
34560 use syn::punctuated::Punctuated;
34561 use syn::*;
34562
34563 struct CollectExprs(Vec<Expr>);
34564 impl Fold for CollectExprs {
34565 fn fold_expr(&mut self, expr: Expr) -> Expr {
34566- self.0.push(expr);
34567+ match expr {
34568+ Expr::Verbatim(tokens) if tokens.is_empty() => {}
34569+ _ => self.0.push(expr),
34570+ }
34571
34572 Expr::Tuple(ExprTuple {
34573 attrs: vec![],
34574 elems: Punctuated::new(),
34575 paren_token: token::Paren::default(),
34576 })
34577 }
34578 }
34579diff --git a/third_party/rust/syn/tests/test_receiver.rs b/third_party/rust/syn/tests/test_receiver.rs
34580new file mode 100644
34581--- /dev/null
34582+++ b/third_party/rust/syn/tests/test_receiver.rs
34583@@ -0,0 +1,127 @@
34584+use syn::{parse_quote, FnArg, Receiver, TraitItemMethod};
34585+
34586+#[test]
34587+fn test_by_value() {
34588+ let TraitItemMethod { sig, .. } = parse_quote! {
34589+ fn by_value(self: Self);
34590+ };
34591+ match sig.receiver() {
34592+ Some(FnArg::Typed(_)) => (),
34593+ value => panic!("expected FnArg::Typed, got {:?}", value),
34594+ }
34595+}
34596+
34597+#[test]
34598+fn test_by_mut_value() {
34599+ let TraitItemMethod { sig, .. } = parse_quote! {
34600+ fn by_mut(mut self: Self);
34601+ };
34602+ match sig.receiver() {
34603+ Some(FnArg::Typed(_)) => (),
34604+ value => panic!("expected FnArg::Typed, got {:?}", value),
34605+ }
34606+}
34607+
34608+#[test]
34609+fn test_by_ref() {
34610+ let TraitItemMethod { sig, .. } = parse_quote! {
34611+ fn by_ref(self: &Self);
34612+ };
34613+ match sig.receiver() {
34614+ Some(FnArg::Typed(_)) => (),
34615+ value => panic!("expected FnArg::Typed, got {:?}", value),
34616+ }
34617+}
34618+
34619+#[test]
34620+fn test_by_box() {
34621+ let TraitItemMethod { sig, .. } = parse_quote! {
34622+ fn by_box(self: Box<Self>);
34623+ };
34624+ match sig.receiver() {
34625+ Some(FnArg::Typed(_)) => (),
34626+ value => panic!("expected FnArg::Typed, got {:?}", value),
34627+ }
34628+}
34629+
34630+#[test]
34631+fn test_by_pin() {
34632+ let TraitItemMethod { sig, .. } = parse_quote! {
34633+ fn by_pin(self: Pin<Self>);
34634+ };
34635+ match sig.receiver() {
34636+ Some(FnArg::Typed(_)) => (),
34637+ value => panic!("expected FnArg::Typed, got {:?}", value),
34638+ }
34639+}
34640+
34641+#[test]
34642+fn test_explicit_type() {
34643+ let TraitItemMethod { sig, .. } = parse_quote! {
34644+ fn explicit_type(self: Pin<MyType>);
34645+ };
34646+ match sig.receiver() {
34647+ Some(FnArg::Typed(_)) => (),
34648+ value => panic!("expected FnArg::Typed, got {:?}", value),
34649+ }
34650+}
34651+
34652+#[test]
34653+fn test_value_shorthand() {
34654+ let TraitItemMethod { sig, .. } = parse_quote! {
34655+ fn value_shorthand(self);
34656+ };
34657+ match sig.receiver() {
34658+ Some(FnArg::Receiver(Receiver {
34659+ reference: None,
34660+ mutability: None,
34661+ ..
34662+ })) => (),
34663+ value => panic!("expected FnArg::Receiver without ref/mut, got {:?}", value),
34664+ }
34665+}
34666+
34667+#[test]
34668+fn test_mut_value_shorthand() {
34669+ let TraitItemMethod { sig, .. } = parse_quote! {
34670+ fn mut_value_shorthand(mut self);
34671+ };
34672+ match sig.receiver() {
34673+ Some(FnArg::Receiver(Receiver {
34674+ reference: None,
34675+ mutability: Some(_),
34676+ ..
34677+ })) => (),
34678+ value => panic!("expected FnArg::Receiver with mut, got {:?}", value),
34679+ }
34680+}
34681+
34682+#[test]
34683+fn test_ref_shorthand() {
34684+ let TraitItemMethod { sig, .. } = parse_quote! {
34685+ fn ref_shorthand(&self);
34686+ };
34687+ match sig.receiver() {
34688+ Some(FnArg::Receiver(Receiver {
34689+ reference: Some(_),
34690+ mutability: None,
34691+ ..
34692+ })) => (),
34693+ value => panic!("expected FnArg::Receiver with ref, got {:?}", value),
34694+ }
34695+}
34696+
34697+#[test]
34698+fn test_ref_mut_shorthand() {
34699+ let TraitItemMethod { sig, .. } = parse_quote! {
34700+ fn ref_mut_shorthand(&mut self);
34701+ };
34702+ match sig.receiver() {
34703+ Some(FnArg::Receiver(Receiver {
34704+ reference: Some(_),
34705+ mutability: Some(_),
34706+ ..
34707+ })) => (),
34708+ value => panic!("expected FnArg::Receiver with ref+mut, got {:?}", value),
34709+ }
34710+}
34711diff --git a/third_party/rust/syn/tests/test_round_trip.rs b/third_party/rust/syn/tests/test_round_trip.rs
34712--- a/third_party/rust/syn/tests/test_round_trip.rs
34713+++ b/third_party/rust/syn/tests/test_round_trip.rs
34714@@ -1,28 +1,26 @@
34715 #![cfg(not(syn_disable_nightly_tests))]
34716 #![recursion_limit = "1024"]
34717 #![feature(rustc_private)]
34718
34719-extern crate quote;
34720-extern crate rayon;
34721-extern crate syn;
34722-extern crate syntax;
34723-extern crate syntax_pos;
34724-extern crate walkdir;
34725-
34726-mod features;
34727+extern crate rustc_ast;
34728+extern crate rustc_errors;
34729+extern crate rustc_expand;
34730+extern crate rustc_parse as parse;
34731+extern crate rustc_session;
34732+extern crate rustc_span;
34733
34734 use quote::quote;
34735 use rayon::iter::{IntoParallelIterator, ParallelIterator};
34736-use syntax::ast;
34737-use syntax::parse::{self, PResult, ParseSess};
34738-use syntax::source_map::FilePathMapping;
34739-use syntax_pos::edition::Edition;
34740-use syntax_pos::FileName;
34741+use rustc_ast::ast;
34742+use rustc_errors::PResult;
34743+use rustc_session::parse::ParseSess;
34744+use rustc_span::source_map::FilePathMapping;
34745+use rustc_span::FileName;
34746 use walkdir::{DirEntry, WalkDir};
34747
34748 use std::fs::File;
34749 use std::io::Read;
34750 use std::panic;
34751 use std::process;
34752 use std::sync::atomic::{AtomicUsize, Ordering};
34753 use std::time::Instant;
34754@@ -33,18 +31,18 @@ mod macros;
34755 #[allow(dead_code)]
34756 mod common;
34757
34758 mod repo;
34759
34760 use common::eq::SpanlessEq;
34761
34762 #[test]
34763-#[cfg_attr(target_os = "windows", ignore = "requires nix .sh")]
34764 fn test_round_trip() {
34765+ common::rayon_init();
34766 repo::clone_rust();
34767 let abort_after = common::abort_after();
34768 if abort_after == 0 {
34769 panic!("Skipping all round_trip tests");
34770 }
34771
34772 let failed = AtomicUsize::new(0);
34773
34774@@ -73,43 +71,44 @@ fn test_round_trip() {
34775 let prev_failed = failed.fetch_add(1, Ordering::SeqCst);
34776 if prev_failed + 1 >= abort_after {
34777 process::exit(1);
34778 }
34779 return;
34780 }
34781 };
34782 let back = quote!(#krate).to_string();
34783+ let edition = repo::edition(path).parse().unwrap();
34784
34785 let equal = panic::catch_unwind(|| {
34786- syntax::with_globals(Edition::Edition2018, || {
34787+ rustc_span::with_session_globals(edition, || {
34788 let sess = ParseSess::new(FilePathMapping::empty());
34789- let before = match libsyntax_parse(content, &sess) {
34790+ let before = match librustc_parse(content, &sess) {
34791 Ok(before) => before,
34792 Err(mut diagnostic) => {
34793 diagnostic.cancel();
34794 if diagnostic
34795 .message()
34796 .starts_with("file not found for module")
34797 {
34798 errorf!("=== {}: ignore\n", path.display());
34799 } else {
34800 errorf!(
34801- "=== {}: ignore - libsyntax failed to parse original content: {}\n",
34802+ "=== {}: ignore - librustc failed to parse original content: {}\n",
34803 path.display(),
34804 diagnostic.message()
34805 );
34806 }
34807 return true;
34808 }
34809 };
34810- let after = match libsyntax_parse(back, &sess) {
34811+ let after = match librustc_parse(back, &sess) {
34812 Ok(after) => after,
34813 Err(mut diagnostic) => {
34814- errorf!("=== {}: libsyntax failed to parse", path.display());
34815+ errorf!("=== {}: librustc failed to parse", path.display());
34816 diagnostic.emit();
34817 return false;
34818 }
34819 };
34820
34821 if SpanlessEq::eq(&before, &after) {
34822 errorf!(
34823 "=== {}: pass in {}ms\n",
34824@@ -125,29 +124,29 @@ fn test_round_trip() {
34825 before,
34826 after,
34827 );
34828 false
34829 }
34830 })
34831 });
34832 match equal {
34833- Err(_) => errorf!("=== {}: ignoring libsyntax panic\n", path.display()),
34834+ Err(_) => errorf!("=== {}: ignoring librustc panic\n", path.display()),
34835 Ok(true) => {}
34836 Ok(false) => {
34837 let prev_failed = failed.fetch_add(1, Ordering::SeqCst);
34838 if prev_failed + 1 >= abort_after {
34839 process::exit(1);
34840 }
34841 }
34842 }
34843 });
34844
34845 let failed = failed.load(Ordering::SeqCst);
34846 if failed > 0 {
34847 panic!("{} failures", failed);
34848 }
34849 }
34850
34851-fn libsyntax_parse(content: String, sess: &ParseSess) -> PResult<ast::Crate> {
34852+fn librustc_parse(content: String, sess: &ParseSess) -> PResult<ast::Crate> {
34853 let name = FileName::Custom("test_round_trip".to_string());
34854 parse::parse_crate_from_source_str(name, content, sess)
34855 }
34856diff --git a/third_party/rust/syn/tests/test_shebang.rs b/third_party/rust/syn/tests/test_shebang.rs
34857new file mode 100644
34858--- /dev/null
34859+++ b/third_party/rust/syn/tests/test_shebang.rs
34860@@ -0,0 +1,59 @@
34861+#[macro_use]
34862+mod macros;
34863+
34864+#[test]
34865+fn test_basic() {
34866+ let content = "#!/usr/bin/env rustx\nfn main() {}";
34867+ let file = syn::parse_file(content).unwrap();
34868+ snapshot!(file, @r###"
34869+ File {
34870+ shebang: Some("#!/usr/bin/env rustx"),
34871+ items: [
34872+ Item::Fn {
34873+ vis: Inherited,
34874+ sig: Signature {
34875+ ident: "main",
34876+ generics: Generics,
34877+ output: Default,
34878+ },
34879+ block: Block,
34880+ },
34881+ ],
34882+ }
34883+ "###);
34884+}
34885+
34886+#[test]
34887+fn test_comment() {
34888+ let content = "#!//am/i/a/comment\n[allow(dead_code)] fn main() {}";
34889+ let file = syn::parse_file(content).unwrap();
34890+ snapshot!(file, @r###"
34891+ File {
34892+ attrs: [
34893+ Attribute {
34894+ style: Inner,
34895+ path: Path {
34896+ segments: [
34897+ PathSegment {
34898+ ident: "allow",
34899+ arguments: None,
34900+ },
34901+ ],
34902+ },
34903+ tokens: TokenStream(`(dead_code)`),
34904+ },
34905+ ],
34906+ items: [
34907+ Item::Fn {
34908+ vis: Inherited,
34909+ sig: Signature {
34910+ ident: "main",
34911+ generics: Generics,
34912+ output: Default,
34913+ },
34914+ block: Block,
34915+ },
34916+ ],
34917+ }
34918+ "###);
34919+}
34920diff --git a/third_party/rust/syn/tests/test_should_parse.rs b/third_party/rust/syn/tests/test_should_parse.rs
34921--- a/third_party/rust/syn/tests/test_should_parse.rs
34922+++ b/third_party/rust/syn/tests/test_should_parse.rs
34923@@ -1,12 +1,8 @@
34924-extern crate syn;
34925-
34926-mod features;
34927-
34928 macro_rules! should_parse {
34929 ($name:ident, { $($in:tt)* }) => {
34930 #[test]
34931 fn $name() {
34932 // Make sure we can parse the file!
34933 syn::parse_file(stringify!($($in)*)).unwrap();
34934 }
34935 }
34936diff --git a/third_party/rust/syn/tests/test_size.rs b/third_party/rust/syn/tests/test_size.rs
34937--- a/third_party/rust/syn/tests/test_size.rs
34938+++ b/third_party/rust/syn/tests/test_size.rs
34939@@ -1,12 +1,10 @@
34940 #![cfg(target_pointer_width = "64")]
34941
34942-mod features;
34943-
34944 use std::mem;
34945 use syn::*;
34946
34947 #[test]
34948 fn test_expr_size() {
34949 assert_eq!(mem::size_of::<Expr>(), 280);
34950 }
34951
34952diff --git a/third_party/rust/syn/tests/test_stmt.rs b/third_party/rust/syn/tests/test_stmt.rs
34953new file mode 100644
34954--- /dev/null
34955+++ b/third_party/rust/syn/tests/test_stmt.rs
34956@@ -0,0 +1,44 @@
34957+#[macro_use]
34958+mod macros;
34959+
34960+use syn::Stmt;
34961+
34962+#[test]
34963+fn test_raw_operator() {
34964+ let stmt = syn::parse_str::<Stmt>("let _ = &raw const x;").unwrap();
34965+
34966+ snapshot!(stmt, @r###"
34967+ Local(Local {
34968+ pat: Pat::Wild,
34969+ init: Some(Verbatim(`& raw const x`)),
34970+ })
34971+ "###);
34972+}
34973+
34974+#[test]
34975+fn test_raw_variable() {
34976+ let stmt = syn::parse_str::<Stmt>("let _ = &raw;").unwrap();
34977+
34978+ snapshot!(stmt, @r###"
34979+ Local(Local {
34980+ pat: Pat::Wild,
34981+ init: Some(Expr::Reference {
34982+ expr: Expr::Path {
34983+ path: Path {
34984+ segments: [
34985+ PathSegment {
34986+ ident: "raw",
34987+ arguments: None,
34988+ },
34989+ ],
34990+ },
34991+ },
34992+ }),
34993+ })
34994+ "###);
34995+}
34996+
34997+#[test]
34998+fn test_raw_invalid() {
34999+ assert!(syn::parse_str::<Stmt>("let _ = &raw x;").is_err());
35000+}
35001diff --git a/third_party/rust/syn/tests/test_token_trees.rs b/third_party/rust/syn/tests/test_token_trees.rs
35002--- a/third_party/rust/syn/tests/test_token_trees.rs
35003+++ b/third_party/rust/syn/tests/test_token_trees.rs
35004@@ -1,14 +1,8 @@
35005-extern crate proc_macro2;
35006-extern crate quote;
35007-extern crate syn;
35008-
35009-mod features;
35010-
35011 #[macro_use]
35012 mod macros;
35013
35014 use proc_macro2::TokenStream;
35015 use quote::quote;
35016 use syn::Lit;
35017
35018 #[test]
35019@@ -16,17 +10,21 @@ fn test_struct() {
35020 let input = "
35021 #[derive(Debug, Clone)]
35022 pub struct Item {
35023 pub ident: Ident,
35024 pub attrs: Vec<Attribute>,
35025 }
35026 ";
35027
35028- snapshot!(input as TokenStream, @"`# [ derive ( Debug , Clone ) ] pub struct Item { pub ident : Ident , pub attrs : Vec < Attribute >, }`");
35029+ snapshot!(input as TokenStream, @r###"
35030+ TokenStream(
35031+ `# [derive (Debug , Clone)] pub struct Item { pub ident : Ident , pub attrs : Vec < Attribute >, }`,
35032+ )
35033+ "###);
35034 }
35035
35036 #[test]
35037 fn test_literal_mangling() {
35038 let code = "0_4";
35039 let parsed: Lit = syn::parse_str(code).unwrap();
35040 assert_eq!(code, quote!(#parsed).to_string());
35041 }
35042diff --git a/third_party/rust/syn/tests/test_ty.rs b/third_party/rust/syn/tests/test_ty.rs
35043new file mode 100644
35044--- /dev/null
35045+++ b/third_party/rust/syn/tests/test_ty.rs
35046@@ -0,0 +1,53 @@
35047+#[macro_use]
35048+mod macros;
35049+
35050+use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
35051+use quote::quote;
35052+use std::iter::FromIterator;
35053+use syn::Type;
35054+
35055+#[test]
35056+fn test_mut_self() {
35057+ syn::parse_str::<Type>("fn(mut self)").unwrap();
35058+ syn::parse_str::<Type>("fn(mut self: ())").unwrap();
35059+ syn::parse_str::<Type>("fn(mut self: ...)").unwrap_err();
35060+ syn::parse_str::<Type>("fn(mut self: mut self)").unwrap_err();
35061+ syn::parse_str::<Type>("fn(mut self::T)").unwrap_err();
35062+}
35063+
35064+#[test]
35065+fn test_macro_variable_type() {
35066+ // mimics the token stream corresponding to `$ty<T>`
35067+ let tokens = TokenStream::from_iter(vec![
35068+ TokenTree::Group(Group::new(Delimiter::None, quote! { ty })),
35069+ TokenTree::Punct(Punct::new('<', Spacing::Alone)),
35070+ TokenTree::Ident(Ident::new("T", Span::call_site())),
35071+ TokenTree::Punct(Punct::new('>', Spacing::Alone)),
35072+ ]);
35073+
35074+ snapshot!(tokens as Type, @r###"
35075+ Type::Path {
35076+ path: Path {
35077+ segments: [
35078+ PathSegment {
35079+ ident: "ty",
35080+ arguments: PathArguments::AngleBracketed {
35081+ args: [
35082+ Type(Type::Path {
35083+ path: Path {
35084+ segments: [
35085+ PathSegment {
35086+ ident: "T",
35087+ arguments: None,
35088+ },
35089+ ],
35090+ },
35091+ }),
35092+ ],
35093+ },
35094+ },
35095+ ],
35096+ },
35097+ }
35098+ "###);
35099+}
35100diff --git a/third_party/rust/syn/tests/test_visibility.rs b/third_party/rust/syn/tests/test_visibility.rs
35101new file mode 100644
35102--- /dev/null
35103+++ b/third_party/rust/syn/tests/test_visibility.rs
35104@@ -0,0 +1,145 @@
35105+#[macro_use]
35106+mod macros;
35107+
35108+use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
35109+use std::iter::FromIterator;
35110+use syn::parse::{Parse, ParseStream};
35111+use syn::{DeriveInput, Result, Visibility};
35112+
35113+#[derive(Debug)]
35114+struct VisRest {
35115+ vis: Visibility,
35116+ rest: TokenStream,
35117+}
35118+
35119+impl Parse for VisRest {
35120+ fn parse(input: ParseStream) -> Result<Self> {
35121+ Ok(VisRest {
35122+ vis: input.parse()?,
35123+ rest: input.parse()?,
35124+ })
35125+ }
35126+}
35127+
35128+macro_rules! assert_vis_parse {
35129+ ($input:expr, Ok($p:pat)) => {
35130+ assert_vis_parse!($input, Ok($p) + "");
35131+ };
35132+
35133+ ($input:expr, Ok($p:pat) + $rest:expr) => {
35134+ let expected = $rest.parse::<TokenStream>().unwrap();
35135+ let parse: VisRest = syn::parse_str($input).unwrap();
35136+
35137+ match parse.vis {
35138+ $p => {}
35139+ _ => panic!("Expected {}, got {:?}", stringify!($p), parse.vis),
35140+ }
35141+
35142+ // NOTE: Round-trips through `to_string` to avoid potential whitespace
35143+ // diffs.
35144+ assert_eq!(parse.rest.to_string(), expected.to_string());
35145+ };
35146+
35147+ ($input:expr, Err) => {
35148+ syn::parse2::<VisRest>($input.parse().unwrap()).unwrap_err();
35149+ };
35150+}
35151+
35152+#[test]
35153+fn test_pub() {
35154+ assert_vis_parse!("pub", Ok(Visibility::Public(_)));
35155+}
35156+
35157+#[test]
35158+fn test_crate() {
35159+ assert_vis_parse!("crate", Ok(Visibility::Crate(_)));
35160+}
35161+
35162+#[test]
35163+fn test_inherited() {
35164+ assert_vis_parse!("", Ok(Visibility::Inherited));
35165+}
35166+
35167+#[test]
35168+fn test_in() {
35169+ assert_vis_parse!("pub(in foo::bar)", Ok(Visibility::Restricted(_)));
35170+}
35171+
35172+#[test]
35173+fn test_pub_crate() {
35174+ assert_vis_parse!("pub(crate)", Ok(Visibility::Restricted(_)));
35175+}
35176+
35177+#[test]
35178+fn test_pub_self() {
35179+ assert_vis_parse!("pub(self)", Ok(Visibility::Restricted(_)));
35180+}
35181+
35182+#[test]
35183+fn test_pub_super() {
35184+ assert_vis_parse!("pub(super)", Ok(Visibility::Restricted(_)));
35185+}
35186+
35187+#[test]
35188+fn test_missing_in() {
35189+ assert_vis_parse!("pub(foo::bar)", Ok(Visibility::Public(_)) + "(foo::bar)");
35190+}
35191+
35192+#[test]
35193+fn test_missing_in_path() {
35194+ assert_vis_parse!("pub(in)", Err);
35195+}
35196+
35197+#[test]
35198+fn test_crate_path() {
35199+ assert_vis_parse!("pub(crate::A, crate::B)", Ok(Visibility::Public(_)) + "(crate::A, crate::B)");
35200+}
35201+
35202+#[test]
35203+fn test_junk_after_in() {
35204+ assert_vis_parse!("pub(in some::path @@garbage)", Err);
35205+}
35206+
35207+#[test]
35208+fn test_empty_group_vis() {
35209+ // mimics `struct S { $vis $field: () }` where $vis is empty
35210+ let tokens = TokenStream::from_iter(vec![
35211+ TokenTree::Ident(Ident::new("struct", Span::call_site())),
35212+ TokenTree::Ident(Ident::new("S", Span::call_site())),
35213+ TokenTree::Group(Group::new(
35214+ Delimiter::Brace,
35215+ TokenStream::from_iter(vec![
35216+ TokenTree::Group(Group::new(Delimiter::None, TokenStream::new())),
35217+ TokenTree::Group(Group::new(
35218+ Delimiter::None,
35219+ TokenStream::from_iter(vec![TokenTree::Ident(Ident::new(
35220+ "f",
35221+ Span::call_site(),
35222+ ))]),
35223+ )),
35224+ TokenTree::Punct(Punct::new(':', Spacing::Alone)),
35225+ TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
35226+ ]),
35227+ )),
35228+ ]);
35229+
35230+ snapshot!(tokens as DeriveInput, @r###"
35231+ DeriveInput {
35232+ vis: Inherited,
35233+ ident: "S",
35234+ generics: Generics,
35235+ data: Data::Struct {
35236+ fields: Fields::Named {
35237+ named: [
35238+ Field {
35239+ vis: Inherited,
35240+ ident: Some("f"),
35241+ colon_token: Some,
35242+ ty: Type::Tuple,
35243+ },
35244+ ],
35245+ },
35246+ },
35247+ }
35248+ "###);
35249+}
35250diff --git a/third_party/rust/syn/tests/zzz_stable.rs b/third_party/rust/syn/tests/zzz_stable.rs
35251--- a/third_party/rust/syn/tests/zzz_stable.rs
35252+++ b/third_party/rust/syn/tests/zzz_stable.rs
35253@@ -1,21 +1,19 @@
35254 #![cfg(syn_disable_nightly_tests)]
35255
35256-extern crate termcolor;
35257-
35258 use std::io::{self, Write};
35259 use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
35260
35261 const MSG: &str = "\
35262
35263 ‖ WARNING:
35264 ‖ This is not a nightly compiler so not all tests were able to
35265 ‖ run. Syn includes tests that compare Syn's parser against the
35266-‖ compiler's parser, which requires access to unstable libsyntax
35267+‖ compiler's parser, which requires access to unstable librustc
35268 ‖ data structures and a nightly compiler.
35269
35270 ";
35271
35272 #[test]
35273 fn notice() -> io::Result<()> {
35274 let header = "WARNING";
35275 let index_of_header = MSG.find(header).unwrap();
35276
This page took 4.650482 seconds and 4 git commands to generate.