3 # User Emilio Cobos Álvarez <emilio@crisal.io>
5 # Node ID 85c38ea4d34969797eb5d24265cd90cc6841e6ae
6 # Parent 5aa243a2fe9d77578dd95ce3ab3a2aa6c1e92604
7 Bug 1663715 - Update syn and proc-macro2 so that Firefox can build on Rust nightly again. r=froydnj, a=RyanVM
11 cargo update -p syn --precise 1.0.40
14 Rust issue: https://github.com/rust-lang/rust/issues/76482
16 Differential Revision: https://phabricator.services.mozilla.com/D89473
18 diff --git a/Cargo.lock b/Cargo.lock
21 @@ -3712,19 +3712,19 @@ checksum = "ecd45702f76d6d3c75a80564378a
31 -source = "registry+https://github.com/rust-lang/crates.io-index"
32 -checksum = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0"
34 +source = "registry+https://github.com/rust-lang/crates.io-index"
35 +checksum = "175c513d55719db99da20232b06cda8bab6b83ec2d04e3283edf0213c37c1a29"
41 name = "procedural-masquerade"
43 source = "registry+https://github.com/rust-lang/crates.io-index"
44 @@ -4642,19 +4642,19 @@ dependencies = [
54 -source = "registry+https://github.com/rust-lang/crates.io-index"
55 -checksum = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf"
57 +source = "registry+https://github.com/rust-lang/crates.io-index"
58 +checksum = "963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350"
67 diff --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
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
75 diff --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
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)
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"
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"
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"]
106 -name = "proc_macro2"
107 +[package.metadata.playground]
108 +features = ["span-locations"]
109 [dependencies.unicode-xid]
111 [dev-dependencies.quote]
113 default_features = false
116 default = ["proc-macro"]
121 -repository = "alexcrichton/proc-macro2"
122 diff --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
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)
133 A wrapper around the procedural macro API of the compiler's `proc_macro` crate.
134 This library serves two purposes:
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
138 diff --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
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.
151 +// Enable Span::mixed_site() and non-dummy behavior of Span::resolved_at
152 +// and Span::located_at. Enabled on Rust 1.45+.
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
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");
167 if semver_exempt || cfg!(feature = "span-locations") {
168 println!("cargo:rustc-cfg=span_locations");
171 + if version.minor < 39 {
172 + println!("cargo:rustc-cfg=no_bind_by_move_pattern_guard");
175 + if version.minor >= 45 {
176 + println!("cargo:rustc-cfg=hygiene");
179 let target = env::var("TARGET").unwrap();
180 if !enable_use_proc_macro(&target) {
184 println!("cargo:rustc-cfg=use_proc_macro");
186 if version.nightly || !semver_exempt {
187 diff --git a/third_party/rust/proc-macro2/src/detection.rs b/third_party/rust/proc-macro2/src/detection.rs
190 +++ b/third_party/rust/proc-macro2/src/detection.rs
192 +use std::panic::{self, PanicInfo};
193 +use std::sync::atomic::*;
194 +use std::sync::Once;
196 +static WORKS: AtomicUsize = AtomicUsize::new(0);
197 +static INIT: Once = Once::new();
199 +pub(crate) fn inside_proc_macro() -> bool {
200 + match WORKS.load(Ordering::SeqCst) {
206 + INIT.call_once(initialize);
207 + inside_proc_macro()
210 +pub(crate) fn force_fallback() {
211 + WORKS.store(1, Ordering::SeqCst);
214 +pub(crate) fn unforce_fallback() {
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.
223 +// The Once is to prevent the possibility of this ordering:
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
232 +// in which the user's hook has been lost.
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.
243 + type PanicHook = dyn Fn(&PanicInfo) + Sync + Send + 'static;
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);
250 + let works = panic::catch_unwind(proc_macro::Span::call_site).is_ok();
251 + WORKS.store(works as usize + 1, Ordering::SeqCst);
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");
259 diff --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
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)]
271 +use std::fmt::{self, Debug, Display};
272 +use std::iter::FromIterator;
274 use std::ops::RangeBounds;
275 #[cfg(procmacro2_semver_exempt)]
277 use std::path::PathBuf;
278 use std::str::FromStr;
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;
285 +/// Force use of proc-macro2's fallback implementation of the API for now, even
286 +/// if the compiler's implementation is available.
288 + #[cfg(wrap_proc_macro)]
289 + crate::detection::force_fallback();
292 +/// Resume using the compiler's implementation of the proc macro API if it is
295 + #[cfg(wrap_proc_macro)]
296 + crate::detection::unforce_fallback();
300 -pub struct TokenStream {
301 - inner: Vec<TokenTree>,
302 +pub(crate) struct TokenStream {
303 + pub(crate) inner: Vec<TokenTree>,
307 -pub struct LexError;
308 +pub(crate) struct LexError;
311 pub fn new() -> TokenStream {
312 TokenStream { inner: Vec::new() }
315 pub fn is_empty(&self) -> bool {
316 self.inner.len() == 0
319 + fn take_inner(&mut self) -> Vec<TokenTree> {
320 + mem::replace(&mut self.inner, Vec::new())
323 + fn push_token(&mut self, token: TokenTree) {
324 + // https://github.com/alexcrichton/proc-macro2/issues/235
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))]
333 + }) if literal.text.starts_with('-') => {
334 + push_negative_literal(self, literal);
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))]
344 + if literal.text.starts_with('-') {
345 + push_negative_literal(self, literal);
348 + .push(TokenTree::Literal(crate::Literal::_new_stable(literal)));
351 + _ => self.inner.push(token),
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));
362 + .push(TokenTree::Literal(crate::Literal::_new_stable(literal)));
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,
375 + #[cfg(wrap_proc_macro)]
376 + let group = match group {
377 + crate::imp::Group::Fallback(group) => group,
380 + let mut group = group;
381 + self.inner.extend(group.stream.take_inner());
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 {
394 impl FromStr for TokenStream {
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);
401 - match token_stream(cursor) {
402 - Ok((input, output)) => {
403 - if skip_whitespace(input).len() != 0 {
409 - Err(LexError) => Err(LexError),
410 + let (rest, tokens) = token_stream(cursor)?;
411 + if rest.is_empty() {
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 {
429 - TokenTree::Group(ref tt) => {
430 - let (start, end) = match tt.delimiter() {
431 - Delimiter::Parenthesis => ("(", ")"),
432 - Delimiter::Brace => ("{", "}"),
433 - Delimiter::Bracket => ("[", "]"),
434 - Delimiter::None => ("", ""),
436 - if tt.stream().into_iter().next().is_none() {
437 - write!(f, "{} {}", start, end)?
439 - write!(f, "{} {} {}", start, tt.stream(), end)?
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)
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,
456 - TokenTree::Literal(ref tt) => write!(f, "{}", tt)?,
458 + TokenTree::Literal(tt) => Display::fmt(tt, f),
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()
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
479 .expect("failed to parse to compiler tokens")
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);
492 -impl iter::FromIterator<TokenTree> for TokenStream {
493 - fn from_iter<I: IntoIterator<Item = TokenTree>>(streams: I) -> Self {
494 - let mut v = Vec::new();
496 - for token in streams.into_iter() {
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);
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();
514 - for stream in streams.into_iter() {
515 - v.extend(stream.inner);
516 + for mut stream in streams {
517 + v.extend(stream.take_inner());
520 TokenStream { inner: v }
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));
532 impl Extend<TokenStream> for TokenStream {
533 fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I) {
535 - .extend(streams.into_iter().flat_map(|stream| stream));
536 + self.inner.extend(streams.into_iter().flatten());
540 -pub type TokenTreeIter = vec::IntoIter<TokenTree>;
541 +pub(crate) type TokenTreeIter = vec::IntoIter<TokenTree>;
543 impl IntoIterator for TokenStream {
544 type Item = TokenTree;
545 type IntoIter = TokenTreeIter;
547 - fn into_iter(self) -> TokenTreeIter {
548 - self.inner.into_iter()
549 + fn into_iter(mut self) -> TokenTreeIter {
550 + self.take_inner().into_iter()
554 #[derive(Clone, PartialEq, Eq)]
555 -pub struct SourceFile {
556 +pub(crate) struct SourceFile {
561 /// Get the path to this source file as a string.
562 pub fn path(&self) -> PathBuf {
566 pub fn is_real(&self) -> bool {
567 // XXX(nika): Support real files in the future?
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())
582 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
583 -pub struct LineColumn {
584 +pub(crate) struct LineColumn {
589 #[cfg(span_locations)]
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.
595 + files: vec![FileInfo {
596 #[cfg(procmacro2_semver_exempt)]
599 - name: "<unspecified>".to_owned(),
600 - span: Span { lo: 0, hi: 0 },
605 - #[cfg(not(procmacro2_semver_exempt))]
608 - span: Span { lo: 0, hi: 0 },
612 + name: "<unspecified>".to_owned(),
613 + span: Span { lo: 0, hi: 0 },
619 #[cfg(span_locations)]
621 #[cfg(procmacro2_semver_exempt)]
623 @@ -277,26 +323,31 @@ impl FileInfo {
627 fn span_within(&self, span: Span) -> bool {
628 span.lo >= self.span.lo && span.hi <= self.span.hi
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];
640 - while let Some(len) = s[prev..].find('\n') {
645 + for ch in s.chars() {
656 #[cfg(span_locations)]
658 files: Vec<FileInfo>,
661 #[cfg(span_locations)]
662 @@ -305,81 +356,83 @@ impl SourceMap {
663 // Add 1 so there's always space between files.
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
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?
677 - hi: lo + (src.len() as u32),
678 + hi: lo + (len as u32),
681 - #[cfg(procmacro2_semver_exempt)]
682 self.files.push(FileInfo {
683 + #[cfg(procmacro2_semver_exempt)]
684 name: name.to_owned(),
689 #[cfg(not(procmacro2_semver_exempt))]
690 - self.files.push(FileInfo { span, lines });
696 fn fileinfo(&self, span: Span) -> &FileInfo {
697 for file in &self.files {
698 if file.span_within(span) {
702 panic!("Invalid span with no related FileInfo!");
706 #[derive(Clone, Copy, PartialEq, Eq)]
708 +pub(crate) struct Span {
709 #[cfg(span_locations)]
711 + pub(crate) lo: u32,
712 #[cfg(span_locations)]
714 + pub(crate) hi: u32,
718 #[cfg(not(span_locations))]
719 pub fn call_site() -> Span {
723 #[cfg(span_locations)]
724 pub fn call_site() -> Span {
725 Span { lo: 0, hi: 0 }
729 + pub fn mixed_site() -> Span {
733 #[cfg(procmacro2_semver_exempt)]
734 pub fn def_site() -> Span {
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.
746 - #[cfg(procmacro2_semver_exempt)]
747 pub fn located_at(&self, other: Span) -> Span {
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 {
759 lo: cmp::min(self.lo, other.lo),
760 hi: cmp::max(self.hi, other.hi),
765 + #[cfg(not(span_locations))]
766 + fn first_byte(self) -> Self {
770 + #[cfg(span_locations)]
771 + fn first_byte(self) -> Self {
774 + hi: cmp::min(self.lo.saturating_add(1), self.hi),
778 + #[cfg(not(span_locations))]
779 + fn last_byte(self) -> Self {
783 + #[cfg(span_locations)]
784 + fn last_byte(self) -> Self {
786 + lo: cmp::max(self.hi.saturating_sub(1), self.lo),
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);
799 - #[cfg(not(procmacro2_semver_exempt))]
800 + #[cfg(not(span_locations))]
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)]
810 + if span.lo == 0 && span.hi == 0 {
815 + if cfg!(span_locations) {
816 debug.field("span", &span);
822 +pub(crate) struct Group {
823 delimiter: Delimiter,
829 pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group {
831 @@ -469,58 +555,67 @@ impl Group {
835 pub fn span(&self) -> Span {
839 pub fn span_open(&self) -> Span {
841 + self.span.first_byte()
844 pub fn span_close(&self) -> Span {
846 + self.span.last_byte()
849 pub fn set_span(&mut self, span: Span) {
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 => ("", ""),
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() {
881 + f.write_str(close)?;
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);
902 +pub(crate) struct Ident {
909 fn _new(string: &str, raw: bool, span: Span) -> Ident {
910 validate_ident(string);
911 @@ -544,26 +639,24 @@ impl Ident {
915 pub fn set_span(&mut self, span: Span) {
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')
926 || (c > '\x7f' && UnicodeXID::is_xid_start(c))
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')
935 || ('0' <= c && c <= '9')
936 || (c > '\x7f' && UnicodeXID::is_xid_continue(c))
939 fn validate_ident(string: &str) {
940 @@ -610,49 +703,49 @@ where
942 other.starts_with("r#") && self.sym == other[2..]
949 -impl fmt::Display for Ident {
950 +impl Display for Ident {
951 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
954 + f.write_str("r#")?;
957 + Display::fmt(&self.sym, f)
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));
974 // span: bytes(128..138)
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);
988 -pub struct Literal {
989 +pub(crate) struct Literal {
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())
1007 - fn _new(text: String) -> Literal {
1008 + pub(crate) fn _new(text: String) -> Literal {
1011 span: Span::call_site(),
1017 @@ -706,61 +799,62 @@ impl Literal {
1018 i32_unsuffixed => i32,
1019 i64_unsuffixed => i64,
1020 i128_unsuffixed => i128,
1021 isize_unsuffixed => isize,
1024 pub fn f32_unsuffixed(f: f32) -> Literal {
1025 let mut s = f.to_string();
1026 - if !s.contains(".") {
1027 + if !s.contains('.') {
1033 pub fn f64_unsuffixed(f: f64) -> Literal {
1034 let mut s = f.to_string();
1035 - if !s.contains(".") {
1036 + if !s.contains('.') {
1042 pub fn string(t: &str) -> Literal {
1043 let mut text = String::with_capacity(t.len() + 2);
1045 for c in t.chars() {
1047 - // escape_default turns this into "\'" which is unnecessary.
1048 + // escape_debug turns this into "\'" which is unnecessary.
1051 - text.extend(c.escape_default());
1052 + text.extend(c.escape_debug());
1059 pub fn character(t: char) -> Literal {
1060 let mut text = String::new();
1063 - // escape_default turns this into '\"' which is unnecessary.
1064 + // escape_debug turns this into '\"' which is unnecessary.
1067 - text.extend(t.escape_default());
1068 + text.extend(t.escape_debug());
1074 pub fn byte_string(bytes: &[u8]) -> Literal {
1075 let mut escaped = "b\"".to_string();
1077 + #[allow(clippy::match_overlapping_arm)]
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 {
1090 pub fn subspan<R: RangeBounds<usize>>(&self, _range: R) -> Option<Span> {
1095 -impl fmt::Display for Literal {
1096 +impl Display for Literal {
1097 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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);
1112 -fn token_stream(mut input: Cursor) -> PResult<TokenStream> {
1113 - let mut trees = Vec::new();
1115 - let input_no_ws = skip_whitespace(input);
1116 - if input_no_ws.rest.len() == 0 {
1119 - if let Ok((a, tokens)) = doc_comment(input_no_ws) {
1121 - trees.extend(tokens);
1125 - let (a, tt) = match token_tree(input_no_ws) {
1132 - Ok((input, TokenStream { inner: trees }))
1135 -#[cfg(not(span_locations))]
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())))))
1144 -#[cfg(span_locations)]
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)?;
1153 - let span = crate::Span::_new_stable(Span { lo, hi });
1154 - Ok((a, (b, span)))
1157 -fn token_tree(input: Cursor) -> PResult<TokenTree> {
1158 - let (rest, (mut tt, span)) = spanned(input, token_kind)?;
1159 - tt.set_span(span);
1163 -named!(token_kind -> TokenTree, alt!(
1164 - map!(group, |g| TokenTree::Group(crate::Group::_new_stable(g)))
1166 - map!(literal, |l| TokenTree::Literal(crate::Literal::_new_stable(l))) // must be before symbol
1168 - map!(op, TokenTree::Punct)
1173 -named!(group -> Group, alt!(
1178 - ) => { |ts| Group::new(Delimiter::Parenthesis, ts) }
1184 - ) => { |ts| Group::new(Delimiter::Bracket, ts) }
1190 - ) => { |ts| Group::new(Delimiter::Brace, ts) }
1193 -fn symbol_leading_ws(input: Cursor) -> PResult<TokenTree> {
1194 - symbol(skip_whitespace(input))
1197 -fn symbol(input: Cursor) -> PResult<TokenTree> {
1198 - let raw = input.starts_with("r#");
1199 - let rest = input.advance((raw as usize) << 1);
1201 - let (rest, sym) = symbol_not_raw(rest)?;
1204 - let ident = crate::Ident::new(sym, crate::Span::call_site());
1205 - return Ok((rest, ident.into()));
1209 - return Err(LexError);
1212 - let ident = crate::Ident::_new_raw(sym, crate::Span::call_site());
1213 - Ok((rest, ident.into()))
1216 -fn symbol_not_raw(input: Cursor) -> PResult<&str> {
1217 - let mut chars = input.char_indices();
1219 - match chars.next() {
1220 - Some((_, ch)) if is_ident_start(ch) => {}
1221 - _ => return Err(LexError),
1224 - let mut end = input.len();
1225 - for (i, ch) in chars {
1226 - if !is_ident_continue(ch) {
1232 - Ok((input.advance(end), &input.rest[..end]))
1235 -fn literal(input: Cursor) -> PResult<Literal> {
1236 - let input_no_ws = skip_whitespace(input);
1238 - match literal_nocapture(input_no_ws) {
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())))
1245 - Err(LexError) => Err(LexError),
1246 + Display::fmt(&self.text, f)
1250 -named!(literal_nocapture -> (), alt!(
1264 -named!(string -> (), alt!(
1273 -named!(quoted_string -> (), do_parse!(
1277 - option!(symbol_not_raw) >>
1281 -fn cooked_string(input: Cursor) -> PResult<()> {
1282 - let mut chars = input.char_indices().peekable();
1283 - while let Some((byte_offset, ch)) = chars.next() {
1286 - return Ok((input.advance(byte_offset), ()));
1289 - if let Some((_, '\n')) = chars.next() {
1295 - '\\' => match chars.next() {
1296 - Some((_, 'x')) => {
1297 - if !backslash_x_char(&mut chars) {
1301 - Some((_, 'n')) | Some((_, 'r')) | Some((_, 't')) | Some((_, '\\'))
1302 - | Some((_, '\'')) | Some((_, '"')) | Some((_, '0')) => {}
1303 - Some((_, 'u')) => {
1304 - if !backslash_u(&mut chars) {
1308 - Some((_, '\n')) | Some((_, '\r')) => {
1309 - while let Some(&(_, ch)) = chars.peek() {
1310 - if ch.is_whitespace() {
1325 -named!(byte_string -> (), alt!(
1328 - cooked_byte_string,
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() {
1343 - return Ok((input.advance(offset), ()));
1346 - if let Some((_, b'\n')) = bytes.next() {
1352 - b'\\' => match bytes.next() {
1353 - Some((_, b'x')) => {
1354 - if !backslash_x_byte(&mut bytes) {
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();
1373 - b if b < 0x80 => {}
1380 -fn raw_string(input: Cursor) -> PResult<()> {
1381 - let mut chars = input.char_indices();
1383 - while let Some((byte_offset, ch)) = chars.next() {
1390 - _ => return Err(LexError),
1393 - for (byte_offset, ch) in chars {
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, ()));
1406 -named!(byte -> (), do_parse!(
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,
1426 - match bytes.next() {
1427 - Some((offset, _)) => {
1428 - if input.chars().as_str().is_char_boundary(offset) {
1429 - Ok((input.advance(offset), ()))
1434 - None => Ok((input.advance(input.len()), ())),
1441 -named!(character -> (), do_parse!(
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('"') => {
1459 - ch => ch.is_some(),
1462 - match chars.next() {
1463 - Some((idx, _)) => Ok((input.advance(idx), ())),
1464 - None => Ok((input.advance(input.len()), ())),
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);
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,
1484 - None => return false
1489 -fn backslash_x_char<I>(chars: &mut I) -> bool
1491 - I: Iterator<Item = (usize, char)>,
1493 - next_ch!(chars @ '0'..='7');
1494 - next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
1498 -fn backslash_x_byte<I>(chars: &mut I) -> bool
1500 - I: Iterator<Item = (usize, u8)>,
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');
1507 -fn backslash_u<I>(chars: &mut I) -> bool
1509 - I: Iterator<Item = (usize, char)>,
1511 - next_ch!(chars @ '{');
1512 - next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
1514 - let c = next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F' | '_' | '}');
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;
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),
1539 - let mut has_dot = false;
1540 - let mut has_exp = false;
1541 - while let Some(&ch) = chars.peek() {
1543 - '0'..='9' | '_' => {
1554 - .map(|&ch| ch == '.' || is_ident_start(ch))
1557 - return Err(LexError);
1572 - let rest = input.advance(len);
1573 - if !(has_dot || has_exp || rest.starts_with("f32") || rest.starts_with("f64")) {
1574 - return Err(LexError);
1578 - let mut has_exp_value = false;
1579 - while let Some(&ch) = chars.peek() {
1582 - if has_exp_value {
1591 - has_exp_value = true;
1600 - if !has_exp_value {
1601 - return Err(LexError);
1605 - Ok((input.advance(len), ()))
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;
1618 -fn digits(mut input: Cursor) -> PResult<()> {
1619 - let base = if input.starts_with("0x") {
1620 - input = input.advance(2);
1622 - } else if input.starts_with("0o") {
1623 - input = input.advance(2);
1625 - } else if input.starts_with("0b") {
1626 - input = input.advance(2);
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,
1640 - if empty && base == 10 {
1641 - return Err(LexError);
1648 - if digit >= base {
1649 - return Err(LexError);
1657 - Ok((input.advance(len), ()))
1661 -fn op(input: Cursor) -> PResult<Punct> {
1662 - let input = skip_whitespace(input);
1663 - match op_char(input) {
1664 - Ok((rest, '\'')) => {
1666 - Ok((rest, Punct::new('\'', Spacing::Joint)))
1668 - Ok((rest, ch)) => {
1669 - let kind = match op_char(rest) {
1670 - Ok(_) => Spacing::Joint,
1671 - Err(LexError) => Spacing::Alone,
1673 - Ok((rest, Punct::new(ch, kind)))
1675 - Err(LexError) => Err(LexError),
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);
1685 - let mut chars = input.chars();
1686 - let first = match chars.next() {
1689 - return Err(LexError);
1692 - let recognized = "~!@#$%^&*-=+|;:,<.>/?'";
1693 - if recognized.contains(first) {
1694 - Ok((input.advance(first.len_utf8()), first))
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)));
1705 - trees.push(Punct::new('!', Spacing::Alone).into());
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)),
1712 - for tt in stream.iter_mut() {
1713 - tt.set_span(span);
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);
1723 -named!(doc_comment_contents -> (&str, bool), alt!(
1726 - s: take_until_newline_or_eof!() >>
1731 - option!(whitespace) >>
1732 - peek!(tag!("/*!")) >>
1733 - s: block_comment >>
1739 - not!(tag!("/")) >>
1740 - s: take_until_newline_or_eof!() >>
1745 - option!(whitespace) >>
1746 - peek!(tuple!(tag!("/**"), not!(tag!("*")))) >>
1747 - s: block_comment >>
1751 diff --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
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.
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)]
1769 #[cfg(use_proc_macro)]
1770 extern crate proc_macro;
1772 use std::cmp::Ordering;
1774 +use std::fmt::{self, Debug, Display};
1775 use std::hash::{Hash, Hasher};
1776 use std::iter::FromIterator;
1778 use std::ops::RangeBounds;
1779 #[cfg(procmacro2_semver_exempt)]
1780 use std::path::PathBuf;
1782 use std::str::FromStr;
1789 +#[cfg(wrap_proc_macro)]
1792 +// Public for proc_macro2::fallback::force() and unforce(), but those are quite
1793 +// a niche use case so we omit it from rustdoc.
1797 #[cfg(not(wrap_proc_macro))]
1798 use crate::fallback as imp;
1799 #[path = "wrapper.rs"]
1800 #[cfg(wrap_proc_macro)]
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())
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 {
1817 + Display::fmt(&self.inner, f)
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 {
1826 + Debug::fmt(&self.inner, f)
1830 -impl fmt::Debug for LexError {
1831 +impl Debug for LexError {
1832 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1834 + Debug::fmt(&self.inner, f)
1838 /// The source file of a given `Span`.
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()
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 {
1856 + Debug::fmt(&self.inner, f)
1860 /// A line-column pair representing the start or end of a `Span`.
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
1869 /// The 0-indexed column (in UTF-8 characters) in the source file on which
1870 /// the span starts or ends (inclusive).
1874 +#[cfg(span_locations)]
1875 +impl Ord for LineColumn {
1876 + fn cmp(&self, other: &Self) -> Ordering {
1879 + .then(self.column.cmp(&other.column))
1883 +#[cfg(span_locations)]
1884 +impl PartialOrd for LineColumn {
1885 + fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
1886 + Some(self.cmp(other))
1890 /// A region of source code, along with macro expansion information.
1891 #[derive(Copy, Clone)]
1894 _marker: marker::PhantomData<Rc<()>>,
1898 @@ -337,38 +360,42 @@ impl Span {
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())
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`.
1911 + /// This function requires Rust 1.45 or later.
1913 + pub fn mixed_site() -> Span {
1914 + Span::_new(imp::Span::mixed_site())
1917 /// A span that resolves at the macro definition site.
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())
1925 /// Creates a new span with the same line/column information as `self` but
1926 /// that resolves symbols as though it were at `other`.
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))
1934 /// Creates a new span with the same name resolution behavior as `self` but
1935 /// with the line/column information of `other`.
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))
1943 /// Convert `proc_macro2::Span` to `proc_macro::Span`.
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)
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 {
1960 + Debug::fmt(&self.inner, f)
1964 /// A single token or a delimited sequence of token trees (e.g. `[1, (), ..]`).
1966 pub enum TokenTree {
1967 /// A token stream surrounded by bracket delimiters.
1969 @@ -457,35 +484,35 @@ pub enum TokenTree {
1970 /// A literal character (`'a'`), string (`"hello"`), number (`2.3`), etc.
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 {
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(),
1984 + TokenTree::Group(t) => t.span(),
1985 + TokenTree::Ident(t) => t.span(),
1986 + TokenTree::Punct(t) => t.span(),
1987 + TokenTree::Literal(t) => t.span(),
1991 /// Configures the span for *only this token*.
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) {
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),
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),
2011 impl From<Group> for TokenTree {
2012 fn from(g: Group) -> TokenTree {
2015 @@ -508,42 +535,42 @@ impl From<Literal> for TokenTree {
2016 TokenTree::Literal(g)
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 {
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),
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),
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
2048 - TokenTree::Group(ref t) => t.fmt(f),
2049 - TokenTree::Ident(ref t) => {
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);
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),
2066 /// A delimited token stream.
2068 /// A `Group` internally contains a `TokenStream` which is surrounded by
2070 @@ -646,25 +673,25 @@ impl Group {
2071 pub fn set_span(&mut self, span: Span) {
2072 self.inner.set_span(span.inner)
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)
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)
2095 /// An `Punct` is an single punctuation character like `+`, `-` or `#`.
2097 /// Multicharacter operators like `+=` are represented as two instances of
2098 /// `Punct` with different forms of `Spacing` returned.
2100 @@ -725,23 +752,23 @@ impl Punct {
2101 /// Configure the span for this punctuation character.
2102 pub fn set_span(&mut self, span: Span) {
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 {
2113 + Display::fmt(&self.op, f)
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);
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)
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 {
2140 + Display::fmt(&self.inner, f)
2144 -impl fmt::Debug for Ident {
2145 +impl Debug for Ident {
2146 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2148 + Debug::fmt(&self.inner, f)
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`).
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`.
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)
2166 -impl fmt::Debug for Literal {
2167 +impl Debug for Literal {
2168 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2170 + Debug::fmt(&self.inner, f)
2174 -impl fmt::Display for Literal {
2175 +impl Display for Literal {
2176 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2178 + Display::fmt(&self.inner, f)
2182 /// Public implementation details for the `TokenStream` type, such as iterators.
2183 pub mod token_stream {
2185 + use crate::{imp, TokenTree};
2186 + use std::fmt::{self, Debug};
2190 pub use crate::TokenStream;
2191 - use crate::{imp, TokenTree};
2193 /// An iterator over `TokenStream`'s `TokenTree`s.
2195 /// The iteration is "shallow", e.g. the iterator doesn't recurse into
2196 /// delimited groups, and returns whole groups as token trees.
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;
2204 fn next(&mut self) -> Option<TokenTree> {
2209 - impl fmt::Debug for IntoIter {
2210 + impl Debug for IntoIter {
2211 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2213 + Debug::fmt(&self.inner, f)
2217 impl IntoIterator for TokenStream {
2218 type Item = TokenTree;
2219 type IntoIter = IntoIter;
2221 fn into_iter(self) -> IntoIter {
2222 diff --git a/third_party/rust/proc-macro2/src/parse.rs b/third_party/rust/proc-macro2/src/parse.rs
2223 new file mode 100644
2225 +++ b/third_party/rust/proc-macro2/src/parse.rs
2227 +use crate::fallback::{
2228 + is_ident_continue, is_ident_start, Group, LexError, Literal, Span, TokenStream,
2230 +use crate::{Delimiter, Punct, Spacing, TokenTree};
2231 +use std::str::{Bytes, CharIndices, Chars};
2232 +use unicode_xid::UnicodeXID;
2234 +#[derive(Copy, Clone, Eq, PartialEq)]
2235 +pub(crate) struct Cursor<'a> {
2236 + pub rest: &'a str,
2237 + #[cfg(span_locations)]
2241 +impl<'a> Cursor<'a> {
2242 + fn advance(&self, bytes: usize) -> Cursor<'a> {
2243 + let (_front, rest) = self.rest.split_at(bytes);
2246 + #[cfg(span_locations)]
2247 + off: self.off + _front.chars().count() as u32,
2251 + fn starts_with(&self, s: &str) -> bool {
2252 + self.rest.starts_with(s)
2255 + pub(crate) fn is_empty(&self) -> bool {
2256 + self.rest.is_empty()
2259 + fn len(&self) -> usize {
2263 + fn as_bytes(&self) -> &'a [u8] {
2264 + self.rest.as_bytes()
2267 + fn bytes(&self) -> Bytes<'a> {
2271 + fn chars(&self) -> Chars<'a> {
2275 + fn char_indices(&self) -> CharIndices<'a> {
2276 + self.rest.char_indices()
2279 + fn parse(&self, tag: &str) -> Result<Cursor<'a>, LexError> {
2280 + if self.starts_with(tag) {
2281 + Ok(self.advance(tag.len()))
2288 +type PResult<'a, O> = Result<(Cursor<'a>, O), LexError>;
2290 +fn skip_whitespace(input: Cursor) -> Cursor {
2291 + let mut s = input;
2293 + while !s.is_empty() {
2294 + let byte = s.as_bytes()[0];
2296 + if s.starts_with("//")
2297 + && (!s.starts_with("///") || s.starts_with("////"))
2298 + && !s.starts_with("//!")
2300 + let (cursor, _) = take_until_newline_or_eof(s);
2303 + } else if s.starts_with("/**/") {
2306 + } else if s.starts_with("/*")
2307 + && (!s.starts_with("/**") || s.starts_with("/***"))
2308 + && !s.starts_with("/*!")
2310 + match block_comment(s) {
2311 + Ok((rest, _)) => {
2315 + Err(LexError) => return s,
2320 + b' ' | 0x09..=0x0d => {
2324 + b if b <= 0x7f => {}
2326 + let ch = s.chars().next().unwrap();
2327 + if is_whitespace(ch) {
2328 + s = s.advance(ch.len_utf8());
2338 +fn block_comment(input: Cursor) -> PResult<&str> {
2339 + if !input.starts_with("/*") {
2340 + return Err(LexError);
2343 + let mut depth = 0;
2344 + let bytes = input.as_bytes();
2346 + let upper = bytes.len() - 1;
2349 + if bytes[i] == b'/' && bytes[i + 1] == b'*' {
2351 + i += 1; // eat '*'
2352 + } else if bytes[i] == b'*' && bytes[i + 1] == b'/' {
2355 + return Ok((input.advance(i + 2), &input.rest[..i + 2]));
2357 + i += 1; // eat '/'
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}'
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),
2377 +pub(crate) fn token_stream(mut input: Cursor) -> PResult<TokenStream> {
2378 + let mut trees = Vec::new();
2379 + let mut stack = Vec::new();
2382 + input = skip_whitespace(input);
2384 + if let Ok((rest, tt)) = doc_comment(input) {
2390 + #[cfg(span_locations)]
2391 + let lo = input.off;
2393 + let first = match input.bytes().next() {
2394 + Some(first) => first,
2398 + if let Some(open_delimiter) = match first {
2399 + b'(' => Some(Delimiter::Parenthesis),
2400 + b'[' => Some(Delimiter::Bracket),
2401 + b'{' => Some(Delimiter::Brace),
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),
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);
2424 + let mut g = Group::new(open_delimiter, TokenStream { inner: trees });
2426 + #[cfg(span_locations)]
2428 + #[cfg(span_locations)]
2432 + trees.push(TokenTree::Group(crate::Group::_new_stable(g)));
2434 + let (rest, mut tt) = leaf_token(input)?;
2435 + tt.set_span(crate::Span::_new_stable(Span {
2436 + #[cfg(span_locations)]
2438 + #[cfg(span_locations)]
2446 + if stack.is_empty() {
2447 + Ok((input, TokenStream { inner: trees }))
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)))
2466 +fn ident(input: Cursor) -> PResult<crate::Ident> {
2467 + let raw = input.starts_with("r#");
2468 + let rest = input.advance((raw as usize) << 1);
2470 + let (rest, sym) = ident_not_raw(rest)?;
2473 + let ident = crate::Ident::new(sym, crate::Span::call_site());
2474 + return Ok((rest, ident));
2478 + return Err(LexError);
2481 + let ident = crate::Ident::_new_raw(sym, crate::Span::call_site());
2485 +fn ident_not_raw(input: Cursor) -> PResult<&str> {
2486 + let mut chars = input.char_indices();
2488 + match chars.next() {
2489 + Some((_, ch)) if is_ident_start(ch) => {}
2490 + _ => return Err(LexError),
2493 + let mut end = input.len();
2494 + for (i, ch) in chars {
2495 + if !is_ident_continue(ch) {
2501 + Ok((input.advance(end), &input.rest[..end]))
2504 +fn literal(input: Cursor) -> PResult<Literal> {
2505 + match literal_nocapture(input) {
2507 + let end = input.len() - a.len();
2508 + Ok((a, Literal::_new(input.rest[..end].to_string())))
2510 + Err(LexError) => Err(LexError),
2514 +fn literal_nocapture(input: Cursor) -> Result<Cursor, LexError> {
2515 + if let Ok(ok) = string(input) {
2517 + } else if let Ok(ok) = byte_string(input) {
2519 + } else if let Ok(ok) = byte(input) {
2521 + } else if let Ok(ok) = character(input) {
2523 + } else if let Ok(ok) = float(input) {
2525 + } else if let Ok(ok) = int(input) {
2532 +fn literal_suffix(input: Cursor) -> Cursor {
2533 + match ident_not_raw(input) {
2534 + Ok((input, _)) => input,
2535 + Err(LexError) => input,
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") {
2549 +fn cooked_string(input: Cursor) -> Result<Cursor, LexError> {
2550 + let mut chars = input.char_indices().peekable();
2552 + while let Some((i, ch)) = chars.next() {
2555 + let input = input.advance(i + 1);
2556 + return Ok(literal_suffix(input));
2559 + if let Some((_, '\n')) = chars.next() {
2565 + '\\' => match chars.next() {
2566 + Some((_, 'x')) => {
2567 + if !backslash_x_char(&mut chars) {
2571 + Some((_, 'n')) | Some((_, 'r')) | Some((_, 't')) | Some((_, '\\'))
2572 + | Some((_, '\'')) | Some((_, '"')) | Some((_, '0')) => {}
2573 + Some((_, 'u')) => {
2574 + if !backslash_u(&mut chars) {
2578 + Some((_, '\n')) | Some((_, '\r')) => {
2579 + while let Some(&(_, ch)) = chars.peek() {
2580 + if ch.is_whitespace() {
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") {
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() {
2610 + let input = input.advance(offset + 1);
2611 + return Ok(literal_suffix(input));
2614 + if let Some((_, b'\n')) = bytes.next() {
2620 + b'\\' => match bytes.next() {
2621 + Some((_, b'x')) => {
2622 + if !backslash_x_byte(&mut bytes) {
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();
2641 + b if b < 0x80 => {}
2648 +fn raw_string(input: Cursor) -> Result<Cursor, LexError> {
2649 + let mut chars = input.char_indices();
2651 + while let Some((i, ch)) = chars.next() {
2658 + _ => return Err(LexError),
2661 + for (i, ch) in chars {
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));
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,
2687 + return Err(LexError);
2689 + let (offset, _) = bytes.next().ok_or(LexError)?;
2690 + if !input.chars().as_str().is_char_boundary(offset) {
2691 + return Err(LexError);
2693 + let input = input.advance(offset).parse("'")?;
2694 + Ok(literal_suffix(input))
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('"') => {
2709 + ch => ch.is_some(),
2712 + return Err(LexError);
2714 + let (idx, _) = chars.next().ok_or(LexError)?;
2715 + let input = input.advance(idx).parse("'")?;
2716 + Ok(literal_suffix(input))
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,
2726 + None => return false,
2731 +fn backslash_x_char<I>(chars: &mut I) -> bool
2733 + I: Iterator<Item = (usize, char)>,
2735 + next_ch!(chars @ '0'..='7');
2736 + next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
2740 +fn backslash_x_byte<I>(chars: &mut I) -> bool
2742 + I: Iterator<Item = (usize, u8)>,
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');
2749 +fn backslash_u<I>(chars: &mut I) -> bool
2751 + I: Iterator<Item = (usize, char)>,
2753 + next_ch!(chars @ '{');
2754 + next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F');
2756 + let c = next_ch!(chars @ '0'..='9' | 'a'..='f' | 'A'..='F' | '_' | '}');
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;
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),
2781 + let mut has_dot = false;
2782 + let mut has_exp = false;
2783 + while let Some(&ch) = chars.peek() {
2785 + '0'..='9' | '_' => {
2796 + .map(|&ch| ch == '.' || is_ident_start(ch))
2799 + return Err(LexError);
2814 + let rest = input.advance(len);
2815 + if !(has_dot || has_exp || rest.starts_with("f32") || rest.starts_with("f64")) {
2816 + return Err(LexError);
2820 + let mut has_exp_value = false;
2821 + while let Some(&ch) = chars.peek() {
2824 + if has_exp_value {
2833 + has_exp_value = true;
2842 + if !has_exp_value {
2843 + return Err(LexError);
2847 + Ok(input.advance(len))
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;
2860 +fn digits(mut input: Cursor) -> Result<Cursor, LexError> {
2861 + let base = if input.starts_with("0x") {
2862 + input = input.advance(2);
2864 + } else if input.starts_with("0o") {
2865 + input = input.advance(2);
2867 + } else if input.starts_with("0b") {
2868 + input = input.advance(2);
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,
2882 + if empty && base == 10 {
2883 + return Err(LexError);
2890 + if digit >= base {
2891 + return Err(LexError);
2899 + Ok(input.advance(len))
2903 +fn op(input: Cursor) -> PResult<Punct> {
2904 + match op_char(input) {
2905 + Ok((rest, '\'')) => {
2907 + Ok((rest, Punct::new('\'', Spacing::Joint)))
2909 + Ok((rest, ch)) => {
2910 + let kind = match op_char(rest) {
2911 + Ok(_) => Spacing::Joint,
2912 + Err(LexError) => Spacing::Alone,
2914 + Ok((rest, Punct::new(ch, kind)))
2916 + Err(LexError) => Err(LexError),
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);
2926 + let mut chars = input.chars();
2927 + let first = match chars.next() {
2930 + return Err(LexError);
2933 + let recognized = "~!@#$%^&*-=+|;:,<.>/?'";
2934 + if recognized.contains(first) {
2935 + Ok((input.advance(first.len_utf8()), first))
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)]
2948 + #[cfg(span_locations)]
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);
2958 + scan_for_bare_cr = rest;
2961 + let mut trees = Vec::new();
2962 + trees.push(TokenTree::Punct(Punct::new('#', Spacing::Alone)));
2964 + trees.push(Punct::new('!', Spacing::Alone).into());
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)),
2971 + for tt in stream.iter_mut() {
2972 + tt.set_span(span);
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);
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);
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)))
3005 +fn take_until_newline_or_eof(input: Cursor) -> (Cursor, &str) {
3006 + let chars = input.char_indices();
3008 + for (i, ch) in chars {
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]);
3016 + (input.advance(input.len()), input.rest)
3018 diff --git a/third_party/rust/proc-macro2/src/strnom.rs b/third_party/rust/proc-macro2/src/strnom.rs
3019 deleted file mode 100644
3020 --- a/third_party/rust/proc-macro2/src/strnom.rs
3023 -//! Adapted from [`nom`](https://github.com/Geal/nom).
3025 -use crate::fallback::LexError;
3026 -use std::str::{Bytes, CharIndices, Chars};
3027 -use unicode_xid::UnicodeXID;
3029 -#[derive(Copy, Clone, Eq, PartialEq)]
3030 -pub struct Cursor<'a> {
3031 - pub rest: &'a str,
3032 - #[cfg(span_locations)]
3036 -impl<'a> Cursor<'a> {
3037 - #[cfg(not(span_locations))]
3038 - pub fn advance(&self, amt: usize) -> Cursor<'a> {
3040 - rest: &self.rest[amt..],
3043 - #[cfg(span_locations)]
3044 - pub fn advance(&self, amt: usize) -> Cursor<'a> {
3046 - rest: &self.rest[amt..],
3047 - off: self.off + (amt as u32),
3051 - pub fn find(&self, p: char) -> Option<usize> {
3055 - pub fn starts_with(&self, s: &str) -> bool {
3056 - self.rest.starts_with(s)
3059 - pub fn is_empty(&self) -> bool {
3060 - self.rest.is_empty()
3063 - pub fn len(&self) -> usize {
3067 - pub fn as_bytes(&self) -> &'a [u8] {
3068 - self.rest.as_bytes()
3071 - pub fn bytes(&self) -> Bytes<'a> {
3075 - pub fn chars(&self) -> Chars<'a> {
3079 - pub fn char_indices(&self) -> CharIndices<'a> {
3080 - self.rest.char_indices()
3084 -pub type PResult<'a, O> = Result<(Cursor<'a>, O), LexError>;
3086 -pub fn whitespace(input: Cursor) -> PResult<()> {
3087 - if input.is_empty() {
3088 - return Err(LexError);
3091 - let bytes = input.as_bytes();
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("//!")
3100 - if let Some(len) = s.find('\n') {
3105 - } else if s.starts_with("/**/") {
3108 - } else if s.starts_with("/*")
3109 - && (!s.starts_with("/**") || s.starts_with("/***"))
3110 - && !s.starts_with("/*!")
3112 - let (_, com) = block_comment(s)?;
3118 - b' ' | 0x09..=0x0d => {
3122 - b if b <= 0x7f => {}
3124 - let ch = s.chars().next().unwrap();
3125 - if is_whitespace(ch) {
3126 - i += ch.len_utf8();
3131 - return if i > 0 { Ok((s, ())) } else { Err(LexError) };
3133 - Ok((input.advance(input.len()), ()))
3136 -pub fn block_comment(input: Cursor) -> PResult<&str> {
3137 - if !input.starts_with("/*") {
3138 - return Err(LexError);
3141 - let mut depth = 0;
3142 - let bytes = input.as_bytes();
3144 - let upper = bytes.len() - 1;
3146 - if bytes[i] == b'/' && bytes[i + 1] == b'*' {
3148 - i += 1; // eat '*'
3149 - } else if bytes[i] == b'*' && bytes[i + 1] == b'/' {
3152 - return Ok((input.advance(i + 2), &input.rest[..i + 2]));
3154 - i += 1; // eat '/'
3161 -pub fn skip_whitespace(input: Cursor) -> Cursor {
3162 - match whitespace(input) {
3163 - Ok((rest, _)) => rest,
3164 - Err(LexError) => input,
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}'
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, ())),
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)*)
3189 - ($i:expr, $e:ident | $($rest:tt)*) => {
3190 - alt!($i, call!($e) | $($rest)*)
3193 - ($i:expr, $subrule:ident!( $($args:tt)*) | $($rest:tt)*) => {
3194 - match $subrule!($i, $($args)*) {
3195 - res @ Ok(_) => res,
3196 - _ => alt!($i, $($rest)*)
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)*)
3207 - ($i:expr, $e:ident => { $gen:expr } | $($rest:tt)*) => {
3208 - alt!($i, call!($e) => { $gen } | $($rest)*)
3211 - ($i:expr, $e:ident => { $gen:expr }) => {
3212 - alt!($i, call!($e) => { $gen })
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),
3222 - ($i:expr, $e:ident) => {
3223 - alt!($i, call!($e))
3226 - ($i:expr, $subrule:ident!( $($args:tt)*)) => {
3227 - $subrule!($i, $($args)*)
3231 -macro_rules! do_parse {
3232 - ($i:expr, ( $($rest:expr),* )) => {
3233 - Ok(($i, ( $($rest),* )))
3236 - ($i:expr, $e:ident >> $($rest:tt)*) => {
3237 - do_parse!($i, call!($e) >> $($rest)*)
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)*),
3247 - ($i:expr, $field:ident : $e:ident >> $($rest:tt)*) => {
3248 - do_parse!($i, $field: call!($e) >> $($rest)*)
3251 - ($i:expr, $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => {
3252 - match $submac!($i, $($args)*) {
3253 - Err(LexError) => Err(LexError),
3256 - do_parse!(i, $($rest)*)
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),
3271 -macro_rules! call {
3272 - ($i:expr, $fun:expr $(, $args:expr)*) => {
3273 - $fun($i $(, $args)*)
3277 -macro_rules! option {
3278 - ($i:expr, $f:expr) => {
3280 - Ok((i, o)) => Ok((i, Some(o))),
3281 - Err(LexError) => Ok(($i, None)),
3286 -macro_rules! take_until_newline_or_eof {
3288 - if $i.len() == 0 {
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()])),
3299 -macro_rules! tuple {
3300 - ($i:expr, $($rest:tt)*) => {
3301 - tuple_parser!($i, (), $($rest)*)
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)*)
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)*),
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)*),
3325 - ($i:expr, ($($parsed:tt),*), $e:ident) => {
3326 - tuple_parser!($i, ($($parsed),*), call!($e))
3329 - ($i:expr, (), $submac:ident!( $($args:tt)* )) => {
3330 - $submac!($i, $($args)*)
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)))
3340 - ($i:expr, ($($parsed:expr),*)) => {
3341 - Ok(($i, ($($parsed),*)))
3346 - ($i:expr, $submac:ident!( $($args:tt)* )) => {
3347 - match $submac!($i, $($args)*) {
3348 - Ok((_, _)) => Err(LexError),
3349 - Err(LexError) => Ok(($i, ())),
3355 - ($i:expr, $tag:expr) => {
3356 - if $i.starts_with($tag) {
3357 - Ok(($i.advance($tag.len()), &$i.rest[..$tag.len()]))
3364 -macro_rules! punct {
3365 - ($i:expr, $punct:expr) => {
3366 - $crate::strnom::punct($i, $punct)
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))
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),
3388 - ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => {
3389 - preceded!($i, $submac!($($args)*), call!($g))
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))
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)))
3410 - ($i:expr, $f:expr, $g:expr) => {
3411 - map!($i, call!($f), $g)
3414 diff --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
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};
3427 #[cfg(super_unstable)]
3428 use std::path::PathBuf;
3429 use std::str::FromStr;
3431 -use crate::{fallback, Delimiter, Punct, Spacing, TokenTree};
3434 -pub enum TokenStream {
3435 +pub(crate) enum TokenStream {
3436 Compiler(DeferredTokenStream),
3437 Fallback(fallback::TokenStream),
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.
3445 -pub struct DeferredTokenStream {
3446 +pub(crate) struct DeferredTokenStream {
3447 stream: proc_macro::TokenStream,
3448 extra: Vec<proc_macro::TokenTree>,
3451 -pub enum LexError {
3452 +pub(crate) enum LexError {
3453 Compiler(proc_macro::LexError),
3454 Fallback(fallback::LexError),
3457 -fn nightly_works() -> bool {
3458 - use std::sync::atomic::*;
3459 - use std::sync::Once;
3461 - static WORKS: AtomicUsize = AtomicUsize::new(0);
3462 - static INIT: Once = Once::new();
3464 - match WORKS.load(Ordering::SeqCst) {
3465 - 1 => return false,
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.
3475 - // The Once is to prevent the possibility of this ordering:
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
3484 - // in which the user's hook has been lost.
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;
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);
3502 - let works = panic::catch_unwind(|| proc_macro::Span::call_site()).is_ok();
3503 - WORKS.store(works as usize + 1, Ordering::SeqCst);
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");
3514 fn mismatch() -> ! {
3515 panic!("stable/nightly mismatch")
3518 impl DeferredTokenStream {
3519 fn new(stream: proc_macro::TokenStream) -> Self {
3520 DeferredTokenStream {
3522 @@ -98,28 +41,33 @@ impl DeferredTokenStream {
3526 fn is_empty(&self) -> bool {
3527 self.stream.is_empty() && self.extra.is_empty()
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(..));
3540 fn into_token_stream(mut self) -> proc_macro::TokenStream {
3541 self.evaluate_now();
3547 pub fn new() -> TokenStream {
3548 - if nightly_works() {
3549 + if inside_proc_macro() {
3550 TokenStream::Compiler(DeferredTokenStream::new(proc_macro::TokenStream::new()))
3552 TokenStream::Fallback(fallback::TokenStream::new())
3556 pub fn is_empty(&self) -> bool {
3558 @@ -142,31 +90,37 @@ impl TokenStream {
3563 impl FromStr for TokenStream {
3564 type Err = LexError;
3566 fn from_str(src: &str) -> Result<TokenStream, LexError> {
3567 - if nightly_works() {
3568 + if inside_proc_macro() {
3569 Ok(TokenStream::Compiler(DeferredTokenStream::new(
3571 + proc_macro_parse(src)?,
3574 Ok(TokenStream::Fallback(src.parse()?))
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)))
3586 +impl Display for TokenStream {
3587 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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),
3597 impl From<proc_macro::TokenStream> for TokenStream {
3598 fn from(inner: proc_macro::TokenStream) -> TokenStream {
3599 TokenStream::Compiler(DeferredTokenStream::new(inner))
3601 @@ -182,17 +136,17 @@ impl From<TokenStream> for proc_macro::T
3604 impl From<fallback::TokenStream> for TokenStream {
3605 fn from(inner: fallback::TokenStream) -> TokenStream {
3606 TokenStream::Fallback(inner)
3610 -// Assumes nightly_works().
3611 +// Assumes inside_proc_macro().
3612 fn into_compiler_token(token: TokenTree) -> proc_macro::TokenTree {
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,
3620 @@ -202,37 +156,37 @@ fn into_compiler_token(token: TokenTree)
3622 TokenTree::Ident(tt) => tt.inner.unwrap_nightly().into(),
3623 TokenTree::Literal(tt) => tt.inner.unwrap_nightly().into(),
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()))
3633 TokenStream::Fallback(token.into())
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(),
3647 TokenStream::Fallback(trees.into_iter().collect())
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)
3665 None => TokenStream::new(),
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) {
3674 TokenStream::Compiler(tts) => {
3675 // Here is the reason for DeferredTokenStream.
3677 - .extend(streams.into_iter().map(into_compiler_token));
3678 + for token in stream {
3679 + tts.extra.push(into_compiler_token(token));
3682 - TokenStream::Fallback(tts) => tts.extend(streams),
3683 + TokenStream::Fallback(tts) => tts.extend(stream),
3688 impl Extend<TokenStream> for TokenStream {
3689 fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I) {
3691 TokenStream::Compiler(tts) => {
3694 - .extend(streams.into_iter().map(|stream| stream.unwrap_nightly()));
3695 + .extend(streams.into_iter().map(TokenStream::unwrap_nightly));
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));
3705 -impl fmt::Debug for TokenStream {
3706 +impl Debug for TokenStream {
3707 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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),
3717 impl From<proc_macro::LexError> for LexError {
3718 fn from(e: proc_macro::LexError) -> LexError {
3719 LexError::Compiler(e)
3723 impl From<fallback::LexError> for LexError {
3724 fn from(e: fallback::LexError) -> LexError {
3725 LexError::Fallback(e)
3729 -impl fmt::Debug for LexError {
3730 +impl Debug for LexError {
3731 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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),
3742 -pub enum TokenTreeIter {
3743 +pub(crate) enum TokenTreeIter {
3744 Compiler(proc_macro::token_stream::IntoIter),
3745 Fallback(fallback::TokenTreeIter),
3748 impl IntoIterator for TokenStream {
3749 type Item = TokenTree;
3750 type IntoIter = TokenTreeIter;
3752 @@ -356,25 +311,25 @@ impl Iterator for TokenTreeIter {
3753 fn size_hint(&self) -> (usize, Option<usize>) {
3755 TokenTreeIter::Compiler(tts) => tts.size_hint(),
3756 TokenTreeIter::Fallback(tts) => tts.size_hint(),
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()
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),
3776 #[cfg(super_unstable)]
3778 fn nightly(sf: proc_macro::SourceFile) -> Self {
3779 SourceFile::Compiler(sf)
3780 @@ -392,68 +347,87 @@ impl SourceFile {
3782 SourceFile::Compiler(a) => a.is_real(),
3783 SourceFile::Fallback(a) => a.is_real(),
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 {
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),
3801 #[cfg(any(super_unstable, feature = "span-locations"))]
3802 -pub struct LineColumn {
3803 +pub(crate) struct LineColumn {
3808 #[derive(Copy, Clone)]
3810 +pub(crate) enum Span {
3811 Compiler(proc_macro::Span),
3812 Fallback(fallback::Span),
3816 pub fn call_site() -> Span {
3817 - if nightly_works() {
3818 + if inside_proc_macro() {
3819 Span::Compiler(proc_macro::Span::call_site())
3821 Span::Fallback(fallback::Span::call_site())
3826 + pub fn mixed_site() -> Span {
3827 + if inside_proc_macro() {
3828 + Span::Compiler(proc_macro::Span::mixed_site())
3830 + Span::Fallback(fallback::Span::mixed_site())
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())
3840 Span::Fallback(fallback::Span::def_site())
3844 - #[cfg(super_unstable)]
3845 pub fn resolved_at(&self, other: Span) -> Span {
3846 match (self, other) {
3848 (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.resolved_at(b)),
3850 + // Name resolution affects semantics, but location is only cosmetic
3851 + #[cfg(not(hygiene))]
3852 + (Span::Compiler(_), Span::Compiler(_)) => other,
3854 (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.resolved_at(b)),
3859 - #[cfg(super_unstable)]
3860 pub fn located_at(&self, other: Span) -> Span {
3861 match (self, other) {
3863 (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.located_at(b)),
3865 + // Name resolution affects semantics, but location is only cosmetic
3866 + #[cfg(not(hygiene))]
3867 + (Span::Compiler(_), Span::Compiler(_)) => *self,
3869 (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.located_at(b)),
3874 pub fn unwrap(self) -> proc_macro::Span {
3876 Span::Compiler(s) => s,
3877 @@ -537,36 +511,36 @@ impl From<proc_macro::Span> for crate::S
3880 impl From<fallback::Span> for Span {
3881 fn from(inner: fallback::Span) -> Span {
3882 Span::Fallback(inner)
3886 -impl fmt::Debug for Span {
3887 +impl Debug for Span {
3888 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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),
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) {
3901 Span::Compiler(s) => {
3902 debug.field("span", &s);
3904 Span::Fallback(s) => fallback::debug_span_field_if_nontrivial(debug, s),
3910 +pub(crate) enum Group {
3911 Compiler(proc_macro::Group),
3912 Fallback(fallback::Group),
3916 pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group {
3918 TokenStream::Compiler(tts) => {
3919 @@ -647,36 +621,36 @@ impl Group {
3922 impl From<fallback::Group> for Group {
3923 fn from(g: fallback::Group) -> Self {
3928 -impl fmt::Display for Group {
3929 +impl Display for Group {
3930 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
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),
3940 -impl fmt::Debug for Group {
3941 +impl Debug for Group {
3942 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
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),
3954 +pub(crate) enum Ident {
3955 Compiler(proc_macro::Ident),
3956 Fallback(fallback::Ident),
3960 pub fn new(string: &str, span: Span) -> Ident {
3962 Span::Compiler(s) => Ident::Compiler(proc_macro::Ident::new(string, s)),
3963 @@ -742,56 +716,56 @@ where
3964 let other = other.as_ref();
3966 Ident::Compiler(t) => t.to_string() == other,
3967 Ident::Fallback(t) => t == other,
3972 -impl fmt::Display for Ident {
3973 +impl Display for Ident {
3974 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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),
3984 -impl fmt::Debug for Ident {
3985 +impl Debug for Ident {
3986 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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),
3998 +pub(crate) enum Literal {
3999 Compiler(proc_macro::Literal),
4000 Fallback(fallback::Literal),
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))
4010 Literal::Fallback(fallback::Literal::$name(n))
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))
4023 Literal::Fallback(fallback::Literal::$name(n))
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,
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))
4042 Literal::Fallback(fallback::Literal::f32_unsuffixed(f))
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))
4051 Literal::Fallback(fallback::Literal::f64_unsuffixed(f))
4055 pub fn string(t: &str) -> Literal {
4056 - if nightly_works() {
4057 + if inside_proc_macro() {
4058 Literal::Compiler(proc_macro::Literal::string(t))
4060 Literal::Fallback(fallback::Literal::string(t))
4064 pub fn character(t: char) -> Literal {
4065 - if nightly_works() {
4066 + if inside_proc_macro() {
4067 Literal::Compiler(proc_macro::Literal::character(t))
4069 Literal::Fallback(fallback::Literal::character(t))
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))
4078 Literal::Fallback(fallback::Literal::byte_string(bytes))
4082 pub fn span(&self) -> Span {
4084 @@ -903,25 +877,25 @@ impl Literal {
4087 impl From<fallback::Literal> for Literal {
4088 fn from(s: fallback::Literal) -> Literal {
4089 Literal::Fallback(s)
4093 -impl fmt::Display for Literal {
4094 +impl Display for Literal {
4095 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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),
4105 -impl fmt::Debug for Literal {
4106 +impl Debug for Literal {
4107 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
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),
4116 diff --git a/third_party/rust/proc-macro2/tests/comments.rs b/third_party/rust/proc-macro2/tests/comments.rs
4117 new file mode 100644
4119 +++ b/third_party/rust/proc-macro2/tests/comments.rs
4121 +use proc_macro2::{Delimiter, Literal, Spacing, TokenStream, TokenTree};
4123 +// #[doc = "..."] -> "..."
4124 +fn lit_of_outer_doc_comment(tokens: TokenStream) -> Literal {
4125 + lit_of_doc_comment(tokens, false)
4128 +// #![doc = "..."] -> "..."
4129 +fn lit_of_inner_doc_comment(tokens: TokenStream) -> Literal {
4130 + lit_of_doc_comment(tokens, true)
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);
4140 + _ => panic!("wrong token {:?}", tokens),
4143 + match iter.next().unwrap() {
4144 + TokenTree::Punct(punct) => {
4145 + assert_eq!(punct.as_char(), '!');
4146 + assert_eq!(punct.spacing(), Spacing::Alone);
4148 + _ => panic!("wrong token {:?}", tokens),
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()
4157 + _ => panic!("wrong token {:?}", tokens),
4159 + match iter.next().unwrap() {
4160 + TokenTree::Ident(ident) => assert_eq!(ident.to_string(), "doc"),
4161 + _ => panic!("wrong token {:?}", tokens),
4163 + match iter.next().unwrap() {
4164 + TokenTree::Punct(punct) => {
4165 + assert_eq!(punct.as_char(), '=');
4166 + assert_eq!(punct.spacing(), Spacing::Alone);
4168 + _ => panic!("wrong token {:?}", tokens),
4170 + match iter.next().unwrap() {
4171 + TokenTree::Literal(literal) => {
4172 + assert!(iter.next().is_none(), "unexpected token {:?}", tokens);
4175 + _ => panic!("wrong token {:?}", tokens),
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);
4188 + assert!("/*/".parse::<TokenStream>().is_err());
4193 + let stream = "/// doc".parse::<TokenStream>().unwrap();
4194 + let lit = lit_of_outer_doc_comment(stream);
4195 + assert_eq!(lit.to_string(), "\" doc\"");
4197 + let stream = "//! doc".parse::<TokenStream>().unwrap();
4198 + let lit = lit_of_inner_doc_comment(stream);
4199 + assert_eq!(lit.to_string(), "\" doc\"");
4201 + let stream = "/** doc */".parse::<TokenStream>().unwrap();
4202 + let lit = lit_of_outer_doc_comment(stream);
4203 + assert_eq!(lit.to_string(), "\" doc \"");
4205 + let stream = "/*! doc */".parse::<TokenStream>().unwrap();
4206 + let lit = lit_of_inner_doc_comment(stream);
4207 + assert_eq!(lit.to_string(), "\" doc \"");
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(), "\"\"");
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\"");
4220 + "///\r".parse::<TokenStream>().unwrap_err();
4221 + "///\r \n".parse::<TokenStream>().unwrap_err();
4222 + "/**\r \n*/".parse::<TokenStream>().unwrap_err();
4224 diff --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
4228 +use proc_macro2::{Ident, Literal, Spacing, Span, TokenStream, TokenTree};
4229 use std::str::{self, FromStr};
4231 -use proc_macro2::{Ident, Literal, Spacing, Span, TokenStream, TokenTree};
4236 Ident::new("String", Span::call_site()).to_string(),
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);
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);
4268 + unexpected => panic!("unexpected token {:?}", unexpected),
4270 + match iter.next().unwrap() {
4271 + TokenTree::Literal(literal) => {
4272 + assert_eq!(literal.to_string(), "3i32");
4274 + unexpected => panic!("unexpected token {:?}", unexpected),
4276 + assert!(iter.next().is_none());
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() {
4291 #[cfg(span_locations)]
4294 - use proc_macro2::TokenTree;
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);
4301 - fn check_spans_internal(ts: TokenStream, lines: &mut &[(usize, usize, usize, usize)]) {
4303 - if let Some((&(sline, scol, eline, ecol), rest)) = lines.split_first() {
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);
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);
4315 - TokenTree::Group(ref g) => {
4316 - check_spans_internal(g.stream().clone(), lines);
4326 /// This is a document comment
4332 @@ -269,59 +265,17 @@ fn span_join() {
4333 joined1.unwrap().source_file(),
4334 source1[0].span().source_file()
4340 let s = str::from_utf8(b"b\'\xc2\x86 \x00\x00\x00^\"").unwrap();
4341 - assert!(s.parse::<proc_macro2::TokenStream>().is_err());
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);
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);
4354 - proc_macro2::TokenTree::Punct(ref tt) => assert_eq!(tt.as_char(), '#'),
4355 - _ => panic!("wrong token {:?}", tokens[0]),
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()
4362 - _ => panic!("wrong token {:?}", tokens[0]),
4365 - match tokens.next().unwrap() {
4366 - proc_macro2::TokenTree::Ident(ref tt) => assert_eq!(tt.to_string(), "doc"),
4367 - t => panic!("wrong token {:?}", t),
4369 - match tokens.next().unwrap() {
4370 - proc_macro2::TokenTree::Punct(ref tt) => assert_eq!(tt.as_char(), '='),
4371 - t => panic!("wrong token {:?}", t),
4373 - match tokens.next().unwrap() {
4374 - proc_macro2::TokenTree::Literal(ref tt) => {
4375 - assert_eq!(tt.to_string(), "\" doc\"");
4377 - t => panic!("wrong token {:?}", t),
4379 - assert!(tokens.next().is_none());
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());
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() {
4395 assert!(tts.next().is_none());
4399 fn test_debug_ident() {
4400 let ident = Ident::new("proc_macro", Span::call_site());
4402 - #[cfg(not(procmacro2_semver_exempt))]
4403 + #[cfg(not(span_locations))]
4404 let expected = "Ident(proc_macro)";
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 }";
4411 assert_eq!(expected, format!("{:?}", ident));
4415 fn test_debug_tokenstream() {
4416 let tts = TokenStream::from_str("[a + 1]").unwrap();
4418 - #[cfg(not(procmacro2_semver_exempt))]
4419 + #[cfg(not(span_locations))]
4424 stream: TokenStream [
4428 @@ -374,17 +328,17 @@ TokenStream [
4437 - #[cfg(not(procmacro2_semver_exempt))]
4438 + #[cfg(not(span_locations))]
4439 let expected_before_trailing_commas = "\
4443 stream: TokenStream [
4447 @@ -395,17 +349,17 @@ TokenStream [
4456 - #[cfg(procmacro2_semver_exempt)]
4457 + #[cfg(span_locations)]
4462 stream: TokenStream [
4466 @@ -420,17 +374,17 @@ TokenStream [
4475 - #[cfg(procmacro2_semver_exempt)]
4476 + #[cfg(span_locations)]
4477 let expected_before_trailing_commas = "\
4481 stream: TokenStream [
4485 @@ -459,8 +413,85 @@ TokenStream [
4489 fn default_tokenstream_is_empty() {
4490 let default_token_stream: TokenStream = Default::default();
4492 assert!(default_token_stream.is_empty());
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());
4505 +#[cfg(span_locations)]
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)]);
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);
4551 +#[cfg(span_locations)]
4552 +fn check_spans_internal(ts: TokenStream, lines: &mut &[(usize, usize, usize, usize)]) {
4554 + if let Some((&(sline, scol, eline, ecol), rest)) = lines.split_first() {
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);
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);
4565 + if let TokenTree::Group(g) = i {
4566 + check_spans_internal(g.stream().clone(), lines);
4571 diff --git a/third_party/rust/proc-macro2/tests/test_fmt.rs b/third_party/rust/proc-macro2/tests/test_fmt.rs
4572 new file mode 100644
4574 +++ b/third_party/rust/proc-macro2/tests/test_fmt.rs
4576 +use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
4577 +use std::iter::{self, FromIterator};
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());
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());
4602 diff --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
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
4610 diff --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
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)
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]
4634 +targets = ["x86_64-unknown-linux-gnu"]
4636 [package.metadata.playground]
4637 -all-features = true
4641 +features = ["full", "visit", "visit-mut", "fold", "extra-traits"]
4646 required-features = ["full", "parsing"]
4651 required-features = ["full", "parsing"]
4653 [dependencies.proc-macro2]
4656 default-features = false
4658 [dependencies.quote]
4661 default-features = false
4663 [dependencies.unicode-xid]
4665 +[dev-dependencies.anyhow]
4668 +[dev-dependencies.flate2]
4671 [dev-dependencies.insta]
4675 [dev-dependencies.rayon]
4678 [dev-dependencies.ref-cast]
4682 [dev-dependencies.regex]
4685 +[dev-dependencies.reqwest]
4687 +features = ["blocking"]
4689 +[dev-dependencies.syn-test-suite]
4692 +[dev-dependencies.tar]
4695 [dev-dependencies.termcolor]
4698 [dev-dependencies.walkdir]
4703 default = ["derive", "parsing", "printing", "clone-impls", "proc-macro"]
4709 printing = ["quote"]
4710 proc-macro = ["proc-macro2/proc-macro", "quote/proc-macro"]
4711 +test = ["syn-test-suite/all-features"]
4715 -repository = "dtolnay/syn"
4716 diff --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
4720 Parser for Rust source code
4721 ===========================
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)
4732 Syn is a parsing library for parsing a stream of Rust tokens into a syntax tree
4733 of Rust source code.
4735 Currently this library is geared toward use in Rust procedural macros, but
4736 contains some APIs that may be useful more generally.
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
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
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
4752 *Version requirement: Syn supports rustc 1.31 and up.*
4754 [*Release notes*](https://github.com/dtolnay/syn/releases)
4760 @@ -83,18 +79,16 @@ tokens back to the compiler to compile i
4769 -extern crate proc_macro;
4771 use proc_macro::TokenStream;
4773 use syn::{parse_macro_input, DeriveInput};
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
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`.
4785 The proc-macro2 crate will automatically detect and use the compiler's data
4786 structures when a procedural macro is active.
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/
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.
4798 diff --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
4802 // $ cargo bench --features full --bench file
4804 #![feature(rustc_private, test)]
4805 +#![recursion_limit = "1024"]
4810 +#[path = "../tests/macros/mod.rs"]
4813 +#[path = "../tests/common/mod.rs"]
4815 #[path = "../tests/repo/mod.rs"]
4818 use proc_macro2::TokenStream;
4820 use std::str::FromStr;
4823 diff --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
4827 // $ cargo bench --features full --bench rust
4829 // Syn only, useful for profiling:
4830 // $ RUSTFLAGS='--cfg syn_only' cargo build --release --features full --bench rust
4832 #![cfg_attr(not(syn_only), feature(rustc_private))]
4833 +#![recursion_limit = "1024"]
4836 +#[path = "../tests/macros/mod.rs"]
4839 +#[path = "../tests/common/mod.rs"]
4841 #[path = "../tests/repo/mod.rs"]
4845 use std::time::{Duration, Instant};
4847 #[cfg(not(syn_only))]
4848 mod tokenstream_parse {
4849 @@ -23,41 +30,45 @@ mod tokenstream_parse {
4852 pub fn bench(content: &str) -> Result<(), ()> {
4853 syn::parse_file(content).map(drop).map_err(drop)
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;
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};
4879 pub fn bench(content: &str) -> Result<(), ()> {
4880 struct SilentEmitter;
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>> {
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()),
4902 diagnostic.cancel();
4906 @@ -99,21 +110,21 @@ fn exec(mut codepath: impl FnMut(&str) -
4907 assert_eq!(success, total);
4914 macro_rules! testcases {
4915 - ($($(#[$cfg:meta])* $name:path,)*) => {
4916 + ($($(#[$cfg:meta])* $name:ident,)*) => {
4920 - (stringify!($name), $name as fn(&str) -> Result<(), ()>),
4921 + (stringify!($name), $name::bench as fn(&str) -> Result<(), ()>),
4927 #[cfg(not(syn_only))]
4930 @@ -123,22 +134,22 @@ fn main() {
4934 eprintln!("\n{} lines in {} files", lines, files);
4937 for (name, f) in testcases!(
4938 #[cfg(not(syn_only))]
4939 - read_from_disk::bench,
4941 #[cfg(not(syn_only))]
4942 - tokenstream_parse::bench,
4944 + tokenstream_parse,
4946 #[cfg(not(syn_only))]
4947 - libsyntax_parse::bench,
4950 eprint!("{:20}", format!("{}:", name));
4951 let elapsed = exec(f);
4953 "elapsed={}.{:03}s",
4955 elapsed.subsec_millis(),
4957 diff --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
4962 use std::process::Command;
4963 -use std::str::{self, FromStr};
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.
4970 let compiler = match rustc_version() {
4971 Some(compiler) => compiler,
4973 @@ -21,43 +21,19 @@ fn main() {
4981 fn rustc_version() -> Option<Compiler> {
4982 - let rustc = match env::var_os("RUSTC") {
4983 - Some(rustc) => rustc,
4984 - None => return None,
4987 - let output = match Command::new(rustc).arg("--version").output() {
4988 - Ok(output) => output,
4989 - Err(_) => return None,
4992 - let version = match str::from_utf8(&output.stdout) {
4993 - Ok(version) => version,
4994 - Err(_) => return None,
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") {
5005 - let next = match pieces.next() {
5006 - Some(next) => next,
5007 - None => return None,
5010 - let minor = match u32::from_str(next) {
5011 - Ok(minor) => minor,
5012 - Err(_) => return None,
5017 - nightly: version.contains("nightly"),
5019 + let minor = pieces.next()?.parse().ok()?;
5020 + let nightly = version.contains("nightly");
5021 + Some(Compiler { minor, nightly })
5023 diff --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;
5029 use proc_macro2::TokenStream;
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};
5041 /// An attribute like `#[repr(transparent)]`.
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"`
5051 /// Rust has six types of attributes.
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.
5060 /// [`parse_meta()`]: Attribute::parse_meta
5061 /// [`parse_args()`]: Attribute::parse_args
5062 - pub struct Attribute #manual_extra_traits {
5066 + /// # Doc comments
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"]`.
5072 + /// As an example, the following `mod` items are expanded identically:
5075 + /// # use syn::{ItemMod, parse_quote};
5076 + /// let doc: ItemMod = parse_quote! {
5077 + /// /// Single line doc comments
5078 + /// /// We write so many!
5080 + /// * Multi-line comments...
5081 + /// * May span many lines
5084 + /// //! Of course, they can be inner too
5085 + /// /*! And fit in a single line */
5088 + /// let attr: ItemMod = parse_quote! {
5089 + /// #[doc = r" Single line doc comments"]
5090 + /// #[doc = r" We write so many!"]
5092 + /// * Multi-line comments...
5093 + /// * May span many lines
5096 + /// #![doc = r" Of course, they can be inner too"]
5097 + /// #![doc = r" And fit in a single line "]
5100 + /// assert_eq!(doc, attr);
5102 + pub struct Attribute {
5103 pub pound_token: Token![#],
5104 pub style: AttrStyle,
5105 pub bracket_token: token::Bracket,
5107 pub tokens: TokenStream,
5111 -#[cfg(feature = "extra-traits")]
5112 -impl Eq for Attribute {}
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)
5125 -#[cfg(feature = "extra-traits")]
5126 -impl Hash for Attribute {
5127 - fn hash<H>(&self, state: &mut H)
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);
5140 /// Parses the content of the attribute, consisting of the path and tokens,
5141 /// as a [`Meta`] if possible.
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"`
5146 #[cfg(feature = "parsing")]
5147 pub fn parse_meta(&self) -> Result<Meta> {
5148 fn clone_ident_segment(segment: &PathSegment) -> PathSegment {
5150 ident: segment.ident.clone(),
5151 arguments: PathArguments::None,
5153 @@ -194,91 +201,95 @@ impl Attribute {
5155 /// - the error message has a more useful span when `tokens` is empty.
5158 /// #[my_attr(value < 5)]
5159 /// ^^^^^^^^^ what gets parsed
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"`
5165 #[cfg(feature = "parsing")]
5166 pub fn parse_args<T: Parse>(&self) -> Result<T> {
5167 self.parse_args_with(T::parse)
5170 /// Parse the arguments to the attribute using the given parser.
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"`
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)
5181 parser.parse2(self.tokens.clone())
5184 /// Parses zero or more outer attributes from the stream.
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"`
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)?);
5198 /// Parses zero or more inner attributes from the stream.
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"`
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)?);
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(_) => "#!",
5221 let mut path = String::new();
5222 for segment in &attr.path.segments {
5223 if !path.is_empty() || attr.path.leading_colon.is_some() {
5226 path += &segment.ident.to_string();
5229 - let msg = format!("expected attribute arguments: {}[{}(...)]", style, path);
5231 - #[cfg(feature = "printing")]
5232 - return Error::new_spanned(attr, msg);
5234 - #[cfg(not(feature = "printing"))]
5235 - return Error::new(attr.bracket_token.span, msg);
5236 + format!("{}[{}(...)]", style, path)
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,
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));
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"))
5268 /// Distinguishes between attributes that decorate an item and attributes
5269 /// that are contained within an item.
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"`
5275 /// # Outer attributes
5277 /// - `#[repr(transparent)]`
5278 /// - `/// # Example`
5279 /// - `/** Please file an issue */`
5281 /// # Inner attributes
5283 /// - `#![feature(proc_macro)]`
5284 /// - `//! # Example`
5285 /// - `/*! Please file an issue */`
5286 - #[cfg_attr(feature = "clone-impls", derive(Copy))]
5287 pub enum AttrStyle {
5293 ast_enum_of_structs! {
5294 /// Content of a compile-time structured attribute.
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"`
5302 /// A meta path is like the `test` in `#[test]`.
5306 @@ -355,29 +365,29 @@ ast_enum_of_structs! {
5307 /// A name-value pair within an attribute, like `feature = "nightly"`.
5308 NameValue(MetaNameValue),
5313 /// A structured list within an attribute, like `derive(Copy, Clone)`.
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 {
5320 pub paren_token: token::Paren,
5321 pub nested: Punctuated<NestedMeta, Token![,]>,
5326 /// A name-value pair within an attribute, like `feature = "nightly"`.
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 {
5333 pub eq_token: Token![=],
5338 @@ -393,17 +403,17 @@ impl Meta {
5339 Meta::NameValue(meta) => &meta.path,
5344 ast_enum_of_structs! {
5345 /// Element of a compile-time attribute list.
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"`
5350 pub enum NestedMeta {
5351 /// A structured meta item, like the `Copy` in `#[derive(Copy)]` which
5352 /// would be a nested `Meta::Path`.
5355 /// A Rust literal, like the `"new_name"` in `#[rename("new_name")]`.
5357 @@ -424,18 +434,18 @@ ast_enum_of_structs! {
5362 /// The implementation of this macro would want to parse its attribute arguments
5363 /// as type `AttributeArgs`.
5366 -/// extern crate proc_macro;
5368 +/// # extern crate proc_macro;
5370 /// use proc_macro::TokenStream;
5371 /// use syn::{parse_macro_input, AttributeArgs, ItemFn};
5373 /// # const IGNORE: &str = stringify! {
5374 /// #[proc_macro_attribute]
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>,
5381 type Ret = iter::Filter<T::IntoIter, fn(&&Attribute) -> bool>;
5383 fn outer(self) -> Self::Ret {
5384 fn is_outer(attr: &&Attribute) -> bool {
5386 AttrStyle::Outer => true,
5388 + AttrStyle::Inner(_) => false,
5391 self.into_iter().filter(is_outer)
5394 fn inner(self) -> Self::Ret {
5395 fn is_inner(attr: &&Attribute) -> bool {
5397 AttrStyle::Inner(_) => true,
5399 + AttrStyle::Outer => false,
5402 self.into_iter().filter(is_inner)
5406 #[cfg(feature = "parsing")]
5408 diff --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
5412 //! A stably addressed token buffer supporting efficient traversal based on a
5413 //! cheaply copyable cursor.
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.*
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.
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.
5430 /// A buffer that can be efficiently traversed multiple times, unlike
5431 /// `TokenStream` which requires a deep copy in order to traverse more than
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.
5444 @@ -93,17 +93,17 @@ impl TokenBuffer {
5447 TokenBuffer { data: entries }
5450 /// Creates a `TokenBuffer` containing all the tokens from the input
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.*
5457 not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
5458 feature = "proc-macro"
5460 pub fn new(stream: pm::TokenStream) -> TokenBuffer {
5461 Self::new2(stream.into())
5463 @@ -128,18 +128,17 @@ impl TokenBuffer {
5464 /// and copied around.
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()`.
5469 /// Two cursors are equal if they have the same location in the same input
5470 /// stream, and have the same scope.
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.
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
5483 @@ -196,37 +195,38 @@ impl<'a> Cursor<'a> {
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
5488 unsafe fn bump(self) -> Cursor<'a> {
5489 Cursor::create(self.ptr.offset(1), self.scope)
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.
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.
5507 *self = Cursor::create(&buf.data[0], self.scope);
5515 /// Checks whether the cursor is currently pointing at the end of its valid
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
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(),
5536 + /// Skip over the next token without cloning it. Returns `None` if this
5537 + /// cursor points to eof.
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,
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() }),
5552 + _ => Some(unsafe { self.bump() }),
5557 +impl<'a> Copy for Cursor<'a> {}
5559 +impl<'a> Clone for Cursor<'a> {
5560 + fn clone(&self) -> Self {
5565 +impl<'a> Eq for Cursor<'a> {}
5567 +impl<'a> PartialEq for Cursor<'a> {
5568 + fn eq(&self, other: &Self) -> bool {
5569 + let Cursor { ptr, scope, marker } = self;
5571 + *ptr == other.ptr && *scope == other.scope
5575 pub(crate) fn same_scope(a: Cursor, b: Cursor) -> bool {
5579 pub(crate) fn open_span_of_group(cursor: Cursor) -> Span {
5580 match cursor.entry() {
5581 diff --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
5585 /// value: input.parse()?,
5588 /// Err(lookahead.error())
5593 -#[macro_export(local_inner_macros)]
5595 macro_rules! custom_keyword {
5597 #[allow(non_camel_case_types)]
5599 pub span: $crate::export::Span,
5603 - #[allow(non_snake_case)]
5604 + #[allow(dead_code, non_snake_case)]
5605 pub fn $ident<__S: $crate::export::IntoSpans<[$crate::export::Span; 1]>>(
5609 span: $crate::export::IntoSpans::into_spans(span)[0],
5613 impl $crate::export::Default for $ident {
5614 fn default() -> Self {
5616 span: $crate::export::Span::call_site(),
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);
5633 #[cfg(feature = "parsing")]
5636 macro_rules! impl_parse_for_custom_keyword {
5637 diff --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
5645 /// let input = r#" a::b </> c::d::e "#;
5646 /// let _: PathSegments = syn::parse_str(input).unwrap();
5649 -#[macro_export(local_inner_macros)]
5651 macro_rules! custom_punctuation {
5652 ($ident:ident, $($tt:tt)+) => {
5654 - pub spans: custom_punctuation_repr!($($tt)+),
5655 + pub spans: $crate::custom_punctuation_repr!($($tt)+),
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)+)>>(
5665 - let _validate_len = 0 $(+ custom_punctuation_len!(strict, $tt))*;
5666 + let _validate_len = 0 $(+ $crate::custom_punctuation_len!(strict, $tt))*;
5668 spans: $crate::export::IntoSpans::into_spans(spans)
5672 impl $crate::export::Default for $ident {
5673 fn default() -> Self {
5674 $ident($crate::export::Span::call_site())
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)+);
5690 #[cfg(feature = "parsing")]
5692 -#[macro_export(local_inner_macros)]
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)+))
5702 fn display() -> &'static $crate::export::str {
5703 - custom_punctuation_concat!("`", stringify_punct!($($tt)+), "`")
5704 + concat!("`", $crate::stringify_punct!($($tt)+), "`")
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)+))?;
5721 #[cfg(not(feature = "parsing"))]
5722 @@ -137,22 +137,22 @@ macro_rules! impl_parse_for_custom_punct
5724 macro_rules! impl_parse_for_custom_punctuation {
5725 ($ident:ident, $($tt:tt)+) => {};
5729 #[cfg(feature = "printing")]
5731 -#[macro_export(local_inner_macros)]
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)
5745 #[cfg(not(feature = "printing"))]
5747 @@ -216,26 +216,26 @@ macro_rules! impl_extra_traits_for_custo
5750 macro_rules! impl_extra_traits_for_custom_punctuation {
5751 ($ident:ident, $($tt:tt)+) => {};
5756 -#[macro_export(local_inner_macros)]
5758 macro_rules! custom_punctuation_repr {
5760 - [$crate::export::Span; 0 $(+ custom_punctuation_len!(lenient, $tt))+]
5761 + [$crate::export::Span; 0 $(+ $crate::custom_punctuation_len!(lenient, $tt))+]
5767 -#[macro_export(local_inner_macros)]
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 }};
5793 macro_rules! custom_punctuation_unexpected {
5796 @@ -292,18 +292,8 @@ macro_rules! custom_punctuation_unexpect
5800 macro_rules! stringify_punct {
5802 concat!($(stringify!($tt)),+)
5807 -// Without this, local_inner_macros breaks when looking for concat!
5810 -macro_rules! custom_punctuation_concat {
5815 diff --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
5820 use crate::punctuated::Punctuated;
5823 /// An enum variant.
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"`
5828 pub struct Variant {
5829 /// Attributes tagged on the variant.
5830 pub attrs: Vec<Attribute>,
5832 /// Name of the variant.
5835 @@ -19,17 +19,17 @@ ast_struct! {
5836 /// Explicit discriminant: `Variant = 1`
5837 pub discriminant: Option<(Token![=], Expr)>,
5841 ast_enum_of_structs! {
5842 /// Data stored within an enum variant or struct.
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"`
5848 /// # Syntax tree enum
5850 /// This type is a [syntax tree enum].
5852 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
5854 @@ -47,28 +47,28 @@ ast_enum_of_structs! {
5860 /// Named fields of a struct or struct variant such as `Point { x: f64,
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![,]>,
5873 /// Unnamed fields of a tuple struct or tuple variant such as `Some(T)`.
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![,]>,
5885 @@ -88,16 +88,34 @@ impl Fields {
5886 /// struct or variant's fields uniformly.
5887 pub fn iter_mut(&mut self) -> punctuated::IterMut<Field> {
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(),
5895 + /// Returns the number of fields.
5896 + pub fn len(&self) -> usize {
5898 + Fields::Unit => 0,
5899 + Fields::Named(f) => f.named.len(),
5900 + Fields::Unnamed(f) => f.unnamed.len(),
5904 + /// Returns `true` if there are zero fields.
5905 + pub fn is_empty(&self) -> bool {
5907 + Fields::Unit => true,
5908 + Fields::Named(f) => f.named.is_empty(),
5909 + Fields::Unnamed(f) => f.unnamed.is_empty(),
5914 impl IntoIterator for Fields {
5916 type IntoIter = punctuated::IntoIter<Field>;
5918 fn into_iter(self) -> Self::IntoIter {
5920 @@ -124,17 +142,17 @@ impl<'a> IntoIterator for &'a mut Fields
5921 fn into_iter(self) -> Self::IntoIter {
5927 /// A field of a struct or enum variant.
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"`
5933 /// Attributes tagged on the field.
5934 pub attrs: Vec<Attribute>,
5936 /// Visibility of the field.
5937 pub vis: Visibility,
5939 @@ -149,17 +167,17 @@ ast_struct! {
5944 ast_enum_of_structs! {
5945 /// The visibility level of an item: inherited or `pub` or
5946 /// `pub(restricted)`.
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"`
5952 /// # Syntax tree enum
5954 /// This type is a [syntax tree enum].
5956 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
5958 @@ -179,58 +197,61 @@ ast_enum_of_structs! {
5959 /// An inherited visibility, which usually means private.
5965 /// A public visibility level: `pub`.
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],
5976 /// A crate-level visibility: `crate`.
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],
5987 /// A visibility level restricted to some path: `pub(self)` or
5988 /// `pub(super)` or `pub(crate)` or `pub(in some::module)`.
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>,
6001 #[cfg(feature = "parsing")]
6005 use crate::ext::IdentExt;
6006 + use crate::parse::discouraged::Speculative;
6007 use crate::parse::{Parse, ParseStream, Result};
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()?;
6014 - attrs: input.call(Attribute::parse_outer)?,
6016 ident: input.parse()?,
6018 if input.peek(token::Brace) {
6019 Fields::Named(input.parse()?)
6020 } else if input.peek(token::Paren) {
6021 Fields::Unnamed(input.parse()?)
6024 @@ -290,68 +311,99 @@ pub mod parsing {
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);
6044 if input.peek(Token![pub]) {
6045 Self::parse_pub(input)
6046 } else if input.peek(Token![crate]) {
6047 Self::parse_crate(input)
6049 Ok(Visibility::Inherited)
6055 fn parse_pub(input: ParseStream) -> Result<Self> {
6056 let pub_token = input.parse::<Token![pub]>()?;
6058 if input.peek(token::Paren) {
6059 - // TODO: optimize using advance_to
6060 let ahead = input.fork();
6062 - parenthesized!(content in ahead);
6065 + let paren_token = parenthesized!(content in ahead);
6066 if content.peek(Token![crate])
6067 || content.peek(Token![self])
6068 || content.peek(Token![super])
6070 + let path = content.call(Ident::parse_any)?;
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 {
6082 + path: Box::new(Path::from(path)),
6085 + } else if content.peek(Token![in]) {
6086 + let in_token: Token![in] = content.parse()?;
6087 + let path = content.call(Path::parse_mod_style)?;
6089 + input.advance_to(&ahead);
6090 return Ok(Visibility::Restricted(VisRestricted {
6092 - paren_token: parenthesized!(content in input),
6094 - path: Box::new(Path::from(content.call(Ident::parse_any)?)),
6096 - } else if content.peek(Token![in]) {
6097 - return Ok(Visibility::Restricted(VisRestricted {
6099 - paren_token: parenthesized!(content in input),
6100 - in_token: Some(content.parse()?),
6101 - path: Box::new(content.call(Path::parse_mod_style)?),
6103 + in_token: Some(in_token),
6104 + path: Box::new(path),
6109 Ok(Visibility::Public(VisPublic { pub_token }))
6112 fn parse_crate(input: ParseStream) -> Result<Self> {
6113 if input.peek2(Token![::]) {
6114 Ok(Visibility::Inherited)
6116 Ok(Visibility::Crate(VisCrate {
6117 crate_token: input.parse()?,
6122 + #[cfg(feature = "full")]
6123 + pub(crate) fn is_some(&self) -> bool {
6125 + Visibility::Inherited => false,
6132 #[cfg(feature = "printing")]
6136 use proc_macro2::TokenStream;
6137 diff --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
6142 use crate::punctuated::Punctuated;
6145 /// Data structure sent to a `proc_macro_derive` macro.
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>,
6153 /// Visibility of the struct or enum.
6154 pub vis: Visibility,
6156 /// Name of the struct or enum.
6157 @@ -21,17 +21,17 @@ ast_struct! {
6158 /// Data within the struct or enum.
6163 ast_enum_of_structs! {
6164 /// The storage of a struct, enum or union data structure.
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.*
6169 /// # Syntax tree enum
6171 /// This type is a [syntax tree enum].
6173 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
6175 // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
6176 @@ -48,41 +48,41 @@ ast_enum_of_structs! {
6179 do_not_generate_to_tokens
6183 /// A struct input to a `proc_macro_derive` macro.
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"`
6188 pub struct DataStruct {
6189 pub struct_token: Token![struct],
6191 pub semi_token: Option<Token![;]>,
6196 /// An enum input to a `proc_macro_derive` macro.
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"`
6201 pub struct DataEnum {
6202 pub enum_token: Token![enum],
6203 pub brace_token: token::Brace,
6204 pub variants: Punctuated<Variant, Token![,]>,
6209 /// An untagged union input to a `proc_macro_derive` macro.
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"`
6214 pub struct DataUnion {
6215 pub union_token: Token![union],
6216 pub fields: FieldsNamed,
6220 #[cfg(feature = "parsing")]
6221 diff --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
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.
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.
6242 /// [`ParseStream::fork`]: ParseBuffer::fork
6243 @@ -67,17 +67,16 @@ pub trait Speculative {
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])
6254 /// let ident = input.call(Ident::parse_any)?;
6255 /// return Ok(PathSegment::from(ident));
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 {
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");
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));
6278 + // Unexpected unset. Use chain to propagate errors from fork.
6280 + fork_unexp.set(Unexpected::Chain(self_unexp));
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.
6287 + .set(Some(Rc::new(Cell::new(Unexpected::None))));
6289 + // Unexpected has been set on `self`. No changes needed.
6290 + (_, Some(_)) => {}
6294 // See comment on `cell` in the struct definition.
6296 .set(unsafe { mem::transmute::<Cursor, Cursor<'static>>(fork.cursor()) })
6299 diff --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
6304 use std::fmt::{self, Debug, Display};
6305 use std::iter::FromIterator;
6310 Delimiter, Group, Ident, LexError, Literal, Punct, Spacing, Span, TokenStream, TokenTree,
6312 @@ -27,18 +26,18 @@ pub type Result<T> = std::result::Result
6313 /// message than simply panicking the macro.
6315 /// [`compile_error!`]: https://doc.rust-lang.org/std/macro.compile_error.html
6317 /// When parsing macro input, the [`parse_macro_input!`] macro handles the
6318 /// conversion to `compile_error!` automatically.
6321 -/// extern crate proc_macro;
6323 +/// # extern crate proc_macro;
6325 /// use proc_macro::TokenStream;
6326 /// use syn::{parse_macro_input, AttributeArgs, ItemFn};
6328 /// # const IGNORE: &str = stringify! {
6329 /// #[proc_macro_attribute]
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};
6337 /// # pub fn my_derive(input: DeriveInput) -> Result<TokenStream> {
6338 /// # unimplemented!()
6344 messages: Vec<ErrorMessage>,
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
6353 Error::new(scope, format!("unexpected end of input, {}", message))
6355 let span = crate::buffer::open_span_of_group(cursor);
6356 Error::new(span, message)
6360 +#[cfg(all(feature = "parsing", any(feature = "full", feature = "derive")))]
6361 +pub fn new2<T: Display>(start: Span, end: Span, message: T) -> Error {
6363 + messages: vec![ErrorMessage {
6364 + start_span: ThreadBound::new(start),
6365 + end_span: ThreadBound::new(end),
6366 + message: message.to_string(),
6371 impl Debug for Error {
6372 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
6373 if self.messages.len() == 1 {
6375 .debug_tuple("Error")
6376 .field(&self.messages[0])
6379 @@ -273,16 +282,24 @@ impl Debug for ErrorMessage {
6382 impl Display for Error {
6383 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
6384 formatter.write_str(&self.messages[0].message)
6388 +impl Clone for Error {
6389 + fn clone(&self) -> Self {
6391 + messages: self.messages.clone(),
6396 impl Clone for ErrorMessage {
6397 fn clone(&self) -> Self {
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> {
6407 fn next(&mut self) -> Option<Self::Item> {
6409 messages: vec![self.messages.next()?.clone()],
6414 +impl Extend<Error> for Error {
6415 + fn extend<T: IntoIterator<Item = Error>>(&mut self, iter: T) {
6417 + self.combine(err);
6421 diff --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
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")]
6442 ast_enum_of_structs! {
6443 /// A Rust expression.
6445 - /// *This type is available if Syn is built with the `"derive"` or `"full"`
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.*
6450 /// # Syntax tree enums
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.
6456 /// # use syn::Expr;
6457 @@ -78,17 +81,17 @@ ast_enum_of_structs! {
6458 /// if let Expr::Tuple(base) = *discriminant.base {
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 {
6468 /// A slice literal expression: `[a, b, c, d]`.
6471 /// An assignment expression: `a = compute()`.
6474 /// A compound assignment expression: `counter += 1`.
6475 AssignOp(ExprAssignOp),
6476 @@ -223,191 +226,191 @@ ast_enum_of_structs! {
6483 /// A slice literal expression: `[a, b, c, d]`.
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![,]>,
6495 /// An assignment expression: `a = compute()`.
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>,
6508 /// A compound assignment expression: `counter += 1`.
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>,
6516 pub right: Box<Expr>,
6521 /// An async block: `async { ... }`.
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]>,
6534 /// An await expression: `fut.await`.
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,
6547 /// A binary operation: `a + b`, `a * b`.
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>,
6556 pub right: Box<Expr>,
6561 /// A blocked scope: `{ ... }`.
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>,
6573 /// A box expression: `box f`.
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>,
6585 /// A `break`, with an optional label to break and an optional
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>>,
6599 /// A function call expression: `invoke(a, b)`.
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![,]>,
6613 /// A cast expression: `foo as f64`.
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],
6627 /// A closure expression: `|a, b| a + b`.
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>,
6645 /// A `continue`, with an optional label.
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>,
6657 /// Access of a named struct field (`obj.k`) or unnamed tuple struct
6658 /// field (`obj.0`).
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![.],
6671 /// A for loop: `for pat in expr { ... }`.
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],
6680 pub in_token: Token![in],
6681 pub expr: Box<Expr>,
6683 @@ -416,538 +419,312 @@ ast_struct! {
6686 /// An expression contained within invisible delimiters.
6688 /// This variant is important for faithfully representing the precedence
6689 /// of expressions and is related to `None`-delimited spans in a
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>,
6702 /// An `if` expression with an optional `else` block: `if expr { ... }
6705 /// The `else` branch expression may only be an `If` or `Block`
6706 /// expression, not any of the other types of expression.
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>)>,
6720 /// A square bracketed indexing expression: `vector[2]`.
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>,
6734 /// A `let` guard: `let Some(x) = opt`.
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],
6742 pub eq_token: Token![=],
6743 pub expr: Box<Expr>,
6748 /// A literal in place of an expression: `1`, `"foo"`.
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>,
6760 /// Conditionless loop: `loop { ... }`.
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],
6773 /// A macro invocation expression: `format!("{}", q)`.
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>,
6784 /// A `match` expression: `match n { Some(n) => {}, None => {} }`.
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,
6798 /// A method call expression: `x.foo::<T>(a, b)`.
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![.],
6807 pub turbofish: Option<MethodTurbofish>,
6808 pub paren_token: token::Paren,
6809 pub args: Punctuated<Expr, Token![,]>,
6814 /// A parenthesized expression: `(a + b)`.
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>,
6826 /// A path like `std::mem::replace` possibly containing generic
6827 /// parameters and a qualified self-type.
6829 /// A plain identifier like `x` is a path of length 1.
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>,
6842 /// A range expression: `1..2`, `1..`, `..2`, `1..=2`, `..=2`.
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>>,
6855 /// A referencing operation: `&a` or `&mut a`.
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![&],
6863 pub mutability: Option<Token![mut]>,
6864 pub expr: Box<Expr>,
6869 /// An array literal constructed from one repeated element: `[0u8; N]`.
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![;],
6883 /// A `return`, with an optional value to be returned.
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>>,
6895 /// A struct literal expression: `Point { x: 1, y: 1 }`.
6897 /// The `rest` provides the value of the remaining fields as in `S { a:
6898 /// 1, b: 1, ..rest }`.
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>,
6905 pub brace_token: token::Brace,
6906 pub fields: Punctuated<FieldValue, Token![,]>,
6907 pub dot2_token: Option<Token![..]>,
6908 pub rest: Option<Box<Expr>>,
6913 /// A try-expression: `expr?`.
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![?],
6925 /// A try block: `try { ... }`.
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],
6937 /// A tuple expression: `(a, b, c, d)`.
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![,]>,
6949 /// A type ascription expression: `foo: f64`.
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![:],
6962 /// A unary operation: `!x`, `*x`.
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>,
6970 pub expr: Box<Expr>,
6975 /// An unsafe block: `unsafe { ... }`.
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],
6987 /// A while loop: `while expr { ... }`.
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>,
7001 /// A yield expression: `yield expr`.
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>>,
7012 -#[cfg(feature = "extra-traits")]
7013 -impl Eq for Expr {}
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)
7059 - (Expr::While(this), Expr::While(other)) => this == other,
7060 - (Expr::Yield(this), Expr::Yield(other)) => this == other,
7066 -#[cfg(feature = "extra-traits")]
7067 -impl Hash for Expr {
7068 - fn hash<H>(&self, hash: &mut H)
7073 - Expr::Array(expr) => {
7077 - Expr::Assign(expr) => {
7081 - Expr::AssignOp(expr) => {
7085 - Expr::Async(expr) => {
7089 - Expr::Await(expr) => {
7093 - Expr::Binary(expr) => {
7097 - Expr::Block(expr) => {
7101 - Expr::Box(expr) => {
7105 - Expr::Break(expr) => {
7109 - Expr::Call(expr) => {
7113 - Expr::Cast(expr) => {
7114 - hash.write_u8(10);
7117 - Expr::Closure(expr) => {
7118 - hash.write_u8(11);
7121 - Expr::Continue(expr) => {
7122 - hash.write_u8(12);
7125 - Expr::Field(expr) => {
7126 - hash.write_u8(13);
7129 - Expr::ForLoop(expr) => {
7130 - hash.write_u8(14);
7133 - Expr::Group(expr) => {
7134 - hash.write_u8(15);
7137 - Expr::If(expr) => {
7138 - hash.write_u8(16);
7141 - Expr::Index(expr) => {
7142 - hash.write_u8(17);
7145 - Expr::Let(expr) => {
7146 - hash.write_u8(18);
7149 - Expr::Lit(expr) => {
7150 - hash.write_u8(19);
7153 - Expr::Loop(expr) => {
7154 - hash.write_u8(20);
7157 - Expr::Macro(expr) => {
7158 - hash.write_u8(21);
7161 - Expr::Match(expr) => {
7162 - hash.write_u8(22);
7165 - Expr::MethodCall(expr) => {
7166 - hash.write_u8(23);
7169 - Expr::Paren(expr) => {
7170 - hash.write_u8(24);
7173 - Expr::Path(expr) => {
7174 - hash.write_u8(25);
7177 - Expr::Range(expr) => {
7178 - hash.write_u8(26);
7181 - Expr::Reference(expr) => {
7182 - hash.write_u8(27);
7185 - Expr::Repeat(expr) => {
7186 - hash.write_u8(28);
7189 - Expr::Return(expr) => {
7190 - hash.write_u8(29);
7193 - Expr::Struct(expr) => {
7194 - hash.write_u8(30);
7197 - Expr::Try(expr) => {
7198 - hash.write_u8(31);
7201 - Expr::TryBlock(expr) => {
7202 - hash.write_u8(32);
7205 - Expr::Tuple(expr) => {
7206 - hash.write_u8(33);
7209 - Expr::Type(expr) => {
7210 - hash.write_u8(34);
7213 - Expr::Unary(expr) => {
7214 - hash.write_u8(35);
7217 - Expr::Unsafe(expr) => {
7218 - hash.write_u8(36);
7221 - Expr::Verbatim(expr) => {
7222 - hash.write_u8(37);
7223 - TokenStreamHelper(expr).hash(hash);
7225 - Expr::While(expr) => {
7226 - hash.write_u8(38);
7229 - Expr::Yield(expr) => {
7230 - hash.write_u8(39);
7233 - Expr::__Nonexhaustive => unreachable!(),
7239 #[cfg(all(feature = "parsing", feature = "full"))]
7240 pub(crate) fn replace_attrs(&mut self, new: Vec<Attribute>) -> Vec<Attribute> {
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 {
7252 /// A struct or tuple struct field accessed in a struct literal or field
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"`
7259 /// A named field like `self.x`.
7261 /// An unnamed field like `self.0`.
7266 +impl Eq for Member {}
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,
7278 +impl Hash for Member {
7279 + fn hash<H: Hasher>(&self, state: &mut H) {
7281 + Member::Named(m) => m.hash(state),
7282 + Member::Unnamed(m) => m.hash(state),
7287 +#[cfg(feature = "printing")]
7288 +impl IdentFragment for Member {
7289 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
7291 + Member::Named(m) => Display::fmt(m, formatter),
7292 + Member::Unnamed(m) => Display::fmt(&m.index, formatter),
7296 + fn span(&self) -> Option<Span> {
7298 + Member::Named(m) => Some(m.span()),
7299 + Member::Unnamed(m) => Some(m.span),
7305 /// The index of an unnamed tuple struct field.
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"`
7310 - pub struct Index #manual_extra_traits {
7311 + pub struct Index {
7317 impl From<usize> for Index {
7318 fn from(index: usize) -> Index {
7319 assert!(index < u32::max_value() as usize);
7321 index: index as u32,
7322 span: Span::call_site(),
7327 -#[cfg(feature = "extra-traits")]
7328 impl Eq for Index {}
7330 -#[cfg(feature = "extra-traits")]
7331 impl PartialEq for Index {
7332 fn eq(&self, other: &Self) -> bool {
7333 self.index == other.index
7337 -#[cfg(feature = "extra-traits")]
7338 impl Hash for Index {
7339 fn hash<H: Hasher>(&self, state: &mut H) {
7340 self.index.hash(state);
7344 -#[cfg(feature = "full")]
7346 - #[derive(Default)]
7347 - pub struct Reserved {
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)
7355 + fn span(&self) -> Option<Span> {
7360 #[cfg(feature = "full")]
7362 /// The `::<>` explicit type parameters passed to a method call:
7363 /// `parse::<u64>()`.
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![>],
7375 #[cfg(feature = "full")]
7377 /// An individual generic argument to a method, like `T`.
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.
7384 /// A const expression. Must be inside of a block.
7386 /// NOTE: Identity expressions are represented as Type arguments, as
7387 /// they are indistinguishable syntactically.
7392 #[cfg(feature = "full")]
7394 /// A field-value pair in a struct literal.
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>,
7402 /// Name or index of the field.
7405 /// The colon in `Struct { x: x }`. If written in shorthand like
7406 @@ -1102,17 +917,17 @@ ast_struct! {
7411 #[cfg(feature = "full")]
7413 /// A lifetime labeling a `for`, `while`, or `loop`.
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.*
7419 pub colon_token: Token![:],
7423 #[cfg(feature = "full")]
7425 @@ -1129,45 +944,44 @@ ast_struct! {
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.*
7437 pub attrs: Vec<Attribute>,
7439 pub guard: Option<(Token![if], Box<Expr>)>,
7440 pub fat_arrow_token: Token![=>],
7441 pub body: Box<Expr>,
7442 pub comma: Option<Token![,]>,
7446 #[cfg(feature = "full")]
7448 /// Limit types of a range, inclusive or exclusive.
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![..=]),
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
7474 @@ -1178,26 +992,27 @@ pub(crate) fn requires_terminator(expr:
7477 #[cfg(feature = "parsing")]
7478 pub(crate) mod parsing {
7481 use crate::parse::{Parse, ParseStream, Result};
7483 + use std::cmp::Ordering;
7485 + crate::custom_keyword!(raw);
7487 // When we're parsing expressions which occur before blocks, like in an if
7488 // statement's condition, we cannot parse a struct literal.
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);
7495 - #[derive(Copy, Clone, PartialEq, PartialOrd)]
7504 @@ -1241,19 +1056,131 @@ pub(crate) mod parsing {
7507 impl Parse for Expr {
7508 fn parse(input: ParseStream) -> Result<Self> {
7509 ambiguous_expr(input, AllowStruct(true))
7513 - #[cfg(feature = "full")]
7514 - fn expr_no_struct(input: ParseStream) -> Result<Expr> {
7515 - ambiguous_expr(input, AllowStruct(false))
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.
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.
7529 + /// # impl std::ops::Deref for S {
7530 + /// # type Target = bool;
7531 + /// # fn deref(&self) -> &Self::Target {
7535 + /// let _ = *S {};
7537 + /// // parsed by rustc as: `*(S {})`
7540 + /// We would want to parse the above using `Expr::parse` after the `=`
7543 + /// But in the following, `S {}` is *not* a struct init expression.
7546 + /// # const S: &bool = &true;
7549 + /// // parsed by rustc as:
7552 + /// // /* empty block */
7555 + /// // /* another empty block */
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`.
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.
7572 + /// # fn doc() -> S {
7573 + /// if return S {} {}
7574 + /// # unreachable!()
7577 + /// // parsed by rustc as:
7579 + /// // if (return (S {})) {
7582 + /// // but could equally well have been this other arbitrary choice:
7584 + /// // if (return S) {
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))
7603 + impl Copy for AllowStruct {}
7605 + impl Clone for AllowStruct {
7606 + fn clone(&self) -> Self {
7611 + impl Copy for Precedence {}
7613 + impl Clone for Precedence {
7614 + fn clone(&self) -> Self {
7619 + impl PartialEq for Precedence {
7620 + fn eq(&self, other: &Self) -> bool {
7621 + *self as u8 == *other as u8
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))
7633 #[cfg(feature = "full")]
7637 allow_struct: AllowStruct,
7639 @@ -1425,88 +1352,114 @@ pub(crate) mod parsing {
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)
7648 + #[cfg(feature = "full")]
7649 + fn expr_attrs(input: ParseStream) -> Result<Vec<Attribute>> {
7650 + let mut attrs = Vec::new();
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![!]) {
7658 + let attr = group.content.call(attr::parsing::single_parse_outer)?;
7659 + if !group.content.is_empty() {
7663 + } else if input.peek(Token![#]) {
7664 + attrs.push(input.call(attr::parsing::single_parse_outer)?);
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![-])
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()?)
7699 + let mutability: Option<Token![mut]> = input.parse()?;
7700 + if raw.is_some() && mutability.is_none() {
7701 + input.parse::<Token![const]>()?;
7703 + let expr = Box::new(unary_expr(input, allow_struct)?);
7704 + if raw.is_some() {
7705 + Ok(Expr::Verbatim(verbatim::between(begin, input)))
7707 Ok(Expr::Reference(ExprReference {
7709 - and_token: input.parse()?,
7711 raw: Reserved::default(),
7712 - mutability: input.parse()?,
7713 - expr: Box::new(unary_expr(input, allow_struct)?),
7715 - } else if input.peek(Token![box]) {
7716 - Ok(Expr::Box(ExprBox {
7718 - box_token: input.parse()?,
7719 - expr: Box::new(unary_expr(input, allow_struct)?),
7722 - Ok(Expr::Unary(ExprUnary {
7724 - op: input.parse()?,
7725 - expr: Box::new(unary_expr(input, allow_struct)?),
7730 + } else if input.peek(Token![box]) {
7731 + Ok(Expr::Box(ExprBox {
7733 + box_token: input.parse()?,
7734 + expr: Box::new(unary_expr(input, allow_struct)?),
7736 + } else if input.peek(Token![*]) || input.peek(Token![!]) || input.peek(Token![-]) {
7737 + Ok(Expr::Unary(ExprUnary {
7739 + op: input.parse()?,
7740 + expr: Box::new(unary_expr(input, allow_struct)?),
7743 - trailer_expr(input, allow_struct)
7744 + trailer_expr(attrs, input, allow_struct)
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(),
7759 expr: Box::new(unary_expr(input, allow_struct)?),
7762 trailer_expr(input, allow_struct)
7766 // <atom> (..<args>) ...
7767 // <atom> . <ident> (..<args>) ...
7768 // <atom> . <ident> ...
7769 // <atom> . <lit> ...
7770 // <atom> [ <expr> ] ...
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);
7778 - let outer_attrs = input.call(Attribute::parse_outer)?;
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)?;
7788 let inner_attrs = e.replace_attrs(Vec::new());
7789 let attrs = private::attrs(outer_attrs, inner_attrs);
7790 e.replace_attrs(attrs);
7793 @@ -1518,28 +1471,36 @@ pub(crate) mod parsing {
7795 e = Expr::Call(ExprCall {
7798 paren_token: parenthesized!(content in input),
7799 args: content.parse_terminated(Expr::parse)?,
7801 } else if input.peek(Token![.]) && !input.peek(Token![..]) {
7802 - let dot_token: Token![.] = input.parse()?;
7803 + let mut dot_token: Token![.] = input.parse()?;
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 {
7812 - await_token: input.parse()?,
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)? {
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()?,
7831 let mut args = Punctuated::new();
7833 @@ -1615,20 +1576,27 @@ pub(crate) mod parsing {
7834 e = Expr::Call(ExprCall {
7837 paren_token: parenthesized!(content in input),
7838 args: content.parse_terminated(Expr::parse)?,
7840 } else if input.peek(Token![.]) && !input.peek(Token![..]) && !input.peek2(token::Await)
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)? {
7849 e = Expr::Field(ExprField {
7852 - dot_token: input.parse()?,
7854 member: input.parse()?,
7856 } else if input.peek(token::Bracket) {
7858 e = Expr::Index(ExprIndex {
7861 bracket_token: bracketed!(content in input),
7862 @@ -1641,17 +1609,21 @@ pub(crate) mod parsing {
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)
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))
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 {
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])
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])
7915 input.parse().map(Expr::Path)
7917 Err(input.error("unsupported expression; enable syn's features=[\"full\"]"))
7921 @@ -1873,17 +1843,17 @@ pub(crate) mod parsing {
7924 Err(content.error("expected `,` or `;`"))
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)?;
7943 attrs.extend(expr.replace_attrs(Vec::new()));
7944 expr.replace_attrs(attrs);
7946 return parse_expr(input, expr, allow_struct, Precedence::Any);
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)?;
7953 attrs.extend(expr.replace_attrs(Vec::new()));
7954 expr.replace_attrs(attrs);
7956 let allow_struct = AllowStruct(true);
7957 return parse_expr(input, expr, allow_struct, Precedence::Any);
7959 @@ -1946,63 +1916,48 @@ pub(crate) mod parsing {
7961 paren_token: parenthesized!(content in input),
7962 expr: content.parse()?,
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)));
7974 + if input.peek(token::Brace) {
7975 + let block = input.call(expr::parsing::expr_block)?;
7976 + return Ok(GenericMethodArgument::Const(Expr::Block(block)));
7979 input.parse().map(GenericMethodArgument::Type)
7982 #[cfg(feature = "full")]
7983 fn expr_let(input: ParseStream) -> Result<ExprLet> {
7986 let_token: input.parse()?,
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![|=])
7993 - let mut cases = Punctuated::new();
7994 - cases.push_value(pat);
7995 - while input.peek(Token![|])
7996 - && !input.peek(Token![||])
7997 - && !input.peek(Token![|=])
7999 - let punct = input.parse()?;
8000 - cases.push_punct(punct);
8001 - let pat: Pat = input.parse()?;
8002 - cases.push_value(pat);
8005 - attrs: Vec::new(),
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)?),
8020 #[cfg(feature = "full")]
8021 impl Parse for ExprIf {
8022 fn parse(input: ParseStream) -> Result<Self> {
8023 + let attrs = input.call(Attribute::parse_outer)?;
8025 - attrs: Vec::new(),
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()?,
8032 if input.peek(Token![else]) {
8033 Some(input.call(else_block)?)
8038 @@ -2028,94 +1983,81 @@ pub(crate) mod parsing {
8041 Ok((else_token, Box::new(else_branch)))
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()?;
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);
8062 - pat = Pat::Or(PatOr {
8063 - attrs: Vec::new(),
8068 + let pat = pat::parsing::multi_pat_with_leading_vert(input)?;
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)?;
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)?;
8080 - attrs: inner_attrs,
8081 + attrs: private::attrs(outer_attrs, inner_attrs),
8086 expr: Box::new(expr),
8087 body: Block { brace_token, stmts },
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()?;
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)?;
8105 - attrs: inner_attrs,
8106 + attrs: private::attrs(outer_attrs, inner_attrs),
8109 body: Block { brace_token, stmts },
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)?;
8123 let brace_token = braced!(content in input);
8124 let inner_attrs = content.call(Attribute::parse_inner)?;
8126 let mut arms = Vec::new();
8127 while !content.is_empty() {
8128 arms.push(content.call(Arm::parse)?);
8132 - attrs: inner_attrs,
8133 + attrs: private::attrs(outer_attrs, inner_attrs),
8135 expr: Box::new(expr),
8142 @@ -2300,27 +2242,28 @@ pub(crate) mod parsing {
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)?;
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)?;
8163 - attrs: inner_attrs,
8164 + attrs: private::attrs(outer_attrs, inner_attrs),
8167 cond: Box::new(cond),
8168 body: Block { brace_token, stmts },
8173 @@ -2394,16 +2337,17 @@ pub(crate) mod parsing {
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 {
8191 @@ -2411,73 +2355,63 @@ pub(crate) mod parsing {
8192 path: Path::from(ident.clone()),
8200 - attrs: Vec::new(),
8209 #[cfg(feature = "full")]
8210 fn expr_struct_helper(
8212 outer_attrs: Vec<Attribute>,
8214 ) -> Result<ExprStruct> {
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);
8220 let mut fields = Punctuated::new();
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() {
8228 - return Err(content.error("expected struct field"));
8230 + while !content.is_empty() {
8231 + if content.peek(Token![..]) {
8232 + return Ok(ExprStruct {
8237 + dot2_token: Some(content.parse()?),
8238 + rest: Some(Box::new(content.parse()?)),
8242 - fields.push(FieldValue {
8244 - ..content.parse()?
8247 - if !content.peek(Token![,]) {
8248 + fields.push(content.parse()?);
8249 + if content.is_empty() {
8252 let punct: Token![,] = content.parse()?;
8253 fields.push_punct(punct);
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)))
8265 - attrs: private::attrs(outer_attrs, inner_attrs),
8277 #[cfg(feature = "full")]
8278 fn expr_unsafe(input: ParseStream) -> Result<ExprUnsafe> {
8279 let unsafe_token: Token![unsafe] = input.parse()?;
8282 @@ -2572,37 +2506,17 @@ pub(crate) mod parsing {
8285 #[cfg(feature = "full")]
8286 impl Parse for Arm {
8287 fn parse(input: ParseStream) -> Result<Arm> {
8290 attrs: input.call(Attribute::parse_outer)?,
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);
8304 - attrs: Vec::new(),
8312 + pat: pat::parsing::multi_pat_with_leading_vert(input)?,
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)))
8321 @@ -2636,16 +2550,36 @@ pub(crate) mod parsing {
8325 Err(Error::new(lit.span(), "expected unsuffixed integer"))
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('.');
8334 + float_repr.truncate(float_repr.len() - 1);
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),
8345 + *dot_token = Token![.](float.span());
8350 #[cfg(feature = "full")]
8352 fn is_named(&self) -> bool {
8354 Member::Named(_) => true,
8355 Member::Unnamed(_) => false,
8358 diff --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
8362 //! Extension traits to provide parsing methods on foreign types.
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.*
8367 use proc_macro2::Ident;
8369 use crate::parse::{ParseStream, Result};
8371 use crate::buffer::Cursor;
8372 use crate::parse::Peek;
8373 use crate::sealed::lookahead;
8374 use crate::token::CustomToken;
8376 /// Additional methods for `Ident` not provided by proc-macro2 or libproc_macro.
8378 /// This trait is sealed and cannot be implemented for types outside of Syn. It
8379 /// is implemented only for `proc_macro2::Ident`.
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.
8386 /// This is useful when parsing macro input which allows Rust keywords as
8391 @@ -124,12 +124,18 @@ impl lookahead::Sealed for private::Peek
8394 use proc_macro2::Ident;
8398 impl Sealed for Ident {}
8400 - #[derive(Copy, Clone)]
8402 pub struct IdentAny;
8404 + impl Copy for PeekFn {}
8405 + impl Clone for PeekFn {
8406 + fn clone(&self) -> Self {
8411 diff --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
8418 /// A complete file of Rust source code.
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.*
8425 /// Parse a Rust source file into a `syn::File` and print out a debug
8426 /// representation of the syntax tree.
8430 @@ -32,16 +32,18 @@ ast_struct! {
8433 /// let mut file = File::open(&filename).expect("Unable to open file");
8435 /// let mut src = String::new();
8436 /// file.read_to_string(&mut src).expect("Unable to read file");
8438 /// let syntax = syn::parse_file(&src).expect("Unable to parse file");
8440 + /// // Debug impl is available if Syn is built with "extra-traits" feature.
8441 /// println!("{:#?}", syntax);
8445 /// Running with its own source code as input, this program prints output
8446 /// that begins with:
8449 diff --git a/third_party/rust/syn/src/gen/clone.rs b/third_party/rust/syn/src/gen/clone.rs
8450 new file mode 100644
8452 +++ b/third_party/rust/syn/src/gen/clone.rs
8454 +// This file is @generated by syn-internal-codegen.
8455 +// It is not intended for manual editing.
8457 +#![allow(clippy::clone_on_copy, clippy::expl_impl_clone_on_copy)]
8459 +#[cfg(any(feature = "derive", feature = "full"))]
8460 +impl Clone for Abi {
8461 + fn clone(&self) -> Self {
8463 + extern_token: self.extern_token.clone(),
8464 + name: self.name.clone(),
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(),
8479 +#[cfg(feature = "full")]
8480 +impl Clone for Arm {
8481 + fn clone(&self) -> Self {
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(),
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 {
8500 +#[cfg(any(feature = "derive", feature = "full"))]
8501 +impl Clone for Attribute {
8502 + fn clone(&self) -> Self {
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(),
8512 +#[cfg(any(feature = "derive", feature = "full"))]
8513 +impl Clone for BareFnArg {
8514 + fn clone(&self) -> Self {
8516 + attrs: self.attrs.clone(),
8517 + name: self.name.clone(),
8518 + ty: self.ty.clone(),
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 {
8530 +#[cfg(any(feature = "derive", feature = "full"))]
8531 +impl Clone for Binding {
8532 + fn clone(&self) -> Self {
8534 + ident: self.ident.clone(),
8535 + eq_token: self.eq_token.clone(),
8536 + ty: self.ty.clone(),
8540 +#[cfg(feature = "full")]
8541 +impl Clone for Block {
8542 + fn clone(&self) -> Self {
8544 + brace_token: self.brace_token.clone(),
8545 + stmts: self.stmts.clone(),
8549 +#[cfg(any(feature = "derive", feature = "full"))]
8550 +impl Clone for BoundLifetimes {
8551 + fn clone(&self) -> Self {
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(),
8560 +#[cfg(any(feature = "derive", feature = "full"))]
8561 +impl Clone for ConstParam {
8562 + fn clone(&self) -> Self {
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(),
8574 +#[cfg(any(feature = "derive", feature = "full"))]
8575 +impl Clone for Constraint {
8576 + fn clone(&self) -> Self {
8578 + ident: self.ident.clone(),
8579 + colon_token: self.colon_token.clone(),
8580 + bounds: self.bounds.clone(),
8584 +#[cfg(feature = "derive")]
8585 +impl Clone for Data {
8586 + fn clone(&self) -> 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()),
8594 +#[cfg(feature = "derive")]
8595 +impl Clone for DataEnum {
8596 + fn clone(&self) -> Self {
8598 + enum_token: self.enum_token.clone(),
8599 + brace_token: self.brace_token.clone(),
8600 + variants: self.variants.clone(),
8604 +#[cfg(feature = "derive")]
8605 +impl Clone for DataStruct {
8606 + fn clone(&self) -> Self {
8608 + struct_token: self.struct_token.clone(),
8609 + fields: self.fields.clone(),
8610 + semi_token: self.semi_token.clone(),
8614 +#[cfg(feature = "derive")]
8615 +impl Clone for DataUnion {
8616 + fn clone(&self) -> Self {
8618 + union_token: self.union_token.clone(),
8619 + fields: self.fields.clone(),
8623 +#[cfg(feature = "derive")]
8624 +impl Clone for DeriveInput {
8625 + fn clone(&self) -> Self {
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(),
8635 +#[cfg(any(feature = "derive", feature = "full"))]
8636 +impl Clone for Expr {
8637 + fn clone(&self) -> 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!(),
8713 +#[cfg(feature = "full")]
8714 +impl Clone for ExprArray {
8715 + fn clone(&self) -> Self {
8717 + attrs: self.attrs.clone(),
8718 + bracket_token: self.bracket_token.clone(),
8719 + elems: self.elems.clone(),
8723 +#[cfg(feature = "full")]
8724 +impl Clone for ExprAssign {
8725 + fn clone(&self) -> Self {
8727 + attrs: self.attrs.clone(),
8728 + left: self.left.clone(),
8729 + eq_token: self.eq_token.clone(),
8730 + right: self.right.clone(),
8734 +#[cfg(feature = "full")]
8735 +impl Clone for ExprAssignOp {
8736 + fn clone(&self) -> Self {
8738 + attrs: self.attrs.clone(),
8739 + left: self.left.clone(),
8740 + op: self.op.clone(),
8741 + right: self.right.clone(),
8745 +#[cfg(feature = "full")]
8746 +impl Clone for ExprAsync {
8747 + fn clone(&self) -> Self {
8749 + attrs: self.attrs.clone(),
8750 + async_token: self.async_token.clone(),
8751 + capture: self.capture.clone(),
8752 + block: self.block.clone(),
8756 +#[cfg(feature = "full")]
8757 +impl Clone for ExprAwait {
8758 + fn clone(&self) -> Self {
8760 + attrs: self.attrs.clone(),
8761 + base: self.base.clone(),
8762 + dot_token: self.dot_token.clone(),
8763 + await_token: self.await_token.clone(),
8767 +#[cfg(any(feature = "derive", feature = "full"))]
8768 +impl Clone for ExprBinary {
8769 + fn clone(&self) -> Self {
8771 + attrs: self.attrs.clone(),
8772 + left: self.left.clone(),
8773 + op: self.op.clone(),
8774 + right: self.right.clone(),
8778 +#[cfg(feature = "full")]
8779 +impl Clone for ExprBlock {
8780 + fn clone(&self) -> Self {
8782 + attrs: self.attrs.clone(),
8783 + label: self.label.clone(),
8784 + block: self.block.clone(),
8788 +#[cfg(feature = "full")]
8789 +impl Clone for ExprBox {
8790 + fn clone(&self) -> Self {
8792 + attrs: self.attrs.clone(),
8793 + box_token: self.box_token.clone(),
8794 + expr: self.expr.clone(),
8798 +#[cfg(feature = "full")]
8799 +impl Clone for ExprBreak {
8800 + fn clone(&self) -> Self {
8802 + attrs: self.attrs.clone(),
8803 + break_token: self.break_token.clone(),
8804 + label: self.label.clone(),
8805 + expr: self.expr.clone(),
8809 +#[cfg(any(feature = "derive", feature = "full"))]
8810 +impl Clone for ExprCall {
8811 + fn clone(&self) -> Self {
8813 + attrs: self.attrs.clone(),
8814 + func: self.func.clone(),
8815 + paren_token: self.paren_token.clone(),
8816 + args: self.args.clone(),
8820 +#[cfg(any(feature = "derive", feature = "full"))]
8821 +impl Clone for ExprCast {
8822 + fn clone(&self) -> Self {
8824 + attrs: self.attrs.clone(),
8825 + expr: self.expr.clone(),
8826 + as_token: self.as_token.clone(),
8827 + ty: self.ty.clone(),
8831 +#[cfg(feature = "full")]
8832 +impl Clone for ExprClosure {
8833 + fn clone(&self) -> Self {
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(),
8847 +#[cfg(feature = "full")]
8848 +impl Clone for ExprContinue {
8849 + fn clone(&self) -> Self {
8851 + attrs: self.attrs.clone(),
8852 + continue_token: self.continue_token.clone(),
8853 + label: self.label.clone(),
8857 +#[cfg(any(feature = "derive", feature = "full"))]
8858 +impl Clone for ExprField {
8859 + fn clone(&self) -> Self {
8861 + attrs: self.attrs.clone(),
8862 + base: self.base.clone(),
8863 + dot_token: self.dot_token.clone(),
8864 + member: self.member.clone(),
8868 +#[cfg(feature = "full")]
8869 +impl Clone for ExprForLoop {
8870 + fn clone(&self) -> Self {
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(),
8882 +#[cfg(feature = "full")]
8883 +impl Clone for ExprGroup {
8884 + fn clone(&self) -> Self {
8886 + attrs: self.attrs.clone(),
8887 + group_token: self.group_token.clone(),
8888 + expr: self.expr.clone(),
8892 +#[cfg(feature = "full")]
8893 +impl Clone for ExprIf {
8894 + fn clone(&self) -> Self {
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(),
8904 +#[cfg(any(feature = "derive", feature = "full"))]
8905 +impl Clone for ExprIndex {
8906 + fn clone(&self) -> Self {
8908 + attrs: self.attrs.clone(),
8909 + expr: self.expr.clone(),
8910 + bracket_token: self.bracket_token.clone(),
8911 + index: self.index.clone(),
8915 +#[cfg(feature = "full")]
8916 +impl Clone for ExprLet {
8917 + fn clone(&self) -> Self {
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(),
8927 +#[cfg(any(feature = "derive", feature = "full"))]
8928 +impl Clone for ExprLit {
8929 + fn clone(&self) -> Self {
8931 + attrs: self.attrs.clone(),
8932 + lit: self.lit.clone(),
8936 +#[cfg(feature = "full")]
8937 +impl Clone for ExprLoop {
8938 + fn clone(&self) -> Self {
8940 + attrs: self.attrs.clone(),
8941 + label: self.label.clone(),
8942 + loop_token: self.loop_token.clone(),
8943 + body: self.body.clone(),
8947 +#[cfg(feature = "full")]
8948 +impl Clone for ExprMacro {
8949 + fn clone(&self) -> Self {
8951 + attrs: self.attrs.clone(),
8952 + mac: self.mac.clone(),
8956 +#[cfg(feature = "full")]
8957 +impl Clone for ExprMatch {
8958 + fn clone(&self) -> Self {
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(),
8968 +#[cfg(feature = "full")]
8969 +impl Clone for ExprMethodCall {
8970 + fn clone(&self) -> Self {
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(),
8982 +#[cfg(any(feature = "derive", feature = "full"))]
8983 +impl Clone for ExprParen {
8984 + fn clone(&self) -> Self {
8986 + attrs: self.attrs.clone(),
8987 + paren_token: self.paren_token.clone(),
8988 + expr: self.expr.clone(),
8992 +#[cfg(any(feature = "derive", feature = "full"))]
8993 +impl Clone for ExprPath {
8994 + fn clone(&self) -> Self {
8996 + attrs: self.attrs.clone(),
8997 + qself: self.qself.clone(),
8998 + path: self.path.clone(),
9002 +#[cfg(feature = "full")]
9003 +impl Clone for ExprRange {
9004 + fn clone(&self) -> Self {
9006 + attrs: self.attrs.clone(),
9007 + from: self.from.clone(),
9008 + limits: self.limits.clone(),
9009 + to: self.to.clone(),
9013 +#[cfg(feature = "full")]
9014 +impl Clone for ExprReference {
9015 + fn clone(&self) -> Self {
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(),
9025 +#[cfg(feature = "full")]
9026 +impl Clone for ExprRepeat {
9027 + fn clone(&self) -> Self {
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(),
9037 +#[cfg(feature = "full")]
9038 +impl Clone for ExprReturn {
9039 + fn clone(&self) -> Self {
9041 + attrs: self.attrs.clone(),
9042 + return_token: self.return_token.clone(),
9043 + expr: self.expr.clone(),
9047 +#[cfg(feature = "full")]
9048 +impl Clone for ExprStruct {
9049 + fn clone(&self) -> Self {
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(),
9060 +#[cfg(feature = "full")]
9061 +impl Clone for ExprTry {
9062 + fn clone(&self) -> Self {
9064 + attrs: self.attrs.clone(),
9065 + expr: self.expr.clone(),
9066 + question_token: self.question_token.clone(),
9070 +#[cfg(feature = "full")]
9071 +impl Clone for ExprTryBlock {
9072 + fn clone(&self) -> Self {
9074 + attrs: self.attrs.clone(),
9075 + try_token: self.try_token.clone(),
9076 + block: self.block.clone(),
9080 +#[cfg(feature = "full")]
9081 +impl Clone for ExprTuple {
9082 + fn clone(&self) -> Self {
9084 + attrs: self.attrs.clone(),
9085 + paren_token: self.paren_token.clone(),
9086 + elems: self.elems.clone(),
9090 +#[cfg(feature = "full")]
9091 +impl Clone for ExprType {
9092 + fn clone(&self) -> Self {
9094 + attrs: self.attrs.clone(),
9095 + expr: self.expr.clone(),
9096 + colon_token: self.colon_token.clone(),
9097 + ty: self.ty.clone(),
9101 +#[cfg(any(feature = "derive", feature = "full"))]
9102 +impl Clone for ExprUnary {
9103 + fn clone(&self) -> Self {
9105 + attrs: self.attrs.clone(),
9106 + op: self.op.clone(),
9107 + expr: self.expr.clone(),
9111 +#[cfg(feature = "full")]
9112 +impl Clone for ExprUnsafe {
9113 + fn clone(&self) -> Self {
9115 + attrs: self.attrs.clone(),
9116 + unsafe_token: self.unsafe_token.clone(),
9117 + block: self.block.clone(),
9121 +#[cfg(feature = "full")]
9122 +impl Clone for ExprWhile {
9123 + fn clone(&self) -> Self {
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(),
9133 +#[cfg(feature = "full")]
9134 +impl Clone for ExprYield {
9135 + fn clone(&self) -> Self {
9137 + attrs: self.attrs.clone(),
9138 + yield_token: self.yield_token.clone(),
9139 + expr: self.expr.clone(),
9143 +#[cfg(any(feature = "derive", feature = "full"))]
9144 +impl Clone for Field {
9145 + fn clone(&self) -> Self {
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(),
9155 +#[cfg(feature = "full")]
9156 +impl Clone for FieldPat {
9157 + fn clone(&self) -> Self {
9159 + attrs: self.attrs.clone(),
9160 + member: self.member.clone(),
9161 + colon_token: self.colon_token.clone(),
9162 + pat: self.pat.clone(),
9166 +#[cfg(feature = "full")]
9167 +impl Clone for FieldValue {
9168 + fn clone(&self) -> Self {
9170 + attrs: self.attrs.clone(),
9171 + member: self.member.clone(),
9172 + colon_token: self.colon_token.clone(),
9173 + expr: self.expr.clone(),
9177 +#[cfg(any(feature = "derive", feature = "full"))]
9178 +impl Clone for Fields {
9179 + fn clone(&self) -> Self {
9181 + Fields::Named(v0) => Fields::Named(v0.clone()),
9182 + Fields::Unnamed(v0) => Fields::Unnamed(v0.clone()),
9183 + Fields::Unit => Fields::Unit,
9187 +#[cfg(any(feature = "derive", feature = "full"))]
9188 +impl Clone for FieldsNamed {
9189 + fn clone(&self) -> Self {
9191 + brace_token: self.brace_token.clone(),
9192 + named: self.named.clone(),
9196 +#[cfg(any(feature = "derive", feature = "full"))]
9197 +impl Clone for FieldsUnnamed {
9198 + fn clone(&self) -> Self {
9200 + paren_token: self.paren_token.clone(),
9201 + unnamed: self.unnamed.clone(),
9205 +#[cfg(feature = "full")]
9206 +impl Clone for File {
9207 + fn clone(&self) -> Self {
9209 + shebang: self.shebang.clone(),
9210 + attrs: self.attrs.clone(),
9211 + items: self.items.clone(),
9215 +#[cfg(feature = "full")]
9216 +impl Clone for FnArg {
9217 + fn clone(&self) -> Self {
9219 + FnArg::Receiver(v0) => FnArg::Receiver(v0.clone()),
9220 + FnArg::Typed(v0) => FnArg::Typed(v0.clone()),
9224 +#[cfg(feature = "full")]
9225 +impl Clone for ForeignItem {
9226 + fn clone(&self) -> 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!(),
9237 +#[cfg(feature = "full")]
9238 +impl Clone for ForeignItemFn {
9239 + fn clone(&self) -> Self {
9241 + attrs: self.attrs.clone(),
9242 + vis: self.vis.clone(),
9243 + sig: self.sig.clone(),
9244 + semi_token: self.semi_token.clone(),
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(),
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(),
9273 +#[cfg(feature = "full")]
9274 +impl Clone for ForeignItemType {
9275 + fn clone(&self) -> Self {
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(),
9285 +#[cfg(any(feature = "derive", feature = "full"))]
9286 +impl Clone for GenericArgument {
9287 + fn clone(&self) -> 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()),
9297 +#[cfg(feature = "full")]
9298 +impl Clone for GenericMethodArgument {
9299 + fn clone(&self) -> Self {
9301 + GenericMethodArgument::Type(v0) => GenericMethodArgument::Type(v0.clone()),
9302 + GenericMethodArgument::Const(v0) => GenericMethodArgument::Const(v0.clone()),
9306 +#[cfg(any(feature = "derive", feature = "full"))]
9307 +impl Clone for GenericParam {
9308 + fn clone(&self) -> 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()),
9316 +#[cfg(any(feature = "derive", feature = "full"))]
9317 +impl Clone for Generics {
9318 + fn clone(&self) -> Self {
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(),
9327 +#[cfg(feature = "full")]
9328 +impl Clone for ImplItem {
9329 + fn clone(&self) -> 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!(),
9340 +#[cfg(feature = "full")]
9341 +impl Clone for ImplItemConst {
9342 + fn clone(&self) -> Self {
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(),
9357 +#[cfg(feature = "full")]
9358 +impl Clone for ImplItemMacro {
9359 + fn clone(&self) -> Self {
9361 + attrs: self.attrs.clone(),
9362 + mac: self.mac.clone(),
9363 + semi_token: self.semi_token.clone(),
9367 +#[cfg(feature = "full")]
9368 +impl Clone for ImplItemMethod {
9369 + fn clone(&self) -> Self {
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(),
9379 +#[cfg(feature = "full")]
9380 +impl Clone for ImplItemType {
9381 + fn clone(&self) -> Self {
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(),
9395 +#[cfg(any(feature = "derive", feature = "full"))]
9396 +impl Clone for Index {
9397 + fn clone(&self) -> Self {
9399 + index: self.index.clone(),
9400 + span: self.span.clone(),
9404 +#[cfg(feature = "full")]
9405 +impl Clone for Item {
9406 + fn clone(&self) -> 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!(),
9429 +#[cfg(feature = "full")]
9430 +impl Clone for ItemConst {
9431 + fn clone(&self) -> Self {
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(),
9445 +#[cfg(feature = "full")]
9446 +impl Clone for ItemEnum {
9447 + fn clone(&self) -> Self {
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(),
9459 +#[cfg(feature = "full")]
9460 +impl Clone for ItemExternCrate {
9461 + fn clone(&self) -> Self {
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(),
9473 +#[cfg(feature = "full")]
9474 +impl Clone for ItemFn {
9475 + fn clone(&self) -> Self {
9477 + attrs: self.attrs.clone(),
9478 + vis: self.vis.clone(),
9479 + sig: self.sig.clone(),
9480 + block: self.block.clone(),
9484 +#[cfg(feature = "full")]
9485 +impl Clone for ItemForeignMod {
9486 + fn clone(&self) -> Self {
9488 + attrs: self.attrs.clone(),
9489 + abi: self.abi.clone(),
9490 + brace_token: self.brace_token.clone(),
9491 + items: self.items.clone(),
9495 +#[cfg(feature = "full")]
9496 +impl Clone for ItemImpl {
9497 + fn clone(&self) -> Self {
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(),
9511 +#[cfg(feature = "full")]
9512 +impl Clone for ItemMacro {
9513 + fn clone(&self) -> Self {
9515 + attrs: self.attrs.clone(),
9516 + ident: self.ident.clone(),
9517 + mac: self.mac.clone(),
9518 + semi_token: self.semi_token.clone(),
9522 +#[cfg(feature = "full")]
9523 +impl Clone for ItemMacro2 {
9524 + fn clone(&self) -> Self {
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(),
9534 +#[cfg(feature = "full")]
9535 +impl Clone for ItemMod {
9536 + fn clone(&self) -> Self {
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(),
9547 +#[cfg(feature = "full")]
9548 +impl Clone for ItemStatic {
9549 + fn clone(&self) -> Self {
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(),
9564 +#[cfg(feature = "full")]
9565 +impl Clone for ItemStruct {
9566 + fn clone(&self) -> Self {
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(),
9578 +#[cfg(feature = "full")]
9579 +impl Clone for ItemTrait {
9580 + fn clone(&self) -> Self {
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(),
9596 +#[cfg(feature = "full")]
9597 +impl Clone for ItemTraitAlias {
9598 + fn clone(&self) -> Self {
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(),
9611 +#[cfg(feature = "full")]
9612 +impl Clone for ItemType {
9613 + fn clone(&self) -> Self {
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(),
9626 +#[cfg(feature = "full")]
9627 +impl Clone for ItemUnion {
9628 + fn clone(&self) -> Self {
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(),
9639 +#[cfg(feature = "full")]
9640 +impl Clone for ItemUse {
9641 + fn clone(&self) -> Self {
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(),
9652 +#[cfg(feature = "full")]
9653 +impl Clone for Label {
9654 + fn clone(&self) -> Self {
9656 + name: self.name.clone(),
9657 + colon_token: self.colon_token.clone(),
9661 +#[cfg(any(feature = "derive", feature = "full"))]
9662 +impl Clone for LifetimeDef {
9663 + fn clone(&self) -> Self {
9665 + attrs: self.attrs.clone(),
9666 + lifetime: self.lifetime.clone(),
9667 + colon_token: self.colon_token.clone(),
9668 + bounds: self.bounds.clone(),
9672 +impl Clone for Lit {
9673 + fn clone(&self) -> 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()),
9686 +impl Clone for LitBool {
9687 + fn clone(&self) -> Self {
9689 + value: self.value.clone(),
9690 + span: self.span.clone(),
9694 +#[cfg(feature = "full")]
9695 +impl Clone for Local {
9696 + fn clone(&self) -> Self {
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(),
9706 +#[cfg(any(feature = "derive", feature = "full"))]
9707 +impl Clone for Macro {
9708 + fn clone(&self) -> Self {
9710 + path: self.path.clone(),
9711 + bang_token: self.bang_token.clone(),
9712 + delimiter: self.delimiter.clone(),
9713 + tokens: self.tokens.clone(),
9717 +#[cfg(any(feature = "derive", feature = "full"))]
9718 +impl Clone for MacroDelimiter {
9719 + fn clone(&self) -> 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()),
9727 +#[cfg(any(feature = "derive", feature = "full"))]
9728 +impl Clone for Member {
9729 + fn clone(&self) -> Self {
9731 + Member::Named(v0) => Member::Named(v0.clone()),
9732 + Member::Unnamed(v0) => Member::Unnamed(v0.clone()),
9736 +#[cfg(any(feature = "derive", feature = "full"))]
9737 +impl Clone for Meta {
9738 + fn clone(&self) -> 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()),
9746 +#[cfg(any(feature = "derive", feature = "full"))]
9747 +impl Clone for MetaList {
9748 + fn clone(&self) -> Self {
9750 + path: self.path.clone(),
9751 + paren_token: self.paren_token.clone(),
9752 + nested: self.nested.clone(),
9756 +#[cfg(any(feature = "derive", feature = "full"))]
9757 +impl Clone for MetaNameValue {
9758 + fn clone(&self) -> Self {
9760 + path: self.path.clone(),
9761 + eq_token: self.eq_token.clone(),
9762 + lit: self.lit.clone(),
9766 +#[cfg(feature = "full")]
9767 +impl Clone for MethodTurbofish {
9768 + fn clone(&self) -> Self {
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(),
9777 +#[cfg(any(feature = "derive", feature = "full"))]
9778 +impl Clone for NestedMeta {
9779 + fn clone(&self) -> Self {
9781 + NestedMeta::Meta(v0) => NestedMeta::Meta(v0.clone()),
9782 + NestedMeta::Lit(v0) => NestedMeta::Lit(v0.clone()),
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(),
9796 +#[cfg(feature = "full")]
9797 +impl Clone for Pat {
9798 + fn clone(&self) -> 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!(),
9820 +#[cfg(feature = "full")]
9821 +impl Clone for PatBox {
9822 + fn clone(&self) -> Self {
9824 + attrs: self.attrs.clone(),
9825 + box_token: self.box_token.clone(),
9826 + pat: self.pat.clone(),
9830 +#[cfg(feature = "full")]
9831 +impl Clone for PatIdent {
9832 + fn clone(&self) -> Self {
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(),
9842 +#[cfg(feature = "full")]
9843 +impl Clone for PatLit {
9844 + fn clone(&self) -> Self {
9846 + attrs: self.attrs.clone(),
9847 + expr: self.expr.clone(),
9851 +#[cfg(feature = "full")]
9852 +impl Clone for PatMacro {
9853 + fn clone(&self) -> Self {
9855 + attrs: self.attrs.clone(),
9856 + mac: self.mac.clone(),
9860 +#[cfg(feature = "full")]
9861 +impl Clone for PatOr {
9862 + fn clone(&self) -> Self {
9864 + attrs: self.attrs.clone(),
9865 + leading_vert: self.leading_vert.clone(),
9866 + cases: self.cases.clone(),
9870 +#[cfg(feature = "full")]
9871 +impl Clone for PatPath {
9872 + fn clone(&self) -> Self {
9874 + attrs: self.attrs.clone(),
9875 + qself: self.qself.clone(),
9876 + path: self.path.clone(),
9880 +#[cfg(feature = "full")]
9881 +impl Clone for PatRange {
9882 + fn clone(&self) -> Self {
9884 + attrs: self.attrs.clone(),
9885 + lo: self.lo.clone(),
9886 + limits: self.limits.clone(),
9887 + hi: self.hi.clone(),
9891 +#[cfg(feature = "full")]
9892 +impl Clone for PatReference {
9893 + fn clone(&self) -> Self {
9895 + attrs: self.attrs.clone(),
9896 + and_token: self.and_token.clone(),
9897 + mutability: self.mutability.clone(),
9898 + pat: self.pat.clone(),
9902 +#[cfg(feature = "full")]
9903 +impl Clone for PatRest {
9904 + fn clone(&self) -> Self {
9906 + attrs: self.attrs.clone(),
9907 + dot2_token: self.dot2_token.clone(),
9911 +#[cfg(feature = "full")]
9912 +impl Clone for PatSlice {
9913 + fn clone(&self) -> Self {
9915 + attrs: self.attrs.clone(),
9916 + bracket_token: self.bracket_token.clone(),
9917 + elems: self.elems.clone(),
9921 +#[cfg(feature = "full")]
9922 +impl Clone for PatStruct {
9923 + fn clone(&self) -> Self {
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(),
9933 +#[cfg(feature = "full")]
9934 +impl Clone for PatTuple {
9935 + fn clone(&self) -> Self {
9937 + attrs: self.attrs.clone(),
9938 + paren_token: self.paren_token.clone(),
9939 + elems: self.elems.clone(),
9943 +#[cfg(feature = "full")]
9944 +impl Clone for PatTupleStruct {
9945 + fn clone(&self) -> Self {
9947 + attrs: self.attrs.clone(),
9948 + path: self.path.clone(),
9949 + pat: self.pat.clone(),
9953 +#[cfg(feature = "full")]
9954 +impl Clone for PatType {
9955 + fn clone(&self) -> Self {
9957 + attrs: self.attrs.clone(),
9958 + pat: self.pat.clone(),
9959 + colon_token: self.colon_token.clone(),
9960 + ty: self.ty.clone(),
9964 +#[cfg(feature = "full")]
9965 +impl Clone for PatWild {
9966 + fn clone(&self) -> Self {
9968 + attrs: self.attrs.clone(),
9969 + underscore_token: self.underscore_token.clone(),
9973 +#[cfg(any(feature = "derive", feature = "full"))]
9974 +impl Clone for Path {
9975 + fn clone(&self) -> Self {
9977 + leading_colon: self.leading_colon.clone(),
9978 + segments: self.segments.clone(),
9982 +#[cfg(any(feature = "derive", feature = "full"))]
9983 +impl Clone for PathArguments {
9984 + fn clone(&self) -> Self {
9986 + PathArguments::None => PathArguments::None,
9987 + PathArguments::AngleBracketed(v0) => PathArguments::AngleBracketed(v0.clone()),
9988 + PathArguments::Parenthesized(v0) => PathArguments::Parenthesized(v0.clone()),
9992 +#[cfg(any(feature = "derive", feature = "full"))]
9993 +impl Clone for PathSegment {
9994 + fn clone(&self) -> Self {
9996 + ident: self.ident.clone(),
9997 + arguments: self.arguments.clone(),
10001 +#[cfg(any(feature = "derive", feature = "full"))]
10002 +impl Clone for PredicateEq {
10003 + fn clone(&self) -> Self {
10005 + lhs_ty: self.lhs_ty.clone(),
10006 + eq_token: self.eq_token.clone(),
10007 + rhs_ty: self.rhs_ty.clone(),
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(),
10021 +#[cfg(any(feature = "derive", feature = "full"))]
10022 +impl Clone for PredicateType {
10023 + fn clone(&self) -> Self {
10025 + lifetimes: self.lifetimes.clone(),
10026 + bounded_ty: self.bounded_ty.clone(),
10027 + colon_token: self.colon_token.clone(),
10028 + bounds: self.bounds.clone(),
10032 +#[cfg(any(feature = "derive", feature = "full"))]
10033 +impl Clone for QSelf {
10034 + fn clone(&self) -> Self {
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(),
10044 +#[cfg(feature = "full")]
10045 +impl Copy for RangeLimits {}
10046 +#[cfg(feature = "full")]
10047 +impl Clone for RangeLimits {
10048 + fn clone(&self) -> Self {
10052 +#[cfg(feature = "full")]
10053 +impl Clone for Receiver {
10054 + fn clone(&self) -> Self {
10056 + attrs: self.attrs.clone(),
10057 + reference: self.reference.clone(),
10058 + mutability: self.mutability.clone(),
10059 + self_token: self.self_token.clone(),
10063 +#[cfg(any(feature = "derive", feature = "full"))]
10064 +impl Clone for ReturnType {
10065 + fn clone(&self) -> Self {
10067 + ReturnType::Default => ReturnType::Default,
10068 + ReturnType::Type(v0, v1) => ReturnType::Type(v0.clone(), v1.clone()),
10072 +#[cfg(feature = "full")]
10073 +impl Clone for Signature {
10074 + fn clone(&self) -> Self {
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(),
10090 +#[cfg(feature = "full")]
10091 +impl Clone for Stmt {
10092 + fn clone(&self) -> 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()),
10101 +#[cfg(any(feature = "derive", feature = "full"))]
10102 +impl Clone for TraitBound {
10103 + fn clone(&self) -> Self {
10105 + paren_token: self.paren_token.clone(),
10106 + modifier: self.modifier.clone(),
10107 + lifetimes: self.lifetimes.clone(),
10108 + path: self.path.clone(),
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 {
10120 +#[cfg(feature = "full")]
10121 +impl Clone for TraitItem {
10122 + fn clone(&self) -> 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!(),
10133 +#[cfg(feature = "full")]
10134 +impl Clone for TraitItemConst {
10135 + fn clone(&self) -> Self {
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(),
10147 +#[cfg(feature = "full")]
10148 +impl Clone for TraitItemMacro {
10149 + fn clone(&self) -> Self {
10151 + attrs: self.attrs.clone(),
10152 + mac: self.mac.clone(),
10153 + semi_token: self.semi_token.clone(),
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(),
10168 +#[cfg(feature = "full")]
10169 +impl Clone for TraitItemType {
10170 + fn clone(&self) -> Self {
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(),
10183 +#[cfg(any(feature = "derive", feature = "full"))]
10184 +impl Clone for Type {
10185 + fn clone(&self) -> 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!(),
10206 +#[cfg(any(feature = "derive", feature = "full"))]
10207 +impl Clone for TypeArray {
10208 + fn clone(&self) -> Self {
10210 + bracket_token: self.bracket_token.clone(),
10211 + elem: self.elem.clone(),
10212 + semi_token: self.semi_token.clone(),
10213 + len: self.len.clone(),
10217 +#[cfg(any(feature = "derive", feature = "full"))]
10218 +impl Clone for TypeBareFn {
10219 + fn clone(&self) -> Self {
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(),
10232 +#[cfg(any(feature = "derive", feature = "full"))]
10233 +impl Clone for TypeGroup {
10234 + fn clone(&self) -> Self {
10236 + group_token: self.group_token.clone(),
10237 + elem: self.elem.clone(),
10241 +#[cfg(any(feature = "derive", feature = "full"))]
10242 +impl Clone for TypeImplTrait {
10243 + fn clone(&self) -> Self {
10245 + impl_token: self.impl_token.clone(),
10246 + bounds: self.bounds.clone(),
10250 +#[cfg(any(feature = "derive", feature = "full"))]
10251 +impl Clone for TypeInfer {
10252 + fn clone(&self) -> Self {
10254 + underscore_token: self.underscore_token.clone(),
10258 +#[cfg(any(feature = "derive", feature = "full"))]
10259 +impl Clone for TypeMacro {
10260 + fn clone(&self) -> Self {
10262 + mac: self.mac.clone(),
10266 +#[cfg(any(feature = "derive", feature = "full"))]
10267 +impl Clone for TypeNever {
10268 + fn clone(&self) -> Self {
10270 + bang_token: self.bang_token.clone(),
10274 +#[cfg(any(feature = "derive", feature = "full"))]
10275 +impl Clone for TypeParam {
10276 + fn clone(&self) -> Self {
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(),
10287 +#[cfg(any(feature = "derive", feature = "full"))]
10288 +impl Clone for TypeParamBound {
10289 + fn clone(&self) -> Self {
10291 + TypeParamBound::Trait(v0) => TypeParamBound::Trait(v0.clone()),
10292 + TypeParamBound::Lifetime(v0) => TypeParamBound::Lifetime(v0.clone()),
10296 +#[cfg(any(feature = "derive", feature = "full"))]
10297 +impl Clone for TypeParen {
10298 + fn clone(&self) -> Self {
10300 + paren_token: self.paren_token.clone(),
10301 + elem: self.elem.clone(),
10305 +#[cfg(any(feature = "derive", feature = "full"))]
10306 +impl Clone for TypePath {
10307 + fn clone(&self) -> Self {
10309 + qself: self.qself.clone(),
10310 + path: self.path.clone(),
10314 +#[cfg(any(feature = "derive", feature = "full"))]
10315 +impl Clone for TypePtr {
10316 + fn clone(&self) -> Self {
10318 + star_token: self.star_token.clone(),
10319 + const_token: self.const_token.clone(),
10320 + mutability: self.mutability.clone(),
10321 + elem: self.elem.clone(),
10325 +#[cfg(any(feature = "derive", feature = "full"))]
10326 +impl Clone for TypeReference {
10327 + fn clone(&self) -> Self {
10329 + and_token: self.and_token.clone(),
10330 + lifetime: self.lifetime.clone(),
10331 + mutability: self.mutability.clone(),
10332 + elem: self.elem.clone(),
10336 +#[cfg(any(feature = "derive", feature = "full"))]
10337 +impl Clone for TypeSlice {
10338 + fn clone(&self) -> Self {
10340 + bracket_token: self.bracket_token.clone(),
10341 + elem: self.elem.clone(),
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(),
10354 +#[cfg(any(feature = "derive", feature = "full"))]
10355 +impl Clone for TypeTuple {
10356 + fn clone(&self) -> Self {
10358 + paren_token: self.paren_token.clone(),
10359 + elems: self.elems.clone(),
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 {
10371 +#[cfg(feature = "full")]
10372 +impl Clone for UseGlob {
10373 + fn clone(&self) -> Self {
10375 + star_token: self.star_token.clone(),
10379 +#[cfg(feature = "full")]
10380 +impl Clone for UseGroup {
10381 + fn clone(&self) -> Self {
10383 + brace_token: self.brace_token.clone(),
10384 + items: self.items.clone(),
10388 +#[cfg(feature = "full")]
10389 +impl Clone for UseName {
10390 + fn clone(&self) -> Self {
10392 + ident: self.ident.clone(),
10396 +#[cfg(feature = "full")]
10397 +impl Clone for UsePath {
10398 + fn clone(&self) -> Self {
10400 + ident: self.ident.clone(),
10401 + colon2_token: self.colon2_token.clone(),
10402 + tree: self.tree.clone(),
10406 +#[cfg(feature = "full")]
10407 +impl Clone for UseRename {
10408 + fn clone(&self) -> Self {
10410 + ident: self.ident.clone(),
10411 + as_token: self.as_token.clone(),
10412 + rename: self.rename.clone(),
10416 +#[cfg(feature = "full")]
10417 +impl Clone for UseTree {
10418 + fn clone(&self) -> 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()),
10428 +#[cfg(any(feature = "derive", feature = "full"))]
10429 +impl Clone for Variadic {
10430 + fn clone(&self) -> Self {
10432 + attrs: self.attrs.clone(),
10433 + dots: self.dots.clone(),
10437 +#[cfg(any(feature = "derive", feature = "full"))]
10438 +impl Clone for Variant {
10439 + fn clone(&self) -> Self {
10441 + attrs: self.attrs.clone(),
10442 + ident: self.ident.clone(),
10443 + fields: self.fields.clone(),
10444 + discriminant: self.discriminant.clone(),
10448 +#[cfg(any(feature = "derive", feature = "full"))]
10449 +impl Clone for VisCrate {
10450 + fn clone(&self) -> Self {
10452 + crate_token: self.crate_token.clone(),
10456 +#[cfg(any(feature = "derive", feature = "full"))]
10457 +impl Clone for VisPublic {
10458 + fn clone(&self) -> Self {
10460 + pub_token: self.pub_token.clone(),
10464 +#[cfg(any(feature = "derive", feature = "full"))]
10465 +impl Clone for VisRestricted {
10466 + fn clone(&self) -> Self {
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(),
10475 +#[cfg(any(feature = "derive", feature = "full"))]
10476 +impl Clone for Visibility {
10477 + fn clone(&self) -> 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,
10486 +#[cfg(any(feature = "derive", feature = "full"))]
10487 +impl Clone for WhereClause {
10488 + fn clone(&self) -> Self {
10490 + where_token: self.where_token.clone(),
10491 + predicates: self.predicates.clone(),
10495 +#[cfg(any(feature = "derive", feature = "full"))]
10496 +impl Clone for WherePredicate {
10497 + fn clone(&self) -> 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()),
10505 diff --git a/third_party/rust/syn/src/gen/debug.rs b/third_party/rust/syn/src/gen/debug.rs
10506 new file mode 100644
10508 +++ b/third_party/rust/syn/src/gen/debug.rs
10510 +// This file is @generated by syn-internal-codegen.
10511 +// It is not intended for manual editing.
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()
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()
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()
10548 +#[cfg(any(feature = "derive", feature = "full"))]
10549 +impl Debug for AttrStyle {
10550 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
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()
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()
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()
10583 +#[cfg(any(feature = "derive", feature = "full"))]
10584 +impl Debug for BinOp {
10585 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10587 + BinOp::Add(v0) => {
10588 + let mut formatter = formatter.debug_tuple("Add");
10589 + formatter.field(v0);
10590 + formatter.finish()
10592 + BinOp::Sub(v0) => {
10593 + let mut formatter = formatter.debug_tuple("Sub");
10594 + formatter.field(v0);
10595 + formatter.finish()
10597 + BinOp::Mul(v0) => {
10598 + let mut formatter = formatter.debug_tuple("Mul");
10599 + formatter.field(v0);
10600 + formatter.finish()
10602 + BinOp::Div(v0) => {
10603 + let mut formatter = formatter.debug_tuple("Div");
10604 + formatter.field(v0);
10605 + formatter.finish()
10607 + BinOp::Rem(v0) => {
10608 + let mut formatter = formatter.debug_tuple("Rem");
10609 + formatter.field(v0);
10610 + formatter.finish()
10612 + BinOp::And(v0) => {
10613 + let mut formatter = formatter.debug_tuple("And");
10614 + formatter.field(v0);
10615 + formatter.finish()
10617 + BinOp::Or(v0) => {
10618 + let mut formatter = formatter.debug_tuple("Or");
10619 + formatter.field(v0);
10620 + formatter.finish()
10622 + BinOp::BitXor(v0) => {
10623 + let mut formatter = formatter.debug_tuple("BitXor");
10624 + formatter.field(v0);
10625 + formatter.finish()
10627 + BinOp::BitAnd(v0) => {
10628 + let mut formatter = formatter.debug_tuple("BitAnd");
10629 + formatter.field(v0);
10630 + formatter.finish()
10632 + BinOp::BitOr(v0) => {
10633 + let mut formatter = formatter.debug_tuple("BitOr");
10634 + formatter.field(v0);
10635 + formatter.finish()
10637 + BinOp::Shl(v0) => {
10638 + let mut formatter = formatter.debug_tuple("Shl");
10639 + formatter.field(v0);
10640 + formatter.finish()
10642 + BinOp::Shr(v0) => {
10643 + let mut formatter = formatter.debug_tuple("Shr");
10644 + formatter.field(v0);
10645 + formatter.finish()
10647 + BinOp::Eq(v0) => {
10648 + let mut formatter = formatter.debug_tuple("Eq");
10649 + formatter.field(v0);
10650 + formatter.finish()
10652 + BinOp::Lt(v0) => {
10653 + let mut formatter = formatter.debug_tuple("Lt");
10654 + formatter.field(v0);
10655 + formatter.finish()
10657 + BinOp::Le(v0) => {
10658 + let mut formatter = formatter.debug_tuple("Le");
10659 + formatter.field(v0);
10660 + formatter.finish()
10662 + BinOp::Ne(v0) => {
10663 + let mut formatter = formatter.debug_tuple("Ne");
10664 + formatter.field(v0);
10665 + formatter.finish()
10667 + BinOp::Ge(v0) => {
10668 + let mut formatter = formatter.debug_tuple("Ge");
10669 + formatter.field(v0);
10670 + formatter.finish()
10672 + BinOp::Gt(v0) => {
10673 + let mut formatter = formatter.debug_tuple("Gt");
10674 + formatter.field(v0);
10675 + formatter.finish()
10677 + BinOp::AddEq(v0) => {
10678 + let mut formatter = formatter.debug_tuple("AddEq");
10679 + formatter.field(v0);
10680 + formatter.finish()
10682 + BinOp::SubEq(v0) => {
10683 + let mut formatter = formatter.debug_tuple("SubEq");
10684 + formatter.field(v0);
10685 + formatter.finish()
10687 + BinOp::MulEq(v0) => {
10688 + let mut formatter = formatter.debug_tuple("MulEq");
10689 + formatter.field(v0);
10690 + formatter.finish()
10692 + BinOp::DivEq(v0) => {
10693 + let mut formatter = formatter.debug_tuple("DivEq");
10694 + formatter.field(v0);
10695 + formatter.finish()
10697 + BinOp::RemEq(v0) => {
10698 + let mut formatter = formatter.debug_tuple("RemEq");
10699 + formatter.field(v0);
10700 + formatter.finish()
10702 + BinOp::BitXorEq(v0) => {
10703 + let mut formatter = formatter.debug_tuple("BitXorEq");
10704 + formatter.field(v0);
10705 + formatter.finish()
10707 + BinOp::BitAndEq(v0) => {
10708 + let mut formatter = formatter.debug_tuple("BitAndEq");
10709 + formatter.field(v0);
10710 + formatter.finish()
10712 + BinOp::BitOrEq(v0) => {
10713 + let mut formatter = formatter.debug_tuple("BitOrEq");
10714 + formatter.field(v0);
10715 + formatter.finish()
10717 + BinOp::ShlEq(v0) => {
10718 + let mut formatter = formatter.debug_tuple("ShlEq");
10719 + formatter.field(v0);
10720 + formatter.finish()
10722 + BinOp::ShrEq(v0) => {
10723 + let mut formatter = formatter.debug_tuple("ShrEq");
10724 + formatter.field(v0);
10725 + formatter.finish()
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()
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()
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()
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()
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()
10784 +#[cfg(feature = "derive")]
10785 +impl Debug for Data {
10786 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10788 + Data::Struct(v0) => {
10789 + let mut formatter = formatter.debug_tuple("Struct");
10790 + formatter.field(v0);
10791 + formatter.finish()
10793 + Data::Enum(v0) => {
10794 + let mut formatter = formatter.debug_tuple("Enum");
10795 + formatter.field(v0);
10796 + formatter.finish()
10798 + Data::Union(v0) => {
10799 + let mut formatter = formatter.debug_tuple("Union");
10800 + formatter.field(v0);
10801 + formatter.finish()
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()
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()
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()
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()
10847 +#[cfg(any(feature = "derive", feature = "full"))]
10848 +impl Debug for Expr {
10849 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10851 + #[cfg(feature = "full")]
10852 + Expr::Array(v0) => {
10853 + let mut formatter = formatter.debug_tuple("Array");
10854 + formatter.field(v0);
10855 + formatter.finish()
10857 + #[cfg(feature = "full")]
10858 + Expr::Assign(v0) => {
10859 + let mut formatter = formatter.debug_tuple("Assign");
10860 + formatter.field(v0);
10861 + formatter.finish()
10863 + #[cfg(feature = "full")]
10864 + Expr::AssignOp(v0) => {
10865 + let mut formatter = formatter.debug_tuple("AssignOp");
10866 + formatter.field(v0);
10867 + formatter.finish()
10869 + #[cfg(feature = "full")]
10870 + Expr::Async(v0) => {
10871 + let mut formatter = formatter.debug_tuple("Async");
10872 + formatter.field(v0);
10873 + formatter.finish()
10875 + #[cfg(feature = "full")]
10876 + Expr::Await(v0) => {
10877 + let mut formatter = formatter.debug_tuple("Await");
10878 + formatter.field(v0);
10879 + formatter.finish()
10881 + Expr::Binary(v0) => {
10882 + let mut formatter = formatter.debug_tuple("Binary");
10883 + formatter.field(v0);
10884 + formatter.finish()
10886 + #[cfg(feature = "full")]
10887 + Expr::Block(v0) => {
10888 + let mut formatter = formatter.debug_tuple("Block");
10889 + formatter.field(v0);
10890 + formatter.finish()
10892 + #[cfg(feature = "full")]
10893 + Expr::Box(v0) => {
10894 + let mut formatter = formatter.debug_tuple("Box");
10895 + formatter.field(v0);
10896 + formatter.finish()
10898 + #[cfg(feature = "full")]
10899 + Expr::Break(v0) => {
10900 + let mut formatter = formatter.debug_tuple("Break");
10901 + formatter.field(v0);
10902 + formatter.finish()
10904 + Expr::Call(v0) => {
10905 + let mut formatter = formatter.debug_tuple("Call");
10906 + formatter.field(v0);
10907 + formatter.finish()
10909 + Expr::Cast(v0) => {
10910 + let mut formatter = formatter.debug_tuple("Cast");
10911 + formatter.field(v0);
10912 + formatter.finish()
10914 + #[cfg(feature = "full")]
10915 + Expr::Closure(v0) => {
10916 + let mut formatter = formatter.debug_tuple("Closure");
10917 + formatter.field(v0);
10918 + formatter.finish()
10920 + #[cfg(feature = "full")]
10921 + Expr::Continue(v0) => {
10922 + let mut formatter = formatter.debug_tuple("Continue");
10923 + formatter.field(v0);
10924 + formatter.finish()
10926 + Expr::Field(v0) => {
10927 + let mut formatter = formatter.debug_tuple("Field");
10928 + formatter.field(v0);
10929 + formatter.finish()
10931 + #[cfg(feature = "full")]
10932 + Expr::ForLoop(v0) => {
10933 + let mut formatter = formatter.debug_tuple("ForLoop");
10934 + formatter.field(v0);
10935 + formatter.finish()
10937 + #[cfg(feature = "full")]
10938 + Expr::Group(v0) => {
10939 + let mut formatter = formatter.debug_tuple("Group");
10940 + formatter.field(v0);
10941 + formatter.finish()
10943 + #[cfg(feature = "full")]
10944 + Expr::If(v0) => {
10945 + let mut formatter = formatter.debug_tuple("If");
10946 + formatter.field(v0);
10947 + formatter.finish()
10949 + Expr::Index(v0) => {
10950 + let mut formatter = formatter.debug_tuple("Index");
10951 + formatter.field(v0);
10952 + formatter.finish()
10954 + #[cfg(feature = "full")]
10955 + Expr::Let(v0) => {
10956 + let mut formatter = formatter.debug_tuple("Let");
10957 + formatter.field(v0);
10958 + formatter.finish()
10960 + Expr::Lit(v0) => {
10961 + let mut formatter = formatter.debug_tuple("Lit");
10962 + formatter.field(v0);
10963 + formatter.finish()
10965 + #[cfg(feature = "full")]
10966 + Expr::Loop(v0) => {
10967 + let mut formatter = formatter.debug_tuple("Loop");
10968 + formatter.field(v0);
10969 + formatter.finish()
10971 + #[cfg(feature = "full")]
10972 + Expr::Macro(v0) => {
10973 + let mut formatter = formatter.debug_tuple("Macro");
10974 + formatter.field(v0);
10975 + formatter.finish()
10977 + #[cfg(feature = "full")]
10978 + Expr::Match(v0) => {
10979 + let mut formatter = formatter.debug_tuple("Match");
10980 + formatter.field(v0);
10981 + formatter.finish()
10983 + #[cfg(feature = "full")]
10984 + Expr::MethodCall(v0) => {
10985 + let mut formatter = formatter.debug_tuple("MethodCall");
10986 + formatter.field(v0);
10987 + formatter.finish()
10989 + Expr::Paren(v0) => {
10990 + let mut formatter = formatter.debug_tuple("Paren");
10991 + formatter.field(v0);
10992 + formatter.finish()
10994 + Expr::Path(v0) => {
10995 + let mut formatter = formatter.debug_tuple("Path");
10996 + formatter.field(v0);
10997 + formatter.finish()
10999 + #[cfg(feature = "full")]
11000 + Expr::Range(v0) => {
11001 + let mut formatter = formatter.debug_tuple("Range");
11002 + formatter.field(v0);
11003 + formatter.finish()
11005 + #[cfg(feature = "full")]
11006 + Expr::Reference(v0) => {
11007 + let mut formatter = formatter.debug_tuple("Reference");
11008 + formatter.field(v0);
11009 + formatter.finish()
11011 + #[cfg(feature = "full")]
11012 + Expr::Repeat(v0) => {
11013 + let mut formatter = formatter.debug_tuple("Repeat");
11014 + formatter.field(v0);
11015 + formatter.finish()
11017 + #[cfg(feature = "full")]
11018 + Expr::Return(v0) => {
11019 + let mut formatter = formatter.debug_tuple("Return");
11020 + formatter.field(v0);
11021 + formatter.finish()
11023 + #[cfg(feature = "full")]
11024 + Expr::Struct(v0) => {
11025 + let mut formatter = formatter.debug_tuple("Struct");
11026 + formatter.field(v0);
11027 + formatter.finish()
11029 + #[cfg(feature = "full")]
11030 + Expr::Try(v0) => {
11031 + let mut formatter = formatter.debug_tuple("Try");
11032 + formatter.field(v0);
11033 + formatter.finish()
11035 + #[cfg(feature = "full")]
11036 + Expr::TryBlock(v0) => {
11037 + let mut formatter = formatter.debug_tuple("TryBlock");
11038 + formatter.field(v0);
11039 + formatter.finish()
11041 + #[cfg(feature = "full")]
11042 + Expr::Tuple(v0) => {
11043 + let mut formatter = formatter.debug_tuple("Tuple");
11044 + formatter.field(v0);
11045 + formatter.finish()
11047 + #[cfg(feature = "full")]
11048 + Expr::Type(v0) => {
11049 + let mut formatter = formatter.debug_tuple("Type");
11050 + formatter.field(v0);
11051 + formatter.finish()
11053 + Expr::Unary(v0) => {
11054 + let mut formatter = formatter.debug_tuple("Unary");
11055 + formatter.field(v0);
11056 + formatter.finish()
11058 + #[cfg(feature = "full")]
11059 + Expr::Unsafe(v0) => {
11060 + let mut formatter = formatter.debug_tuple("Unsafe");
11061 + formatter.field(v0);
11062 + formatter.finish()
11064 + Expr::Verbatim(v0) => {
11065 + let mut formatter = formatter.debug_tuple("Verbatim");
11066 + formatter.field(v0);
11067 + formatter.finish()
11069 + #[cfg(feature = "full")]
11070 + Expr::While(v0) => {
11071 + let mut formatter = formatter.debug_tuple("While");
11072 + formatter.field(v0);
11073 + formatter.finish()
11075 + #[cfg(feature = "full")]
11076 + Expr::Yield(v0) => {
11077 + let mut formatter = formatter.debug_tuple("Yield");
11078 + formatter.field(v0);
11079 + formatter.finish()
11081 + _ => unreachable!(),
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
11549 +#[cfg(any(feature = "derive", feature = "full"))]
11550 +impl Debug for Fields {
11551 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11553 + Fields::Named(v0) => {
11554 + let mut formatter = formatter.debug_tuple("Named");
11555 + formatter.field(v0);
11556 + formatter.finish()
11558 + Fields::Unnamed(v0) => {
11559 + let mut formatter = formatter.debug_tuple("Unnamed");
11560 + formatter.field(v0);
11561 + formatter.finish()
11563 + Fields::Unit => formatter.write_str("Unit"),
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()
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()
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()
11595 +#[cfg(feature = "full")]
11596 +impl Debug for FnArg {
11597 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11599 + FnArg::Receiver(v0) => {
11600 + let mut formatter = formatter.debug_tuple("Receiver");
11601 + formatter.field(v0);
11602 + formatter.finish()
11604 + FnArg::Typed(v0) => {
11605 + let mut formatter = formatter.debug_tuple("Typed");
11606 + formatter.field(v0);
11607 + formatter.finish()
11612 +#[cfg(feature = "full")]
11613 +impl Debug for ForeignItem {
11614 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11616 + ForeignItem::Fn(v0) => {
11617 + let mut formatter = formatter.debug_tuple("Fn");
11618 + formatter.field(v0);
11619 + formatter.finish()
11621 + ForeignItem::Static(v0) => {
11622 + let mut formatter = formatter.debug_tuple("Static");
11623 + formatter.field(v0);
11624 + formatter.finish()
11626 + ForeignItem::Type(v0) => {
11627 + let mut formatter = formatter.debug_tuple("Type");
11628 + formatter.field(v0);
11629 + formatter.finish()
11631 + ForeignItem::Macro(v0) => {
11632 + let mut formatter = formatter.debug_tuple("Macro");
11633 + formatter.field(v0);
11634 + formatter.finish()
11636 + ForeignItem::Verbatim(v0) => {
11637 + let mut formatter = formatter.debug_tuple("Verbatim");
11638 + formatter.field(v0);
11639 + formatter.finish()
11641 + _ => unreachable!(),
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()
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()
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()
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()
11693 +#[cfg(any(feature = "derive", feature = "full"))]
11694 +impl Debug for GenericArgument {
11695 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11697 + GenericArgument::Lifetime(v0) => {
11698 + let mut formatter = formatter.debug_tuple("Lifetime");
11699 + formatter.field(v0);
11700 + formatter.finish()
11702 + GenericArgument::Type(v0) => {
11703 + let mut formatter = formatter.debug_tuple("Type");
11704 + formatter.field(v0);
11705 + formatter.finish()
11707 + GenericArgument::Binding(v0) => {
11708 + let mut formatter = formatter.debug_tuple("Binding");
11709 + formatter.field(v0);
11710 + formatter.finish()
11712 + GenericArgument::Constraint(v0) => {
11713 + let mut formatter = formatter.debug_tuple("Constraint");
11714 + formatter.field(v0);
11715 + formatter.finish()
11717 + GenericArgument::Const(v0) => {
11718 + let mut formatter = formatter.debug_tuple("Const");
11719 + formatter.field(v0);
11720 + formatter.finish()
11725 +#[cfg(feature = "full")]
11726 +impl Debug for GenericMethodArgument {
11727 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11729 + GenericMethodArgument::Type(v0) => {
11730 + let mut formatter = formatter.debug_tuple("Type");
11731 + formatter.field(v0);
11732 + formatter.finish()
11734 + GenericMethodArgument::Const(v0) => {
11735 + let mut formatter = formatter.debug_tuple("Const");
11736 + formatter.field(v0);
11737 + formatter.finish()
11742 +#[cfg(any(feature = "derive", feature = "full"))]
11743 +impl Debug for GenericParam {
11744 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11746 + GenericParam::Type(v0) => {
11747 + let mut formatter = formatter.debug_tuple("Type");
11748 + formatter.field(v0);
11749 + formatter.finish()
11751 + GenericParam::Lifetime(v0) => {
11752 + let mut formatter = formatter.debug_tuple("Lifetime");
11753 + formatter.field(v0);
11754 + formatter.finish()
11756 + GenericParam::Const(v0) => {
11757 + let mut formatter = formatter.debug_tuple("Const");
11758 + formatter.field(v0);
11759 + formatter.finish()
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()
11775 +#[cfg(feature = "full")]
11776 +impl Debug for ImplItem {
11777 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11779 + ImplItem::Const(v0) => {
11780 + let mut formatter = formatter.debug_tuple("Const");
11781 + formatter.field(v0);
11782 + formatter.finish()
11784 + ImplItem::Method(v0) => {
11785 + let mut formatter = formatter.debug_tuple("Method");
11786 + formatter.field(v0);
11787 + formatter.finish()
11789 + ImplItem::Type(v0) => {
11790 + let mut formatter = formatter.debug_tuple("Type");
11791 + formatter.field(v0);
11792 + formatter.finish()
11794 + ImplItem::Macro(v0) => {
11795 + let mut formatter = formatter.debug_tuple("Macro");
11796 + formatter.field(v0);
11797 + formatter.finish()
11799 + ImplItem::Verbatim(v0) => {
11800 + let mut formatter = formatter.debug_tuple("Verbatim");
11801 + formatter.field(v0);
11802 + formatter.finish()
11804 + _ => unreachable!(),
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()
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()
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()
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()
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()
11872 +#[cfg(feature = "full")]
11873 +impl Debug for Item {
11874 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11876 + Item::Const(v0) => {
11877 + let mut formatter = formatter.debug_tuple("Const");
11878 + formatter.field(v0);
11879 + formatter.finish()
11881 + Item::Enum(v0) => {
11882 + let mut formatter = formatter.debug_tuple("Enum");
11883 + formatter.field(v0);
11884 + formatter.finish()
11886 + Item::ExternCrate(v0) => {
11887 + let mut formatter = formatter.debug_tuple("ExternCrate");
11888 + formatter.field(v0);
11889 + formatter.finish()
11891 + Item::Fn(v0) => {
11892 + let mut formatter = formatter.debug_tuple("Fn");
11893 + formatter.field(v0);
11894 + formatter.finish()
11896 + Item::ForeignMod(v0) => {
11897 + let mut formatter = formatter.debug_tuple("ForeignMod");
11898 + formatter.field(v0);
11899 + formatter.finish()
11901 + Item::Impl(v0) => {
11902 + let mut formatter = formatter.debug_tuple("Impl");
11903 + formatter.field(v0);
11904 + formatter.finish()
11906 + Item::Macro(v0) => {
11907 + let mut formatter = formatter.debug_tuple("Macro");
11908 + formatter.field(v0);
11909 + formatter.finish()
11911 + Item::Macro2(v0) => {
11912 + let mut formatter = formatter.debug_tuple("Macro2");
11913 + formatter.field(v0);
11914 + formatter.finish()
11916 + Item::Mod(v0) => {
11917 + let mut formatter = formatter.debug_tuple("Mod");
11918 + formatter.field(v0);
11919 + formatter.finish()
11921 + Item::Static(v0) => {
11922 + let mut formatter = formatter.debug_tuple("Static");
11923 + formatter.field(v0);
11924 + formatter.finish()
11926 + Item::Struct(v0) => {
11927 + let mut formatter = formatter.debug_tuple("Struct");
11928 + formatter.field(v0);
11929 + formatter.finish()
11931 + Item::Trait(v0) => {
11932 + let mut formatter = formatter.debug_tuple("Trait");
11933 + formatter.field(v0);
11934 + formatter.finish()
11936 + Item::TraitAlias(v0) => {
11937 + let mut formatter = formatter.debug_tuple("TraitAlias");
11938 + formatter.field(v0);
11939 + formatter.finish()
11941 + Item::Type(v0) => {
11942 + let mut formatter = formatter.debug_tuple("Type");
11943 + formatter.field(v0);
11944 + formatter.finish()
11946 + Item::Union(v0) => {
11947 + let mut formatter = formatter.debug_tuple("Union");
11948 + formatter.field(v0);
11949 + formatter.finish()
11951 + Item::Use(v0) => {
11952 + let mut formatter = formatter.debug_tuple("Use");
11953 + formatter.field(v0);
11954 + formatter.finish()
11956 + Item::Verbatim(v0) => {
11957 + let mut formatter = formatter.debug_tuple("Verbatim");
11958 + formatter.field(v0);
11959 + formatter.finish()
11961 + _ => unreachable!(),
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
12216 +impl Debug for Lit {
12217 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12219 + Lit::Str(v0) => {
12220 + let mut formatter = formatter.debug_tuple("Str");
12221 + formatter.field(v0);
12222 + formatter.finish()
12224 + Lit::ByteStr(v0) => {
12225 + let mut formatter = formatter.debug_tuple("ByteStr");
12226 + formatter.field(v0);
12227 + formatter.finish()
12229 + Lit::Byte(v0) => {
12230 + let mut formatter = formatter.debug_tuple("Byte");
12231 + formatter.field(v0);
12232 + formatter.finish()
12234 + Lit::Char(v0) => {
12235 + let mut formatter = formatter.debug_tuple("Char");
12236 + formatter.field(v0);
12237 + formatter.finish()
12239 + Lit::Int(v0) => {
12240 + let mut formatter = formatter.debug_tuple("Int");
12241 + formatter.field(v0);
12242 + formatter.finish()
12244 + Lit::Float(v0) => {
12245 + let mut formatter = formatter.debug_tuple("Float");
12246 + formatter.field(v0);
12247 + formatter.finish()
12249 + Lit::Bool(v0) => {
12250 + let mut formatter = formatter.debug_tuple("Bool");
12251 + formatter.field(v0);
12252 + formatter.finish()
12254 + Lit::Verbatim(v0) => {
12255 + let mut formatter = formatter.debug_tuple("Verbatim");
12256 + formatter.field(v0);
12257 + formatter.finish()
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()
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()
12285 +#[cfg(any(feature = "derive", feature = "full"))]
12286 +impl Debug for MacroDelimiter {
12287 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12289 + MacroDelimiter::Paren(v0) => {
12290 + let mut formatter = formatter.debug_tuple("Paren");
12291 + formatter.field(v0);
12292 + formatter.finish()
12294 + MacroDelimiter::Brace(v0) => {
12295 + let mut formatter = formatter.debug_tuple("Brace");
12296 + formatter.field(v0);
12297 + formatter.finish()
12299 + MacroDelimiter::Bracket(v0) => {
12300 + let mut formatter = formatter.debug_tuple("Bracket");
12301 + formatter.field(v0);
12302 + formatter.finish()
12307 +#[cfg(any(feature = "derive", feature = "full"))]
12308 +impl Debug for Member {
12309 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12311 + Member::Named(v0) => {
12312 + let mut formatter = formatter.debug_tuple("Named");
12313 + formatter.field(v0);
12314 + formatter.finish()
12316 + Member::Unnamed(v0) => {
12317 + let mut formatter = formatter.debug_tuple("Unnamed");
12318 + formatter.field(v0);
12319 + formatter.finish()
12324 +#[cfg(any(feature = "derive", feature = "full"))]
12325 +impl Debug for Meta {
12326 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12328 + Meta::Path(v0) => {
12329 + let mut formatter = formatter.debug_tuple("Path");
12330 + formatter.field(v0);
12331 + formatter.finish()
12333 + Meta::List(v0) => {
12334 + let mut formatter = formatter.debug_tuple("List");
12335 + formatter.field(v0);
12336 + formatter.finish()
12338 + Meta::NameValue(v0) => {
12339 + let mut formatter = formatter.debug_tuple("NameValue");
12340 + formatter.field(v0);
12341 + formatter.finish()
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()
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()
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()
12377 +#[cfg(any(feature = "derive", feature = "full"))]
12378 +impl Debug for NestedMeta {
12379 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12381 + NestedMeta::Meta(v0) => {
12382 + let mut formatter = formatter.debug_tuple("Meta");
12383 + formatter.field(v0);
12384 + formatter.finish()
12386 + NestedMeta::Lit(v0) => {
12387 + let mut formatter = formatter.debug_tuple("Lit");
12388 + formatter.field(v0);
12389 + formatter.finish()
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()
12404 +#[cfg(feature = "full")]
12405 +impl Debug for Pat {
12406 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12408 + Pat::Box(v0) => {
12409 + let mut formatter = formatter.debug_tuple("Box");
12410 + formatter.field(v0);
12411 + formatter.finish()
12413 + Pat::Ident(v0) => {
12414 + let mut formatter = formatter.debug_tuple("Ident");
12415 + formatter.field(v0);
12416 + formatter.finish()
12418 + Pat::Lit(v0) => {
12419 + let mut formatter = formatter.debug_tuple("Lit");
12420 + formatter.field(v0);
12421 + formatter.finish()
12423 + Pat::Macro(v0) => {
12424 + let mut formatter = formatter.debug_tuple("Macro");
12425 + formatter.field(v0);
12426 + formatter.finish()
12429 + let mut formatter = formatter.debug_tuple("Or");
12430 + formatter.field(v0);
12431 + formatter.finish()
12433 + Pat::Path(v0) => {
12434 + let mut formatter = formatter.debug_tuple("Path");
12435 + formatter.field(v0);
12436 + formatter.finish()
12438 + Pat::Range(v0) => {
12439 + let mut formatter = formatter.debug_tuple("Range");
12440 + formatter.field(v0);
12441 + formatter.finish()
12443 + Pat::Reference(v0) => {
12444 + let mut formatter = formatter.debug_tuple("Reference");
12445 + formatter.field(v0);
12446 + formatter.finish()
12448 + Pat::Rest(v0) => {
12449 + let mut formatter = formatter.debug_tuple("Rest");
12450 + formatter.field(v0);
12451 + formatter.finish()
12453 + Pat::Slice(v0) => {
12454 + let mut formatter = formatter.debug_tuple("Slice");
12455 + formatter.field(v0);
12456 + formatter.finish()
12458 + Pat::Struct(v0) => {
12459 + let mut formatter = formatter.debug_tuple("Struct");
12460 + formatter.field(v0);
12461 + formatter.finish()
12463 + Pat::Tuple(v0) => {
12464 + let mut formatter = formatter.debug_tuple("Tuple");
12465 + formatter.field(v0);
12466 + formatter.finish()
12468 + Pat::TupleStruct(v0) => {
12469 + let mut formatter = formatter.debug_tuple("TupleStruct");
12470 + formatter.field(v0);
12471 + formatter.finish()
12473 + Pat::Type(v0) => {
12474 + let mut formatter = formatter.debug_tuple("Type");
12475 + formatter.field(v0);
12476 + formatter.finish()
12478 + Pat::Verbatim(v0) => {
12479 + let mut formatter = formatter.debug_tuple("Verbatim");
12480 + formatter.field(v0);
12481 + formatter.finish()
12483 + Pat::Wild(v0) => {
12484 + let mut formatter = formatter.debug_tuple("Wild");
12485 + formatter.field(v0);
12486 + formatter.finish()
12488 + _ => unreachable!(),
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
12654 +#[cfg(any(feature = "derive", feature = "full"))]
12655 +impl Debug for PathArguments {
12656 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
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()
12664 + PathArguments::Parenthesized(v0) => {
12665 + let mut formatter = formatter.debug_tuple("Parenthesized");
12666 + formatter.field(v0);
12667 + formatter.finish()
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()
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()
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()
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()
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()
12724 +#[cfg(feature = "full")]
12725 +impl Debug for RangeLimits {
12726 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12728 + RangeLimits::HalfOpen(v0) => {
12729 + let mut formatter = formatter.debug_tuple("HalfOpen");
12730 + formatter.field(v0);
12731 + formatter.finish()
12733 + RangeLimits::Closed(v0) => {
12734 + let mut formatter = formatter.debug_tuple("Closed");
12735 + formatter.field(v0);
12736 + formatter.finish()
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()
12752 +#[cfg(any(feature = "derive", feature = "full"))]
12753 +impl Debug for ReturnType {
12754 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
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()
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()
12784 +#[cfg(feature = "full")]
12785 +impl Debug for Stmt {
12786 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12788 + Stmt::Local(v0) => {
12789 + let mut formatter = formatter.debug_tuple("Local");
12790 + formatter.field(v0);
12791 + formatter.finish()
12793 + Stmt::Item(v0) => {
12794 + let mut formatter = formatter.debug_tuple("Item");
12795 + formatter.field(v0);
12796 + formatter.finish()
12798 + Stmt::Expr(v0) => {
12799 + let mut formatter = formatter.debug_tuple("Expr");
12800 + formatter.field(v0);
12801 + formatter.finish()
12803 + Stmt::Semi(v0, v1) => {
12804 + let mut formatter = formatter.debug_tuple("Semi");
12805 + formatter.field(v0);
12806 + formatter.field(v1);
12807 + formatter.finish()
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()
12823 +#[cfg(any(feature = "derive", feature = "full"))]
12824 +impl Debug for TraitBoundModifier {
12825 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
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()
12836 +#[cfg(feature = "full")]
12837 +impl Debug for TraitItem {
12838 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12840 + TraitItem::Const(v0) => {
12841 + let mut formatter = formatter.debug_tuple("Const");
12842 + formatter.field(v0);
12843 + formatter.finish()
12845 + TraitItem::Method(v0) => {
12846 + let mut formatter = formatter.debug_tuple("Method");
12847 + formatter.field(v0);
12848 + formatter.finish()
12850 + TraitItem::Type(v0) => {
12851 + let mut formatter = formatter.debug_tuple("Type");
12852 + formatter.field(v0);
12853 + formatter.finish()
12855 + TraitItem::Macro(v0) => {
12856 + let mut formatter = formatter.debug_tuple("Macro");
12857 + formatter.field(v0);
12858 + formatter.finish()
12860 + TraitItem::Verbatim(v0) => {
12861 + let mut formatter = formatter.debug_tuple("Verbatim");
12862 + formatter.field(v0);
12863 + formatter.finish()
12865 + _ => unreachable!(),
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()
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()
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()
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()
12919 +#[cfg(any(feature = "derive", feature = "full"))]
12920 +impl Debug for Type {
12921 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
12923 + Type::Array(v0) => {
12924 + let mut formatter = formatter.debug_tuple("Array");
12925 + formatter.field(v0);
12926 + formatter.finish()
12928 + Type::BareFn(v0) => {
12929 + let mut formatter = formatter.debug_tuple("BareFn");
12930 + formatter.field(v0);
12931 + formatter.finish()
12933 + Type::Group(v0) => {
12934 + let mut formatter = formatter.debug_tuple("Group");
12935 + formatter.field(v0);
12936 + formatter.finish()
12938 + Type::ImplTrait(v0) => {
12939 + let mut formatter = formatter.debug_tuple("ImplTrait");
12940 + formatter.field(v0);
12941 + formatter.finish()
12943 + Type::Infer(v0) => {
12944 + let mut formatter = formatter.debug_tuple("Infer");
12945 + formatter.field(v0);
12946 + formatter.finish()
12948 + Type::Macro(v0) => {
12949 + let mut formatter = formatter.debug_tuple("Macro");
12950 + formatter.field(v0);
12951 + formatter.finish()
12953 + Type::Never(v0) => {
12954 + let mut formatter = formatter.debug_tuple("Never");
12955 + formatter.field(v0);
12956 + formatter.finish()
12958 + Type::Paren(v0) => {
12959 + let mut formatter = formatter.debug_tuple("Paren");
12960 + formatter.field(v0);
12961 + formatter.finish()
12963 + Type::Path(v0) => {
12964 + let mut formatter = formatter.debug_tuple("Path");
12965 + formatter.field(v0);
12966 + formatter.finish()
12968 + Type::Ptr(v0) => {
12969 + let mut formatter = formatter.debug_tuple("Ptr");
12970 + formatter.field(v0);
12971 + formatter.finish()
12973 + Type::Reference(v0) => {
12974 + let mut formatter = formatter.debug_tuple("Reference");
12975 + formatter.field(v0);
12976 + formatter.finish()
12978 + Type::Slice(v0) => {
12979 + let mut formatter = formatter.debug_tuple("Slice");
12980 + formatter.field(v0);
12981 + formatter.finish()
12983 + Type::TraitObject(v0) => {
12984 + let mut formatter = formatter.debug_tuple("TraitObject");
12985 + formatter.field(v0);
12986 + formatter.finish()
12988 + Type::Tuple(v0) => {
12989 + let mut formatter = formatter.debug_tuple("Tuple");
12990 + formatter.field(v0);
12991 + formatter.finish()
12993 + Type::Verbatim(v0) => {
12994 + let mut formatter = formatter.debug_tuple("Verbatim");
12995 + formatter.field(v0);
12996 + formatter.finish()
12998 + _ => unreachable!(),
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()
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()
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()
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()
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()
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()
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()
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()
13083 +#[cfg(any(feature = "derive", feature = "full"))]
13084 +impl Debug for TypeParamBound {
13085 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13087 + TypeParamBound::Trait(v0) => {
13088 + let mut formatter = formatter.debug_tuple("Trait");
13089 + formatter.field(v0);
13090 + formatter.finish()
13092 + TypeParamBound::Lifetime(v0) => {
13093 + let mut formatter = formatter.debug_tuple("Lifetime");
13094 + formatter.field(v0);
13095 + formatter.finish()
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()
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()
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()
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()
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()
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()
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()
13167 +#[cfg(any(feature = "derive", feature = "full"))]
13168 +impl Debug for UnOp {
13169 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13171 + UnOp::Deref(v0) => {
13172 + let mut formatter = formatter.debug_tuple("Deref");
13173 + formatter.field(v0);
13174 + formatter.finish()
13176 + UnOp::Not(v0) => {
13177 + let mut formatter = formatter.debug_tuple("Not");
13178 + formatter.field(v0);
13179 + formatter.finish()
13181 + UnOp::Neg(v0) => {
13182 + let mut formatter = formatter.debug_tuple("Neg");
13183 + formatter.field(v0);
13184 + formatter.finish()
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()
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()
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()
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()
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()
13234 +#[cfg(feature = "full")]
13235 +impl Debug for UseTree {
13236 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13238 + UseTree::Path(v0) => {
13239 + let mut formatter = formatter.debug_tuple("Path");
13240 + formatter.field(v0);
13241 + formatter.finish()
13243 + UseTree::Name(v0) => {
13244 + let mut formatter = formatter.debug_tuple("Name");
13245 + formatter.field(v0);
13246 + formatter.finish()
13248 + UseTree::Rename(v0) => {
13249 + let mut formatter = formatter.debug_tuple("Rename");
13250 + formatter.field(v0);
13251 + formatter.finish()
13253 + UseTree::Glob(v0) => {
13254 + let mut formatter = formatter.debug_tuple("Glob");
13255 + formatter.field(v0);
13256 + formatter.finish()
13258 + UseTree::Group(v0) => {
13259 + let mut formatter = formatter.debug_tuple("Group");
13260 + formatter.field(v0);
13261 + formatter.finish()
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()
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()
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()
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()
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()
13313 +#[cfg(any(feature = "derive", feature = "full"))]
13314 +impl Debug for Visibility {
13315 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13317 + Visibility::Public(v0) => {
13318 + let mut formatter = formatter.debug_tuple("Public");
13319 + formatter.field(v0);
13320 + formatter.finish()
13322 + Visibility::Crate(v0) => {
13323 + let mut formatter = formatter.debug_tuple("Crate");
13324 + formatter.field(v0);
13325 + formatter.finish()
13327 + Visibility::Restricted(v0) => {
13328 + let mut formatter = formatter.debug_tuple("Restricted");
13329 + formatter.field(v0);
13330 + formatter.finish()
13332 + Visibility::Inherited => formatter.write_str("Inherited"),
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()
13345 +#[cfg(any(feature = "derive", feature = "full"))]
13346 +impl Debug for WherePredicate {
13347 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
13349 + WherePredicate::Type(v0) => {
13350 + let mut formatter = formatter.debug_tuple("Type");
13351 + formatter.field(v0);
13352 + formatter.finish()
13354 + WherePredicate::Lifetime(v0) => {
13355 + let mut formatter = formatter.debug_tuple("Lifetime");
13356 + formatter.field(v0);
13357 + formatter.finish()
13359 + WherePredicate::Eq(v0) => {
13360 + let mut formatter = formatter.debug_tuple("Eq");
13361 + formatter.field(v0);
13362 + formatter.finish()
13367 diff --git a/third_party/rust/syn/src/gen/eq.rs b/third_party/rust/syn/src/gen/eq.rs
13368 new file mode 100644
13370 +++ b/third_party/rust/syn/src/gen/eq.rs
13372 +// This file is @generated by syn-internal-codegen.
13373 +// It is not intended for manual editing.
13375 +#[cfg(any(feature = "derive", feature = "full"))]
13376 +use crate::tt::TokenStreamHelper;
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
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
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
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,
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)
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
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,
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
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
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
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
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
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,
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
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
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
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
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)
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,
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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,
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
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
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
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,
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)
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
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
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
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
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)) => {
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)) => {
14144 + (GenericArgument::Const(self0), GenericArgument::Const(other0)) => self0 == other0,
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)) => {
14158 + (GenericMethodArgument::Const(self0), GenericMethodArgument::Const(other0)) => {
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,
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
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)
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
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
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
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
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)
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
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
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
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
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
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
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
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)
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
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
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
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
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
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
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
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
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
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
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()
14509 +impl Eq for LitBool {}
14510 +impl PartialEq for LitBool {
14511 + fn eq(&self, other: &Self) -> bool {
14512 + self.value == other.value
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
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)
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,
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,
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
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
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
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,
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
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)
14632 + (Pat::Wild(self0), Pat::Wild(other0)) => self0 == other0,
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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)) => {
14787 + (PathArguments::Parenthesized(self0), PathArguments::Parenthesized(other0)) => {
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
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
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
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
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
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,
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
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,
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
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,
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
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,
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)
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
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
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
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
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)
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
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
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
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
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 {
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
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 {
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
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,
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
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
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
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
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
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
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
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,
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 {
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
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
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
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
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,
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
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
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 {
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 {
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
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,
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
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,
15302 diff --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
15306 // This file is @generated by syn-internal-codegen.
15307 // It is not intended for manual editing.
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};
15316 use proc_macro2::Span;
15317 #[cfg(feature = "full")]
15318 macro_rules! full {
15319 @@ -21,17 +22,17 @@ macro_rules! full {
15322 /// Syntax tree traversal to transform the nodes of an owned syntax tree.
15324 /// See the [module documentation] for details.
15326 /// [module documentation]: self
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.*
15331 #[cfg(any(feature = "derive", feature = "full"))]
15332 fn fold_abi(&mut self, i: Abi) -> Abi {
15335 #[cfg(any(feature = "derive", feature = "full"))]
15336 fn fold_angle_bracketed_generic_arguments(
15338 @@ -428,45 +429,37 @@ pub trait Fold {
15340 fn fold_lifetime(&mut self, i: Lifetime) -> Lifetime {
15341 fold_lifetime(self, i)
15343 #[cfg(any(feature = "derive", feature = "full"))]
15344 fn fold_lifetime_def(&mut self, i: LifetimeDef) -> LifetimeDef {
15345 fold_lifetime_def(self, i)
15347 - #[cfg(any(feature = "derive", feature = "full"))]
15348 fn fold_lit(&mut self, i: Lit) -> Lit {
15351 - #[cfg(any(feature = "derive", feature = "full"))]
15352 fn fold_lit_bool(&mut self, i: LitBool) -> LitBool {
15353 fold_lit_bool(self, i)
15355 - #[cfg(any(feature = "derive", feature = "full"))]
15356 fn fold_lit_byte(&mut self, i: LitByte) -> LitByte {
15357 fold_lit_byte(self, i)
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)
15363 - #[cfg(any(feature = "derive", feature = "full"))]
15364 fn fold_lit_char(&mut self, i: LitChar) -> LitChar {
15365 fold_lit_char(self, i)
15367 - #[cfg(any(feature = "derive", feature = "full"))]
15368 fn fold_lit_float(&mut self, i: LitFloat) -> LitFloat {
15369 fold_lit_float(self, i)
15371 - #[cfg(any(feature = "derive", feature = "full"))]
15372 fn fold_lit_int(&mut self, i: LitInt) -> LitInt {
15373 fold_lit_int(self, i)
15375 - #[cfg(any(feature = "derive", feature = "full"))]
15376 fn fold_lit_str(&mut self, i: LitStr) -> LitStr {
15377 fold_lit_str(self, i)
15379 #[cfg(feature = "full")]
15380 fn fold_local(&mut self, i: Local) -> Local {
15381 fold_local(self, i)
15383 #[cfg(any(feature = "derive", feature = "full"))]
15384 @@ -794,39 +787,39 @@ where
15385 pub fn fold_angle_bracketed_generic_arguments<F>(
15387 node: AngleBracketedGenericArguments,
15388 ) -> AngleBracketedGenericArguments
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)),
15402 #[cfg(feature = "full")]
15403 pub fn fold_arm<F>(f: &mut F, node: Arm) -> 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| {
15412 Token![if](tokens_helper(f, &(it).0.span)),
15413 Box::new(f.fold_expr(*(it).1)),
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))),
15423 #[cfg(any(feature = "derive", feature = "full"))]
15424 pub fn fold_attr_style<F>(f: &mut F, node: AttrStyle) -> AttrStyle
15429 @@ -837,109 +830,97 @@ where
15432 #[cfg(any(feature = "derive", feature = "full"))]
15433 pub fn fold_attribute<F>(f: &mut F, node: Attribute) -> 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,
15446 #[cfg(any(feature = "derive", feature = "full"))]
15447 pub fn fold_bare_fn_arg<F>(f: &mut F, node: BareFnArg) -> BareFnArg
15452 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
15453 name: (node.name).map(|it| {
15455 f.fold_ident((it).0),
15456 - Token ! [ : ](tokens_helper(f, &(it).1.spans)),
15457 + Token ! [:](tokens_helper(f, &(it).1.spans)),
15460 ty: f.fold_type(node.ty),
15463 #[cfg(any(feature = "derive", feature = "full"))]
15464 pub fn fold_bin_op<F>(f: &mut F, node: BinOp) -> BinOp
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)))
15487 BinOp::BitAnd(_binding_0) => {
15488 - BinOp::BitAnd(Token ! [ & ](tokens_helper(f, &_binding_0.spans)))
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)))
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)))
15505 - BinOp::SubEq(_binding_0) => {
15506 - BinOp::SubEq(Token ! [ -= ](tokens_helper(f, &_binding_0.spans)))
15508 - BinOp::MulEq(_binding_0) => {
15509 - BinOp::MulEq(Token ! [ *= ](tokens_helper(f, &_binding_0.spans)))
15511 - BinOp::DivEq(_binding_0) => {
15512 - BinOp::DivEq(Token ! [ /= ](tokens_helper(f, &_binding_0.spans)))
15514 - BinOp::RemEq(_binding_0) => {
15515 - BinOp::RemEq(Token ! [ %= ](tokens_helper(f, &_binding_0.spans)))
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)))
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)))
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)))
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)))
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)))
15553 #[cfg(any(feature = "derive", feature = "full"))]
15554 pub fn fold_binding<F>(f: &mut F, node: Binding) -> 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),
15565 #[cfg(feature = "full")]
15566 pub fn fold_block<F>(f: &mut F, node: Block) -> Block
15570 @@ -950,44 +931,44 @@ where
15572 #[cfg(any(feature = "derive", feature = "full"))]
15573 pub fn fold_bound_lifetimes<F>(f: &mut F, node: BoundLifetimes) -> 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)),
15586 #[cfg(any(feature = "derive", feature = "full"))]
15587 pub fn fold_const_param<F>(f: &mut F, node: ConstParam) -> 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)),
15603 #[cfg(any(feature = "derive", feature = "full"))]
15604 pub fn fold_constraint<F>(f: &mut F, node: Constraint) -> 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)),
15615 #[cfg(feature = "derive")]
15616 pub fn fold_data<F>(f: &mut F, node: Data) -> Data
15620 @@ -1011,17 +992,17 @@ where
15621 #[cfg(feature = "derive")]
15622 pub fn fold_data_struct<F>(f: &mut F, node: DataStruct) -> 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))),
15633 #[cfg(feature = "derive")]
15634 pub fn fold_data_union<F>(f: &mut F, node: DataUnion) -> DataUnion
15639 @@ -1107,17 +1088,17 @@ where
15640 #[cfg(feature = "full")]
15641 pub fn fold_expr_assign<F>(f: &mut F, node: ExprAssign) -> 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)),
15653 #[cfg(feature = "full")]
15654 pub fn fold_expr_assign_op<F>(f: &mut F, node: ExprAssignOp) -> ExprAssignOp
15658 @@ -1143,17 +1124,17 @@ where
15659 #[cfg(feature = "full")]
15660 pub fn fold_expr_await<F>(f: &mut F, node: ExprAwait) -> 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)),
15672 #[cfg(any(feature = "derive", feature = "full"))]
15673 pub fn fold_expr_binary<F>(f: &mut F, node: ExprBinary) -> ExprBinary
15677 @@ -1227,19 +1208,19 @@ pub fn fold_expr_closure<F>(f: &mut F, n
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)),
15695 #[cfg(feature = "full")]
15696 pub fn fold_expr_continue<F>(f: &mut F, node: ExprContinue) -> ExprContinue
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
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),
15713 #[cfg(feature = "full")]
15714 pub fn fold_expr_for_loop<F>(f: &mut F, node: ExprForLoop) -> ExprForLoop
15718 @@ -1322,17 +1303,17 @@ where
15719 pub fn fold_expr_let<F>(f: &mut F, node: ExprLet) -> 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)),
15732 #[cfg(any(feature = "derive", feature = "full"))]
15733 pub fn fold_expr_lit<F>(f: &mut F, node: ExprLit) -> ExprLit
15737 @@ -1379,17 +1360,17 @@ where
15738 #[cfg(feature = "full")]
15739 pub fn fold_expr_method_call<F>(f: &mut F, node: ExprMethodCall) -> 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)),
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
15758 #[cfg(feature = "full")]
15759 pub fn fold_expr_reference<F>(f: &mut F, node: ExprReference) -> 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)),
15768 mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))),
15769 expr: Box::new(f.fold_expr(*node.expr)),
15772 #[cfg(feature = "full")]
15773 pub fn fold_expr_repeat<F>(f: &mut F, node: ExprRepeat) -> 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)),
15786 #[cfg(feature = "full")]
15787 pub fn fold_expr_return<F>(f: &mut F, node: ExprReturn) -> ExprReturn
15791 @@ -1479,17 +1460,17 @@ where
15792 #[cfg(feature = "full")]
15793 pub fn fold_expr_try<F>(f: &mut F, node: ExprTry) -> 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)),
15804 #[cfg(feature = "full")]
15805 pub fn fold_expr_try_block<F>(f: &mut F, node: ExprTryBlock) -> ExprTryBlock
15810 @@ -1512,17 +1493,17 @@ where
15811 #[cfg(feature = "full")]
15812 pub fn fold_expr_type<F>(f: &mut F, node: ExprType) -> 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)),
15824 #[cfg(any(feature = "derive", feature = "full"))]
15825 pub fn fold_expr_unary<F>(f: &mut F, node: ExprUnary) -> ExprUnary
15829 @@ -1571,41 +1552,41 @@ where
15830 pub fn fold_field<F>(f: &mut F, node: Field) -> 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),
15843 #[cfg(feature = "full")]
15844 pub fn fold_field_pat<F>(f: &mut F, node: FieldPat) -> 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)),
15856 #[cfg(feature = "full")]
15857 pub fn fold_field_value<F>(f: &mut F, node: FieldValue) -> 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),
15869 #[cfg(any(feature = "derive", feature = "full"))]
15870 pub fn fold_fields<F>(f: &mut F, node: Fields) -> Fields
15874 @@ -1676,57 +1657,57 @@ where
15875 pub fn fold_foreign_item_fn<F>(f: &mut F, node: ForeignItemFn) -> 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)),
15887 #[cfg(feature = "full")]
15888 pub fn fold_foreign_item_macro<F>(f: &mut F, node: ForeignItemMacro) -> 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))),
15899 #[cfg(feature = "full")]
15900 pub fn fold_foreign_item_static<F>(f: &mut F, node: ForeignItemStatic) -> ForeignItemStatic
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)),
15917 #[cfg(feature = "full")]
15918 pub fn fold_foreign_item_type<F>(f: &mut F, node: ForeignItemType) -> 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)),
15931 #[cfg(any(feature = "derive", feature = "full"))]
15932 pub fn fold_generic_argument<F>(f: &mut F, node: GenericArgument) -> GenericArgument
15937 @@ -1774,19 +1755,19 @@ where
15940 #[cfg(any(feature = "derive", feature = "full"))]
15941 pub fn fold_generics<F>(f: &mut F, node: Generics) -> 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)),
15954 pub fn fold_ident<F>(f: &mut F, node: Ident) -> Ident
15958 let mut node = node;
15959 @@ -1814,32 +1795,32 @@ where
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)),
15978 #[cfg(feature = "full")]
15979 pub fn fold_impl_item_macro<F>(f: &mut F, node: ImplItemMacro) -> 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))),
15990 #[cfg(feature = "full")]
15991 pub fn fold_impl_item_method<F>(f: &mut F, node: ImplItemMethod) -> ImplItemMethod
15996 @@ -1857,19 +1838,19 @@ where
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)),
16012 #[cfg(any(feature = "derive", feature = "full"))]
16013 pub fn fold_index<F>(f: &mut F, node: Index) -> Index
16018 @@ -1908,21 +1889,21 @@ pub fn fold_item_const<F>(f: &mut F, nod
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)),
16037 #[cfg(feature = "full")]
16038 pub fn fold_item_enum<F>(f: &mut F, node: ItemEnum) -> 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| {
16048 Token![as](tokens_helper(f, &(it).0.span)),
16049 f.fold_ident((it).1),
16052 - semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16053 + semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16056 #[cfg(feature = "full")]
16057 pub fn fold_item_fn<F>(f: &mut F, node: ItemFn) -> ItemFn
16062 @@ -2006,17 +1987,17 @@ where
16063 pub fn fold_item_macro<F>(f: &mut F, node: ItemMacro) -> 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))),
16075 #[cfg(feature = "full")]
16076 pub fn fold_item_macro2<F>(f: &mut F, node: ItemMacro2) -> 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| {
16086 Brace(tokens_helper(f, &(it).0.span)),
16087 FoldHelper::lift((it).1, |it| f.fold_item(it)),
16090 - semi: (node.semi).map(|it| Token ! [ ; ](tokens_helper(f, &it.spans))),
16091 + semi: (node.semi).map(|it| Token ! [;](tokens_helper(f, &it.spans))),
16094 #[cfg(feature = "full")]
16095 pub fn fold_item_static<F>(f: &mut F, node: ItemStatic) -> 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)),
16115 #[cfg(feature = "full")]
16116 pub fn fold_item_struct<F>(f: &mut F, node: ItemStruct) -> 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))),
16131 #[cfg(feature = "full")]
16132 pub fn fold_item_trait<F>(f: &mut F, node: ItemTrait) -> 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)),
16151 #[cfg(feature = "full")]
16152 pub fn fold_item_trait_alias<F>(f: &mut F, node: ItemTraitAlias) -> 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)),
16169 #[cfg(feature = "full")]
16170 pub fn fold_item_type<F>(f: &mut F, node: ItemType) -> 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)),
16187 #[cfg(feature = "full")]
16188 pub fn fold_item_union<F>(f: &mut F, node: ItemUnion) -> ItemUnion
16193 @@ -2148,29 +2129,29 @@ where
16194 pub fn fold_item_use<F>(f: &mut F, node: ItemUse) -> 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)),
16209 #[cfg(feature = "full")]
16210 pub fn fold_label<F>(f: &mut F, node: Label) -> 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)),
16220 pub fn fold_lifetime<F>(f: &mut F, node: Lifetime) -> 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
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)),
16240 -#[cfg(any(feature = "derive", feature = "full"))]
16241 pub fn fold_lit<F>(f: &mut F, node: Lit) -> Lit
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),
16256 -#[cfg(any(feature = "derive", feature = "full"))]
16257 pub fn fold_lit_bool<F>(f: &mut F, node: LitBool) -> LitBool
16263 span: f.fold_span(node.span),
16266 -#[cfg(any(feature = "derive", feature = "full"))]
16267 pub fn fold_lit_byte<F>(f: &mut F, node: LitByte) -> LitByte
16271 let span = f.fold_span(node.span());
16272 let mut node = node;
16273 node.set_span(span);
16276 -#[cfg(any(feature = "derive", feature = "full"))]
16277 pub fn fold_lit_byte_str<F>(f: &mut F, node: LitByteStr) -> LitByteStr
16281 let span = f.fold_span(node.span());
16282 let mut node = node;
16283 node.set_span(span);
16286 -#[cfg(any(feature = "derive", feature = "full"))]
16287 pub fn fold_lit_char<F>(f: &mut F, node: LitChar) -> LitChar
16291 let span = f.fold_span(node.span());
16292 let mut node = node;
16293 node.set_span(span);
16296 -#[cfg(any(feature = "derive", feature = "full"))]
16297 pub fn fold_lit_float<F>(f: &mut F, node: LitFloat) -> LitFloat
16301 let span = f.fold_span(node.span());
16302 let mut node = node;
16303 node.set_span(span);
16306 -#[cfg(any(feature = "derive", feature = "full"))]
16307 pub fn fold_lit_int<F>(f: &mut F, node: LitInt) -> LitInt
16311 let span = f.fold_span(node.span());
16312 let mut node = node;
16313 node.set_span(span);
16316 -#[cfg(any(feature = "derive", feature = "full"))]
16317 pub fn fold_lit_str<F>(f: &mut F, node: LitStr) -> LitStr
16321 let span = f.fold_span(node.span());
16322 let mut node = node;
16323 node.set_span(span);
16325 @@ -2281,21 +2254,21 @@ where
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| {
16334 - Token ! [ = ](tokens_helper(f, &(it).0.spans)),
16335 + Token ! [=](tokens_helper(f, &(it).0.spans)),
16336 Box::new(f.fold_expr(*(it).1)),
16339 - semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16340 + semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16343 #[cfg(any(feature = "derive", feature = "full"))]
16344 pub fn fold_macro<F>(f: &mut F, node: Macro) -> Macro
16349 @@ -2356,30 +2329,30 @@ where
16351 #[cfg(any(feature = "derive", feature = "full"))]
16352 pub fn fold_meta_name_value<F>(f: &mut F, node: MetaNameValue) -> 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),
16363 #[cfg(feature = "full")]
16364 pub fn fold_method_turbofish<F>(f: &mut F, node: MethodTurbofish) -> 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)),
16378 #[cfg(any(feature = "derive", feature = "full"))]
16379 pub fn fold_nested_meta<F>(f: &mut F, node: NestedMeta) -> NestedMeta
16384 @@ -2444,17 +2417,17 @@ where
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| {
16393 - Token ! [ @ ](tokens_helper(f, &(it).0.spans)),
16394 + Token ! [@](tokens_helper(f, &(it).0.spans)),
16395 Box::new(f.fold_pat(*(it).1)),
16400 #[cfg(feature = "full")]
16401 pub fn fold_pat_lit<F>(f: &mut F, node: PatLit) -> PatLit
16403 @@ -2477,17 +2450,17 @@ where
16405 #[cfg(feature = "full")]
16406 pub fn fold_pat_or<F>(f: &mut F, node: PatOr) -> 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)),
16417 #[cfg(feature = "full")]
16418 pub fn fold_pat_path<F>(f: &mut F, node: PatPath) -> PatPath
16422 @@ -2511,17 +2484,17 @@ where
16424 #[cfg(feature = "full")]
16425 pub fn fold_pat_reference<F>(f: &mut F, node: PatReference) -> 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)),
16437 #[cfg(feature = "full")]
16438 pub fn fold_pat_rest<F>(f: &mut F, node: PatRest) -> PatRest
16441 @@ -2580,17 +2553,17 @@ where
16442 #[cfg(feature = "full")]
16443 pub fn fold_pat_type<F>(f: &mut F, node: PatType) -> 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)),
16455 #[cfg(feature = "full")]
16456 pub fn fold_pat_wild<F>(f: &mut F, node: PatWild) -> PatWild
16460 @@ -2600,17 +2573,17 @@ where
16463 #[cfg(any(feature = "derive", feature = "full"))]
16464 pub fn fold_path<F>(f: &mut F, node: Path) -> 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)),
16474 #[cfg(any(feature = "derive", feature = "full"))]
16475 pub fn fold_path_arguments<F>(f: &mut F, node: PathArguments) -> PathArguments
16479 @@ -2636,96 +2609,96 @@ where
16481 #[cfg(any(feature = "derive", feature = "full"))]
16482 pub fn fold_predicate_eq<F>(f: &mut F, node: PredicateEq) -> 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),
16493 #[cfg(any(feature = "derive", feature = "full"))]
16494 pub fn fold_predicate_lifetime<F>(f: &mut F, node: PredicateLifetime) -> PredicateLifetime
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)),
16505 #[cfg(any(feature = "derive", feature = "full"))]
16506 pub fn fold_predicate_type<F>(f: &mut F, node: PredicateType) -> 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)),
16518 #[cfg(any(feature = "derive", feature = "full"))]
16519 pub fn fold_qself<F>(f: &mut F, node: QSelf) -> 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)),
16533 #[cfg(feature = "full")]
16534 pub fn fold_range_limits<F>(f: &mut F, node: RangeLimits) -> RangeLimits
16539 RangeLimits::HalfOpen(_binding_0) => {
16540 RangeLimits::HalfOpen(Token![..](tokens_helper(f, &_binding_0.spans)))
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)))
16548 #[cfg(feature = "full")]
16549 pub fn fold_receiver<F>(f: &mut F, node: Receiver) -> Receiver
16554 attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)),
16555 reference: (node.reference).map(|it| {
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)),
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)),
16566 #[cfg(any(feature = "derive", feature = "full"))]
16567 pub fn fold_return_type<F>(f: &mut F, node: ReturnType) -> ReturnType
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)),
16580 #[cfg(feature = "full")]
16581 pub fn fold_signature<F>(f: &mut F, node: Signature) -> Signature
16584 @@ -2756,17 +2729,17 @@ where
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)),
16598 #[cfg(any(feature = "derive", feature = "full"))]
16599 pub fn fold_trait_bound<F>(f: &mut F, node: TraitBound) -> TraitBound
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
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)))
16617 #[cfg(feature = "full")]
16618 pub fn fold_trait_item<F>(f: &mut F, node: TraitItem) -> TraitItem
16622 @@ -2807,69 +2780,69 @@ where
16623 pub fn fold_trait_item_const<F>(f: &mut F, node: TraitItemConst) -> 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| {
16636 - Token ! [ = ](tokens_helper(f, &(it).0.spans)),
16637 + Token ! [=](tokens_helper(f, &(it).0.spans)),
16638 f.fold_expr((it).1),
16641 - semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16642 + semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16645 #[cfg(feature = "full")]
16646 pub fn fold_trait_item_macro<F>(f: &mut F, node: TraitItemMacro) -> 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))),
16657 #[cfg(feature = "full")]
16658 pub fn fold_trait_item_method<F>(f: &mut F, node: TraitItemMethod) -> 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))),
16670 #[cfg(feature = "full")]
16671 pub fn fold_trait_item_type<F>(f: &mut F, node: TraitItemType) -> 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| {
16685 - Token ! [ = ](tokens_helper(f, &(it).0.spans)),
16686 + Token ! [=](tokens_helper(f, &(it).0.spans)),
16687 f.fold_type((it).1),
16690 - semi_token: Token ! [ ; ](tokens_helper(f, &node.semi_token.spans)),
16691 + semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)),
16694 #[cfg(any(feature = "derive", feature = "full"))]
16695 pub fn fold_type<F>(f: &mut F, node: Type) -> Type
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
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),
16714 #[cfg(any(feature = "derive", feature = "full"))]
16715 pub fn fold_type_bare_fn<F>(f: &mut F, node: TypeBareFn) -> TypeBareFn
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
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)),
16736 #[cfg(any(feature = "derive", feature = "full"))]
16737 pub fn fold_type_param_bound<F>(f: &mut F, node: TypeParamBound) -> TypeParamBound
16741 @@ -3013,29 +2986,29 @@ where
16744 #[cfg(any(feature = "derive", feature = "full"))]
16745 pub fn fold_type_ptr<F>(f: &mut F, node: TypePtr) -> 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)),
16757 #[cfg(any(feature = "derive", feature = "full"))]
16758 pub fn fold_type_reference<F>(f: &mut F, node: TypeReference) -> 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)),
16770 #[cfg(any(feature = "derive", feature = "full"))]
16771 pub fn fold_type_slice<F>(f: &mut F, node: TypeSlice) -> TypeSlice
16773 @@ -3067,28 +3040,28 @@ where
16776 #[cfg(any(feature = "derive", feature = "full"))]
16777 pub fn fold_un_op<F>(f: &mut F, node: UnOp) -> UnOp
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))),
16789 #[cfg(feature = "full")]
16790 pub fn fold_use_glob<F>(f: &mut F, node: UseGlob) -> UseGlob
16795 - star_token: Token ! [ * ](tokens_helper(f, &node.star_token.spans)),
16796 + star_token: Token ! [*](tokens_helper(f, &node.star_token.spans)),
16799 #[cfg(feature = "full")]
16800 pub fn fold_use_group<F>(f: &mut F, node: UseGroup) -> UseGroup
16805 @@ -3107,17 +3080,17 @@ where
16807 #[cfg(feature = "full")]
16808 pub fn fold_use_path<F>(f: &mut F, node: UsePath) -> 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)),
16819 #[cfg(feature = "full")]
16820 pub fn fold_use_rename<F>(f: &mut F, node: UseRename) -> UseRename
16824 @@ -3142,31 +3115,31 @@ where
16826 #[cfg(any(feature = "derive", feature = "full"))]
16827 pub fn fold_variadic<F>(f: &mut F, node: Variadic) -> 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)),
16837 #[cfg(any(feature = "derive", feature = "full"))]
16838 pub fn fold_variant<F>(f: &mut F, node: Variant) -> 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| {
16848 - Token ! [ = ](tokens_helper(f, &(it).0.spans)),
16849 + Token ! [=](tokens_helper(f, &(it).0.spans)),
16850 f.fold_expr((it).1),
16855 #[cfg(any(feature = "derive", feature = "full"))]
16856 pub fn fold_vis_crate<F>(f: &mut F, node: VisCrate) -> VisCrate
16858 diff --git a/third_party/rust/syn/src/gen/hash.rs b/third_party/rust/syn/src/gen/hash.rs
16859 new file mode 100644
16861 +++ b/third_party/rust/syn/src/gen/hash.rs
16863 +// This file is @generated by syn-internal-codegen.
16864 +// It is not intended for manual editing.
16866 +#[cfg(any(feature = "derive", feature = "full"))]
16867 +use crate::tt::TokenStreamHelper;
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)
16876 + self.name.hash(state);
16879 +#[cfg(any(feature = "derive", feature = "full"))]
16880 +impl Hash for AngleBracketedGenericArguments {
16881 + fn hash<H>(&self, state: &mut H)
16885 + self.colon2_token.hash(state);
16886 + self.args.hash(state);
16889 +#[cfg(feature = "full")]
16890 +impl Hash for Arm {
16891 + fn hash<H>(&self, state: &mut H)
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);
16902 +#[cfg(any(feature = "derive", feature = "full"))]
16903 +impl Hash for AttrStyle {
16904 + fn hash<H>(&self, state: &mut H)
16909 + AttrStyle::Outer => {
16910 + state.write_u8(0u8);
16912 + AttrStyle::Inner(_) => {
16913 + state.write_u8(1u8);
16918 +#[cfg(any(feature = "derive", feature = "full"))]
16919 +impl Hash for Attribute {
16920 + fn hash<H>(&self, state: &mut H)
16924 + self.style.hash(state);
16925 + self.path.hash(state);
16926 + TokenStreamHelper(&self.tokens).hash(state);
16929 +#[cfg(any(feature = "derive", feature = "full"))]
16930 +impl Hash for BareFnArg {
16931 + fn hash<H>(&self, state: &mut H)
16935 + self.attrs.hash(state);
16936 + self.name.hash(state);
16937 + self.ty.hash(state);
16940 +#[cfg(any(feature = "derive", feature = "full"))]
16941 +impl Hash for BinOp {
16942 + fn hash<H>(&self, state: &mut H)
16947 + BinOp::Add(_) => {
16948 + state.write_u8(0u8);
16950 + BinOp::Sub(_) => {
16951 + state.write_u8(1u8);
16953 + BinOp::Mul(_) => {
16954 + state.write_u8(2u8);
16956 + BinOp::Div(_) => {
16957 + state.write_u8(3u8);
16959 + BinOp::Rem(_) => {
16960 + state.write_u8(4u8);
16962 + BinOp::And(_) => {
16963 + state.write_u8(5u8);
16965 + BinOp::Or(_) => {
16966 + state.write_u8(6u8);
16968 + BinOp::BitXor(_) => {
16969 + state.write_u8(7u8);
16971 + BinOp::BitAnd(_) => {
16972 + state.write_u8(8u8);
16974 + BinOp::BitOr(_) => {
16975 + state.write_u8(9u8);
16977 + BinOp::Shl(_) => {
16978 + state.write_u8(10u8);
16980 + BinOp::Shr(_) => {
16981 + state.write_u8(11u8);
16983 + BinOp::Eq(_) => {
16984 + state.write_u8(12u8);
16986 + BinOp::Lt(_) => {
16987 + state.write_u8(13u8);
16989 + BinOp::Le(_) => {
16990 + state.write_u8(14u8);
16992 + BinOp::Ne(_) => {
16993 + state.write_u8(15u8);
16995 + BinOp::Ge(_) => {
16996 + state.write_u8(16u8);
16998 + BinOp::Gt(_) => {
16999 + state.write_u8(17u8);
17001 + BinOp::AddEq(_) => {
17002 + state.write_u8(18u8);
17004 + BinOp::SubEq(_) => {
17005 + state.write_u8(19u8);
17007 + BinOp::MulEq(_) => {
17008 + state.write_u8(20u8);
17010 + BinOp::DivEq(_) => {
17011 + state.write_u8(21u8);
17013 + BinOp::RemEq(_) => {
17014 + state.write_u8(22u8);
17016 + BinOp::BitXorEq(_) => {
17017 + state.write_u8(23u8);
17019 + BinOp::BitAndEq(_) => {
17020 + state.write_u8(24u8);
17022 + BinOp::BitOrEq(_) => {
17023 + state.write_u8(25u8);
17025 + BinOp::ShlEq(_) => {
17026 + state.write_u8(26u8);
17028 + BinOp::ShrEq(_) => {
17029 + state.write_u8(27u8);
17034 +#[cfg(any(feature = "derive", feature = "full"))]
17035 +impl Hash for Binding {
17036 + fn hash<H>(&self, state: &mut H)
17040 + self.ident.hash(state);
17041 + self.ty.hash(state);
17044 +#[cfg(feature = "full")]
17045 +impl Hash for Block {
17046 + fn hash<H>(&self, state: &mut H)
17050 + self.stmts.hash(state);
17053 +#[cfg(any(feature = "derive", feature = "full"))]
17054 +impl Hash for BoundLifetimes {
17055 + fn hash<H>(&self, state: &mut H)
17059 + self.lifetimes.hash(state);
17062 +#[cfg(any(feature = "derive", feature = "full"))]
17063 +impl Hash for ConstParam {
17064 + fn hash<H>(&self, state: &mut H)
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);
17075 +#[cfg(any(feature = "derive", feature = "full"))]
17076 +impl Hash for Constraint {
17077 + fn hash<H>(&self, state: &mut H)
17081 + self.ident.hash(state);
17082 + self.bounds.hash(state);
17085 +#[cfg(feature = "derive")]
17086 +impl Hash for Data {
17087 + fn hash<H>(&self, state: &mut H)
17092 + Data::Struct(v0) => {
17093 + state.write_u8(0u8);
17096 + Data::Enum(v0) => {
17097 + state.write_u8(1u8);
17100 + Data::Union(v0) => {
17101 + state.write_u8(2u8);
17107 +#[cfg(feature = "derive")]
17108 +impl Hash for DataEnum {
17109 + fn hash<H>(&self, state: &mut H)
17113 + self.variants.hash(state);
17116 +#[cfg(feature = "derive")]
17117 +impl Hash for DataStruct {
17118 + fn hash<H>(&self, state: &mut H)
17122 + self.fields.hash(state);
17123 + self.semi_token.hash(state);
17126 +#[cfg(feature = "derive")]
17127 +impl Hash for DataUnion {
17128 + fn hash<H>(&self, state: &mut H)
17132 + self.fields.hash(state);
17135 +#[cfg(feature = "derive")]
17136 +impl Hash for DeriveInput {
17137 + fn hash<H>(&self, state: &mut H)
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);
17148 +#[cfg(any(feature = "derive", feature = "full"))]
17149 +impl Hash for Expr {
17150 + fn hash<H>(&self, state: &mut H)
17155 + #[cfg(feature = "full")]
17156 + Expr::Array(v0) => {
17157 + state.write_u8(0u8);
17160 + #[cfg(feature = "full")]
17161 + Expr::Assign(v0) => {
17162 + state.write_u8(1u8);
17165 + #[cfg(feature = "full")]
17166 + Expr::AssignOp(v0) => {
17167 + state.write_u8(2u8);
17170 + #[cfg(feature = "full")]
17171 + Expr::Async(v0) => {
17172 + state.write_u8(3u8);
17175 + #[cfg(feature = "full")]
17176 + Expr::Await(v0) => {
17177 + state.write_u8(4u8);
17180 + Expr::Binary(v0) => {
17181 + state.write_u8(5u8);
17184 + #[cfg(feature = "full")]
17185 + Expr::Block(v0) => {
17186 + state.write_u8(6u8);
17189 + #[cfg(feature = "full")]
17190 + Expr::Box(v0) => {
17191 + state.write_u8(7u8);
17194 + #[cfg(feature = "full")]
17195 + Expr::Break(v0) => {
17196 + state.write_u8(8u8);
17199 + Expr::Call(v0) => {
17200 + state.write_u8(9u8);
17203 + Expr::Cast(v0) => {
17204 + state.write_u8(10u8);
17207 + #[cfg(feature = "full")]
17208 + Expr::Closure(v0) => {
17209 + state.write_u8(11u8);
17212 + #[cfg(feature = "full")]
17213 + Expr::Continue(v0) => {
17214 + state.write_u8(12u8);
17217 + Expr::Field(v0) => {
17218 + state.write_u8(13u8);
17221 + #[cfg(feature = "full")]
17222 + Expr::ForLoop(v0) => {
17223 + state.write_u8(14u8);
17226 + #[cfg(feature = "full")]
17227 + Expr::Group(v0) => {
17228 + state.write_u8(15u8);
17231 + #[cfg(feature = "full")]
17232 + Expr::If(v0) => {
17233 + state.write_u8(16u8);
17236 + Expr::Index(v0) => {
17237 + state.write_u8(17u8);
17240 + #[cfg(feature = "full")]
17241 + Expr::Let(v0) => {
17242 + state.write_u8(18u8);
17245 + Expr::Lit(v0) => {
17246 + state.write_u8(19u8);
17249 + #[cfg(feature = "full")]
17250 + Expr::Loop(v0) => {
17251 + state.write_u8(20u8);
17254 + #[cfg(feature = "full")]
17255 + Expr::Macro(v0) => {
17256 + state.write_u8(21u8);
17259 + #[cfg(feature = "full")]
17260 + Expr::Match(v0) => {
17261 + state.write_u8(22u8);
17264 + #[cfg(feature = "full")]
17265 + Expr::MethodCall(v0) => {
17266 + state.write_u8(23u8);
17269 + Expr::Paren(v0) => {
17270 + state.write_u8(24u8);
17273 + Expr::Path(v0) => {
17274 + state.write_u8(25u8);
17277 + #[cfg(feature = "full")]
17278 + Expr::Range(v0) => {
17279 + state.write_u8(26u8);
17282 + #[cfg(feature = "full")]
17283 + Expr::Reference(v0) => {
17284 + state.write_u8(27u8);
17287 + #[cfg(feature = "full")]
17288 + Expr::Repeat(v0) => {
17289 + state.write_u8(28u8);
17292 + #[cfg(feature = "full")]
17293 + Expr::Return(v0) => {
17294 + state.write_u8(29u8);
17297 + #[cfg(feature = "full")]
17298 + Expr::Struct(v0) => {
17299 + state.write_u8(30u8);
17302 + #[cfg(feature = "full")]
17303 + Expr::Try(v0) => {
17304 + state.write_u8(31u8);
17307 + #[cfg(feature = "full")]
17308 + Expr::TryBlock(v0) => {
17309 + state.write_u8(32u8);
17312 + #[cfg(feature = "full")]
17313 + Expr::Tuple(v0) => {
17314 + state.write_u8(33u8);
17317 + #[cfg(feature = "full")]
17318 + Expr::Type(v0) => {
17319 + state.write_u8(34u8);
17322 + Expr::Unary(v0) => {
17323 + state.write_u8(35u8);
17326 + #[cfg(feature = "full")]
17327 + Expr::Unsafe(v0) => {
17328 + state.write_u8(36u8);
17331 + Expr::Verbatim(v0) => {
17332 + state.write_u8(37u8);
17333 + TokenStreamHelper(v0).hash(state);
17335 + #[cfg(feature = "full")]
17336 + Expr::While(v0) => {
17337 + state.write_u8(38u8);
17340 + #[cfg(feature = "full")]
17341 + Expr::Yield(v0) => {
17342 + state.write_u8(39u8);
17345 + _ => unreachable!(),
17349 +#[cfg(feature = "full")]
17350 +impl Hash for ExprArray {
17351 + fn hash<H>(&self, state: &mut H)
17355 + self.attrs.hash(state);
17356 + self.elems.hash(state);
17359 +#[cfg(feature = "full")]
17360 +impl Hash for ExprAssign {
17361 + fn hash<H>(&self, state: &mut H)
17365 + self.attrs.hash(state);
17366 + self.left.hash(state);
17367 + self.right.hash(state);
17370 +#[cfg(feature = "full")]
17371 +impl Hash for ExprAssignOp {
17372 + fn hash<H>(&self, state: &mut H)
17376 + self.attrs.hash(state);
17377 + self.left.hash(state);
17378 + self.op.hash(state);
17379 + self.right.hash(state);
17382 +#[cfg(feature = "full")]
17383 +impl Hash for ExprAsync {
17384 + fn hash<H>(&self, state: &mut H)
17388 + self.attrs.hash(state);
17389 + self.capture.hash(state);
17390 + self.block.hash(state);
17393 +#[cfg(feature = "full")]
17394 +impl Hash for ExprAwait {
17395 + fn hash<H>(&self, state: &mut H)
17399 + self.attrs.hash(state);
17400 + self.base.hash(state);
17403 +#[cfg(any(feature = "derive", feature = "full"))]
17404 +impl Hash for ExprBinary {
17405 + fn hash<H>(&self, state: &mut H)
17409 + self.attrs.hash(state);
17410 + self.left.hash(state);
17411 + self.op.hash(state);
17412 + self.right.hash(state);
17415 +#[cfg(feature = "full")]
17416 +impl Hash for ExprBlock {
17417 + fn hash<H>(&self, state: &mut H)
17421 + self.attrs.hash(state);
17422 + self.label.hash(state);
17423 + self.block.hash(state);
17426 +#[cfg(feature = "full")]
17427 +impl Hash for ExprBox {
17428 + fn hash<H>(&self, state: &mut H)
17432 + self.attrs.hash(state);
17433 + self.expr.hash(state);
17436 +#[cfg(feature = "full")]
17437 +impl Hash for ExprBreak {
17438 + fn hash<H>(&self, state: &mut H)
17442 + self.attrs.hash(state);
17443 + self.label.hash(state);
17444 + self.expr.hash(state);
17447 +#[cfg(any(feature = "derive", feature = "full"))]
17448 +impl Hash for ExprCall {
17449 + fn hash<H>(&self, state: &mut H)
17453 + self.attrs.hash(state);
17454 + self.func.hash(state);
17455 + self.args.hash(state);
17458 +#[cfg(any(feature = "derive", feature = "full"))]
17459 +impl Hash for ExprCast {
17460 + fn hash<H>(&self, state: &mut H)
17464 + self.attrs.hash(state);
17465 + self.expr.hash(state);
17466 + self.ty.hash(state);
17469 +#[cfg(feature = "full")]
17470 +impl Hash for ExprClosure {
17471 + fn hash<H>(&self, state: &mut H)
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);
17484 +#[cfg(feature = "full")]
17485 +impl Hash for ExprContinue {
17486 + fn hash<H>(&self, state: &mut H)
17490 + self.attrs.hash(state);
17491 + self.label.hash(state);
17494 +#[cfg(any(feature = "derive", feature = "full"))]
17495 +impl Hash for ExprField {
17496 + fn hash<H>(&self, state: &mut H)
17500 + self.attrs.hash(state);
17501 + self.base.hash(state);
17502 + self.member.hash(state);
17505 +#[cfg(feature = "full")]
17506 +impl Hash for ExprForLoop {
17507 + fn hash<H>(&self, state: &mut H)
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);
17518 +#[cfg(feature = "full")]
17519 +impl Hash for ExprGroup {
17520 + fn hash<H>(&self, state: &mut H)
17524 + self.attrs.hash(state);
17525 + self.expr.hash(state);
17528 +#[cfg(feature = "full")]
17529 +impl Hash for ExprIf {
17530 + fn hash<H>(&self, state: &mut H)
17534 + self.attrs.hash(state);
17535 + self.cond.hash(state);
17536 + self.then_branch.hash(state);
17537 + self.else_branch.hash(state);
17540 +#[cfg(any(feature = "derive", feature = "full"))]
17541 +impl Hash for ExprIndex {
17542 + fn hash<H>(&self, state: &mut H)
17546 + self.attrs.hash(state);
17547 + self.expr.hash(state);
17548 + self.index.hash(state);
17551 +#[cfg(feature = "full")]
17552 +impl Hash for ExprLet {
17553 + fn hash<H>(&self, state: &mut H)
17557 + self.attrs.hash(state);
17558 + self.pat.hash(state);
17559 + self.expr.hash(state);
17562 +#[cfg(any(feature = "derive", feature = "full"))]
17563 +impl Hash for ExprLit {
17564 + fn hash<H>(&self, state: &mut H)
17568 + self.attrs.hash(state);
17569 + self.lit.hash(state);
17572 +#[cfg(feature = "full")]
17573 +impl Hash for ExprLoop {
17574 + fn hash<H>(&self, state: &mut H)
17578 + self.attrs.hash(state);
17579 + self.label.hash(state);
17580 + self.body.hash(state);
17583 +#[cfg(feature = "full")]
17584 +impl Hash for ExprMacro {
17585 + fn hash<H>(&self, state: &mut H)
17589 + self.attrs.hash(state);
17590 + self.mac.hash(state);
17593 +#[cfg(feature = "full")]
17594 +impl Hash for ExprMatch {
17595 + fn hash<H>(&self, state: &mut H)
17599 + self.attrs.hash(state);
17600 + self.expr.hash(state);
17601 + self.arms.hash(state);
17604 +#[cfg(feature = "full")]
17605 +impl Hash for ExprMethodCall {
17606 + fn hash<H>(&self, state: &mut H)
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);
17617 +#[cfg(any(feature = "derive", feature = "full"))]
17618 +impl Hash for ExprParen {
17619 + fn hash<H>(&self, state: &mut H)
17623 + self.attrs.hash(state);
17624 + self.expr.hash(state);
17627 +#[cfg(any(feature = "derive", feature = "full"))]
17628 +impl Hash for ExprPath {
17629 + fn hash<H>(&self, state: &mut H)
17633 + self.attrs.hash(state);
17634 + self.qself.hash(state);
17635 + self.path.hash(state);
17638 +#[cfg(feature = "full")]
17639 +impl Hash for ExprRange {
17640 + fn hash<H>(&self, state: &mut H)
17644 + self.attrs.hash(state);
17645 + self.from.hash(state);
17646 + self.limits.hash(state);
17647 + self.to.hash(state);
17650 +#[cfg(feature = "full")]
17651 +impl Hash for ExprReference {
17652 + fn hash<H>(&self, state: &mut H)
17656 + self.attrs.hash(state);
17657 + self.mutability.hash(state);
17658 + self.expr.hash(state);
17661 +#[cfg(feature = "full")]
17662 +impl Hash for ExprRepeat {
17663 + fn hash<H>(&self, state: &mut H)
17667 + self.attrs.hash(state);
17668 + self.expr.hash(state);
17669 + self.len.hash(state);
17672 +#[cfg(feature = "full")]
17673 +impl Hash for ExprReturn {
17674 + fn hash<H>(&self, state: &mut H)
17678 + self.attrs.hash(state);
17679 + self.expr.hash(state);
17682 +#[cfg(feature = "full")]
17683 +impl Hash for ExprStruct {
17684 + fn hash<H>(&self, state: &mut H)
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);
17695 +#[cfg(feature = "full")]
17696 +impl Hash for ExprTry {
17697 + fn hash<H>(&self, state: &mut H)
17701 + self.attrs.hash(state);
17702 + self.expr.hash(state);
17705 +#[cfg(feature = "full")]
17706 +impl Hash for ExprTryBlock {
17707 + fn hash<H>(&self, state: &mut H)
17711 + self.attrs.hash(state);
17712 + self.block.hash(state);
17715 +#[cfg(feature = "full")]
17716 +impl Hash for ExprTuple {
17717 + fn hash<H>(&self, state: &mut H)
17721 + self.attrs.hash(state);
17722 + self.elems.hash(state);
17725 +#[cfg(feature = "full")]
17726 +impl Hash for ExprType {
17727 + fn hash<H>(&self, state: &mut H)
17731 + self.attrs.hash(state);
17732 + self.expr.hash(state);
17733 + self.ty.hash(state);
17736 +#[cfg(any(feature = "derive", feature = "full"))]
17737 +impl Hash for ExprUnary {
17738 + fn hash<H>(&self, state: &mut H)
17742 + self.attrs.hash(state);
17743 + self.op.hash(state);
17744 + self.expr.hash(state);
17747 +#[cfg(feature = "full")]
17748 +impl Hash for ExprUnsafe {
17749 + fn hash<H>(&self, state: &mut H)
17753 + self.attrs.hash(state);
17754 + self.block.hash(state);
17757 +#[cfg(feature = "full")]
17758 +impl Hash for ExprWhile {
17759 + fn hash<H>(&self, state: &mut H)
17763 + self.attrs.hash(state);
17764 + self.label.hash(state);
17765 + self.cond.hash(state);
17766 + self.body.hash(state);
17769 +#[cfg(feature = "full")]
17770 +impl Hash for ExprYield {
17771 + fn hash<H>(&self, state: &mut H)
17775 + self.attrs.hash(state);
17776 + self.expr.hash(state);
17779 +#[cfg(any(feature = "derive", feature = "full"))]
17780 +impl Hash for Field {
17781 + fn hash<H>(&self, state: &mut H)
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);
17792 +#[cfg(feature = "full")]
17793 +impl Hash for FieldPat {
17794 + fn hash<H>(&self, state: &mut H)
17798 + self.attrs.hash(state);
17799 + self.member.hash(state);
17800 + self.colon_token.hash(state);
17801 + self.pat.hash(state);
17804 +#[cfg(feature = "full")]
17805 +impl Hash for FieldValue {
17806 + fn hash<H>(&self, state: &mut H)
17810 + self.attrs.hash(state);
17811 + self.member.hash(state);
17812 + self.colon_token.hash(state);
17813 + self.expr.hash(state);
17816 +#[cfg(any(feature = "derive", feature = "full"))]
17817 +impl Hash for Fields {
17818 + fn hash<H>(&self, state: &mut H)
17823 + Fields::Named(v0) => {
17824 + state.write_u8(0u8);
17827 + Fields::Unnamed(v0) => {
17828 + state.write_u8(1u8);
17831 + Fields::Unit => {
17832 + state.write_u8(2u8);
17837 +#[cfg(any(feature = "derive", feature = "full"))]
17838 +impl Hash for FieldsNamed {
17839 + fn hash<H>(&self, state: &mut H)
17843 + self.named.hash(state);
17846 +#[cfg(any(feature = "derive", feature = "full"))]
17847 +impl Hash for FieldsUnnamed {
17848 + fn hash<H>(&self, state: &mut H)
17852 + self.unnamed.hash(state);
17855 +#[cfg(feature = "full")]
17856 +impl Hash for File {
17857 + fn hash<H>(&self, state: &mut H)
17861 + self.shebang.hash(state);
17862 + self.attrs.hash(state);
17863 + self.items.hash(state);
17866 +#[cfg(feature = "full")]
17867 +impl Hash for FnArg {
17868 + fn hash<H>(&self, state: &mut H)
17873 + FnArg::Receiver(v0) => {
17874 + state.write_u8(0u8);
17877 + FnArg::Typed(v0) => {
17878 + state.write_u8(1u8);
17884 +#[cfg(feature = "full")]
17885 +impl Hash for ForeignItem {
17886 + fn hash<H>(&self, state: &mut H)
17891 + ForeignItem::Fn(v0) => {
17892 + state.write_u8(0u8);
17895 + ForeignItem::Static(v0) => {
17896 + state.write_u8(1u8);
17899 + ForeignItem::Type(v0) => {
17900 + state.write_u8(2u8);
17903 + ForeignItem::Macro(v0) => {
17904 + state.write_u8(3u8);
17907 + ForeignItem::Verbatim(v0) => {
17908 + state.write_u8(4u8);
17909 + TokenStreamHelper(v0).hash(state);
17911 + _ => unreachable!(),
17915 +#[cfg(feature = "full")]
17916 +impl Hash for ForeignItemFn {
17917 + fn hash<H>(&self, state: &mut H)
17921 + self.attrs.hash(state);
17922 + self.vis.hash(state);
17923 + self.sig.hash(state);
17926 +#[cfg(feature = "full")]
17927 +impl Hash for ForeignItemMacro {
17928 + fn hash<H>(&self, state: &mut H)
17932 + self.attrs.hash(state);
17933 + self.mac.hash(state);
17934 + self.semi_token.hash(state);
17937 +#[cfg(feature = "full")]
17938 +impl Hash for ForeignItemStatic {
17939 + fn hash<H>(&self, state: &mut H)
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);
17950 +#[cfg(feature = "full")]
17951 +impl Hash for ForeignItemType {
17952 + fn hash<H>(&self, state: &mut H)
17956 + self.attrs.hash(state);
17957 + self.vis.hash(state);
17958 + self.ident.hash(state);
17961 +#[cfg(any(feature = "derive", feature = "full"))]
17962 +impl Hash for GenericArgument {
17963 + fn hash<H>(&self, state: &mut H)
17968 + GenericArgument::Lifetime(v0) => {
17969 + state.write_u8(0u8);
17972 + GenericArgument::Type(v0) => {
17973 + state.write_u8(1u8);
17976 + GenericArgument::Binding(v0) => {
17977 + state.write_u8(2u8);
17980 + GenericArgument::Constraint(v0) => {
17981 + state.write_u8(3u8);
17984 + GenericArgument::Const(v0) => {
17985 + state.write_u8(4u8);
17991 +#[cfg(feature = "full")]
17992 +impl Hash for GenericMethodArgument {
17993 + fn hash<H>(&self, state: &mut H)
17998 + GenericMethodArgument::Type(v0) => {
17999 + state.write_u8(0u8);
18002 + GenericMethodArgument::Const(v0) => {
18003 + state.write_u8(1u8);
18009 +#[cfg(any(feature = "derive", feature = "full"))]
18010 +impl Hash for GenericParam {
18011 + fn hash<H>(&self, state: &mut H)
18016 + GenericParam::Type(v0) => {
18017 + state.write_u8(0u8);
18020 + GenericParam::Lifetime(v0) => {
18021 + state.write_u8(1u8);
18024 + GenericParam::Const(v0) => {
18025 + state.write_u8(2u8);
18031 +#[cfg(any(feature = "derive", feature = "full"))]
18032 +impl Hash for Generics {
18033 + fn hash<H>(&self, state: &mut H)
18037 + self.lt_token.hash(state);
18038 + self.params.hash(state);
18039 + self.gt_token.hash(state);
18040 + self.where_clause.hash(state);
18043 +#[cfg(feature = "full")]
18044 +impl Hash for ImplItem {
18045 + fn hash<H>(&self, state: &mut H)
18050 + ImplItem::Const(v0) => {
18051 + state.write_u8(0u8);
18054 + ImplItem::Method(v0) => {
18055 + state.write_u8(1u8);
18058 + ImplItem::Type(v0) => {
18059 + state.write_u8(2u8);
18062 + ImplItem::Macro(v0) => {
18063 + state.write_u8(3u8);
18066 + ImplItem::Verbatim(v0) => {
18067 + state.write_u8(4u8);
18068 + TokenStreamHelper(v0).hash(state);
18070 + _ => unreachable!(),
18074 +#[cfg(feature = "full")]
18075 +impl Hash for ImplItemConst {
18076 + fn hash<H>(&self, state: &mut H)
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);
18088 +#[cfg(feature = "full")]
18089 +impl Hash for ImplItemMacro {
18090 + fn hash<H>(&self, state: &mut H)
18094 + self.attrs.hash(state);
18095 + self.mac.hash(state);
18096 + self.semi_token.hash(state);
18099 +#[cfg(feature = "full")]
18100 +impl Hash for ImplItemMethod {
18101 + fn hash<H>(&self, state: &mut H)
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);
18112 +#[cfg(feature = "full")]
18113 +impl Hash for ImplItemType {
18114 + fn hash<H>(&self, state: &mut H)
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);
18126 +#[cfg(feature = "full")]
18127 +impl Hash for Item {
18128 + fn hash<H>(&self, state: &mut H)
18133 + Item::Const(v0) => {
18134 + state.write_u8(0u8);
18137 + Item::Enum(v0) => {
18138 + state.write_u8(1u8);
18141 + Item::ExternCrate(v0) => {
18142 + state.write_u8(2u8);
18145 + Item::Fn(v0) => {
18146 + state.write_u8(3u8);
18149 + Item::ForeignMod(v0) => {
18150 + state.write_u8(4u8);
18153 + Item::Impl(v0) => {
18154 + state.write_u8(5u8);
18157 + Item::Macro(v0) => {
18158 + state.write_u8(6u8);
18161 + Item::Macro2(v0) => {
18162 + state.write_u8(7u8);
18165 + Item::Mod(v0) => {
18166 + state.write_u8(8u8);
18169 + Item::Static(v0) => {
18170 + state.write_u8(9u8);
18173 + Item::Struct(v0) => {
18174 + state.write_u8(10u8);
18177 + Item::Trait(v0) => {
18178 + state.write_u8(11u8);
18181 + Item::TraitAlias(v0) => {
18182 + state.write_u8(12u8);
18185 + Item::Type(v0) => {
18186 + state.write_u8(13u8);
18189 + Item::Union(v0) => {
18190 + state.write_u8(14u8);
18193 + Item::Use(v0) => {
18194 + state.write_u8(15u8);
18197 + Item::Verbatim(v0) => {
18198 + state.write_u8(16u8);
18199 + TokenStreamHelper(v0).hash(state);
18201 + _ => unreachable!(),
18205 +#[cfg(feature = "full")]
18206 +impl Hash for ItemConst {
18207 + fn hash<H>(&self, state: &mut H)
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);
18218 +#[cfg(feature = "full")]
18219 +impl Hash for ItemEnum {
18220 + fn hash<H>(&self, state: &mut H)
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);
18231 +#[cfg(feature = "full")]
18232 +impl Hash for ItemExternCrate {
18233 + fn hash<H>(&self, state: &mut H)
18237 + self.attrs.hash(state);
18238 + self.vis.hash(state);
18239 + self.ident.hash(state);
18240 + self.rename.hash(state);
18243 +#[cfg(feature = "full")]
18244 +impl Hash for ItemFn {
18245 + fn hash<H>(&self, state: &mut H)
18249 + self.attrs.hash(state);
18250 + self.vis.hash(state);
18251 + self.sig.hash(state);
18252 + self.block.hash(state);
18255 +#[cfg(feature = "full")]
18256 +impl Hash for ItemForeignMod {
18257 + fn hash<H>(&self, state: &mut H)
18261 + self.attrs.hash(state);
18262 + self.abi.hash(state);
18263 + self.items.hash(state);
18266 +#[cfg(feature = "full")]
18267 +impl Hash for ItemImpl {
18268 + fn hash<H>(&self, state: &mut H)
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);
18281 +#[cfg(feature = "full")]
18282 +impl Hash for ItemMacro {
18283 + fn hash<H>(&self, state: &mut H)
18287 + self.attrs.hash(state);
18288 + self.ident.hash(state);
18289 + self.mac.hash(state);
18290 + self.semi_token.hash(state);
18293 +#[cfg(feature = "full")]
18294 +impl Hash for ItemMacro2 {
18295 + fn hash<H>(&self, state: &mut H)
18299 + self.attrs.hash(state);
18300 + self.vis.hash(state);
18301 + self.ident.hash(state);
18302 + TokenStreamHelper(&self.rules).hash(state);
18305 +#[cfg(feature = "full")]
18306 +impl Hash for ItemMod {
18307 + fn hash<H>(&self, state: &mut H)
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);
18318 +#[cfg(feature = "full")]
18319 +impl Hash for ItemStatic {
18320 + fn hash<H>(&self, state: &mut H)
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);
18332 +#[cfg(feature = "full")]
18333 +impl Hash for ItemStruct {
18334 + fn hash<H>(&self, state: &mut H)
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);
18346 +#[cfg(feature = "full")]
18347 +impl Hash for ItemTrait {
18348 + fn hash<H>(&self, state: &mut H)
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);
18363 +#[cfg(feature = "full")]
18364 +impl Hash for ItemTraitAlias {
18365 + fn hash<H>(&self, state: &mut H)
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);
18376 +#[cfg(feature = "full")]
18377 +impl Hash for ItemType {
18378 + fn hash<H>(&self, state: &mut H)
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);
18389 +#[cfg(feature = "full")]
18390 +impl Hash for ItemUnion {
18391 + fn hash<H>(&self, state: &mut H)
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);
18402 +#[cfg(feature = "full")]
18403 +impl Hash for ItemUse {
18404 + fn hash<H>(&self, state: &mut H)
18408 + self.attrs.hash(state);
18409 + self.vis.hash(state);
18410 + self.leading_colon.hash(state);
18411 + self.tree.hash(state);
18414 +#[cfg(feature = "full")]
18415 +impl Hash for Label {
18416 + fn hash<H>(&self, state: &mut H)
18420 + self.name.hash(state);
18423 +#[cfg(any(feature = "derive", feature = "full"))]
18424 +impl Hash for LifetimeDef {
18425 + fn hash<H>(&self, state: &mut H)
18429 + self.attrs.hash(state);
18430 + self.lifetime.hash(state);
18431 + self.colon_token.hash(state);
18432 + self.bounds.hash(state);
18435 +impl Hash for Lit {
18436 + fn hash<H>(&self, state: &mut H)
18441 + Lit::Str(v0) => {
18442 + state.write_u8(0u8);
18445 + Lit::ByteStr(v0) => {
18446 + state.write_u8(1u8);
18449 + Lit::Byte(v0) => {
18450 + state.write_u8(2u8);
18453 + Lit::Char(v0) => {
18454 + state.write_u8(3u8);
18457 + Lit::Int(v0) => {
18458 + state.write_u8(4u8);
18461 + Lit::Float(v0) => {
18462 + state.write_u8(5u8);
18465 + Lit::Bool(v0) => {
18466 + state.write_u8(6u8);
18469 + Lit::Verbatim(v0) => {
18470 + state.write_u8(7u8);
18471 + v0.to_string().hash(state);
18476 +impl Hash for LitBool {
18477 + fn hash<H>(&self, state: &mut H)
18481 + self.value.hash(state);
18484 +#[cfg(feature = "full")]
18485 +impl Hash for Local {
18486 + fn hash<H>(&self, state: &mut H)
18490 + self.attrs.hash(state);
18491 + self.pat.hash(state);
18492 + self.init.hash(state);
18495 +#[cfg(any(feature = "derive", feature = "full"))]
18496 +impl Hash for Macro {
18497 + fn hash<H>(&self, state: &mut H)
18501 + self.path.hash(state);
18502 + self.delimiter.hash(state);
18503 + TokenStreamHelper(&self.tokens).hash(state);
18506 +#[cfg(any(feature = "derive", feature = "full"))]
18507 +impl Hash for MacroDelimiter {
18508 + fn hash<H>(&self, state: &mut H)
18513 + MacroDelimiter::Paren(_) => {
18514 + state.write_u8(0u8);
18516 + MacroDelimiter::Brace(_) => {
18517 + state.write_u8(1u8);
18519 + MacroDelimiter::Bracket(_) => {
18520 + state.write_u8(2u8);
18525 +#[cfg(any(feature = "derive", feature = "full"))]
18526 +impl Hash for Meta {
18527 + fn hash<H>(&self, state: &mut H)
18532 + Meta::Path(v0) => {
18533 + state.write_u8(0u8);
18536 + Meta::List(v0) => {
18537 + state.write_u8(1u8);
18540 + Meta::NameValue(v0) => {
18541 + state.write_u8(2u8);
18547 +#[cfg(any(feature = "derive", feature = "full"))]
18548 +impl Hash for MetaList {
18549 + fn hash<H>(&self, state: &mut H)
18553 + self.path.hash(state);
18554 + self.nested.hash(state);
18557 +#[cfg(any(feature = "derive", feature = "full"))]
18558 +impl Hash for MetaNameValue {
18559 + fn hash<H>(&self, state: &mut H)
18563 + self.path.hash(state);
18564 + self.lit.hash(state);
18567 +#[cfg(feature = "full")]
18568 +impl Hash for MethodTurbofish {
18569 + fn hash<H>(&self, state: &mut H)
18573 + self.args.hash(state);
18576 +#[cfg(any(feature = "derive", feature = "full"))]
18577 +impl Hash for NestedMeta {
18578 + fn hash<H>(&self, state: &mut H)
18583 + NestedMeta::Meta(v0) => {
18584 + state.write_u8(0u8);
18587 + NestedMeta::Lit(v0) => {
18588 + state.write_u8(1u8);
18594 +#[cfg(any(feature = "derive", feature = "full"))]
18595 +impl Hash for ParenthesizedGenericArguments {
18596 + fn hash<H>(&self, state: &mut H)
18600 + self.inputs.hash(state);
18601 + self.output.hash(state);
18604 +#[cfg(feature = "full")]
18605 +impl Hash for Pat {
18606 + fn hash<H>(&self, state: &mut H)
18611 + Pat::Box(v0) => {
18612 + state.write_u8(0u8);
18615 + Pat::Ident(v0) => {
18616 + state.write_u8(1u8);
18619 + Pat::Lit(v0) => {
18620 + state.write_u8(2u8);
18623 + Pat::Macro(v0) => {
18624 + state.write_u8(3u8);
18628 + state.write_u8(4u8);
18631 + Pat::Path(v0) => {
18632 + state.write_u8(5u8);
18635 + Pat::Range(v0) => {
18636 + state.write_u8(6u8);
18639 + Pat::Reference(v0) => {
18640 + state.write_u8(7u8);
18643 + Pat::Rest(v0) => {
18644 + state.write_u8(8u8);
18647 + Pat::Slice(v0) => {
18648 + state.write_u8(9u8);
18651 + Pat::Struct(v0) => {
18652 + state.write_u8(10u8);
18655 + Pat::Tuple(v0) => {
18656 + state.write_u8(11u8);
18659 + Pat::TupleStruct(v0) => {
18660 + state.write_u8(12u8);
18663 + Pat::Type(v0) => {
18664 + state.write_u8(13u8);
18667 + Pat::Verbatim(v0) => {
18668 + state.write_u8(14u8);
18669 + TokenStreamHelper(v0).hash(state);
18671 + Pat::Wild(v0) => {
18672 + state.write_u8(15u8);
18675 + _ => unreachable!(),
18679 +#[cfg(feature = "full")]
18680 +impl Hash for PatBox {
18681 + fn hash<H>(&self, state: &mut H)
18685 + self.attrs.hash(state);
18686 + self.pat.hash(state);
18689 +#[cfg(feature = "full")]
18690 +impl Hash for PatIdent {
18691 + fn hash<H>(&self, state: &mut H)
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);
18702 +#[cfg(feature = "full")]
18703 +impl Hash for PatLit {
18704 + fn hash<H>(&self, state: &mut H)
18708 + self.attrs.hash(state);
18709 + self.expr.hash(state);
18712 +#[cfg(feature = "full")]
18713 +impl Hash for PatMacro {
18714 + fn hash<H>(&self, state: &mut H)
18718 + self.attrs.hash(state);
18719 + self.mac.hash(state);
18722 +#[cfg(feature = "full")]
18723 +impl Hash for PatOr {
18724 + fn hash<H>(&self, state: &mut H)
18728 + self.attrs.hash(state);
18729 + self.leading_vert.hash(state);
18730 + self.cases.hash(state);
18733 +#[cfg(feature = "full")]
18734 +impl Hash for PatPath {
18735 + fn hash<H>(&self, state: &mut H)
18739 + self.attrs.hash(state);
18740 + self.qself.hash(state);
18741 + self.path.hash(state);
18744 +#[cfg(feature = "full")]
18745 +impl Hash for PatRange {
18746 + fn hash<H>(&self, state: &mut H)
18750 + self.attrs.hash(state);
18751 + self.lo.hash(state);
18752 + self.limits.hash(state);
18753 + self.hi.hash(state);
18756 +#[cfg(feature = "full")]
18757 +impl Hash for PatReference {
18758 + fn hash<H>(&self, state: &mut H)
18762 + self.attrs.hash(state);
18763 + self.mutability.hash(state);
18764 + self.pat.hash(state);
18767 +#[cfg(feature = "full")]
18768 +impl Hash for PatRest {
18769 + fn hash<H>(&self, state: &mut H)
18773 + self.attrs.hash(state);
18776 +#[cfg(feature = "full")]
18777 +impl Hash for PatSlice {
18778 + fn hash<H>(&self, state: &mut H)
18782 + self.attrs.hash(state);
18783 + self.elems.hash(state);
18786 +#[cfg(feature = "full")]
18787 +impl Hash for PatStruct {
18788 + fn hash<H>(&self, state: &mut H)
18792 + self.attrs.hash(state);
18793 + self.path.hash(state);
18794 + self.fields.hash(state);
18795 + self.dot2_token.hash(state);
18798 +#[cfg(feature = "full")]
18799 +impl Hash for PatTuple {
18800 + fn hash<H>(&self, state: &mut H)
18804 + self.attrs.hash(state);
18805 + self.elems.hash(state);
18808 +#[cfg(feature = "full")]
18809 +impl Hash for PatTupleStruct {
18810 + fn hash<H>(&self, state: &mut H)
18814 + self.attrs.hash(state);
18815 + self.path.hash(state);
18816 + self.pat.hash(state);
18819 +#[cfg(feature = "full")]
18820 +impl Hash for PatType {
18821 + fn hash<H>(&self, state: &mut H)
18825 + self.attrs.hash(state);
18826 + self.pat.hash(state);
18827 + self.ty.hash(state);
18830 +#[cfg(feature = "full")]
18831 +impl Hash for PatWild {
18832 + fn hash<H>(&self, state: &mut H)
18836 + self.attrs.hash(state);
18839 +#[cfg(any(feature = "derive", feature = "full"))]
18840 +impl Hash for Path {
18841 + fn hash<H>(&self, state: &mut H)
18845 + self.leading_colon.hash(state);
18846 + self.segments.hash(state);
18849 +#[cfg(any(feature = "derive", feature = "full"))]
18850 +impl Hash for PathArguments {
18851 + fn hash<H>(&self, state: &mut H)
18856 + PathArguments::None => {
18857 + state.write_u8(0u8);
18859 + PathArguments::AngleBracketed(v0) => {
18860 + state.write_u8(1u8);
18863 + PathArguments::Parenthesized(v0) => {
18864 + state.write_u8(2u8);
18870 +#[cfg(any(feature = "derive", feature = "full"))]
18871 +impl Hash for PathSegment {
18872 + fn hash<H>(&self, state: &mut H)
18876 + self.ident.hash(state);
18877 + self.arguments.hash(state);
18880 +#[cfg(any(feature = "derive", feature = "full"))]
18881 +impl Hash for PredicateEq {
18882 + fn hash<H>(&self, state: &mut H)
18886 + self.lhs_ty.hash(state);
18887 + self.rhs_ty.hash(state);
18890 +#[cfg(any(feature = "derive", feature = "full"))]
18891 +impl Hash for PredicateLifetime {
18892 + fn hash<H>(&self, state: &mut H)
18896 + self.lifetime.hash(state);
18897 + self.bounds.hash(state);
18900 +#[cfg(any(feature = "derive", feature = "full"))]
18901 +impl Hash for PredicateType {
18902 + fn hash<H>(&self, state: &mut H)
18906 + self.lifetimes.hash(state);
18907 + self.bounded_ty.hash(state);
18908 + self.bounds.hash(state);
18911 +#[cfg(any(feature = "derive", feature = "full"))]
18912 +impl Hash for QSelf {
18913 + fn hash<H>(&self, state: &mut H)
18917 + self.ty.hash(state);
18918 + self.position.hash(state);
18919 + self.as_token.hash(state);
18922 +#[cfg(feature = "full")]
18923 +impl Hash for RangeLimits {
18924 + fn hash<H>(&self, state: &mut H)
18929 + RangeLimits::HalfOpen(_) => {
18930 + state.write_u8(0u8);
18932 + RangeLimits::Closed(_) => {
18933 + state.write_u8(1u8);
18938 +#[cfg(feature = "full")]
18939 +impl Hash for Receiver {
18940 + fn hash<H>(&self, state: &mut H)
18944 + self.attrs.hash(state);
18945 + self.reference.hash(state);
18946 + self.mutability.hash(state);
18949 +#[cfg(any(feature = "derive", feature = "full"))]
18950 +impl Hash for ReturnType {
18951 + fn hash<H>(&self, state: &mut H)
18956 + ReturnType::Default => {
18957 + state.write_u8(0u8);
18959 + ReturnType::Type(_, v1) => {
18960 + state.write_u8(1u8);
18966 +#[cfg(feature = "full")]
18967 +impl Hash for Signature {
18968 + fn hash<H>(&self, state: &mut H)
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);
18983 +#[cfg(feature = "full")]
18984 +impl Hash for Stmt {
18985 + fn hash<H>(&self, state: &mut H)
18990 + Stmt::Local(v0) => {
18991 + state.write_u8(0u8);
18994 + Stmt::Item(v0) => {
18995 + state.write_u8(1u8);
18998 + Stmt::Expr(v0) => {
18999 + state.write_u8(2u8);
19002 + Stmt::Semi(v0, _) => {
19003 + state.write_u8(3u8);
19009 +#[cfg(any(feature = "derive", feature = "full"))]
19010 +impl Hash for TraitBound {
19011 + fn hash<H>(&self, state: &mut H)
19015 + self.paren_token.hash(state);
19016 + self.modifier.hash(state);
19017 + self.lifetimes.hash(state);
19018 + self.path.hash(state);
19021 +#[cfg(any(feature = "derive", feature = "full"))]
19022 +impl Hash for TraitBoundModifier {
19023 + fn hash<H>(&self, state: &mut H)
19028 + TraitBoundModifier::None => {
19029 + state.write_u8(0u8);
19031 + TraitBoundModifier::Maybe(_) => {
19032 + state.write_u8(1u8);
19037 +#[cfg(feature = "full")]
19038 +impl Hash for TraitItem {
19039 + fn hash<H>(&self, state: &mut H)
19044 + TraitItem::Const(v0) => {
19045 + state.write_u8(0u8);
19048 + TraitItem::Method(v0) => {
19049 + state.write_u8(1u8);
19052 + TraitItem::Type(v0) => {
19053 + state.write_u8(2u8);
19056 + TraitItem::Macro(v0) => {
19057 + state.write_u8(3u8);
19060 + TraitItem::Verbatim(v0) => {
19061 + state.write_u8(4u8);
19062 + TokenStreamHelper(v0).hash(state);
19064 + _ => unreachable!(),
19068 +#[cfg(feature = "full")]
19069 +impl Hash for TraitItemConst {
19070 + fn hash<H>(&self, state: &mut H)
19074 + self.attrs.hash(state);
19075 + self.ident.hash(state);
19076 + self.ty.hash(state);
19077 + self.default.hash(state);
19080 +#[cfg(feature = "full")]
19081 +impl Hash for TraitItemMacro {
19082 + fn hash<H>(&self, state: &mut H)
19086 + self.attrs.hash(state);
19087 + self.mac.hash(state);
19088 + self.semi_token.hash(state);
19091 +#[cfg(feature = "full")]
19092 +impl Hash for TraitItemMethod {
19093 + fn hash<H>(&self, state: &mut H)
19097 + self.attrs.hash(state);
19098 + self.sig.hash(state);
19099 + self.default.hash(state);
19100 + self.semi_token.hash(state);
19103 +#[cfg(feature = "full")]
19104 +impl Hash for TraitItemType {
19105 + fn hash<H>(&self, state: &mut H)
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);
19117 +#[cfg(any(feature = "derive", feature = "full"))]
19118 +impl Hash for Type {
19119 + fn hash<H>(&self, state: &mut H)
19124 + Type::Array(v0) => {
19125 + state.write_u8(0u8);
19128 + Type::BareFn(v0) => {
19129 + state.write_u8(1u8);
19132 + Type::Group(v0) => {
19133 + state.write_u8(2u8);
19136 + Type::ImplTrait(v0) => {
19137 + state.write_u8(3u8);
19140 + Type::Infer(v0) => {
19141 + state.write_u8(4u8);
19144 + Type::Macro(v0) => {
19145 + state.write_u8(5u8);
19148 + Type::Never(v0) => {
19149 + state.write_u8(6u8);
19152 + Type::Paren(v0) => {
19153 + state.write_u8(7u8);
19156 + Type::Path(v0) => {
19157 + state.write_u8(8u8);
19160 + Type::Ptr(v0) => {
19161 + state.write_u8(9u8);
19164 + Type::Reference(v0) => {
19165 + state.write_u8(10u8);
19168 + Type::Slice(v0) => {
19169 + state.write_u8(11u8);
19172 + Type::TraitObject(v0) => {
19173 + state.write_u8(12u8);
19176 + Type::Tuple(v0) => {
19177 + state.write_u8(13u8);
19180 + Type::Verbatim(v0) => {
19181 + state.write_u8(14u8);
19182 + TokenStreamHelper(v0).hash(state);
19184 + _ => unreachable!(),
19188 +#[cfg(any(feature = "derive", feature = "full"))]
19189 +impl Hash for TypeArray {
19190 + fn hash<H>(&self, state: &mut H)
19194 + self.elem.hash(state);
19195 + self.len.hash(state);
19198 +#[cfg(any(feature = "derive", feature = "full"))]
19199 +impl Hash for TypeBareFn {
19200 + fn hash<H>(&self, state: &mut H)
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);
19212 +#[cfg(any(feature = "derive", feature = "full"))]
19213 +impl Hash for TypeGroup {
19214 + fn hash<H>(&self, state: &mut H)
19218 + self.elem.hash(state);
19221 +#[cfg(any(feature = "derive", feature = "full"))]
19222 +impl Hash for TypeImplTrait {
19223 + fn hash<H>(&self, state: &mut H)
19227 + self.bounds.hash(state);
19230 +#[cfg(any(feature = "derive", feature = "full"))]
19231 +impl Hash for TypeInfer {
19232 + fn hash<H>(&self, _state: &mut H)
19238 +#[cfg(any(feature = "derive", feature = "full"))]
19239 +impl Hash for TypeMacro {
19240 + fn hash<H>(&self, state: &mut H)
19244 + self.mac.hash(state);
19247 +#[cfg(any(feature = "derive", feature = "full"))]
19248 +impl Hash for TypeNever {
19249 + fn hash<H>(&self, _state: &mut H)
19255 +#[cfg(any(feature = "derive", feature = "full"))]
19256 +impl Hash for TypeParam {
19257 + fn hash<H>(&self, state: &mut H)
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);
19269 +#[cfg(any(feature = "derive", feature = "full"))]
19270 +impl Hash for TypeParamBound {
19271 + fn hash<H>(&self, state: &mut H)
19276 + TypeParamBound::Trait(v0) => {
19277 + state.write_u8(0u8);
19280 + TypeParamBound::Lifetime(v0) => {
19281 + state.write_u8(1u8);
19287 +#[cfg(any(feature = "derive", feature = "full"))]
19288 +impl Hash for TypeParen {
19289 + fn hash<H>(&self, state: &mut H)
19293 + self.elem.hash(state);
19296 +#[cfg(any(feature = "derive", feature = "full"))]
19297 +impl Hash for TypePath {
19298 + fn hash<H>(&self, state: &mut H)
19302 + self.qself.hash(state);
19303 + self.path.hash(state);
19306 +#[cfg(any(feature = "derive", feature = "full"))]
19307 +impl Hash for TypePtr {
19308 + fn hash<H>(&self, state: &mut H)
19312 + self.const_token.hash(state);
19313 + self.mutability.hash(state);
19314 + self.elem.hash(state);
19317 +#[cfg(any(feature = "derive", feature = "full"))]
19318 +impl Hash for TypeReference {
19319 + fn hash<H>(&self, state: &mut H)
19323 + self.lifetime.hash(state);
19324 + self.mutability.hash(state);
19325 + self.elem.hash(state);
19328 +#[cfg(any(feature = "derive", feature = "full"))]
19329 +impl Hash for TypeSlice {
19330 + fn hash<H>(&self, state: &mut H)
19334 + self.elem.hash(state);
19337 +#[cfg(any(feature = "derive", feature = "full"))]
19338 +impl Hash for TypeTraitObject {
19339 + fn hash<H>(&self, state: &mut H)
19343 + self.dyn_token.hash(state);
19344 + self.bounds.hash(state);
19347 +#[cfg(any(feature = "derive", feature = "full"))]
19348 +impl Hash for TypeTuple {
19349 + fn hash<H>(&self, state: &mut H)
19353 + self.elems.hash(state);
19356 +#[cfg(any(feature = "derive", feature = "full"))]
19357 +impl Hash for UnOp {
19358 + fn hash<H>(&self, state: &mut H)
19363 + UnOp::Deref(_) => {
19364 + state.write_u8(0u8);
19366 + UnOp::Not(_) => {
19367 + state.write_u8(1u8);
19369 + UnOp::Neg(_) => {
19370 + state.write_u8(2u8);
19375 +#[cfg(feature = "full")]
19376 +impl Hash for UseGlob {
19377 + fn hash<H>(&self, _state: &mut H)
19383 +#[cfg(feature = "full")]
19384 +impl Hash for UseGroup {
19385 + fn hash<H>(&self, state: &mut H)
19389 + self.items.hash(state);
19392 +#[cfg(feature = "full")]
19393 +impl Hash for UseName {
19394 + fn hash<H>(&self, state: &mut H)
19398 + self.ident.hash(state);
19401 +#[cfg(feature = "full")]
19402 +impl Hash for UsePath {
19403 + fn hash<H>(&self, state: &mut H)
19407 + self.ident.hash(state);
19408 + self.tree.hash(state);
19411 +#[cfg(feature = "full")]
19412 +impl Hash for UseRename {
19413 + fn hash<H>(&self, state: &mut H)
19417 + self.ident.hash(state);
19418 + self.rename.hash(state);
19421 +#[cfg(feature = "full")]
19422 +impl Hash for UseTree {
19423 + fn hash<H>(&self, state: &mut H)
19428 + UseTree::Path(v0) => {
19429 + state.write_u8(0u8);
19432 + UseTree::Name(v0) => {
19433 + state.write_u8(1u8);
19436 + UseTree::Rename(v0) => {
19437 + state.write_u8(2u8);
19440 + UseTree::Glob(v0) => {
19441 + state.write_u8(3u8);
19444 + UseTree::Group(v0) => {
19445 + state.write_u8(4u8);
19451 +#[cfg(any(feature = "derive", feature = "full"))]
19452 +impl Hash for Variadic {
19453 + fn hash<H>(&self, state: &mut H)
19457 + self.attrs.hash(state);
19460 +#[cfg(any(feature = "derive", feature = "full"))]
19461 +impl Hash for Variant {
19462 + fn hash<H>(&self, state: &mut H)
19466 + self.attrs.hash(state);
19467 + self.ident.hash(state);
19468 + self.fields.hash(state);
19469 + self.discriminant.hash(state);
19472 +#[cfg(any(feature = "derive", feature = "full"))]
19473 +impl Hash for VisCrate {
19474 + fn hash<H>(&self, _state: &mut H)
19480 +#[cfg(any(feature = "derive", feature = "full"))]
19481 +impl Hash for VisPublic {
19482 + fn hash<H>(&self, _state: &mut H)
19488 +#[cfg(any(feature = "derive", feature = "full"))]
19489 +impl Hash for VisRestricted {
19490 + fn hash<H>(&self, state: &mut H)
19494 + self.in_token.hash(state);
19495 + self.path.hash(state);
19498 +#[cfg(any(feature = "derive", feature = "full"))]
19499 +impl Hash for Visibility {
19500 + fn hash<H>(&self, state: &mut H)
19505 + Visibility::Public(v0) => {
19506 + state.write_u8(0u8);
19509 + Visibility::Crate(v0) => {
19510 + state.write_u8(1u8);
19513 + Visibility::Restricted(v0) => {
19514 + state.write_u8(2u8);
19517 + Visibility::Inherited => {
19518 + state.write_u8(3u8);
19523 +#[cfg(any(feature = "derive", feature = "full"))]
19524 +impl Hash for WhereClause {
19525 + fn hash<H>(&self, state: &mut H)
19529 + self.predicates.hash(state);
19532 +#[cfg(any(feature = "derive", feature = "full"))]
19533 +impl Hash for WherePredicate {
19534 + fn hash<H>(&self, state: &mut H)
19539 + WherePredicate::Type(v0) => {
19540 + state.write_u8(0u8);
19543 + WherePredicate::Lifetime(v0) => {
19544 + state.write_u8(1u8);
19547 + WherePredicate::Eq(v0) => {
19548 + state.write_u8(2u8);
19554 diff --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 {
19560 #[cfg(all(feature = "derive", not(feature = "full")))]
19561 macro_rules! full {
19566 -#[cfg(any(feature = "full", feature = "derive"))]
19567 macro_rules! skip {
19568 ($($tt:tt)*) => {};
19570 /// Syntax tree traversal to walk a shared borrow of a syntax tree.
19572 /// See the [module documentation] for details.
19574 /// [module documentation]: self
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) {
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> {
19588 fn visit_lifetime(&mut self, i: &'ast Lifetime) {
19589 visit_lifetime(self, i)
19591 #[cfg(any(feature = "derive", feature = "full"))]
19592 fn visit_lifetime_def(&mut self, i: &'ast LifetimeDef) {
19593 visit_lifetime_def(self, i)
19595 - #[cfg(any(feature = "derive", feature = "full"))]
19596 fn visit_lit(&mut self, i: &'ast Lit) {
19599 - #[cfg(any(feature = "derive", feature = "full"))]
19600 fn visit_lit_bool(&mut self, i: &'ast LitBool) {
19601 visit_lit_bool(self, i)
19603 - #[cfg(any(feature = "derive", feature = "full"))]
19604 fn visit_lit_byte(&mut self, i: &'ast LitByte) {
19605 visit_lit_byte(self, i)
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)
19611 - #[cfg(any(feature = "derive", feature = "full"))]
19612 fn visit_lit_char(&mut self, i: &'ast LitChar) {
19613 visit_lit_char(self, i)
19615 - #[cfg(any(feature = "derive", feature = "full"))]
19616 fn visit_lit_float(&mut self, i: &'ast LitFloat) {
19617 visit_lit_float(self, i)
19619 - #[cfg(any(feature = "derive", feature = "full"))]
19620 fn visit_lit_int(&mut self, i: &'ast LitInt) {
19621 visit_lit_int(self, i)
19623 - #[cfg(any(feature = "derive", feature = "full"))]
19624 fn visit_lit_str(&mut self, i: &'ast LitStr) {
19625 visit_lit_str(self, i)
19627 #[cfg(feature = "full")]
19628 fn visit_local(&mut self, i: &'ast Local) {
19629 visit_local(self, i)
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);
19641 -#[cfg(any(feature = "derive", feature = "full"))]
19642 pub fn visit_lit<'ast, V>(v: &mut V, node: &'ast Lit)
19644 V: Visit<'ast> + ?Sized,
19647 Lit::Str(_binding_0) => {
19648 v.visit_lit_str(_binding_0);
19650 @@ -2564,55 +2554,48 @@ where
19651 Lit::Bool(_binding_0) => {
19652 v.visit_lit_bool(_binding_0);
19654 Lit::Verbatim(_binding_0) => {
19659 -#[cfg(any(feature = "derive", feature = "full"))]
19660 pub fn visit_lit_bool<'ast, V>(v: &mut V, node: &'ast LitBool)
19662 V: Visit<'ast> + ?Sized,
19665 v.visit_span(&node.span);
19667 -#[cfg(any(feature = "derive", feature = "full"))]
19668 pub fn visit_lit_byte<'ast, V>(v: &mut V, node: &'ast LitByte)
19670 V: Visit<'ast> + ?Sized,
19673 -#[cfg(any(feature = "derive", feature = "full"))]
19674 pub fn visit_lit_byte_str<'ast, V>(v: &mut V, node: &'ast LitByteStr)
19676 V: Visit<'ast> + ?Sized,
19679 -#[cfg(any(feature = "derive", feature = "full"))]
19680 pub fn visit_lit_char<'ast, V>(v: &mut V, node: &'ast LitChar)
19682 V: Visit<'ast> + ?Sized,
19685 -#[cfg(any(feature = "derive", feature = "full"))]
19686 pub fn visit_lit_float<'ast, V>(v: &mut V, node: &'ast LitFloat)
19688 V: Visit<'ast> + ?Sized,
19691 -#[cfg(any(feature = "derive", feature = "full"))]
19692 pub fn visit_lit_int<'ast, V>(v: &mut V, node: &'ast LitInt)
19694 V: Visit<'ast> + ?Sized,
19697 -#[cfg(any(feature = "derive", feature = "full"))]
19698 pub fn visit_lit_str<'ast, V>(v: &mut V, node: &'ast LitStr)
19700 V: Visit<'ast> + ?Sized,
19703 #[cfg(feature = "full")]
19704 pub fn visit_local<'ast, V>(v: &mut V, node: &'ast Local)
19706 diff --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 {
19712 #[cfg(all(feature = "derive", not(feature = "full")))]
19713 macro_rules! full {
19718 -#[cfg(any(feature = "full", feature = "derive"))]
19719 macro_rules! skip {
19720 ($($tt:tt)*) => {};
19722 /// Syntax tree traversal to mutate an exclusive borrow of a syntax tree in
19725 /// See the [module documentation] for details.
19727 /// [module documentation]: self
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)
19736 #[cfg(any(feature = "derive", feature = "full"))]
19737 fn visit_angle_bracketed_generic_arguments_mut(
19739 @@ -433,45 +432,37 @@ pub trait VisitMut {
19741 fn visit_lifetime_mut(&mut self, i: &mut Lifetime) {
19742 visit_lifetime_mut(self, i)
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)
19748 - #[cfg(any(feature = "derive", feature = "full"))]
19749 fn visit_lit_mut(&mut self, i: &mut Lit) {
19750 visit_lit_mut(self, i)
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)
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)
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)
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)
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)
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)
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)
19780 #[cfg(feature = "full")]
19781 fn visit_local_mut(&mut self, i: &mut Local) {
19782 visit_local_mut(self, i)
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);
19794 -#[cfg(any(feature = "derive", feature = "full"))]
19795 pub fn visit_lit_mut<V>(v: &mut V, node: &mut Lit)
19797 V: VisitMut + ?Sized,
19800 Lit::Str(_binding_0) => {
19801 v.visit_lit_str_mut(_binding_0);
19803 @@ -2570,55 +2560,48 @@ where
19804 Lit::Bool(_binding_0) => {
19805 v.visit_lit_bool_mut(_binding_0);
19807 Lit::Verbatim(_binding_0) => {
19812 -#[cfg(any(feature = "derive", feature = "full"))]
19813 pub fn visit_lit_bool_mut<V>(v: &mut V, node: &mut LitBool)
19815 V: VisitMut + ?Sized,
19818 v.visit_span_mut(&mut node.span);
19820 -#[cfg(any(feature = "derive", feature = "full"))]
19821 pub fn visit_lit_byte_mut<V>(v: &mut V, node: &mut LitByte)
19823 V: VisitMut + ?Sized,
19826 -#[cfg(any(feature = "derive", feature = "full"))]
19827 pub fn visit_lit_byte_str_mut<V>(v: &mut V, node: &mut LitByteStr)
19829 V: VisitMut + ?Sized,
19832 -#[cfg(any(feature = "derive", feature = "full"))]
19833 pub fn visit_lit_char_mut<V>(v: &mut V, node: &mut LitChar)
19835 V: VisitMut + ?Sized,
19838 -#[cfg(any(feature = "derive", feature = "full"))]
19839 pub fn visit_lit_float_mut<V>(v: &mut V, node: &mut LitFloat)
19841 V: VisitMut + ?Sized,
19844 -#[cfg(any(feature = "derive", feature = "full"))]
19845 pub fn visit_lit_int_mut<V>(v: &mut V, node: &mut LitInt)
19847 V: VisitMut + ?Sized,
19850 -#[cfg(any(feature = "derive", feature = "full"))]
19851 pub fn visit_lit_str_mut<V>(v: &mut V, node: &mut LitStr)
19853 V: VisitMut + ?Sized,
19856 #[cfg(feature = "full")]
19857 pub fn visit_local_mut<V>(v: &mut V, node: &mut Local)
19859 diff --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
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};
19871 /// Lifetimes and type parameters attached to a declaration of a function,
19872 /// enum, trait, etc.
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"`
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>,
19886 ast_enum_of_structs! {
19887 /// A generic type parameter, lifetime, or const generic: `T: Into<String>`,
19888 /// `'a: 'b`, `const LEN: usize`.
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"`
19894 /// # Syntax tree enum
19896 /// This type is a [syntax tree enum].
19898 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
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>`.
19906 /// A lifetime definition: `'a: 'b + 'c + 'd`.
19907 Lifetime(LifetimeDef),
19909 /// A const generic parameter: `const LENGTH: usize`.
19915 /// A generic type parameter: `T: Into<String>`.
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>,
19923 pub colon_token: Option<Token![:]>,
19924 pub bounds: Punctuated<TypeParamBound, Token![+]>,
19925 pub eq_token: Option<Token![=]>,
19926 pub default: Option<Type>,
19931 /// A lifetime definition: `'a: 'b + 'c + 'd`.
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![+]>,
19945 /// A const generic parameter: `const LENGTH: usize`.
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],
19954 pub colon_token: Token![:],
19956 pub eq_token: Option<Token![=]>,
19957 pub default: Option<Expr>,
19961 +impl Default for Generics {
19962 + fn default() -> Self {
19965 + params: Punctuated::new(),
19967 + where_clause: None,
19975 /// style="padding-right:0;">Iterator<Item = &</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;">></code>
19979 /// over the type parameters in `self.params`.
19980 @@ -275,100 +286,148 @@ impl<'a> Iterator for ConstParamsMut<'a>
19987 /// Returned by `Generics::split_for_impl`.
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);
19997 /// Returned by `Generics::split_for_impl`.
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);
20007 /// Returned by `TypeGenerics::as_turbofish`.
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);
20017 #[cfg(feature = "printing")]
20019 /// Split a type's generics into the pieces required for impl'ing a trait
20023 /// # use proc_macro2::{Span, Ident};
20024 /// # use quote::quote;
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());
20032 /// let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
20034 /// impl #impl_generics MyTrait for #name #ty_generics #where_clause {
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>) {
20048 ImplGenerics(self),
20049 TypeGenerics(self),
20050 self.where_clause.as_ref(),
20055 #[cfg(feature = "printing")]
20056 +macro_rules! generics_wrapper_impls {
20058 + #[cfg(feature = "clone-impls")]
20059 + impl<'a> Clone for $ty<'a> {
20060 + fn clone(&self) -> Self {
20065 + #[cfg(feature = "extra-traits")]
20066 + impl<'a> Debug for $ty<'a> {
20067 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
20069 + .debug_tuple(stringify!($ty))
20075 + #[cfg(feature = "extra-traits")]
20076 + impl<'a> Eq for $ty<'a> {}
20078 + #[cfg(feature = "extra-traits")]
20079 + impl<'a> PartialEq for $ty<'a> {
20080 + fn eq(&self, other: &Self) -> bool {
20081 + self.0 == other.0
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);
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);
20101 +#[cfg(feature = "printing")]
20102 impl<'a> TypeGenerics<'a> {
20103 /// Turn a type's generics like `<X, Y>` into a turbofish like `::<X, Y>`.
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 {
20114 /// A set of bound lifetimes: `for<'a, 'b, 'c>`.
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"`
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![>],
20128 +impl Default for BoundLifetimes {
20129 + fn default() -> Self {
20131 + for_token: Default::default(),
20132 + lt_token: Default::default(),
20133 + lifetimes: Punctuated::new(),
20134 + gt_token: Default::default(),
20140 pub fn new(lifetime: Lifetime) -> Self {
20145 bounds: Punctuated::new(),
20147 @@ -386,122 +445,118 @@ impl From<Ident> for TypeParam {
20153 ast_enum_of_structs! {
20154 /// A trait or lifetime used as a bound on a type parameter.
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"`
20159 pub enum TypeParamBound {
20161 Lifetime(Lifetime),
20166 /// A trait used as a bound on a type parameter.
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"`
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>`
20182 /// A modifier on a trait bound, currently only used for the `?` in
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"`
20188 - #[cfg_attr(feature = "clone-impls", derive(Copy))]
20189 pub enum TraitBoundModifier {
20196 /// A `where` clause in a definition: `where T: Deserialize<'de>, D:
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"`
20202 pub struct WhereClause {
20203 pub where_token: Token![where],
20204 pub predicates: Punctuated<WherePredicate, Token![,]>,
20208 ast_enum_of_structs! {
20209 /// A single predicate in a `where` clause: `T: Deserialize<'de>`.
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"`
20215 /// # Syntax tree enum
20217 /// This type is a [syntax tree enum].
20219 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
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),
20227 /// A lifetime predicate in a `where` clause: `'a: 'b + 'c`.
20228 Lifetime(PredicateLifetime),
20230 /// An equality predicate in a `where` clause (unsupported).
20236 /// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`.
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![+]>,
20253 /// A lifetime predicate in a `where` clause: `'a: 'b + 'c`.
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![+]>,
20266 /// An equality predicate in a `where` clause (unsupported).
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 {
20273 pub eq_token: Token![=],
20278 @@ -516,38 +571,36 @@ pub mod parsing {
20279 if !input.peek(Token![<]) {
20280 return Ok(Generics::default());
20283 let lt_token: Token![<] = input.parse()?;
20285 let mut params = Punctuated::new();
20286 let mut allow_lifetime_param = true;
20287 - let mut allow_type_param = true;
20289 if input.peek(Token![>]) {
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 {
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 {
20307 } else if lookahead.peek(Token![const]) {
20308 allow_lifetime_param = false;
20309 - allow_type_param = false;
20310 params.push_value(GenericParam::Const(ConstParam {
20315 return Err(lookahead.error());
20318 @@ -660,67 +713,63 @@ pub mod parsing {
20325 impl Parse for TypeParam {
20326 fn parse(input: ParseStream) -> Result<Self> {
20330 - attrs: input.call(Attribute::parse_outer)?,
20331 - ident: input.parse()?,
20333 - if input.peek(Token![:]) {
20334 - has_colon = true;
20335 - Some(input.parse()?)
20337 - has_colon = false;
20339 + let attrs = input.call(Attribute::parse_outer)?;
20340 + let ident: Ident = input.parse()?;
20341 + let colon_token: Option<Token![:]> = input.parse()?;
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() {
20348 + if input.peek(Token![,]) || input.peek(Token![>]) || input.peek(Token![=]) {
20351 + if input.peek(Token![?]) && input.peek2(Token![const]) {
20352 + input.parse::<Token![?]>()?;
20353 + input.parse::<Token![const]>()?;
20354 + is_maybe_const = true;
20356 + let value: TypeParamBound = input.parse()?;
20357 + bounds.push_value(value);
20358 + if !input.peek(Token![+]) {
20363 - let mut bounds = Punctuated::new();
20366 - if input.peek(Token![,])
20367 - || input.peek(Token![>])
20368 - || input.peek(Token![=])
20372 - let value = input.parse()?;
20373 - bounds.push_value(value);
20374 - if !input.peek(Token![+]) {
20377 - let punct = input.parse()?;
20378 - bounds.push_punct(punct);
20384 - if input.peek(Token![=]) {
20385 - has_default = true;
20386 - Some(input.parse()?)
20388 - has_default = false;
20394 - Some(input.parse()?)
20399 + let punct: Token![+] = input.parse()?;
20400 + bounds.push_punct(punct);
20404 + let mut eq_token: Option<Token![=]> = input.parse()?;
20405 + let mut default = if eq_token.is_some() {
20406 + Some(input.parse::<Type>()?)
20411 + if is_maybe_const {
20414 + default = Some(Type::Verbatim(verbatim::between(begin_bound, input)));
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 {
20436 #[cfg(feature = "printing")]
20440 use proc_macro2::TokenStream;
20441 + #[cfg(feature = "full")]
20442 + use proc_macro2::TokenTree;
20443 use quote::{ToTokens, TokenStreamExt};
20445 use crate::attr::FilterAttrs;
20446 use crate::print::TokensOrDefault;
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);
20460 - if self.default.is_some() {
20461 + if let Some(default) = &self.default {
20462 + #[cfg(feature = "full")]
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" =>
20471 + return default.to_tokens(tokens);
20478 TokensOrDefault(&self.eq_token).to_tokens(tokens);
20479 - self.default.to_tokens(tokens);
20480 + default.to_tokens(tokens);
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 {
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);
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);
20511 diff --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
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;
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")]
20528 ast_enum_of_structs! {
20529 /// Things that can appear directly inside of a module or scope.
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.*
20534 /// # Syntax tree enum
20536 /// This type is a [syntax tree enum].
20538 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
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 {
20544 /// A constant item: `const MAX: u16 = 65535`.
20547 /// An enum definition: `enum Foo<A, B> { A(A), B(B) }`.
20550 /// An `extern crate` item: `extern crate serde`.
20551 ExternCrate(ItemExternCrate),
20552 @@ -78,90 +76,90 @@ ast_enum_of_structs! {
20559 /// A constant item: `const MAX: u16 = 65535`.
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],
20568 pub colon_token: Token![:],
20570 pub eq_token: Token![=],
20571 pub expr: Box<Expr>,
20572 pub semi_token: Token![;],
20577 /// An enum definition: `enum Foo<A, B> { A(A), B(B) }`.
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],
20586 pub generics: Generics,
20587 pub brace_token: token::Brace,
20588 pub variants: Punctuated<Variant, Token![,]>,
20593 /// An `extern crate` item: `extern crate serde`.
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],
20603 pub rename: Option<(Token![as], Ident)>,
20604 pub semi_token: Token![;],
20609 /// A free-standing function: `fn process(n: usize) -> Result<()> { ...
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>,
20623 /// A block of foreign items: `extern "C" { ... }`.
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>,
20630 pub brace_token: token::Brace,
20631 pub items: Vec<ForeignItem>,
20636 /// An impl block providing trait or associated items: `impl<A> Trait
20637 /// for Data<A> { ... }`.
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>,
20656 /// A macro invocation, which includes `macro_rules!` definitions.
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>,
20665 pub semi_token: Option<Token![;]>,
20670 /// A 2.0-style declarative macro introduced by the `macro` keyword.
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],
20680 pub rules: TokenStream,
20685 /// A module or module declaration: `mod m` or `mod m { ... }`.
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],
20694 pub content: Option<(token::Brace, Vec<Item>)>,
20695 pub semi: Option<Token![;]>,
20700 /// A static item: `static BIKE: Shed = Shed(42)`.
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]>,
20710 pub colon_token: Token![:],
20712 @@ -228,32 +226,32 @@ ast_struct! {
20713 pub expr: Box<Expr>,
20714 pub semi_token: Token![;],
20719 /// A struct definition: `struct Foo<A> { x: A }`.
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],
20728 pub generics: Generics,
20729 pub fields: Fields,
20730 pub semi_token: Option<Token![;]>,
20735 /// A trait definition: `pub trait Iterator { ... }`.
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],
20746 pub generics: Generics,
20747 @@ -262,212 +260,99 @@ ast_struct! {
20748 pub brace_token: token::Brace,
20749 pub items: Vec<TraitItem>,
20754 /// A trait alias: `pub trait SharableIterator = Iterator + Sync`.
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],
20763 pub generics: Generics,
20764 pub eq_token: Token![=],
20765 pub bounds: Punctuated<TypeParamBound, Token![+]>,
20766 pub semi_token: Token![;],
20771 /// A type alias: `type Result<T> = std::result::Result<T, MyError>`.
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],
20780 pub generics: Generics,
20781 pub eq_token: Token![=],
20783 pub semi_token: Token![;],
20788 /// A union definition: `union Foo<A, B> { x: A, y: B }`.
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],
20797 pub generics: Generics,
20798 pub fields: FieldsNamed,
20803 /// A use declaration: `use std::collections::HashMap`.
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![::]>,
20813 pub semi_token: Token![;],
20817 -#[cfg(feature = "extra-traits")]
20818 -impl Eq for Item {}
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)
20848 -#[cfg(feature = "extra-traits")]
20849 -impl Hash for Item {
20850 - fn hash<H>(&self, state: &mut H)
20855 + #[cfg(feature = "parsing")]
20856 + pub(crate) fn replace_attrs(&mut self, new: Vec<Attribute>) -> Vec<Attribute> {
20858 - Item::Const(item) => {
20859 - state.write_u8(0);
20860 - item.hash(state);
20862 - Item::Enum(item) => {
20863 - state.write_u8(1);
20864 - item.hash(state);
20866 - Item::ExternCrate(item) => {
20867 - state.write_u8(2);
20868 - item.hash(state);
20870 - Item::Fn(item) => {
20871 - state.write_u8(3);
20872 - item.hash(state);
20874 - Item::ForeignMod(item) => {
20875 - state.write_u8(4);
20876 - item.hash(state);
20878 - Item::Impl(item) => {
20879 - state.write_u8(5);
20880 - item.hash(state);
20882 - Item::Macro(item) => {
20883 - state.write_u8(6);
20884 - item.hash(state);
20886 - Item::Macro2(item) => {
20887 - state.write_u8(7);
20888 - item.hash(state);
20890 - Item::Mod(item) => {
20891 - state.write_u8(8);
20892 - item.hash(state);
20894 - Item::Static(item) => {
20895 - state.write_u8(9);
20896 - item.hash(state);
20898 - Item::Struct(item) => {
20899 - state.write_u8(10);
20900 - item.hash(state);
20902 - Item::Trait(item) => {
20903 - state.write_u8(11);
20904 - item.hash(state);
20906 - Item::TraitAlias(item) => {
20907 - state.write_u8(12);
20908 - item.hash(state);
20910 - Item::Type(item) => {
20911 - state.write_u8(13);
20912 - item.hash(state);
20914 - Item::Union(item) => {
20915 - state.write_u8(14);
20916 - item.hash(state);
20918 - Item::Use(item) => {
20919 - state.write_u8(15);
20920 - item.hash(state);
20922 - Item::Verbatim(item) => {
20923 - state.write_u8(16);
20924 - TokenStreamHelper(item).hash(state);
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!(),
20948 -#[cfg(feature = "extra-traits")]
20949 -impl Eq for ItemMacro2 {}
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)
20962 -#[cfg(feature = "extra-traits")]
20963 -impl Hash for ItemMacro2 {
20964 - fn hash<H>(&self, state: &mut H)
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);
20976 impl From<DeriveInput> for Item {
20977 fn from(input: DeriveInput) -> Item {
20979 Data::Struct(data) => Item::Struct(ItemStruct {
20980 attrs: input.attrs,
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,
20993 +impl From<ItemStruct> for DeriveInput {
20994 + fn from(input: ItemStruct) -> DeriveInput {
20996 + attrs: input.attrs,
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,
21009 +impl From<ItemEnum> for DeriveInput {
21010 + fn from(input: ItemEnum) -> DeriveInput {
21012 + attrs: input.attrs,
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,
21025 +impl From<ItemUnion> for DeriveInput {
21026 + fn from(input: ItemUnion) -> DeriveInput {
21028 + attrs: input.attrs,
21030 + ident: input.ident,
21031 + generics: input.generics,
21032 + data: Data::Union(DataUnion {
21033 + union_token: input.union_token,
21034 + fields: input.fields,
21040 ast_enum_of_structs! {
21041 /// A suffix of an import tree in a `use` item: `Type as Renamed` or `*`.
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.*
21046 /// # Syntax tree enum
21048 /// This type is a [syntax tree enum].
21050 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
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}`.
21060 /// A path prefix of imports in a `use` item: `std::...`.
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 {
21066 pub colon2_token: Token![::],
21067 pub tree: Box<UseTree>,
21072 /// An identifier imported by a `use` item: `HashMap`.
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 {
21082 /// An renamed identifier imported by a `use` item: `HashMap as Map`.
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 {
21088 pub as_token: Token![as],
21094 /// A glob import in a `use` item: `*`.
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![*],
21104 /// A braced group of imports in a `use` item: `{A, B, C}`.
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![,]>,
21114 ast_enum_of_structs! {
21115 /// An item within an `extern` block.
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.*
21120 /// # Syntax tree enum
21122 /// This type is a [syntax tree enum].
21124 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
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.
21133 /// A foreign static item in an `extern` block: `static ext: u8`.
21134 Static(ForeignItemStatic),
21136 /// A foreign type in an `extern` block: `type void`.
21137 Type(ForeignItemType),
21138 @@ -609,130 +541,79 @@ ast_enum_of_structs! {
21145 /// A foreign function in an `extern` block.
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![;],
21158 /// A foreign static item in an `extern` block: `static ext: u8`.
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]>,
21168 pub colon_token: Token![:],
21170 pub semi_token: Token![;],
21175 /// A foreign type in an `extern` block: `type void`.
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],
21184 pub semi_token: Token![;],
21189 /// A macro invocation within an extern block.
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>,
21196 pub semi_token: Option<Token![;]>,
21200 -#[cfg(feature = "extra-traits")]
21201 -impl Eq for ForeignItem {}
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)
21219 -#[cfg(feature = "extra-traits")]
21220 -impl Hash for ForeignItem {
21221 - fn hash<H>(&self, state: &mut H)
21226 - ForeignItem::Fn(item) => {
21227 - state.write_u8(0);
21228 - item.hash(state);
21230 - ForeignItem::Static(item) => {
21231 - state.write_u8(1);
21232 - item.hash(state);
21234 - ForeignItem::Type(item) => {
21235 - state.write_u8(2);
21236 - item.hash(state);
21238 - ForeignItem::Macro(item) => {
21239 - state.write_u8(3);
21240 - item.hash(state);
21242 - ForeignItem::Verbatim(item) => {
21243 - state.write_u8(4);
21244 - TokenStreamHelper(item).hash(state);
21246 - ForeignItem::__Nonexhaustive => unreachable!(),
21251 ast_enum_of_structs! {
21252 /// An item declaration within the definition of a trait.
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.*
21257 /// # Syntax tree enum
21259 /// This type is a [syntax tree enum].
21261 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
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),
21270 /// A trait method within the definition of a trait.
21271 Method(TraitItemMethod),
21273 /// An associated type within the definition of a trait.
21274 Type(TraitItemType),
21275 @@ -746,132 +627,81 @@ ast_enum_of_structs! {
21282 /// An associated constant within the definition of a trait.
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],
21290 pub colon_token: Token![:],
21292 pub default: Option<(Token![=], Expr)>,
21293 pub semi_token: Token![;],
21298 /// A trait method within the definition of a trait.
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![;]>,
21311 /// An associated type within the definition of a trait.
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],
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![;],
21328 /// A macro invocation within the definition of a trait.
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>,
21335 pub semi_token: Option<Token![;]>,
21339 -#[cfg(feature = "extra-traits")]
21340 -impl Eq for TraitItem {}
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)
21358 -#[cfg(feature = "extra-traits")]
21359 -impl Hash for TraitItem {
21360 - fn hash<H>(&self, state: &mut H)
21365 - TraitItem::Const(item) => {
21366 - state.write_u8(0);
21367 - item.hash(state);
21369 - TraitItem::Method(item) => {
21370 - state.write_u8(1);
21371 - item.hash(state);
21373 - TraitItem::Type(item) => {
21374 - state.write_u8(2);
21375 - item.hash(state);
21377 - TraitItem::Macro(item) => {
21378 - state.write_u8(3);
21379 - item.hash(state);
21381 - TraitItem::Verbatim(item) => {
21382 - state.write_u8(4);
21383 - TokenStreamHelper(item).hash(state);
21385 - TraitItem::__Nonexhaustive => unreachable!(),
21390 ast_enum_of_structs! {
21391 /// An item within an impl block.
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.*
21396 /// # Syntax tree enum
21398 /// This type is a [syntax tree enum].
21400 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
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),
21409 /// A method within an impl block.
21410 Method(ImplItemMethod),
21412 /// An associated type within an impl block.
21413 Type(ImplItemType),
21414 @@ -885,17 +715,17 @@ ast_enum_of_structs! {
21421 /// An associated constant within an impl block.
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],
21431 pub colon_token: Token![:],
21433 @@ -903,144 +733,117 @@ ast_struct! {
21435 pub semi_token: Token![;],
21440 /// A method within an impl block.
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,
21454 /// An associated type within an impl block.
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],
21464 pub generics: Generics,
21465 pub eq_token: Token![=],
21467 pub semi_token: Token![;],
21472 /// A macro invocation within an impl block.
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>,
21479 pub semi_token: Option<Token![;]>,
21483 -#[cfg(feature = "extra-traits")]
21484 -impl Eq for ImplItem {}
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)
21502 -#[cfg(feature = "extra-traits")]
21503 -impl Hash for ImplItem {
21504 - fn hash<H>(&self, state: &mut H)
21509 - ImplItem::Const(item) => {
21510 - state.write_u8(0);
21511 - item.hash(state);
21513 - ImplItem::Method(item) => {
21514 - state.write_u8(1);
21515 - item.hash(state);
21517 - ImplItem::Type(item) => {
21518 - state.write_u8(2);
21519 - item.hash(state);
21521 - ImplItem::Macro(item) => {
21522 - state.write_u8(3);
21523 - item.hash(state);
21525 - ImplItem::Verbatim(item) => {
21526 - state.write_u8(4);
21527 - TokenStreamHelper(item).hash(state);
21529 - ImplItem::__Nonexhaustive => unreachable!(),
21535 /// A function signature in a trait or implementation: `unsafe fn
21536 /// initialize(&self)`.
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],
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,
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()?;
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);
21573 ast_enum_of_structs! {
21574 /// An argument in a function signature: the `n: usize` in `fn f(n: usize)`.
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.*
21579 /// The `self` argument of an associated method, whether taken by value
21580 /// or by reference.
21582 + /// Note that `self` receivers with a specified type, such as `self:
21583 + /// Box<Self>`, are parsed as a `FnArg::Typed`.
21584 Receiver(Receiver),
21586 /// A function argument accepted by pattern and type.
21592 /// The `self` argument of an associated method, whether taken by value
21593 /// or by reference.
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`.
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],
21608 @@ -1051,149 +854,233 @@ impl Receiver {
21611 #[cfg(feature = "parsing")]
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};
21623 crate::custom_keyword!(existential);
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()?;
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)))
21641 + parse_rest_of_fn(input, Vec::new(), vis, sig).map(Item::Fn)
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)
21660 Err(lookahead.error())
21663 Err(lookahead.error())
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)))
21679 + Ok(Item::Static(ItemStatic {
21680 + attrs: Vec::new(),
21687 + eq_token: input.parse()?,
21688 + expr: input.parse()?,
21689 + semi_token: input.parse()?,
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])
21702 - input.parse().map(Item::Fn)
21703 + let vis = input.parse()?;
21704 + let const_token = input.parse()?;
21706 + let lookahead = input.lookahead1();
21707 + if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
21708 + input.call(Ident::parse_any)?
21710 + return Err(lookahead.error());
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)))
21719 + Ok(Item::Const(ItemConst {
21720 + attrs: Vec::new(),
21726 + eq_token: input.parse()?,
21727 + expr: input.parse()?,
21728 + semi_token: input.parse()?,
21732 Err(lookahead.error())
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])
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])
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))
21752 + Ok(Item::Verbatim(verbatim::between(begin, input)))
21755 Err(lookahead.error())
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![!])
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))
21784 + Ok(Item::Verbatim(verbatim::between(begin, input)))
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![::]))
21796 input.parse().map(Item::Macro)
21798 Err(lookahead.error())
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!(),
21822 - attrs.extend(item_attrs.drain(..));
21823 - *item_attrs = attrs;
21824 + attrs.extend(item.replace_attrs(Vec::new()));
21825 + item.replace_attrs(attrs);
21830 + struct FlexibleItemType {
21832 + defaultness: Option<Token![default]>,
21833 + type_token: Token![type],
21835 + generics: Generics,
21836 + colon_token: Option<Token![:]>,
21837 + bounds: Punctuated<TypeParamBound, Token![+]>,
21838 + ty: Option<(Token![=], Type)>,
21839 + semi_token: Token![;],
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() {
21853 + bounds.push_value(input.parse::<TypeParamBound>()?);
21854 + if input.peek(Token![where]) || input.peek(Token![=]) || input.peek(Token![;]) {
21857 + bounds.push_punct(input.parse::<Token![+]>()?);
21858 + if input.peek(Token![where]) || input.peek(Token![=]) || input.peek(Token![;]) {
21863 + generics.where_clause = input.parse()?;
21864 + let ty = if let Some(eq_token) = input.parse()? {
21865 + Some((eq_token, input.parse::<Type>()?))
21869 + let semi_token: Token![;] = input.parse()?;
21872 + Ok(FlexibleItemType {
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 {
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])
21902 let ident = input.call(Ident::parse_any)?;
21903 if input.peek(Token![::]) {
21904 Ok(UseTree::Path(UsePath {
21906 colon2_token: input.parse()?,
21907 tree: Box::new(input.parse()?),
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()?,
21918 + fn pop_variadic(args: &mut Punctuated<FnArg, Token![,]>) -> Option<Variadic> {
21919 + let trailing_punct = args.trailing_punct();
21921 + let last = match args.last_mut()? {
21922 + FnArg::Typed(last) => last,
21923 + _ => return None,
21926 + let ty = match last.ty.as_ref() {
21927 + Type::Verbatim(ty) => ty,
21928 + _ => return None,
21931 + let mut variadic = Variadic {
21932 + attrs: Vec::new(),
21933 + dots: parse2(ty.clone()).ok()?,
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());
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]);
21953 + TokenTree::Punct({
21954 + let mut dot = Punct::new('.', Spacing::Joint);
21955 + dot.set_span(dots.spans[1]);
21958 + TokenTree::Punct({
21959 + let mut dot = Punct::new('.', Spacing::Alone);
21960 + dot.set_span(dots.spans[2]);
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])
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()?;
21985 + let paren_token = parenthesized!(content in input);
21986 + let mut inputs = parse_fn_args(&content)?;
21987 + let variadic = pop_variadic(&mut inputs);
21989 + let output: ReturnType = input.parse()?;
21990 + let where_clause: Option<WhereClause> = input.parse()?;
22003 + generics: Generics {
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()?;
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);
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(),
22040 + let sig = parse_signature(input)?;
22041 + parse_rest_of_fn(input, outer_attrs, vis, sig)
22045 - let output: ReturnType = input.parse()?;
22046 - let where_clause: Option<WhereClause> = input.parse()?;
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>,
22057 + ) -> Result<ItemFn> {
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)?;
22064 - attrs: private::attrs(outer_attrs, inner_attrs),
22077 - generics: Generics {
22082 - block: Box::new(Block { brace_token, stmts }),
22086 + attrs: private::attrs(outer_attrs, inner_attrs),
22089 + block: Box::new(Block { brace_token, stmts }),
22093 impl Parse for FnArg {
22094 fn parse(input: ParseStream) -> Result<Self> {
22095 let attrs = input.call(Attribute::parse_outer)?;
22097 let ahead = input.fork();
22098 if let Ok(mut receiver) = ahead.parse::<Receiver>() {
22099 @@ -1486,36 +1429,89 @@ pub mod parsing {
22102 mutability: input.parse()?,
22103 self_token: input.parse()?,
22108 + fn parse_fn_args(input: ParseStream) -> Result<Punctuated<FnArg, Token![,]>> {
22109 + let mut args = Punctuated::new();
22110 + let mut has_receiver = false;
22112 + while !input.is_empty() {
22113 + let attrs = input.call(Attribute::parse_outer)?;
22115 + let arg = if let Some(dots) = input.parse::<Option<Token![...]>>()? {
22116 + FnArg::Typed(PatType {
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))),
22123 + let mut arg: FnArg = input.parse()?;
22125 + FnArg::Receiver(receiver) if has_receiver => {
22126 + return Err(Error::new(
22127 + receiver.self_token.span,
22128 + "unexpected second method receiver",
22131 + FnArg::Receiver(receiver) if !args.is_empty() => {
22132 + return Err(Error::new(
22133 + receiver.self_token.span,
22134 + "unexpected method receiver",
22137 + FnArg::Receiver(receiver) => {
22138 + has_receiver = true;
22139 + receiver.attrs = attrs;
22141 + FnArg::Typed(arg) => arg.attrs = attrs,
22145 + args.push_value(arg);
22147 + if input.is_empty() {
22151 + let comma: Token![,] = input.parse()?;
22152 + args.push_punct(comma);
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),
22170 + colon_token: Token![:](span),
22171 + ty: input.parse()?,
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![...]>>()? {
22183 - TokenTree::Punct(Punct::new('.', Spacing::Joint)),
22184 - TokenTree::Punct(Punct::new('.', Spacing::Joint)),
22185 - TokenTree::Punct(Punct::new('.', Spacing::Alone)),
22187 - let tokens = TokenStream::from_iter(args.into_iter().zip(&dot3.spans).map(
22188 - |(mut arg, span)| {
22189 - arg.set_span(*span);
22193 - Type::Verbatim(tokens)
22195 + Some(dot3) => Type::Verbatim(variadic_to_tokens(&dot3)),
22196 None => input.parse()?,
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 {
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()?;
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) {
22226 + braced!(content in input);
22227 + content.call(Attribute::parse_inner)?;
22228 + content.call(Block::parse_within)?;
22230 + Ok(ForeignItem::Verbatim(verbatim::between(begin, input)))
22232 + Ok(ForeignItem::Fn(ForeignItemFn {
22233 + attrs: Vec::new(),
22236 + semi_token: input.parse()?,
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)))
22253 + Ok(ForeignItem::Static(ForeignItemStatic {
22254 + attrs: Vec::new(),
22261 + semi_token: input.parse()?,
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![::]))
22275 input.parse().map(ForeignItem::Macro)
22277 Err(lookahead.error())
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!(),
22288 - attrs.extend(item_attrs.drain(..));
22289 - *item_attrs = attrs;
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!(),
22299 + attrs.extend(item_attrs.drain(..));
22300 + *item_attrs = attrs;
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()?;
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)?;
22321 - if let Some(dots) = content.parse()? {
22322 - variadic = Some(Variadic { attrs, dots });
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() {
22333 - inputs.push_punct(content.parse()?);
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()?;
22355 - generics: Generics {
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()?,
22378 + fn parse_foreign_item_type(begin: ParseBuffer, input: ParseStream) -> Result<ForeignItem> {
22379 + let FlexibleItemType {
22389 + } = input.parse()?;
22391 + if defaultness.is_some()
22392 + || generics.lt_token.is_some()
22393 + || generics.where_clause.is_some()
22394 + || colon_token.is_some()
22397 + Ok(ForeignItem::Verbatim(verbatim::between(begin, input)))
22399 + Ok(ForeignItem::Type(ForeignItemType {
22400 + attrs: Vec::new(),
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() {
22416 Some(input.parse()?)
22417 @@ -1737,16 +1758,46 @@ pub mod parsing {
22419 eq_token: input.parse()?,
22420 ty: input.parse()?,
22421 semi_token: input.parse()?,
22426 + fn parse_item_type(begin: ParseBuffer, input: ParseStream) -> Result<Item> {
22427 + let FlexibleItemType {
22437 + } = input.parse()?;
22439 + if defaultness.is_some() || colon_token.is_some() || ty.is_none() {
22440 + Ok(Item::Verbatim(verbatim::between(begin, input)))
22442 + let (eq_token, ty) = ty.unwrap();
22443 + Ok(Item::Type(ItemType {
22444 + attrs: Vec::new(),
22450 + ty: Box::new(ty),
22456 #[cfg(not(feature = "printing"))]
22457 fn item_existential(input: ParseStream) -> Result<TokenStream> {
22458 Err(input.error("existential type is not supported"))
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)
22467 Err(lookahead.error())
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(
22495 fn parse_rest_of_trait(
22496 input: ParseStream,
22497 - attrs: Vec<Attribute>,
22498 + outer_attrs: Vec<Attribute>,
22500 unsafety: Option<Token![unsafe]>,
22501 auto_token: Option<Token![auto]>,
22502 trait_token: Token![trait],
22504 mut generics: Generics,
22505 ) -> Result<ItemTrait> {
22506 let colon_token: Option<Token![:]> = input.parse()?;
22507 @@ -1932,23 +1983,24 @@ pub mod parsing {
22512 generics.where_clause = input.parse()?;
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()?);
22524 + attrs: private::attrs(outer_attrs, inner_attrs),
22533 @@ -2009,76 +2061,83 @@ pub mod parsing {
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();
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])
22563 input.parse().map(TraitItem::Method)
22565 Err(lookahead.error())
22567 - } else if lookahead.peek(Token![async])
22568 - || lookahead.peek(Token![unsafe])
22569 - || lookahead.peek(Token![extern])
22570 - || lookahead.peek(Token![fn])
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![::])
22583 input.parse().map(TraitItem::Macro)
22585 Err(lookahead.error())
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!(),
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))),
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!(),
22610 + attrs.extend(item_attrs.drain(..));
22611 + *item_attrs = attrs;
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()?,
22623 + let lookahead = input.lookahead1();
22624 + if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
22625 + input.call(Ident::parse_any)?
22627 + return Err(lookahead.error());
22630 colon_token: input.parse()?,
22631 ty: input.parse()?,
22633 if input.peek(Token![=]) {
22634 let eq_token: Token![=] = input.parse()?;
22635 let default: Expr = input.parse()?;
22636 Some((eq_token, default))
22638 @@ -2088,30 +2147,17 @@ pub mod parsing {
22639 semi_token: input.parse()?,
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()?;
22656 - let paren_token = parenthesized!(content in input);
22657 - let inputs = content.parse_terminated(FnArg::parse)?;
22659 - let output: ReturnType = input.parse()?;
22660 - let where_clause: Option<WhereClause> = input.parse()?;
22661 + let sig = parse_signature(input)?;
22663 let lookahead = input.lookahead1();
22664 let (brace_token, inner_attrs, stmts, semi_token) = if lookahead.peek(token::Brace) {
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))
22674 return Err(lookahead.error());
22677 Ok(TraitItemMethod {
22678 attrs: private::attrs(outer_attrs, inner_attrs),
22690 - generics: Generics {
22696 default: brace_token.map(|brace_token| Block { brace_token, stmts }),
22702 impl Parse for TraitItemType {
22703 fn parse(input: ParseStream) -> Result<Self> {
22704 @@ -2183,16 +2214,45 @@ pub mod parsing {
22713 + fn parse_trait_item_type(begin: ParseBuffer, input: ParseStream) -> Result<TraitItem> {
22714 + let FlexibleItemType {
22724 + } = input.parse()?;
22726 + if defaultness.is_some() || vis.is_some() {
22727 + Ok(TraitItem::Verbatim(verbatim::between(begin, input)))
22729 + Ok(TraitItem::Type(TraitItemType {
22730 + attrs: Vec::new(),
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() {
22749 Some(input.parse()?)
22750 @@ -2202,123 +2262,148 @@ pub mod parsing {
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)
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()?;
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 {
22784 - Generics::default()
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 {
22797 + Generics::default()
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()
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))
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]>()?;
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;
22835 + let for_token: Token![for] = ahead.parse().ok()?;
22836 + input.advance_to(&ahead);
22837 + Some((polarity, path, for_token))
22840 - let mut items = Vec::new();
22841 - while !content.is_empty() {
22842 - items.push(content.parse()?);
22844 + let self_ty: Type = input.parse()?;
22845 + let where_clause: Option<WhereClause> = input.parse()?;
22848 + let brace_token = braced!(content in input);
22849 + let inner_attrs = content.call(Attribute::parse_inner)?;
22852 + let mut items = Vec::new();
22853 + while !content.is_empty() {
22854 + items.push(content.parse()?);
22857 + if is_const_impl {
22860 + Ok(Some(ItemImpl {
22861 attrs: private::attrs(outer_attrs, inner_attrs),
22865 generics: Generics {
22870 self_ty: Box::new(self_ty),
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()?;
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();
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])
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 {
22924 + expr: input.parse()?,
22925 + semi_token: input.parse()?,
22928 + input.parse::<Token![;]>()?;
22929 + return Ok(ImplItem::Verbatim(verbatim::between(begin, input)));
22932 Err(lookahead.error())
22934 - } else if lookahead.peek(Token![unsafe])
22935 - || lookahead.peek(Token![async])
22936 - || lookahead.peek(Token![extern])
22937 - || lookahead.peek(Token![fn])
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![::]))
22954 input.parse().map(ImplItem::Macro)
22956 Err(lookahead.error())
22959 @@ -2341,72 +2426,68 @@ pub mod parsing {
22961 impl Parse for ImplItemConst {
22962 fn parse(input: ParseStream) -> Result<Self> {
22964 attrs: input.call(Attribute::parse_outer)?,
22965 vis: input.parse()?,
22966 defaultness: input.parse()?,
22967 const_token: input.parse()?,
22968 - ident: input.parse()?,
22970 + let lookahead = input.lookahead1();
22971 + if lookahead.peek(Ident) || lookahead.peek(Token![_]) {
22972 + input.call(Ident::parse_any)?
22974 + return Err(lookahead.error());
22977 colon_token: input.parse()?,
22978 ty: input.parse()?,
22979 eq_token: input.parse()?,
22980 expr: input.parse()?,
22981 semi_token: input.parse()?,
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)?;
23002 - let paren_token = parenthesized!(content in input);
23003 - let inputs = content.parse_terminated(FnArg::parse)?;
23005 - let output: ReturnType = input.parse()?;
23006 - let where_clause: Option<WhereClause> = input.parse()?;
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
23017 + let mut punct = Punct::new(';', Spacing::Alone);
23018 + punct.set_span(semi.span);
23019 + let tokens = TokenStream::from_iter(vec![TokenTree::Punct(punct)]);
23021 + brace_token: Brace::default(),
23022 + stmts: vec![Stmt::Item(Item::Verbatim(tokens))],
23026 + let brace_token = braced!(content in input);
23027 + attrs.extend(content.call(Attribute::parse_inner)?);
23030 + stmts: content.call(Block::parse_within)?,
23034 Ok(ImplItemMethod {
23035 - attrs: private::attrs(outer_attrs, inner_attrs),
23050 - generics: Generics {
23055 - block: Block { brace_token, stmts },
23062 impl Parse for ImplItemType {
23063 fn parse(input: ParseStream) -> Result<Self> {
23065 attrs: input.call(Attribute::parse_outer)?,
23066 @@ -2421,16 +2502,47 @@ pub mod parsing {
23068 eq_token: input.parse()?,
23069 ty: input.parse()?,
23070 semi_token: input.parse()?,
23075 + fn parse_impl_item_type(begin: ParseBuffer, input: ParseStream) -> Result<ImplItem> {
23076 + let FlexibleItemType {
23086 + } = input.parse()?;
23088 + if colon_token.is_some() || ty.is_none() {
23089 + Ok(ImplItem::Verbatim(verbatim::between(begin, input)))
23091 + let (eq_token, ty) = ty.unwrap();
23092 + Ok(ImplItem::Type(ImplItemType {
23093 + attrs: Vec::new(),
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() {
23113 Some(input.parse()?)
23114 @@ -2466,16 +2578,17 @@ pub mod parsing {
23118 use proc_macro2::TokenStream;
23119 use quote::{ToTokens, TokenStreamExt};
23121 use crate::attr::FilterAttrs;
23122 use crate::print::TokensOrDefault;
23123 + use crate::punctuated::Pair;
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 {
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);
23149 self.block.brace_token.surround(tokens, |tokens| {
23150 tokens.append_all(self.attrs.inner());
23151 tokens.append_all(&self.block.stmts);
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);
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);
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);
23182 + _ => arg.to_tokens(tokens),
23187 + arg.to_tokens(tokens);
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() {
23209 + Pair::Punctuated(input, comma) => {
23210 + maybe_variadic_to_tokens(input, tokens);
23211 + comma.to_tokens(tokens);
23213 + Pair::End(input) => {
23214 + last_is_variadic = maybe_variadic_to_tokens(input, tokens);
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);
23223 + self.variadic.to_tokens(tokens);
23226 self.output.to_tokens(tokens);
23227 self.generics.where_clause.to_tokens(tokens);
23231 impl ToTokens for Receiver {
23232 fn to_tokens(&self, tokens: &mut TokenStream) {
23233 diff --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
23237 +//! [![github]](https://github.com/dtolnay/syn) [![crates-io]](https://crates.io/crates/syn) [![docs-rs]](https://docs.rs/syn)
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
23245 //! Syn is a parsing library for parsing a stream of Rust tokens into a syntax
23246 //! tree of Rust source code.
23248 //! Currently this library is geared toward use in Rust procedural macros, but
23249 //! contains some APIs that may be useful more generally.
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 @@
23258 //! proc-macro = true
23262 -//! extern crate proc_macro;
23264 +//! # extern crate proc_macro;
23266 //! use proc_macro::TokenStream;
23267 //! use quote::quote;
23268 //! use syn::{parse_macro_input, DeriveInput};
23270 //! # const IGNORE_TOKENS: &str = stringify! {
23271 //! #[proc_macro_derive(MyMacro)]
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
23277 //! - **`extra-traits`** — Debug, Eq, PartialEq, Hash impls for all syntax tree
23279 //! - **`proc-macro`** *(enabled by default)* — Runtime dependency on the
23280 //! dynamic library libproc_macro from rustc toolchain.
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.
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
23307 // Ignored clippy_pedantic lints.
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,
23326 - clippy::used_underscore_binding
23327 + clippy::used_underscore_binding,
23328 + clippy::wildcard_imports
23332 not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
23333 feature = "proc-macro"
23335 extern crate proc_macro;
23336 extern crate proc_macro2;
23337 extern crate unicode_xid;
23339 #[cfg(feature = "printing")]
23340 extern crate quote;
23342 -#[cfg(any(feature = "full", feature = "derive"))]
23347 #[cfg(feature = "parsing")]
23351 @@ -302,17 +322,16 @@ pub use crate::ident::Ident;
23353 #[cfg(any(feature = "full", feature = "derive"))]
23355 #[cfg(any(feature = "full", feature = "derive"))]
23356 pub use crate::attr::{
23357 AttrStyle, Attribute, AttributeArgs, Meta, MetaList, MetaNameValue, NestedMeta,
23360 -#[cfg(any(feature = "full", feature = "derive"))]
23363 #[cfg(any(feature = "full", feature = "derive"))]
23365 #[cfg(any(feature = "full", feature = "derive"))]
23366 pub use crate::data::{
23367 Field, Fields, FieldsNamed, FieldsUnnamed, Variant, VisCrate, VisPublic, VisRestricted,
23369 @@ -359,19 +378,17 @@ pub use crate::item::{
23370 #[cfg(feature = "full")]
23372 #[cfg(feature = "full")]
23373 pub use crate::file::File;
23376 pub use crate::lifetime::Lifetime;
23378 -#[cfg(any(feature = "full", feature = "derive"))]
23380 -#[cfg(any(feature = "full", feature = "derive"))]
23381 pub use crate::lit::{
23382 Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr, StrStyle,
23385 #[cfg(any(feature = "full", feature = "derive"))]
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"
23393 pub mod parse_macro_input;
23395 #[cfg(all(feature = "parsing", feature = "printing"))]
23398 +#[cfg(all(feature = "parsing", feature = "full"))]
23402 /// Syntax tree traversal to walk a shared borrow of a syntax tree.
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.
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);
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.*
23425 /// This visitor will print the name of every freestanding function in the
23426 /// syntax tree, including nested functions.
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);
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"`
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)),
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.*
23463 /// This fold inserts parentheses to fully parenthesizes any expression.
23466 @@ -739,43 +759,63 @@ mod gen {
23468 /// // Output: (((a)()) + (((b)((1))) * ((c).d)))
23471 #[cfg(feature = "fold")]
23475 + #[cfg(feature = "clone-impls")]
23479 + #[cfg(feature = "extra-traits")]
23483 + #[cfg(feature = "extra-traits")]
23487 + #[cfg(feature = "extra-traits")]
23491 #[cfg(any(feature = "full", feature = "derive"))]
23492 #[path = "../gen_helper.rs"]
23495 pub use crate::gen::*;
23501 mod custom_keyword;
23502 mod custom_punctuation;
23507 #[cfg(feature = "parsing")]
23510 #[cfg(feature = "parsing")]
23514 +#[cfg(feature = "full")]
23517 +#[cfg(all(any(feature = "full", feature = "derive"), feature = "parsing"))]
23520 #[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))]
23525 ////////////////////////////////////////////////////////////////////////////////
23527 #[allow(dead_code, non_camel_case_types)]
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};
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.
23540 /// [`syn::parse2`]: parse2
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.*
23549 -/// extern crate proc_macro;
23551 +/// # extern crate proc_macro;
23553 /// use proc_macro::TokenStream;
23554 /// use quote::quote;
23555 /// use syn::DeriveInput;
23557 /// # const IGNORE_TOKENS: &str = stringify! {
23558 /// #[proc_macro_derive(MyMacro)]
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`]
23568 /// [`syn::parse`]: parse()
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)
23577 /// Parse a string of Rust code into the chosen syntax tree node.
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.*
23584 /// Every span in the resulting syntax tree will be set to resolve at the macro
23589 @@ -869,19 +909,17 @@ pub fn parse2<T: parse::Parse>(tokens: p
23591 /// fn run() -> Result<()> {
23592 /// let code = "assert_eq!(u8::max_value(), 255)";
23593 /// let expr = syn::parse_str::<Expr>(code)?;
23594 /// println!("{:#?}", expr);
23599 -/// # run().unwrap();
23601 +/// # run().unwrap();
23603 #[cfg(feature = "parsing")]
23604 pub fn parse_str<T: parse::Parse>(s: &str) -> Result<T> {
23605 parse::Parser::parse_str(T::parse, s)
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
23612 /// This is different from `syn::parse_str::<File>(content)` in two ways:
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`.
23617 /// If present, either of these would be an error using `from_str`.
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.*
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);
23633 /// println!("{} items", ast.items.len());
23639 -/// # run().unwrap();
23641 +/// # run().unwrap();
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()..];
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..];
23657 - shebang = Some(content.to_string());
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..];
23666 + shebang = Some(content.to_string());
23672 let mut file: File = parse_str(content)?;
23673 file.shebang = shebang;
23676 diff --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;
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
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"`
23691 -#[cfg_attr(feature = "extra-traits", derive(Debug))]
23693 pub struct Lifetime {
23694 pub apostrophe: Span,
23701 @@ -67,16 +65,25 @@ impl Lifetime {
23703 impl Display for Lifetime {
23704 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
23705 "'".fmt(formatter)?;
23706 self.ident.fmt(formatter)
23710 +impl Clone for Lifetime {
23711 + fn clone(&self) -> Self {
23713 + apostrophe: self.apostrophe,
23714 + ident: self.ident.clone(),
23719 impl PartialEq for Lifetime {
23720 fn eq(&self, other: &Lifetime) -> bool {
23721 self.ident.eq(&other.ident)
23725 impl Eq for Lifetime {}
23727 diff --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};
23736 ast_enum_of_structs! {
23737 /// A Rust literal such as a string or integer or boolean.
23739 - /// *This type is available if Syn is built with the `"derive"` or `"full"`
23742 /// # Syntax tree enum
23744 /// This type is a [syntax tree enum].
23746 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
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 {
23752 /// A UTF-8 string literal: `"foo"`.
23755 /// A byte string literal: `b"foo"`.
23756 ByteStr(LitByteStr),
23758 /// A byte literal: `b'f'`.
23760 @@ -59,184 +56,98 @@ ast_enum_of_structs! {
23762 /// A raw token literal not interpreted by Syn.
23768 /// A UTF-8 string literal: `"foo"`.
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>,
23779 -#[cfg_attr(feature = "clone-impls", derive(Clone))]
23780 -struct LitStrRepr {
23782 - suffix: Box<str>,
23786 /// A byte string literal: `b"foo"`.
23788 - /// *This type is available if Syn is built with the `"derive"` or
23789 - /// `"full"` feature.*
23790 - pub struct LitByteStr #manual_extra_traits_debug {
23792 + pub struct LitByteStr {
23793 + repr: Box<LitRepr>,
23798 /// A byte literal: `b'f'`.
23800 - /// *This type is available if Syn is built with the `"derive"` or
23801 - /// `"full"` feature.*
23802 - pub struct LitByte #manual_extra_traits_debug {
23804 + pub struct LitByte {
23805 + repr: Box<LitRepr>,
23810 /// A character literal: `'a'`.
23812 - /// *This type is available if Syn is built with the `"derive"` or
23813 - /// `"full"` feature.*
23814 - pub struct LitChar #manual_extra_traits_debug {
23816 + pub struct LitChar {
23817 + repr: Box<LitRepr>,
23823 + suffix: Box<str>,
23827 /// An integer literal: `1` or `1u16`.
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>,
23837 -#[cfg_attr(feature = "clone-impls", derive(Clone))]
23838 struct LitIntRepr {
23845 /// A floating point literal: `1f64` or `1.0e10f64`.
23847 /// Must be finite. May not be infinte or NaN.
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>,
23857 -#[cfg_attr(feature = "clone-impls", derive(Clone))]
23858 struct LitFloatRepr {
23865 /// A boolean literal: `true` or `false`.
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 {
23876 -#[cfg(feature = "extra-traits")]
23877 -impl Eq for Lit {}
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(),
23896 -#[cfg(feature = "extra-traits")]
23897 -impl Hash for Lit {
23898 - fn hash<H>(&self, hash: &mut H)
23903 - Lit::Str(lit) => {
23904 - hash.write_u8(0);
23907 - Lit::ByteStr(lit) => {
23908 - hash.write_u8(1);
23911 - Lit::Byte(lit) => {
23912 - hash.write_u8(2);
23915 - Lit::Char(lit) => {
23916 - hash.write_u8(3);
23919 - Lit::Int(lit) => {
23920 - hash.write_u8(4);
23923 - Lit::Float(lit) => {
23924 - hash.write_u8(5);
23927 - Lit::Bool(lit) => {
23928 - hash.write_u8(6);
23931 - Lit::Verbatim(lit) => {
23932 - hash.write_u8(7);
23933 - lit.to_string().hash(hash);
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);
23946 - repr: Box::new(LitStrRepr {
23948 + repr: Box::new(LitRepr {
23950 suffix: Box::<str>::default(),
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)
23962 /// Parse a syntax tree node from the content of this string literal.
23964 /// All spans in the syntax tree will point to the span of this `LitStr`.
23967 @@ -306,17 +217,17 @@ impl LitStr {
23968 .map(|token| respan_token_tree(token, span))
23972 // Token tree with every span replaced by the given one.
23973 fn respan_token_tree(mut token: TokenTree, span: Span) -> TokenTree {
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);
23981 other => other.set_span(span),
23986 @@ -340,86 +251,124 @@ impl LitStr {
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 }
23997 + repr: Box::new(LitRepr {
23999 + suffix: Box::<str>::default(),
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);
24011 pub fn span(&self) -> Span {
24012 - self.token.span()
24013 + self.repr.token.span()
24016 pub fn set_span(&mut self, span: Span) {
24017 - self.token.set_span(span)
24018 + self.repr.token.set_span(span)
24021 + pub fn suffix(&self) -> &str {
24022 + &self.repr.suffix
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 }
24032 + repr: Box::new(LitRepr {
24034 + suffix: Box::<str>::default(),
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);
24046 pub fn span(&self) -> Span {
24047 - self.token.span()
24048 + self.repr.token.span()
24051 pub fn set_span(&mut self, span: Span) {
24052 - self.token.set_span(span)
24053 + self.repr.token.set_span(span)
24056 + pub fn suffix(&self) -> &str {
24057 + &self.repr.suffix
24062 pub fn new(value: char, span: Span) -> Self {
24063 let mut token = Literal::character(value);
24064 token.set_span(span);
24065 - LitChar { token }
24067 + repr: Box::new(LitRepr {
24069 + suffix: Box::<str>::default(),
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);
24081 pub fn span(&self) -> Span {
24082 - self.token.span()
24083 + self.repr.token.span()
24086 pub fn set_span(&mut self, span: Span) {
24087 - self.token.set_span(span)
24088 + self.repr.token.set_span(span)
24091 + pub fn suffix(&self) -> &str {
24092 + &self.repr.suffix
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);
24102 - repr: Box::new(LitIntRepr {
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),
24115 + let mut token = match value::to_literal(repr, &digits, &suffix) {
24116 + Some(token) => token,
24117 + None => panic!("Unsupported integer literal: `{}`", repr),
24120 + token.set_span(span);
24122 + repr: Box::new(LitIntRepr {
24130 pub fn base10_digits(&self) -> &str {
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)
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);
24148 - repr: Box::new(LitFloatRepr {
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),
24161 + let mut token = match value::to_literal(repr, &digits, &suffix) {
24162 + Some(token) => token,
24163 + None => panic!("Unsupported float literal: `{}`", repr),
24166 + token.set_span(span);
24168 + repr: Box::new(LitFloatRepr {
24176 pub fn base10_digits(&self) -> &str {
24180 pub fn base10_parse<N>(&self) -> Result<N>
24181 @@ -570,35 +524,35 @@ mod debug_impls {
24186 impl Debug for LitByteStr {
24187 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
24189 .debug_struct("LitByteStr")
24190 - .field("token", &format_args!("{}", self.token))
24191 + .field("token", &format_args!("{}", self.repr.token))
24196 impl Debug for LitByte {
24197 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
24199 .debug_struct("LitByte")
24200 - .field("token", &format_args!("{}", self.token))
24201 + .field("token", &format_args!("{}", self.repr.token))
24206 impl Debug for LitChar {
24207 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
24209 .debug_struct("LitChar")
24210 - .field("token", &format_args!("{}", self.token))
24211 + .field("token", &format_args!("{}", self.repr.token))
24216 impl Debug for LitInt {
24217 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
24219 .debug_struct("LitInt")
24220 @@ -621,61 +575,102 @@ mod debug_impls {
24222 .debug_struct("LitBool")
24223 .field("value", &self.value)
24229 +#[cfg(feature = "clone-impls")]
24230 +impl Clone for LitRepr {
24231 + fn clone(&self) -> Self {
24233 + token: self.token.clone(),
24234 + suffix: self.suffix.clone(),
24239 +#[cfg(feature = "clone-impls")]
24240 +impl Clone for LitIntRepr {
24241 + fn clone(&self) -> Self {
24243 + token: self.token.clone(),
24244 + digits: self.digits.clone(),
24245 + suffix: self.suffix.clone(),
24250 +#[cfg(feature = "clone-impls")]
24251 +impl Clone for LitFloatRepr {
24252 + fn clone(&self) -> Self {
24254 + token: self.token.clone(),
24255 + digits: self.digits.clone(),
24256 + suffix: self.suffix.clone(),
24261 macro_rules! lit_extra_traits {
24262 - ($ty:ident, $($field:ident).+) => {
24263 - #[cfg(feature = "extra-traits")]
24264 - impl Eq for $ty {}
24266 + #[cfg(feature = "clone-impls")]
24267 + impl Clone for $ty {
24268 + fn clone(&self) -> Self {
24270 + repr: self.repr.clone(),
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()
24283 #[cfg(feature = "extra-traits")]
24284 impl Hash for $ty {
24285 fn hash<H>(&self, state: &mut H)
24289 - self.$($field).+.to_string().hash(state);
24290 + self.repr.token.to_string().hash(state);
24294 #[cfg(feature = "parsing")]
24296 #[allow(non_snake_case)]
24297 pub fn $ty(marker: lookahead::TokenMarker) -> $ty {
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);
24317 +#[cfg(feature = "parsing")]
24319 +#[allow(non_snake_case)]
24320 +pub fn LitBool(marker: lookahead::TokenMarker) -> LitBool {
24325 /// The style of a string literal, either plain quoted or a raw string like
24328 - /// *This type is available if Syn is built with the `"derive"` or `"full"`
24330 pub enum StrStyle #no_visit {
24331 /// An ordinary string like `"data"`.
24333 /// A raw string like `r##"data"##`.
24335 /// The unsigned integer is the number of `#` symbols used.
24338 @@ -686,43 +681,93 @@ ast_enum! {
24339 #[allow(non_snake_case)]
24340 pub fn Lit(marker: lookahead::TokenMarker) -> Lit {
24344 #[cfg(feature = "parsing")]
24347 + use crate::buffer::Cursor;
24348 use crate::parse::{Parse, ParseStream, Result};
24349 + use proc_macro2::Punct;
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));
24357 - while let Some((ident, rest)) = cursor.ident() {
24358 - let value = if ident == "true" {
24360 - } else if ident == "false" {
24365 - let lit_bool = LitBool {
24367 - span: ident.span(),
24369 - return Ok((Lit::Bool(lit_bool), rest));
24371 + if let Some((ident, rest)) = cursor.ident() {
24372 + let value = ident == "true";
24373 + if value || ident == "false" {
24374 + let lit_bool = LitBool {
24376 + span: ident.span(),
24378 + return Ok((Lit::Bool(lit_bool), rest));
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));
24390 Err(cursor.error("expected literal"))
24395 + fn parse_negative_lit(neg: Punct, cursor: Cursor) -> Option<(Lit, Cursor)> {
24396 + let (lit, rest) = cursor.literal()?;
24398 + let mut span = neg.span();
24399 + span = span.join(lit.span()).unwrap_or(span);
24401 + let mut repr = lit.to_string();
24402 + repr.insert(0, '-');
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);
24409 + Lit::Int(LitInt {
24410 + repr: Box::new(LitIntRepr {
24422 + let (digits, suffix) = value::parse_lit_float(&repr)?;
24423 + let mut token = value::to_literal(&repr, &digits, &suffix)?;
24424 + token.set_span(span);
24426 + Lit::Float(LitFloat {
24427 + repr: Box::new(LitFloatRepr {
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")),
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);
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);
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);
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);
24473 impl ToTokens for LitInt {
24474 fn to_tokens(&self, tokens: &mut TokenStream) {
24475 self.repr.token.to_tokens(tokens);
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();
24483 match byte(&repr, 0) {
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 }),
24491 b'b' => match byte(&repr, 1) {
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 }),
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 }),
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 }),
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 {
24522 @@ -900,16 +954,54 @@ mod value {
24529 panic!("Unrecognized literal: `{}`", repr);
24532 + pub fn suffix(&self) -> &str {
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(_) => "",
24544 + pub fn span(&self) -> Span {
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(),
24557 + pub fn set_span(&mut self, span: Span) {
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),
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();
24577 @@ -999,140 +1091,144 @@ mod value {
24578 assert_eq!(byte(s, 0), b'r');
24581 let mut pounds = 0;
24582 while byte(s, pounds) == b'#' {
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'#');
24593 - let content = s[pounds + 1..s.len() - pounds - 1]
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();
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');
24607 b'"' => parse_lit_byte_str_cooked(s),
24608 b'r' => parse_lit_byte_str_raw(s),
24609 _ => unreachable!(),
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'"');
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();
24626 let mut out = Vec::new();
24628 - let byte = match byte(s, 0) {
24629 + let byte = match byte(v, 0) {
24632 - let b = byte(s, 1);
24634 + let b = byte(v, 1);
24638 - let (b, rest) = backslash_x(s);
24640 + let (b, rest) = backslash_x(v);
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() {
24662 b => panic!("unexpected byte {:?} after \\ character in byte literal", b),
24666 - assert_eq!(byte(s, 1), b'\n', "Bare CR not allowed in string");
24668 + assert_eq!(byte(v, 1), b'\n', "Bare CR not allowed in string");
24681 - assert_eq!(s, b"\"");
24683 + assert_eq!(byte(v, 0), b'"');
24684 + let suffix = s[s.len() - v.len() + 1..].to_owned().into_boxed_str();
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)
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'\'');
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();
24706 - let b = match byte(s, 0) {
24707 + let b = match byte(v, 0) {
24709 - let b = byte(s, 1);
24711 + let b = byte(v, 1);
24715 - let (b, rest) = backslash_x(s);
24717 + let (b, rest) = backslash_x(v);
24728 b => panic!("unexpected byte {:?} after \\ character in byte literal", b),
24738 - assert_eq!(byte(s, 0), b'\'');
24740 + assert_eq!(byte(v, 0), b'\'');
24741 + let suffix = s[s.len() - v.len() + 1..].to_owned().into_boxed_str();
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'\'');
24751 let ch = match byte(s, 0) {
24753 let b = byte(s, 1);
24756 @@ -1158,18 +1254,19 @@ mod value {
24760 let ch = next_chr(s);
24761 s = &s[ch.len_utf8()..];
24765 - assert_eq!(s, "\'", "Expected end of char literal");
24767 + assert_eq!(byte(s, 0), b'\'');
24768 + let suffix = s[1..].to_owned().into_boxed_str();
24772 fn backslash_x<S>(s: &S) -> (u8, &S)
24774 S: Index<RangeFrom<usize>, Output = S> + AsRef<[u8]> + ?Sized,
24777 let b0 = byte(s, 0);
24778 @@ -1329,17 +1426,21 @@ mod value {
24779 if has_e || has_dot {
24783 bytes[write] = b'.';
24788 + if has_exponent {
24795 bytes[write] = b'e';
24798 if has_sign || has_exponent || !has_e {
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()))
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() {
24831 + } else if digits.contains('.') {
24832 + digits.parse().ok().map(Literal::f64_unsuffixed)
24834 + digits.parse().ok().map(Literal::i64_unsuffixed)
24837 + let stream = repr.parse::<TokenStream>().unwrap();
24838 + match stream.into_iter().next().unwrap() {
24839 + TokenTree::Literal(l) => Some(l),
24840 + _ => unreachable!(),
24845 diff --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
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};
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};
24864 /// A macro invocation: `println!("{}", mac)`.
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"`
24869 - pub struct Macro #manual_extra_traits {
24870 + pub struct Macro {
24872 pub bang_token: Token![!],
24873 pub delimiter: MacroDelimiter,
24874 pub tokens: TokenStream,
24879 /// A grouping token that surrounds a macro body: `m!(...)` or `m!{...}` or `m![...]`.
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"`
24884 pub enum MacroDelimiter {
24891 -#[cfg(feature = "extra-traits")]
24892 -impl Eq for Macro {}
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)
24904 -#[cfg(feature = "extra-traits")]
24905 -impl Hash for Macro {
24906 - fn hash<H>(&self, state: &mut H)
24910 - self.path.hash(state);
24911 - self.bang_token.hash(state);
24912 - self.delimiter.hash(state);
24913 - TokenStreamHelper(&self.tokens).hash(state);
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,
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,
24933 + group.span_close()
24937 /// Parse the tokens within the macro invocation's delimiters into a syntax
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)
24947 /// Parse the tokens within the macro invocation's delimiters using the
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())
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() {
24963 diff --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
24967 macro_rules! ast_struct {
24969 [$($attrs_pub:tt)*]
24970 struct $name:ident #full $($rest:tt)*
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)*
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>,
24985 #[cfg(all(not(feature = "full"), feature = "printing"))]
24986 impl ::quote::ToTokens for $name {
24987 fn to_tokens(&self, _: &mut ::proc_macro2::TokenStream) {
24994 [$($attrs_pub:tt)*]
24995 - struct $name:ident #manual_extra_traits $($rest:tt)*
24997 - #[cfg_attr(feature = "extra-traits", derive(Debug))]
24998 - #[cfg_attr(feature = "clone-impls", derive(Clone))]
24999 - $($attrs_pub)* struct $name $($rest)*
25003 - [$($attrs_pub:tt)*]
25004 - struct $name:ident #manual_extra_traits_debug $($rest:tt)*
25006 - #[cfg_attr(feature = "clone-impls", derive(Clone))]
25007 - $($attrs_pub)* struct $name $($rest)*
25011 - [$($attrs_pub:tt)*]
25012 struct $name:ident $($rest:tt)*
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)*
25020 strip_attrs_pub!(ast_struct!($($t)*));
25024 @@ -60,29 +37,18 @@ macro_rules! ast_enum {
25025 [$($attrs_pub:tt)*]
25026 enum $name:ident #no_visit $($rest:tt)*
25028 ast_enum!([$($attrs_pub)*] enum $name $($rest)*);
25032 [$($attrs_pub:tt)*]
25033 - enum $name:ident #manual_extra_traits $($rest:tt)*
25035 - #[cfg_attr(feature = "extra-traits", derive(Debug))]
25036 - #[cfg_attr(feature = "clone-impls", derive(Clone))]
25037 - $($attrs_pub)* enum $name $($rest)*
25041 - [$($attrs_pub:tt)*]
25042 enum $name:ident $($rest:tt)*
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)*
25050 strip_attrs_pub!(ast_enum!($($t)*));
25054 @@ -115,36 +81,43 @@ macro_rules! ast_enum_of_structs_impl {
25060 check_keyword_matches!(pub $pub);
25061 check_keyword_matches!(enum $enum);
25065 - impl From<$member> for $name {
25066 - fn from(e: $member) -> $name {
25067 - $name::$variant(e)
25073 + ast_enum_from_struct!($name::$variant, $member);
25076 #[cfg(feature = "printing")]
25077 generate_to_tokens! {
25081 $name { $($variant $($member)*,)* }
25086 +macro_rules! ast_enum_from_struct {
25087 + // No From<TokenStream> for verbatim variants.
25088 + ($name:ident::Verbatim, $member:ident) => {};
25090 + ($name:ident::$variant:ident, $member:ident) => {
25091 + impl From<$member> for $name {
25092 + fn from(e: $member) -> $name {
25093 + $name::$variant(e)
25099 #[cfg(feature = "printing")]
25100 macro_rules! generate_to_tokens {
25101 (do_not_generate_to_tokens $($foo:tt)*) => ();
25103 (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident, $($next:tt)*}) => {
25104 generate_to_tokens!(
25105 ($($arms)* $name::$variant => {})
25106 $tokens $name { $($next)* }
25107 diff --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
25112 /// A binary operator: `+`, `+=`, `&`.
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"`
25117 - #[cfg_attr(feature = "clone-impls", derive(Copy))]
25119 /// The `+` operator (addition)
25121 /// The `-` operator (subtraction)
25123 /// The `*` operator (multiplication)
25125 /// The `/` operator (division)
25126 @@ -62,19 +61,18 @@ ast_enum! {
25127 /// The `>>=` operator
25128 ShrEq(Token![>>=]),
25133 /// A unary operator: `*`, `!`, `-`.
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"`
25138 - #[cfg_attr(feature = "clone-impls", derive(Copy))]
25140 /// The `*` operator for dereferencing
25142 /// The `!` operator for logical inversion
25144 /// The `-` operator for negation
25147 diff --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.
25156 //! [`parse_macro_input!`]: ../macro.parse_macro_input.html
25159 -//! extern crate proc_macro;
25161 +//! # extern crate proc_macro;
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;
25169 //! Struct(ItemStruct),
25170 //! Enum(ItemEnum),
25171 @@ -104,19 +104,17 @@
25175 //! # fn run_parser() -> syn::Result<()> {
25176 //! let t: Type = syn::parse_str("std::collections::HashMap<String, Value>")?;
25181 -//! # run_parser().unwrap();
25183 +//! # run_parser().unwrap();
25186 //! The [`parse_quote!`] macro also uses this approach.
25188 //! [`parse_quote!`]: ../macro.parse_quote.html
25190 //! # The `Parser` trait
25192 @@ -150,18 +148,18 @@
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.
25198 //! [`Parser`]: trait.Parser.html
25201 -//! extern crate proc_macro;
25203 +//! # extern crate proc_macro;
25205 //! use proc_macro::TokenStream;
25206 //! use syn::parse::Parser;
25207 //! use syn::punctuated::Punctuated;
25208 //! use syn::{Attribute, Expr, PathSegment, Result, Token};
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)?;
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.*
25225 #[path = "discouraged.rs"]
25226 pub mod discouraged;
25228 use std::cell::Cell;
25229 use std::fmt::{self, Debug, Display};
25230 use std::marker::PhantomData;
25232 @@ -212,16 +210,21 @@ use crate::lookahead;
25233 use crate::punctuated::Punctuated;
25234 use crate::token::Token;
25236 pub use crate::error::{Error, Result};
25237 pub use crate::lookahead::{Lookahead1, Peek};
25239 /// Parsing interface implemented by all types that can be parsed in a default
25240 /// way from a token stream.
25242 +/// Refer to the [module documentation] for details about implementing and using
25243 +/// the `Parse` trait.
25245 +/// [module documentation]: self
25246 pub trait Parse: Sized {
25247 fn parse(input: ParseStream) -> Result<Self>;
25250 /// Input to a Syn parser function.
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.
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
25261 cell: Cell<Cursor<'static>>,
25262 marker: PhantomData<Cursor<'a>>,
25263 - unexpected: Rc<Cell<Option<Span>>>,
25264 + unexpected: Cell<Option<Rc<Cell<Unexpected>>>>,
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));
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)
25284 @@ -319,25 +325,22 @@ impl<'a> Debug for ParseBuffer<'a> {
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()
25294 -/// # use syn::parse::Parser;
25295 -/// # let remainder = remainder_after_skipping_past_next_at
25296 -/// # .parse_str("a @ b c")
25298 -/// # assert_eq!(remainder.to_string(), "b c");
25300 +/// # use syn::parse::Parser;
25301 +/// # let remainder = remainder_after_skipping_past_next_at
25302 +/// # .parse_str("a @ b c")
25304 +/// # assert_eq!(remainder.to_string(), "b c");
25306 -#[derive(Copy, Clone)]
25307 pub struct StepCursor<'c, 'a> {
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
25315 @@ -351,16 +354,24 @@ pub struct StepCursor<'c, 'a> {
25316 impl<'c, 'a> Deref for StepCursor<'c, 'a> {
25317 type Target = Cursor<'c>;
25319 fn deref(&self) -> &Self::Target {
25324 +impl<'c, 'a> Copy for StepCursor<'c, 'a> {}
25326 +impl<'c, 'a> Clone for StepCursor<'c, 'a> {
25327 + fn clone(&self) -> Self {
25332 impl<'c, 'a> StepCursor<'c, 'a> {
25333 /// Triggers an error at the current position of the parse stream.
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)
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>.
25346 unsafe { mem::transmute::<Cursor<'c>, Cursor<'a>>(to) }
25349 -fn skip(input: ParseStream) -> bool {
25352 - if let Some((_lifetime, rest)) = cursor.lifetime() {
25354 - } else if let Some((_token, rest)) = cursor.token_tree() {
25357 - Ok((false, *cursor))
25363 pub(crate) fn new_parse_buffer(
25366 - unexpected: Rc<Cell<Option<Span>>>,
25367 + unexpected: Rc<Cell<Unexpected>>,
25371 // See comment on `cell` in the struct definition.
25372 cell: Cell::new(unsafe { mem::transmute::<Cursor, Cursor<'static>>(cursor) }),
25373 marker: PhantomData,
25375 + unexpected: Cell::new(Some(unexpected)),
25379 +pub(crate) enum Unexpected {
25382 + Chain(Rc<Cell<Unexpected>>),
25385 +impl Default for Unexpected {
25386 + fn default() -> Self {
25391 +impl Clone for Unexpected {
25392 + fn clone(&self) -> Self {
25394 + Unexpected::None => Unexpected::None,
25395 + Unexpected::Some(span) => Unexpected::Some(*span),
25396 + Unexpected::Chain(next) => Unexpected::Chain(next.clone()),
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();
25412 +fn inner_unexpected(buffer: &ParseBuffer) -> (Rc<Cell<Unexpected>>, Option<Span>) {
25413 + let mut unexpected = get_unexpected(buffer);
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,
25423 +pub(crate) fn get_unexpected(buffer: &ParseBuffer) -> Rc<Cell<Unexpected>> {
25424 + cell_clone(&buffer.unexpected).unwrap()
25427 +fn span_of_unexpected_ignoring_nones(mut cursor: Cursor) -> Option<Span> {
25428 + if cursor.eof() {
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);
25437 + if cursor.eof() {
25440 + Some(cursor.span())
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> {
25450 @@ -561,24 +617,27 @@ impl<'a> ParseBuffer<'a> {
25451 /// input.parse().map(UnionOrMacro::Union)
25453 /// input.parse().map(UnionOrMacro::Macro)
25458 pub fn peek2<T: Peek>(&self, token: T) -> bool {
25459 - let ahead = self.fork();
25460 - skip(&ahead) && ahead.peek(token)
25462 + self.cursor().skip().map_or(false, T::Token::peek)
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)
25472 + .and_then(Cursor::skip)
25473 + .map_or(false, T::Token::peek)
25476 /// Parses zero or more occurrences of `T` separated by punctuation of type
25477 /// `P`, with optional trailing punctuation.
25479 /// Parsing continues until the end of this parse stream. The entire content
25480 /// of this parse stream must consist of `T` and `P`.
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()?,
25491 - /// # fn main() {
25492 - /// # let input = quote! {
25493 - /// # struct S(A, B);
25495 - /// # syn::parse2::<TupleStruct>(input).unwrap();
25497 + /// # let input = quote! {
25498 + /// # struct S(A, B);
25500 + /// # syn::parse2::<TupleStruct>(input).unwrap();
25502 pub fn parse_terminated<T, P: Parse>(
25504 parser: fn(ParseStream) -> Result<T>,
25505 ) -> Result<Punctuated<T, P>> {
25506 Punctuated::parse_terminated_with(self, parser)
25509 @@ -842,18 +899,18 @@ impl<'a> ParseBuffer<'a> {
25512 pub fn fork(&self) -> Self {
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)))),
25525 /// Triggers an error at the current position of the parse stream.
25530 @@ -918,23 +975,21 @@ impl<'a> ParseBuffer<'a> {
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()
25539 - /// # fn main() {
25540 - /// # use syn::parse::Parser;
25541 - /// # let remainder = remainder_after_skipping_past_next_at
25542 - /// # .parse_str("a @ b c")
25544 - /// # assert_eq!(remainder.to_string(), "b c");
25546 + /// # use syn::parse::Parser;
25547 + /// # let remainder = remainder_after_skipping_past_next_at
25548 + /// # .parse_str("a @ b c")
25550 + /// # assert_eq!(remainder.to_string(), "b c");
25552 pub fn step<F, R>(&self, function: F) -> Result<R>
25554 F: for<'c> FnOnce(StepCursor<'c, 'a>) -> Result<(R, Cursor<'c>)>,
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> {
25561 cursor: self.cell.get(),
25562 marker: PhantomData,
25564 self.cell.set(rest);
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() {
25576 + crate::buffer::open_span_of_group(cursor)
25580 /// Provides low-level access to the token representation underlying this
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> {
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")),
25598 impl<T: Parse> Parse for Box<T> {
25599 fn parse(input: ParseStream) -> Result<Self> {
25600 @@ -1043,32 +1110,32 @@ impl Parse for Literal {
25603 /// Parser that can parse Rust tokens into a particular syntax tree node.
25605 /// Refer to the [module documentation] for details about parsing in Syn.
25607 /// [module documentation]: self
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 {
25614 /// Parse a proc-macro2 token stream into the chosen syntax tree node.
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>;
25620 /// Parse tokens of source code into the chosen syntax tree node.
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.
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.*
25629 not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
25630 feature = "proc-macro"
25632 fn parse(self, tokens: proc_macro::TokenStream) -> Result<Self::Output> {
25633 self.parse2(proc_macro2::TokenStream::from(tokens))
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)?)
25644 + #[cfg(any(feature = "full", feature = "derive"))]
25645 fn __parse_scoped(self, scope: Span, tokens: TokenStream) -> Result<Self::Output> {
25647 self.parse2(tokens)
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))
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)
25666 impl<F, T> Parser for F
25668 F: FnOnce(ParseStream) -> Result<T>,
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"))
25683 - Err(state.error("unexpected token"))
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"))
25703 - Err(state.error("unexpected token"))
25708 + #[cfg(any(feature = "full", feature = "derive"))]
25709 fn __parse_stream(self, input: ParseStream) -> Result<Self::Output> {
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)
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)
25724 /// An empty syntax tree node that consumes no tokens when parsed.
25726 /// This is useful for attribute macros that want to ensure they are not
25727 /// provided any attribute args.
25730 -/// extern crate proc_macro;
25732 +/// # extern crate proc_macro;
25734 /// use proc_macro::TokenStream;
25735 /// use syn::parse_macro_input;
25736 /// use syn::parse::Nothing;
25738 /// # const IGNORE: &str = stringify! {
25739 /// #[proc_macro_attribute]
25741 /// pub fn my_attr(args: TokenStream, input: TokenStream) -> TokenStream {
25742 diff --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
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.
25754 -/// extern crate proc_macro;
25756 +/// # extern crate proc_macro;
25758 /// use proc_macro::TokenStream;
25759 /// use syn::{parse_macro_input, Result};
25760 /// use syn::parse::{Parse, ParseStream};
25762 /// struct MyMacroInput {
25766 @@ -38,28 +38,52 @@
25768 /// pub fn my_macro(tokens: TokenStream) -> TokenStream {
25769 /// let input = parse_macro_input!(tokens as MyMacroInput);
25772 /// # "".parse().unwrap()
25775 -#[macro_export(local_inner_macros)]
25781 +/// `parse_macro_input!($variable as $Type)` expands to something like:
25784 +/// # extern crate proc_macro;
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()),
25795 +/// # fn test(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
25796 +/// # let _ = doc_test!(input as syn::Ident);
25797 +/// # proc_macro::TokenStream::new()
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());
25810 ($tokenstream:ident) => {
25811 - parse_macro_input!($tokenstream as _)
25812 + $crate::parse_macro_input!($tokenstream as _)
25816 ////////////////////////////////////////////////////////////////////////////////
25817 // Can parse any type that implements Parse.
25819 use crate::parse::{Parse, ParseStream, Parser, Result};
25820 use proc_macro::TokenStream;
25821 diff --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();
25829 /// println!("{:#?}", stmt);
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.*
25840 /// The following helper function adds a bound `T: HeapSize` to every type
25841 /// parameter `T` in the input generics.
25843 @@ -51,28 +51,30 @@
25845 /// This macro can parse the following additional types as a special case even
25846 /// though they do not implement the `Parse` trait.
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`
25854 /// [`Punctuated<T, P>`]: punctuated::Punctuated
25855 +/// [`Vec<Stmt>`]: Block::parse_within
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
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)]
25867 macro_rules! parse_quote {
25869 $crate::parse_quote::parse(
25870 $crate::export::From::from(
25871 $crate::export::quote::quote!($($tt)*)
25875 @@ -107,16 +109,18 @@ impl<T: Parse> ParseQuote for T {
25878 ////////////////////////////////////////////////////////////////////////////////
25879 // Any other types that we want `parse_quote!` to be able to parse.
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};
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)
25893 attr::parsing::single_parse_outer(input)
25894 @@ -124,8 +128,15 @@ impl ParseQuote for Attribute {
25898 impl<T: Parse, P: Parse> ParseQuote for Punctuated<T, P> {
25899 fn parse(input: ParseStream) -> Result<Self> {
25900 Self::parse_terminated(input)
25904 +#[cfg(feature = "full")]
25905 +impl ParseQuote for Vec<Stmt> {
25906 + fn parse(input: ParseStream) -> Result<Self> {
25907 + Block::parse_within(input)
25910 diff --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
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};
25922 ast_enum_of_structs! {
25923 /// A pattern in a local binding, function signature, match expression, or
25924 /// various other places.
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.*
25929 /// # Syntax tree enum
25931 /// This type is a [syntax tree enum].
25933 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
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 {
25939 /// A box pattern: `box v`.
25942 /// A pattern that binds a new variable: `ref mut binding @ SUBPATTERN`.
25945 /// A literal pattern: `0`.
25947 @@ -81,321 +77,219 @@ ast_enum_of_structs! {
25954 /// A box pattern: `box v`.
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],
25966 /// A pattern that binds a new variable: `ref mut binding @ SUBPATTERN`.
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.
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]>,
25978 pub subpat: Option<(Token![@], Box<Pat>)>,
25983 /// A literal pattern: `0`.
25985 /// This holds an `Expr` rather than a `Lit` because negative numbers
25986 /// are represented as an `Expr::Unary`.
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>,
25997 /// A macro in pattern position.
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>,
26008 /// A pattern that matches any one of a set of cases.
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.*
26013 pub attrs: Vec<Attribute>,
26014 pub leading_vert: Option<Token![|]>,
26015 pub cases: Punctuated<Pat, Token![|]>,
26020 /// A path pattern like `Color::Red`, optionally qualified with a
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.
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>,
26038 /// A range pattern: `1..=2`.
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>,
26045 pub limits: RangeLimits,
26051 /// A reference pattern: `&mut var`.
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]>,
26064 /// The dots in a tuple or slice pattern: `[0, 1, ..]`
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![..],
26075 /// A dynamically sized slice pattern: `[a, b, ref i @ .., y, z]`.
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![,]>,
26087 /// A struct or struct variant pattern: `Variant { x, y, .. }`.
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>,
26094 pub brace_token: token::Brace,
26095 pub fields: Punctuated<FieldPat, Token![,]>,
26096 pub dot2_token: Option<Token![..]>,
26101 /// A tuple pattern: `(a, b)`.
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![,]>,
26113 /// A tuple struct or tuple variant pattern: `Variant(x, y, .., z)`.
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>,
26125 /// A type ascription pattern: `foo: f64`.
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>,
26132 pub colon_token: Token![:],
26138 /// A pattern that matches any value: `_`.
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![_],
26149 /// A single field in a struct pattern.
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.
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![:]>,
26164 -#[cfg(feature = "extra-traits")]
26165 -impl Eq for Pat {}
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)
26188 - (Pat::Wild(this), Pat::Wild(other)) => this == other,
26194 -#[cfg(feature = "extra-traits")]
26195 -impl Hash for Pat {
26196 - fn hash<H>(&self, hash: &mut H)
26201 - Pat::Box(pat) => {
26202 - hash.write_u8(0);
26205 - Pat::Ident(pat) => {
26206 - hash.write_u8(1);
26209 - Pat::Lit(pat) => {
26210 - hash.write_u8(2);
26213 - Pat::Macro(pat) => {
26214 - hash.write_u8(3);
26217 - Pat::Or(pat) => {
26218 - hash.write_u8(4);
26221 - Pat::Path(pat) => {
26222 - hash.write_u8(5);
26225 - Pat::Range(pat) => {
26226 - hash.write_u8(6);
26229 - Pat::Reference(pat) => {
26230 - hash.write_u8(7);
26233 - Pat::Rest(pat) => {
26234 - hash.write_u8(8);
26237 - Pat::Slice(pat) => {
26238 - hash.write_u8(9);
26241 - Pat::Struct(pat) => {
26242 - hash.write_u8(10);
26245 - Pat::Tuple(pat) => {
26246 - hash.write_u8(11);
26249 - Pat::TupleStruct(pat) => {
26250 - hash.write_u8(12);
26253 - Pat::Type(pat) => {
26254 - hash.write_u8(13);
26257 - Pat::Verbatim(pat) => {
26258 - hash.write_u8(14);
26259 - TokenStreamHelper(pat).hash(hash);
26261 - Pat::Wild(pat) => {
26262 - hash.write_u8(15);
26265 - Pat::__Nonexhaustive => unreachable!(),
26270 #[cfg(feature = "parsing")]
26275 use crate::ext::IdentExt;
26276 - use crate::parse::{Parse, ParseStream, Result};
26277 + use crate::parse::{Parse, ParseBuffer, ParseStream, Result};
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)
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![,])
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])
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)
26321 Err(lookahead.error())
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)?;
26330 if input.peek(Token![..]) {
26331 - return pat_range(input, qself, path).map(Pat::Range);
26332 + return pat_range(input, begin, qself, path);
26335 if qself.is_some() {
26336 return Ok(Pat::Path(PatPath {
26341 @@ -482,17 +376,17 @@ mod parsing {
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)
26353 Ok(Pat::Path(PatPath {
26360 @@ -541,17 +435,17 @@ mod parsing {
26361 fn pat_struct(input: ParseStream, path: Path) -> Result<PatStruct> {
26363 let brace_token = braced!(content in input);
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() {
26373 let punct: Token![,] = content.parse()?;
26374 fields.push_punct(punct);
26377 let dot2_token = if fields.empty_or_trailing() && content.peek(Token![..]) {
26378 Some(content.parse()?)
26379 @@ -573,29 +467,30 @@ mod parsing {
26381 Member::Named(_) => false,
26382 Member::Unnamed(_) => true,
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()?;
26394 if boxed.is_none() && by_ref.is_none() && mutability.is_none() && input.peek(Token![:])
26395 || member.is_unnamed()
26397 return Ok(FieldPat {
26398 - attrs: Vec::new(),
26401 colon_token: input.parse()?,
26402 - pat: input.parse()?,
26403 + pat: Box::new(multi_pat(input)?),
26407 let ident = match member {
26408 Member::Named(ident) => ident,
26409 Member::Unnamed(_) => unreachable!(),
26412 @@ -605,49 +500,76 @@ mod parsing {
26414 ident: ident.clone(),
26418 if let Some(boxed) = boxed {
26419 pat = Pat::Box(PatBox {
26421 + box_token: boxed,
26422 pat: Box::new(pat),
26423 - box_token: boxed,
26429 member: Member::Named(ident),
26430 + colon_token: None,
26431 pat: Box::new(pat),
26432 - attrs: Vec::new(),
26433 - colon_token: None,
26437 - fn pat_range(input: ParseStream, qself: Option<QSelf>, path: Path) -> Result<PatRange> {
26439 - attrs: Vec::new(),
26440 - lo: Box::new(Expr::Path(ExprPath {
26442 + input: ParseStream,
26443 + begin: ParseBuffer,
26444 + qself: Option<QSelf>,
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 {
26455 - limits: input.parse()?,
26456 - hi: input.call(pat_lit_expr)?,
26458 + lo: Box::new(Expr::Path(ExprPath {
26459 + attrs: Vec::new(),
26467 + Ok(Pat::Verbatim(verbatim::between(begin, input)))
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)))
26478 + RangeLimits::HalfOpen(dot2_token) => Ok(Pat::Rest(PatRest {
26479 + attrs: Vec::new(),
26482 + RangeLimits::Closed(_) => Err(input.error("expected range upper bound")),
26487 fn pat_tuple(input: ParseStream) -> Result<PatTuple> {
26489 let paren_token = parenthesized!(content in input);
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() {
26499 let punct = content.parse()?;
26500 elems.push_punct(punct);
26503 @@ -663,225 +585,280 @@ mod parsing {
26505 and_token: input.parse()?,
26506 mutability: input.parse()?,
26507 pat: input.parse()?,
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(),
26519 - limits: input.parse()?,
26520 - hi: input.call(pat_lit_expr)?,
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(),
26532 + Ok(Pat::Verbatim(verbatim::between(begin, input)))
26535 Ok(Pat::Lit(PatLit {
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![;])
26554 let neg: Option<Token![-]> = input.parse()?;
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])
26568 Expr::Path(input.parse()?)
26570 return Err(lookahead.error());
26573 - Ok(Box::new(if let Some(neg) = neg {
26574 + Ok(Some(Box::new(if let Some(neg) = neg {
26575 Expr::Unary(ExprUnary {
26577 op: UnOp::Neg(neg),
26578 expr: Box::new(expr),
26586 fn pat_slice(input: ParseStream) -> Result<PatSlice> {
26588 let bracket_token = bracketed!(content in input);
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() {
26598 let punct = content.parse()?;
26599 elems.push_punct(punct);
26609 - fn pat_rest(input: ParseStream) -> Result<PatRest> {
26611 - attrs: Vec::new(),
26612 - dot2_token: input.parse()?,
26614 + pub fn multi_pat(input: ParseStream) -> Result<Pat> {
26615 + multi_pat_impl(input, None)
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)
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![|=])
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);
26636 + pat = Pat::Or(PatOr {
26637 + attrs: Vec::new(),
26646 #[cfg(feature = "printing")]
26650 use proc_macro2::TokenStream;
26651 use quote::{ToTokens, TokenStreamExt};
26653 use crate::attr::FilterAttrs;
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);
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);
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);
26685 self.dot2_token.to_tokens(tokens);
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);
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);
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);
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);
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);
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);
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);
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);
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),
26762 self.hi.to_tokens(tokens);
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);
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);
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);
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);
26797 self.pat.to_tokens(tokens);
26801 diff --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
26806 use crate::punctuated::Punctuated;
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`).
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"`
26816 pub leading_colon: Option<Token![::]>,
26817 pub segments: Punctuated<PathSegment, Token![::]>,
26821 impl<T> From<T> for Path
26822 @@ -24,17 +24,17 @@ where
26823 path.segments.push_value(segment.into());
26829 /// A segment of a path together with any path arguments on that segment.
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"`
26834 pub struct PathSegment {
26836 pub arguments: PathArguments,
26840 impl<T> From<T> for PathSegment
26841 @@ -47,17 +47,17 @@ where
26842 arguments: PathArguments::None,
26848 /// Angle bracketed or parenthesized arguments of a path segment.
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"`
26854 /// ## Angle bracketed
26856 /// The `<'a, T>` in `std::slice::iter<'a, T>`.
26858 /// ## Parenthesized
26860 @@ -93,17 +93,17 @@ impl PathArguments {
26861 PathArguments::AngleBracketed(_) | PathArguments::Parenthesized(_) => false,
26867 /// An individual generic argument, like `'a`, `T`, or `Item = T`.
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"`
26872 pub enum GenericArgument {
26873 /// A lifetime argument.
26874 Lifetime(Lifetime),
26875 /// A type argument.
26877 /// A binding (equality constraint) on an associated type: the `Item =
26878 /// u8` in `Iterator<Item = u8>`.
26879 @@ -117,55 +117,55 @@ ast_enum! {
26885 /// Angle bracketed arguments of a path segment: the `<K, V>` in `HashMap<K,
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"`
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![>],
26900 /// A binding (equality constraint) on an associated type: `Item = u8`.
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"`
26905 pub struct Binding {
26907 pub eq_token: Token![=],
26913 /// An associated type bound: `Iterator<Item: Display>`.
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"`
26918 pub struct Constraint {
26920 pub colon_token: Token![:],
26921 pub bounds: Punctuated<TypeParamBound, Token![+]>,
26926 /// Arguments of a function path segment: the `(A, B) -> C` in `Fn(A,B) ->
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"`
26932 pub struct ParenthesizedGenericArguments {
26933 pub paren_token: token::Paren,
26935 pub inputs: Punctuated<Type, Token![,]>,
26937 pub output: ReturnType,
26939 @@ -184,17 +184,17 @@ ast_struct! {
26940 /// ^~~~~~ ~~~~~~~~~~~~~~^
26941 /// ty position = 3
26943 /// <Vec<T>>::AssociatedItem
26945 /// ty position = 0
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"`
26952 pub lt_token: Token![<],
26954 pub position: usize,
26955 pub as_token: Option<Token![as]>,
26956 pub gt_token: Token![>],
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)
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])
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));
26977 let ident = if input.peek(Token![Self]) {
26978 input.call(Ident::parse_any)?
26981 @@ -353,17 +349,17 @@ pub mod parsing {
26988 /// Parse a `Path` containing no path arguments on any of its segments.
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"`
26997 /// use syn::{Path, Result, Token};
26998 /// use syn::parse::{Parse, ParseStream};
27000 @@ -395,17 +391,16 @@ pub mod parsing {
27002 let mut segments = Punctuated::new();
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])
27013 let ident = Ident::parse_any(input)?;
27014 segments.push_value(PathSegment::from(ident));
27015 if !input.peek(Token![::]) {
27018 @@ -428,17 +423,17 @@ pub mod parsing {
27019 /// For them to compare equal, it must be the case that:
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.
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"`
27034 /// use syn::{Attribute, Error, Meta, NestedMeta, Result};
27035 /// # use std::iter::FromIterator;
27037 @@ -467,17 +462,17 @@ pub mod parsing {
27039 /// A path is considered an ident if:
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.
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"`
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()
27054 Some(&self.segments[0].ident)
27056 diff --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 @@
27062 //! a_function_call(arg1, arg2, arg3);
27063 //! ~~~~^ ~~~~^ ~~~~
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"))]
27072 use std::iter::FromIterator;
27073 use std::ops::{Index, IndexMut};
27078 @@ -36,18 +38,16 @@ use crate::parse::{Parse, ParseStream, R
27079 use crate::token::Token;
27081 /// A punctuated sequence of syntax tree nodes of type `T` separated by
27082 /// punctuation of type `P`.
27084 /// Refer to the [module documentation] for details about punctuated sequences.
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>>,
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 }
27101 /// Borrows the first element in this sequence.
27102 pub fn first(&self) -> Option<&T> {
27106 + /// Mutably borrows the first element in this sequence.
27107 + pub fn first_mut(&mut self) -> Option<&mut T> {
27108 + self.iter_mut().next()
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)
27116 - self.inner.last().map(|pair| &pair.0)
27118 + self.iter().next_back()
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)
27126 - self.inner.last_mut().map(|pair| &mut pair.0)
27128 + self.iter_mut().next_back()
27131 /// Returns an iterator over borrowed syntax tree nodes of type `&T`.
27132 pub fn iter(&self) -> Iter<T> {
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> {
27139 if index == self.len() {
27142 self.inner.insert(index, (value, Default::default()));
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;
27152 /// Parses zero or more occurrences of `T` separated by punctuation of type
27153 /// `P`, with optional trailing punctuation.
27155 /// Parsing continues until the end of this parse stream. The entire content
27156 /// of this parse stream must consist of `T` and `P`.
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"`
27161 #[cfg(feature = "parsing")]
27162 pub fn parse_terminated(input: ParseStream) -> Result<Self>
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
27172 /// Like [`parse_terminated`], the entire content of this stream is expected
27175 /// [`parse_terminated`]: Punctuated::parse_terminated
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"`
27180 #[cfg(feature = "parsing")]
27181 pub fn parse_terminated_with(
27182 input: ParseStream,
27183 parser: fn(ParseStream) -> Result<T>,
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.
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
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"`
27199 #[cfg(feature = "parsing")]
27200 pub fn parse_separated_nonempty(input: ParseStream) -> Result<Self>
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
27210 /// Like [`parse_separated_nonempty`], may complete early without parsing
27211 /// the entire content of this stream.
27213 /// [`parse_separated_nonempty`]: Punctuated::parse_separated_nonempty
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"`
27218 #[cfg(feature = "parsing")]
27219 pub fn parse_separated_nonempty_with(
27220 input: ParseStream,
27221 parser: fn(ParseStream) -> Result<T>,
27225 @@ -333,16 +336,63 @@ impl<T, P> Punctuated<T, P> {
27226 let punct = input.parse()?;
27227 punctuated.push_punct(punct);
27234 +#[cfg(feature = "clone-impls")]
27235 +impl<T, P> Clone for Punctuated<T, P>
27240 + fn clone(&self) -> Self {
27242 + inner: self.inner.clone(),
27243 + last: self.last.clone(),
27248 +#[cfg(feature = "extra-traits")]
27249 +impl<T, P> Eq for Punctuated<T, P>
27256 +#[cfg(feature = "extra-traits")]
27257 +impl<T, P> PartialEq for Punctuated<T, P>
27262 + fn eq(&self, other: &Self) -> bool {
27263 + let Punctuated { inner, last } = self;
27264 + *inner == other.inner && *last == other.last
27268 +#[cfg(feature = "extra-traits")]
27269 +impl<T, P> Hash for Punctuated<T, P>
27274 + fn hash<H: Hasher>(&self, state: &mut H) {
27275 + let Punctuated { inner, last } = self;
27276 + inner.hash(state);
27277 + last.hash(state);
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 {
27289 @@ -531,17 +581,16 @@ impl<'a, T, P> ExactSizeIterator for Pai
27293 /// An iterator over owned pairs of type `Pair<T, P>`.
27295 /// Refer to the [module documentation] for details about punctuated sequences.
27297 /// [module documentation]: self
27299 pub struct IntoPairs<T, P> {
27300 inner: vec::IntoIter<(T, P)>,
27301 last: option::IntoIter<T>,
27304 impl<T, P> Iterator for IntoPairs<T, P> {
27305 type Item = Pair<T, P>;
27307 @@ -567,22 +616,34 @@ impl<T, P> DoubleEndedIterator for IntoP
27310 impl<T, P> ExactSizeIterator for IntoPairs<T, P> {
27311 fn len(&self) -> usize {
27312 self.inner.len() + self.last.len()
27316 +impl<T, P> Clone for IntoPairs<T, P>
27321 + fn clone(&self) -> Self {
27323 + inner: self.inner.clone(),
27324 + last: self.last.clone(),
27329 /// An iterator over owned values of type `T`.
27331 /// Refer to the [module documentation] for details about punctuated sequences.
27333 /// [module documentation]: self
27335 pub struct IntoIter<T> {
27336 inner: vec::IntoIter<T>,
27339 impl<T> Iterator for IntoIter<T> {
27342 fn next(&mut self) -> Option<Self::Item> {
27343 @@ -601,16 +662,27 @@ impl<T> DoubleEndedIterator for IntoIter
27346 impl<T> ExactSizeIterator for IntoIter<T> {
27347 fn len(&self) -> usize {
27352 +impl<T> Clone for IntoIter<T>
27356 + fn clone(&self) -> Self {
27358 + inner: self.inner.clone(),
27363 /// An iterator over borrowed values of type `&T`.
27365 /// Refer to the [module documentation] for details about punctuated sequences.
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,
27374 /// A single syntax tree node of type `T` followed by its trailing punctuation
27375 /// of type `P` if any.
27377 /// Refer to the [module documentation] for details about punctuated sequences.
27379 /// [module documentation]: self
27380 -#[cfg_attr(feature = "clone-impls", derive(Clone))]
27381 pub enum Pair<T, P> {
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>) {
27392 Pair::Punctuated(t, d) => (t, Some(d)),
27393 Pair::End(t) => (t, None),
27398 +#[cfg(feature = "clone-impls")]
27399 +impl<T, P> Clone for Pair<T, P>
27404 + fn clone(&self) -> Self {
27406 + Pair::Punctuated(t, p) => Pair::Punctuated(t.clone(), p.clone()),
27407 + Pair::End(t) => Pair::End(t.clone()),
27412 impl<T, P> Index<usize> for Punctuated<T, P> {
27415 fn index(&self, index: usize) -> &Self::Output {
27416 if index == self.len() - 1 {
27419 None => &self.inner[index].0,
27420 diff --git a/third_party/rust/syn/src/reserved.rs b/third_party/rust/syn/src/reserved.rs
27421 new file mode 100644
27423 +++ b/third_party/rust/syn/src/reserved.rs
27425 +// Type for a syntax tree node that is reserved for future use.
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.
27432 +use proc_macro2::Span;
27433 +use std::marker::PhantomData;
27435 +#[cfg(feature = "extra-traits")]
27436 +use std::fmt::{self, Debug};
27439 + pub struct Reserved {
27440 + _private: PhantomData<Span>,
27444 +impl Default for Reserved {
27445 + fn default() -> Self {
27447 + _private: PhantomData,
27452 +#[cfg(feature = "clone-impls")]
27453 +impl Clone for Reserved {
27454 + fn clone(&self) -> Self {
27456 + _private: self._private,
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()
27467 diff --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
27471 //! A trait that can provide the `Span` of the complete contents of a syntax
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.*
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.
27487 /// [`ToTokens`]: quote::ToTokens
27489 /// See the [module documentation] for an example.
27491 /// [module documentation]: self
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.
27500 /// [`Span::call_site()`]: proc_macro2::Span::call_site
27501 fn span(&self) -> Span;
27503 diff --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
27510 /// A braced block containing Rust statements.
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.*
27515 pub brace_token: token::Brace,
27516 /// Statements in a block
27517 pub stmts: Vec<Stmt>,
27522 /// A statement, usually ending in a semicolon.
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.*
27527 /// A local (let) binding.
27530 /// An item definition.
27533 /// Expr without trailing semicolon.
27534 @@ -28,38 +28,39 @@ ast_enum! {
27535 /// Expression with trailing semicolon.
27536 Semi(Expr, Token![;]),
27541 /// A local `let` binding: `let x: u64 = s.parse()?`.
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.*
27546 pub attrs: Vec<Attribute>,
27547 pub let_token: Token![let],
27549 pub init: Option<(Token![=], Box<Expr>)>,
27550 pub semi_token: Token![;],
27554 #[cfg(feature = "parsing")]
27558 + use crate::parse::discouraged::Speculative;
27559 use crate::parse::{Parse, ParseStream, Result};
27560 - use crate::punctuated::Punctuated;
27561 + use proc_macro2::TokenStream;
27564 /// Parse the body of a block as zero or more statements, possibly
27565 /// including one trailing expression.
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"`
27574 /// use syn::{braced, token, Attribute, Block, Ident, Result, Stmt, Token};
27575 /// use syn::parse::{Parse, ParseStream};
27577 @@ -101,18 +102,18 @@ pub mod parsing {
27583 pub fn parse_within(input: ParseStream) -> Result<Vec<Stmt>> {
27584 let mut stmts = Vec::new();
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));
27591 if input.is_empty() {
27594 let s = parse_stmt(input, true)?;
27595 let requires_semicolon = if let Stmt::Expr(s) = &s {
27596 expr::requires_terminator(s)
27598 @@ -141,65 +142,65 @@ pub mod parsing {
27600 impl Parse for Stmt {
27601 fn parse(input: ParseStream) -> Result<Self> {
27602 parse_stmt(input, false)
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)?;
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);
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))
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])
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))
27689 - stmt_expr(input, allow_nosemi)
27690 + stmt_expr(input, allow_nosemi, attrs)
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()?;
27703 Ok(Stmt::Item(Item::Macro(ItemMacro {
27706 @@ -208,43 +209,22 @@ pub mod parsing {
27715 - fn stmt_local(input: ParseStream) -> Result<Local> {
27716 + fn stmt_local(input: ParseStream, attrs: Vec<Attribute>) -> Result<Local> {
27718 - attrs: input.call(Attribute::parse_outer)?,
27720 let_token: input.parse()?,
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![|=])
27727 - let mut cases = Punctuated::new();
27728 - cases.push_value(pat);
27729 - while input.peek(Token![|])
27730 - && !input.peek(Token![||])
27731 - && !input.peek(Token![|=])
27733 - let punct = input.parse()?;
27734 - cases.push_punct(punct);
27735 - let pat: Pat = input.parse()?;
27736 - cases.push_value(pat);
27738 - pat = Pat::Or(PatOr {
27739 - attrs: Vec::new(),
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 {
27750 pat: Box::new(pat),
27753 @@ -260,22 +240,29 @@ pub mod parsing {
27758 semi_token: input.parse()?,
27762 - fn stmt_expr(input: ParseStream, allow_nosemi: bool) -> Result<Stmt> {
27763 - let mut attrs = input.call(Attribute::parse_outer)?;
27765 + input: ParseStream,
27766 + allow_nosemi: bool,
27767 + mut attrs: Vec<Attribute>,
27768 + ) -> Result<Stmt> {
27769 let mut e = expr::parsing::expr_early(input)?;
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;
27777 + attrs.extend(attr_target.replace_attrs(Vec::new()));
27778 + attr_target.replace_attrs(attrs);
27780 if input.peek(Token![;]) {
27781 return Ok(Stmt::Semi(e, input.parse()?));
27784 if allow_nosemi || !expr::requires_terminator(&e) {
27787 diff --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 @@
27792 //! - Field access to its span — `let sp = the_token.span`
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
27800 #[cfg(feature = "extra-traits")]
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};
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};
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;
27837 @@ -150,31 +147,30 @@ mod private {
27838 pub struct WithSpan {
27843 #[cfg(feature = "parsing")]
27844 impl private::Sealed for Ident {}
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;
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);
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()
27870 peek_impl(cursor, peek)
27872 @@ -184,34 +180,48 @@ macro_rules! impl_token {
27876 #[cfg(feature = "parsing")]
27877 impl private::Sealed for $name {}
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);
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()
27918 + fn display() -> &'static str {
27923 + #[cfg(feature = "parsing")]
27924 + impl private::Sealed for $ty {}
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);
27934 #[cfg(feature = "parsing")]
27935 pub trait CustomToken {
27936 fn peek(cursor: Cursor) -> bool;
27937 fn display() -> &'static str;
27939 @@ -228,17 +238,16 @@ impl<T: CustomToken> Token for T {
27940 fn display() -> &'static str {
27941 <Self as CustomToken>::display()
27945 macro_rules! define_keywords {
27946 ($($token:tt pub struct $name:ident #[$doc:meta])*) => {
27948 - #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))]
27951 /// Don't try to remember the name of this type — use the
27952 /// [`Token!`] macro instead.
27954 /// [`Token!`]: crate::token
27957 @@ -255,16 +264,26 @@ macro_rules! define_keywords {
27958 impl std::default::Default for $name {
27959 fn default() -> Self {
27961 span: Span::call_site(),
27966 + #[cfg(feature = "clone-impls")]
27967 + impl Copy for $name {}
27969 + #[cfg(feature = "clone-impls")]
27970 + impl Clone for $name {
27971 + fn clone(&self) -> Self {
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))
27983 #[cfg(feature = "extra-traits")]
27984 @@ -333,17 +352,16 @@ macro_rules! impl_deref_if_len_is_1 {
27987 ($name:ident/$len:tt) => {};
27990 macro_rules! define_punctuation_structs {
27991 ($($token:tt pub struct $name:ident/$len:tt #[$doc:meta])*) => {
27993 - #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))]
27997 /// Don't try to remember the name of this type — use the
27998 /// [`Token!`] macro instead.
28000 /// [`Token!`]: crate::token
28002 @@ -361,16 +379,26 @@ macro_rules! define_punctuation_structs
28003 impl std::default::Default for $name {
28004 fn default() -> Self {
28006 spans: [Span::call_site(); $len],
28011 + #[cfg(feature = "clone-impls")]
28012 + impl Copy for $name {}
28014 + #[cfg(feature = "clone-impls")]
28015 + impl Clone for $name {
28016 + fn clone(&self) -> Self {
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))
28028 #[cfg(feature = "extra-traits")]
28029 @@ -431,17 +459,16 @@ macro_rules! define_punctuation {
28030 impl private::Sealed for $name {}
28035 macro_rules! define_delimiters {
28036 ($($token:tt pub struct $name:ident #[$doc:meta])*) => {
28038 - #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))]
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 {
28051 span: Span::call_site(),
28056 + #[cfg(feature = "clone-impls")]
28057 + impl Copy for $name {}
28059 + #[cfg(feature = "clone-impls")]
28060 + impl Clone for $name {
28061 + fn clone(&self) -> Self {
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))
28073 #[cfg(feature = "extra-traits")]
28074 @@ -850,17 +887,17 @@ pub mod parsing {
28075 if let Some((ident, _rest)) = cursor.ident() {
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))
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());
28093 diff --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) => {}
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();
28111 let item2 = match s2.next() {
28112 Some(item) => item,
28113 None => return false,
28115 if TokenTreeHelper(&item1) != TokenTreeHelper(&item2) {
28117 @@ -55,17 +55,17 @@ impl<'a> Hash for TokenTreeHelper<'a> {
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),
28126 - for item in g.stream().clone() {
28127 + for item in g.stream() {
28128 TokenTreeHelper(&item).hash(h);
28130 0xffu8.hash(h); // terminator w/ a variant we don't normally hash
28132 TokenTree::Punct(op) => {
28134 op.as_char().hash(h);
28135 match op.spacing() {
28136 diff --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
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};
28148 ast_enum_of_structs! {
28149 /// The possible types that a Rust value could have.
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"`
28155 /// # Syntax tree enum
28157 /// This type is a [syntax tree enum].
28159 /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
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 {
28165 /// A fixed size array type: `[T; n]`.
28168 /// A bare function type: `fn(usize) -> bool`.
28169 BareFn(TypeBareFn),
28171 /// A type contained within invisible delimiters.
28173 @@ -72,295 +68,194 @@ ast_enum_of_structs! {
28180 /// A fixed size array type: `[T; n]`.
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![;],
28194 /// A bare function type: `fn(usize) -> bool`.
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,
28212 /// A type contained within invisible delimiters.
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>,
28224 /// An `impl Bound1 + Bound2 + Bound3` type where `Bound` is a trait or
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![+]>,
28237 /// Indication that a type should be inferred by the compiler: `_`.
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![_],
28248 /// A macro in the type position.
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 {
28259 /// The never type: `!`.
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![!],
28270 /// A parenthesized type equivalent to the inner type.
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>,
28282 /// A path like `std::slice::Iter`, optionally qualified with a
28283 /// self-type as in `<Vec<T> as SomeTrait>::Associated`.
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>,
28295 /// A raw pointer type: `*const T` or `*mut T`.
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>,
28309 /// A reference type: `&'a T` or `&'a mut T`.
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>,
28323 /// A dynamically sized slice type: `[T]`.
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>,
28335 /// A trait object type `Bound1 + Bound2 + Bound3` where `Bound` is a
28336 /// trait or a lifetime.
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![+]>,
28348 /// A tuple type: `(A, B, C, String)`.
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![,]>,
28359 -#[cfg(feature = "extra-traits")]
28360 -impl Eq for Type {}
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)
28388 -#[cfg(feature = "extra-traits")]
28389 -impl Hash for Type {
28390 - fn hash<H>(&self, hash: &mut H)
28395 - Type::Array(ty) => {
28396 - hash.write_u8(0);
28399 - Type::BareFn(ty) => {
28400 - hash.write_u8(1);
28403 - Type::Group(ty) => {
28404 - hash.write_u8(2);
28407 - Type::ImplTrait(ty) => {
28408 - hash.write_u8(3);
28411 - Type::Infer(ty) => {
28412 - hash.write_u8(4);
28415 - Type::Macro(ty) => {
28416 - hash.write_u8(5);
28419 - Type::Never(ty) => {
28420 - hash.write_u8(6);
28423 - Type::Paren(ty) => {
28424 - hash.write_u8(7);
28427 - Type::Path(ty) => {
28428 - hash.write_u8(8);
28431 - Type::Ptr(ty) => {
28432 - hash.write_u8(9);
28435 - Type::Reference(ty) => {
28436 - hash.write_u8(10);
28439 - Type::Slice(ty) => {
28440 - hash.write_u8(11);
28443 - Type::TraitObject(ty) => {
28444 - hash.write_u8(12);
28447 - Type::Tuple(ty) => {
28448 - hash.write_u8(13);
28451 - Type::Verbatim(ty) => {
28452 - hash.write_u8(14);
28453 - TokenStreamHelper(ty).hash(hash);
28455 - Type::__Nonexhaustive => unreachable!(),
28461 /// The binary interface of a function: `extern "C"`.
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"`
28467 pub extern_token: Token![extern],
28468 pub name: Option<LitStr>,
28473 /// An argument in a function type: the `usize` in `fn(usize) -> bool`.
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"`
28478 pub struct BareFnArg {
28479 pub attrs: Vec<Attribute>,
28480 pub name: Option<(Ident, Token![:])>,
28485 @@ -372,28 +267,28 @@ ast_struct! {
28486 /// # struct c_int;
28489 /// fn printf(format: *const c_char, ...) -> c_int;
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"`
28497 pub struct Variadic {
28498 pub attrs: Vec<Attribute>,
28499 pub dots: Token![...],
28504 /// Return type of a function signature.
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"`
28509 pub enum ReturnType {
28510 /// Return type is not specified.
28512 /// Functions default to `()` and closures default to type inference.
28514 /// A particular type is returned.
28515 Type(Token![->], Box<Type>),
28516 @@ -402,39 +297,44 @@ ast_enum! {
28518 #[cfg(feature = "parsing")]
28522 use crate::ext::IdentExt;
28523 use crate::parse::{Parse, ParseStream, Result};
28525 + use proc_macro2::{Punct, Spacing, TokenTree};
28526 + use std::iter::FromIterator;
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)
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.
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)
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);
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 {
28566 match bounds.into_iter().next().unwrap() {
28567 TypeParamBound::Trait(trait_bound) => {
28568 TypeParamBound::Trait(TraitBound {
28569 paren_token: Some(paren_token),
28574 + other @ TypeParamBound::Lifetime(_) => other,
28579 return Ok(Type::TraitObject(TypeTraitObject {
28582 let mut bounds = Punctuated::new();
28583 @@ -544,27 +444,30 @@ pub mod parsing {
28586 Ok(Type::Paren(TypeParen {
28588 elem: Box::new(first),
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])
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))
28603 + Ok(Type::Verbatim(verbatim::between(begin, input)))
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![<])
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)?),
28626 impl Parse for TypeBareFn {
28627 fn parse(input: ParseStream) -> Result<Self> {
28629 - let allow_variadic;
28631 - lifetimes: input.parse()?,
28632 - unsafety: input.parse()?,
28633 - abi: input.parse()?,
28634 - fn_token: input.parse()?,
28635 - paren_token: parenthesized!(args in input),
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() {
28643 - inputs.push_punct(args.parse()?);
28644 + let allow_mut_self = false;
28645 + parse_bare_fn(input, allow_mut_self).map(Option::unwrap)
28649 + fn parse_bare_fn(input: ParseStream, allow_mut_self: bool) -> Result<Option<TypeBareFn>> {
28651 + let mut variadic = None;
28652 + let mut has_mut_self = false;
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),
28661 + let mut inputs = Punctuated::new();
28663 + while !args.is_empty() {
28664 + let attrs = args.call(Attribute::parse_outer)?;
28666 + if inputs.empty_or_trailing() && args.peek(Token![...]) {
28667 + variadic = Some(Variadic {
28669 + dots: args.parse()?,
28673 - allow_variadic = inputs.empty_or_trailing();
28677 - if allow_variadic && args.peek(Token![...]) {
28679 - attrs: Vec::new(),
28680 - dots: args.parse()?,
28683 + if let Some(arg) = parse_bare_fn_arg(&args, allow_mut_self)? {
28684 + inputs.push_value(BareFnArg { attrs, ..arg });
28687 + has_mut_self = true;
28689 + if args.is_empty() {
28693 - output: input.call(ReturnType::without_plus)?,
28696 + inputs.push_punct(args.parse()?);
28702 + output: input.call(ReturnType::without_plus)?,
28705 + if has_mut_self {
28708 + Ok(Some(bare_fn))
28712 impl Parse for TypeNever {
28713 fn parse(input: ParseStream) -> Result<Self> {
28715 bang_token: input.parse()?,
28717 @@ -771,19 +694,37 @@ pub mod parsing {
28718 underscore_token: input.parse()?,
28723 impl Parse for TypeTuple {
28724 fn parse(input: ParseStream) -> Result<Self> {
28726 + let paren_token = parenthesized!(content in input);
28728 + if content.is_empty() {
28729 + return Ok(TypeTuple {
28731 + elems: Punctuated::new(),
28735 + let first: Type = content.parse()?;
28737 - paren_token: parenthesized!(content in input),
28738 - elems: content.parse_terminated(Type::parse)?,
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);
28753 impl Parse for TypeMacro {
28754 fn parse(input: ParseStream) -> Result<Self> {
28756 mac: input.parse()?,
28757 @@ -802,19 +743,21 @@ pub mod parsing {
28760 Ok(TypePath { qself, path })
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)
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)))
28778 Ok(ReturnType::Default)
28780 @@ -839,20 +782,22 @@ pub mod parsing {
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)
28794 // Only allow multiple trait references if allow_plus is true.
28796 pub fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
28797 Ok(TypeTraitObject {
28798 dyn_token: input.parse()?,
28800 let mut bounds = Punctuated::new();
28803 bounds.push_value(input.parse()?);
28804 @@ -905,48 +850,99 @@ pub mod parsing {
28805 group_token: group.token,
28806 elem: group.content.parse()?,
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)
28820 fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
28823 paren_token: parenthesized!(content in input),
28824 elem: Box::new(ambig_ty(&content, allow_plus)?),
28829 impl Parse for BareFnArg {
28830 fn parse(input: ParseStream) -> Result<Self> {
28832 - attrs: input.call(Attribute::parse_outer)?,
28834 - if (input.peek(Ident) || input.peek(Token![_]))
28835 - && input.peek2(Token![:])
28836 - && !input.peek2(Token![::])
28838 - let name = input.call(Ident::parse_any)?;
28839 - let colon: Token![:] = input.parse()?;
28840 - Some((name, colon))
28845 - ty: input.parse()?,
28847 + let allow_mut_self = false;
28848 + parse_bare_fn_arg(input, allow_mut_self).map(Option::unwrap)
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)?,
28860 + if (input.peek(Ident) || input.peek(Token![_]) || input.peek(Token![self]))
28861 + && input.peek2(Token![:])
28862 + && !input.peek2(Token![::])
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![::])
28873 + has_mut_self = true;
28874 + allow_mut_self = false;
28875 + input.parse::<Token![mut]>()?;
28876 + input.parse::<Token![self]>()?;
28877 + input.parse::<Token![:]>()?;
28883 + ty: if !has_mut_self && input.peek(Token![...]) {
28884 + let dot3 = input.parse::<Token![...]>()?;
28886 + TokenTree::Punct(Punct::new('.', Spacing::Joint)),
28887 + TokenTree::Punct(Punct::new('.', Spacing::Joint)),
28888 + TokenTree::Punct(Punct::new('.', Spacing::Alone)),
28890 + let tokens = TokenStream::from_iter(args.into_iter().zip(&dot3.spans).map(
28891 + |(mut arg, span)| {
28892 + arg.set_span(*span);
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 {
28902 + path: input.parse::<Token![self]>()?.into(),
28909 + if has_mut_self {
28916 impl Parse for Abi {
28917 fn parse(input: ParseStream) -> Result<Self> {
28919 extern_token: input.parse()?,
28920 name: input.parse()?,
28921 diff --git a/third_party/rust/syn/src/verbatim.rs b/third_party/rust/syn/src/verbatim.rs
28922 new file mode 100644
28924 +++ b/third_party/rust/syn/src/verbatim.rs
28926 +use crate::parse::{ParseBuffer, ParseStream};
28927 +use proc_macro2::TokenStream;
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));
28941 diff --git a/third_party/rust/syn/src/whitespace.rs b/third_party/rust/syn/src/whitespace.rs
28942 new file mode 100644
28944 +++ b/third_party/rust/syn/src/whitespace.rs
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("//!")
28954 + if let Some(i) = s.find('\n') {
28960 + } else if s.starts_with("/**/") {
28963 + } else if s.starts_with("/*")
28964 + && (!s.starts_with("/**") || s.starts_with("/***"))
28965 + && !s.starts_with("/*!")
28967 + let mut depth = 0;
28968 + let bytes = s.as_bytes();
28970 + let upper = bytes.len() - 1;
28971 + while i < upper {
28972 + if bytes[i] == b'/' && bytes[i + 1] == b'*' {
28974 + i += 1; // eat '*'
28975 + } else if bytes[i] == b'*' && bytes[i + 1] == b'/' {
28981 + i += 1; // eat '/'
28989 + b' ' | 0x09..=0x0d => {
28993 + b if b <= 0x7f => {}
28995 + let ch = s.chars().next().unwrap();
28996 + if is_whitespace(ch) {
28997 + s = &s[ch.len_utf8()..];
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}'
29011 diff --git a/third_party/rust/syn/tests/.gitignore b/third_party/rust/syn/tests/.gitignore
29012 new file mode 100644
29014 +++ b/third_party/rust/syn/tests/.gitignore
29017 diff --git a/third_party/rust/syn/tests/clone.sh b/third_party/rust/syn/tests/clone.sh
29018 deleted file mode 100755
29019 --- a/third_party/rust/syn/tests/clone.sh
29024 -REV=4560cb830fce63fcffdc4558f4281aaac6a3a1ba
29027 -cd "$(dirname "${BASH_SOURCE[0]}")"
29031 -if [ "$(cat rust/COMMIT)" != "$REV" ]; then
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
29038 diff --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
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;
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,
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};
29102 pub trait SpanlessEq {
29103 fn eq(&self, other: &Self) -> bool;
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
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)
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)
29126 macro_rules! spanless_eq_true {
29128 impl SpanlessEq for $name {
29129 fn eq(&self, _other: &Self) -> bool {
29134 @@ -121,60 +112,62 @@ macro_rules! spanless_eq_partial_eq {
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);
29150 macro_rules! spanless_eq_struct {
29153 + $name:ident $(<$param:ident>)?;
29154 $([$field:ident $other:ident])*
29155 $(![$ignore:ident])*
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))&&*
29169 + $name:ident $(<$param:ident>)?;
29170 $([$field:ident $other:ident])*
29175 spanless_eq_struct! {
29177 + $name $(<$param>)*;
29178 $([$field $other])*
29187 + $name:ident $(<$param:ident>)?;
29188 $([$field:ident $other:ident])*
29189 $(![$ignore:ident])*
29193 spanless_eq_struct! {
29195 + $name $(<$param>)*;
29196 $([$field $other])*
29204 @@ -258,129 +251,141 @@ macro_rules! spanless_eq_enum {
29206 $([$variant $($fields)*])*
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)
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);
29393 impl SpanlessEq for Ident {
29394 fn eq(&self, other: &Self) -> bool {
29395 self.as_str() == other.as_str()
29399 // Give up on comparing literals inside of macros because there are so many
29400 @@ -409,49 +414,25 @@ impl SpanlessEq for TokenKind {
29402 _ => self == other,
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();
29413 + let this = match this.next() {
29414 + None => return other.next().is_none(),
29415 + Some(val) => val,
29417 + let other = match other.next() {
29418 + None => return false,
29419 + Some(val) => val,
29421 + if !SpanlessEq::eq(&this, &other) {
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),
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));
29447 - let lit = token::Lit {
29448 - kind: token::LitKind::Str,
29449 - symbol: Symbol::intern(&contents),
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),
29457 - tokens.push(TokenTree::Delimited(
29458 - DelimSpan::dummy(),
29459 - DelimToken::Bracket,
29460 - tts.into_iter().collect::<TokenStream>().into(),
29465 diff --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
29469 #![allow(dead_code)]
29471 +use rayon::ThreadPoolBuilder;
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(),
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,
29491 + ThreadPoolBuilder::new()
29492 + .stack_size(stack_size)
29496 diff --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
29500 -extern crate proc_macro2;
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;
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;
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(
29530 FileName::Custom("test_precedence".to_string()),
29535 Ok(expr) => Some(expr),
29536 @@ -27,17 +27,17 @@ pub fn libsyntax_expr(input: &str) -> Op
29542 Ok(Some(e)) => Some(e),
29545 - errorf!("libsyntax panicked\n");
29546 + errorf!("librustc panicked\n");
29552 pub fn syn_expr(input: &str) -> Option<syn::Expr> {
29553 match syn::parse_str(input) {
29555 diff --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
29559 // This file is @generated by syn-internal-codegen.
29560 // It is not intended for manual editing.
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 {
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));
29577 formatter.field("block", Lite(&_val.block));
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("`)")?;
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));
29595 if let Some(val) = &_val.label {
29596 @@ -2111,19 +2111,19 @@ impl Debug for Lite<syn::ForeignItem> {
29599 formatter.field("semi_token", Print::ref_cast(val));
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("`)")?;
29613 _ => unreachable!(),
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> {
29622 formatter.field("semi_token", Print::ref_cast(val));
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("`)")?;
29636 _ => unreachable!(),
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> {
29644 formatter.field("leading_colon", Print::ref_cast(val));
29646 formatter.field("tree", Lite(&_val.tree));
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("`)")?;
29659 _ => unreachable!(),
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));
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("`)")?;
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));
29691 formatter.field("pat", Lite(&_val.pat));
29692 formatter.field("ty", Lite(&_val.ty));
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("`)")?;
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));
29711 @@ -4669,19 +4669,19 @@ impl Debug for Lite<syn::TraitItem> {
29714 formatter.field("semi_token", Print::ref_cast(val));
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("`)")?;
29728 _ => unreachable!(),
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));
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("`)")?;
29751 _ => unreachable!(),
29755 impl Debug for Lite<syn::TypeArray> {
29756 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29757 diff --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
29761 -extern crate proc_macro2;
29762 -extern crate ref_cast;
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;
29775 #[repr(transparent)]
29776 pub struct Lite<T: ?Sized> {
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)
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)
29793 + .debug_tuple("TokenStream")
29794 + .field(&format_args!("`{}`", string))
29800 impl<'a, T> Debug for Lite<&'a T>
29804 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29805 diff --git a/third_party/rust/syn/tests/features/error.rs b/third_party/rust/syn/tests/features/error.rs
29806 deleted file mode 100644
29807 --- a/third_party/rust/syn/tests/features/error.rs
29810 -"Hello! You want: cargo test --release --all-features"
29811 diff --git a/third_party/rust/syn/tests/features/mod.rs b/third_party/rust/syn/tests/features/mod.rs
29812 deleted file mode 100644
29813 --- a/third_party/rust/syn/tests/features/mod.rs
29816 -#[allow(unused_macros)]
29817 -macro_rules! hide_from_rustfmt {
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",
29835 -hide_from_rustfmt! {
29838 diff --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
29842 -extern crate proc_macro2;
29844 #[path = "../debug/mod.rs"]
29848 use syn::parse::{Parse, Result};
29851 macro_rules! errorf {
29852 @@ -37,28 +35,28 @@ macro_rules! snapshot {
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);
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);
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);
29878 (($($expr:tt)*) $next:tt $($rest:tt)*) => {
29879 snapshot_impl!(($($expr)* $next) $($rest)*)
29884 diff --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
29888 -extern crate walkdir;
29891 +use self::progress::Progress;
29892 +use anyhow::Result;
29893 +use flate2::read::GzDecoder;
29895 +use std::path::Path;
29897 +use walkdir::DirEntry;
29899 +const REVISION: &str = "792c645ca7d11a8d254df307d019c5bf01445c37";
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",
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",
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",
29926 pub fn base_dir_filter(entry: &DirEntry) -> bool {
29927 let path = entry.path();
29929 return true; // otherwise walkdir does not visit the files
29931 if path.extension().map(|e| e != "rs").unwrap_or(true) {
29934 - let path_string = path.to_string_lossy();
29935 - let path_string = if cfg!(windows) {
29936 - path_string.replace('\\', "/").into()
29938 + let mut path_string = path.to_string_lossy();
29939 + if cfg!(windows) {
29940 + path_string = path_string.replace('\\', "/").into();
29942 + let path = if let Some(path) = path_string.strip_prefix("tests/rust/src/") {
29944 + } else if let Some(path) = path_string.strip_prefix("tests/rust/library/") {
29948 + panic!("unexpected path in Rust dist: {}", path_string);
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")
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
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,
29989 + !EXCLUDE.contains(&path)
29992 +#[allow(dead_code)]
29993 +pub fn edition(path: &Path) -> &'static str {
29994 + if path.ends_with("dyn-2015-no-warnings-without-lints.rs") {
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") {
30006 + Ok(contents) => contents.trim() != REVISION,
30009 + download_and_unpack().unwrap();
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;
30019 + if !missing.is_empty() {
30020 + panic!("excluded test file does not exist:{}\n", missing);
30024 +fn download_and_unpack() -> Result<()> {
30025 + let url = format!(
30026 + "https://github.com/rust-lang/rust/archive/{}.tar.gz",
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);
30035 + let tests_rust = Path::new("tests/rust");
30036 + if tests_rust.exists() {
30037 + fs::remove_dir_all(tests_rust)?;
30040 + for entry in archive.entries()? {
30041 + let mut entry = entry?;
30042 + let path = entry.path()?;
30043 + if path == Path::new("pax_global_header") {
30046 + let relative = path.strip_prefix(&prefix)?;
30047 + let out = tests_rust.join(relative);
30048 + entry.unpack(&out)?;
30051 + fs::write("tests/rust/COMMIT", REVISION)?;
30054 diff --git a/third_party/rust/syn/tests/repo/progress.rs b/third_party/rust/syn/tests/repo/progress.rs
30055 new file mode 100644
30057 +++ b/third_party/rust/syn/tests/repo/progress.rs
30059 +use std::io::{Read, Result};
30060 +use std::time::{Duration, Instant};
30062 +pub struct Progress<R> {
30068 +impl<R> Progress<R> {
30069 + pub fn new(stream: R) -> Self {
30072 + tick: Instant::now() + Duration::from_millis(2000),
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);
30091 +impl<R> Drop for Progress<R> {
30092 + fn drop(&mut self) {
30093 + errorf!("done ({} bytes)\n", self.bytes);
30096 diff --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
30107 use syn::{Expr, Item};
30110 fn test_async_fn() {
30111 let input = "async fn process() {}";
30113 snapshot!(input as Item, @r###"
30115 - ⋮ vis: Inherited,
30116 - ⋮ sig: Signature {
30117 - ⋮ asyncness: Some,
30118 - ⋮ ident: "process",
30119 - ⋮ generics: Generics,
30120 - ⋮ output: Default,
30128 + ident: "process",
30129 + generics: Generics,
30138 fn test_async_closure() {
30139 let input = "async || {}";
30141 snapshot!(input as Expr, @r###"
30143 - ⋮ asyncness: Some,
30144 - ⋮ output: Default,
30145 - ⋮ body: Expr::Block {
30152 + body: Expr::Block {
30158 diff --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 @@
30169 use syn::parse::Parser;
30170 use syn::{Attribute, Meta};
30173 fn test_meta_item_word() {
30174 let meta = test("#[foo]");
30176 snapshot!(meta, @r###"
30181 - ⋮ arguments: None,
30197 fn test_meta_item_name_value() {
30198 let meta = test("#[foo = 5]");
30200 snapshot!(meta, @r###"
30201 - ⋮Meta::NameValue {
30206 - ⋮ arguments: None,
30212 + Meta::NameValue {
30227 fn test_meta_item_bool_value() {
30228 let meta = test("#[foo = true]");
30230 snapshot!(meta, @r###"
30231 - ⋮Meta::NameValue {
30236 - ⋮ arguments: None,
30240 - ⋮ lit: Lit::Bool {
30244 + Meta::NameValue {
30259 let meta = test("#[foo = false]");
30261 snapshot!(meta, @r###"
30262 - ⋮Meta::NameValue {
30267 - ⋮ arguments: None,
30271 - ⋮ lit: Lit::Bool {
30275 + Meta::NameValue {
30292 fn test_meta_item_list_lit() {
30293 let meta = test("#[foo(5)]");
30295 snapshot!(meta, @r###"
30301 - ⋮ arguments: None,
30326 fn test_meta_item_list_word() {
30327 let meta = test("#[foo(bar)]");
30329 snapshot!(meta, @r###"
30335 - ⋮ arguments: None,
30340 - ⋮ Meta(Path(Path {
30344 - ⋮ arguments: None,
30374 fn test_meta_item_list_name_value() {
30375 let meta = test("#[foo(bar = 5)]");
30377 snapshot!(meta, @r###"
30383 - ⋮ arguments: None,
30388 - ⋮ Meta(Meta::NameValue {
30393 - ⋮ arguments: None,
30411 + Meta(Meta::NameValue {
30428 fn test_meta_item_list_bool_value() {
30429 let meta = test("#[foo(bar = true)]");
30431 snapshot!(meta, @r###"
30437 - ⋮ arguments: None,
30442 - ⋮ Meta(Meta::NameValue {
30447 - ⋮ arguments: None,
30451 - ⋮ lit: Lit::Bool {
30467 + Meta(Meta::NameValue {
30486 fn test_meta_item_multiple() {
30487 let meta = test("#[foo(word, name = 5, list(name2 = 6), word2)]");
30489 snapshot!(meta, @r###"
30495 - ⋮ arguments: None,
30500 - ⋮ Meta(Path(Path {
30504 - ⋮ arguments: None,
30508 - ⋮ Meta(Meta::NameValue {
30513 - ⋮ arguments: None,
30519 - ⋮ Meta(Meta::List {
30524 - ⋮ arguments: None,
30529 - ⋮ Meta(Meta::NameValue {
30533 - ⋮ ident: "name2",
30534 - ⋮ arguments: None,
30542 - ⋮ Meta(Path(Path {
30545 - ⋮ ident: "word2",
30546 - ⋮ arguments: None,
30570 + Meta(Meta::NameValue {
30581 + Meta(Meta::List {
30591 + Meta(Meta::NameValue {
30618 fn test_bool_lit() {
30619 let meta = test("#[foo(true)]");
30621 snapshot!(meta, @r###"
30627 - ⋮ arguments: None,
30632 - ⋮ Lit(Lit::Bool {
30656 +fn test_negative_lit() {
30657 + let meta = test("#[form(min = -1, max = 200)]");
30659 + snapshot!(meta, @r###"
30670 + Meta(Meta::NameValue {
30681 + Meta(Meta::NameValue {
30697 fn test(input: &str) -> Meta {
30698 let attrs = Attribute::parse_outer.parse_str(input).unwrap();
30700 assert_eq!(attrs.len(), 1);
30701 let attr = attrs.into_iter().next().unwrap();
30702 diff --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;
30715 use syn::{Data, DeriveInput};
30719 let input = quote! {
30723 snapshot!(input as DeriveInput, @r###"
30725 - ⋮ vis: Inherited,
30727 - ⋮ generics: Generics,
30728 - ⋮ data: Data::Struct {
30730 - ⋮ semi_token: Some,
30736 + generics: Generics,
30737 + data: Data::Struct {
30739 + semi_token: Some,
30747 let input = quote! {
30748 #[derive(Debug, Clone)]
30751 pub attrs: Vec<Attribute>
30755 snapshot!(input as DeriveInput, @r###"
30763 - ⋮ ident: "derive",
30764 - ⋮ arguments: None,
30768 - ⋮ tokens: `( Debug , Clone )`,
30771 - ⋮ vis: Visibility::Public,
30773 - ⋮ generics: Generics,
30774 - ⋮ data: Data::Struct {
30775 - ⋮ fields: Fields::Named {
30778 - ⋮ vis: Visibility::Public,
30779 - ⋮ ident: Some("ident"),
30780 - ⋮ colon_token: Some,
30781 - ⋮ ty: Type::Path {
30785 - ⋮ ident: "Ident",
30786 - ⋮ arguments: None,
30793 - ⋮ vis: Visibility::Public,
30794 - ⋮ ident: Some("attrs"),
30795 - ⋮ colon_token: Some,
30796 - ⋮ ty: Type::Path {
30801 - ⋮ arguments: PathArguments::AngleBracketed {
30803 - ⋮ Type(Type::Path {
30807 - ⋮ ident: "Attribute",
30808 - ⋮ arguments: None,
30836 + tokens: TokenStream(`(Debug , Clone)`),
30839 + vis: Visibility::Public,
30841 + generics: Generics,
30842 + data: Data::Struct {
30843 + fields: Fields::Named {
30846 + vis: Visibility::Public,
30847 + ident: Some("ident"),
30848 + colon_token: Some,
30861 + vis: Visibility::Public,
30862 + ident: Some("attrs"),
30863 + colon_token: Some,
30869 + arguments: PathArguments::AngleBracketed {
30871 + Type(Type::Path {
30875 + ident: "Attribute",
30894 snapshot!(input.attrs[0].parse_meta().unwrap(), @r###"
30899 - ⋮ ident: "derive",
30900 - ⋮ arguments: None,
30905 - ⋮ Meta(Path(Path {
30908 - ⋮ ident: "Debug",
30909 - ⋮ arguments: None,
30913 - ⋮ Meta(Path(Path {
30916 - ⋮ ident: "Clone",
30917 - ⋮ arguments: None,
30956 let input = quote! {
30957 union MaybeUninit<T> {
30963 snapshot!(input as DeriveInput, @r###"
30965 - ⋮ vis: Inherited,
30966 - ⋮ ident: "MaybeUninit",
30967 - ⋮ generics: Generics {
30968 - ⋮ lt_token: Some,
30970 - ⋮ Type(TypeParam {
30974 - ⋮ gt_token: Some,
30976 - ⋮ data: Data::Union {
30977 - ⋮ fields: FieldsNamed {
30980 - ⋮ vis: Inherited,
30981 - ⋮ ident: Some("uninit"),
30982 - ⋮ colon_token: Some,
30983 - ⋮ ty: Type::Tuple,
30986 - ⋮ vis: Inherited,
30987 - ⋮ ident: Some("value"),
30988 - ⋮ colon_token: Some,
30989 - ⋮ ty: Type::Path {
30994 - ⋮ arguments: None,
31006 + ident: "MaybeUninit",
31007 + generics: Generics {
31016 + data: Data::Union {
31017 + fields: FieldsNamed {
31021 + ident: Some("uninit"),
31022 + colon_token: Some,
31027 + ident: Some("value"),
31028 + colon_token: Some,
31048 #[cfg(feature = "full")]
31050 let input = quote! {
31051 /// See the std::result module documentation for details.
31052 @@ -207,472 +202,472 @@ fn test_enum() {
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
31060 snapshot!(input as DeriveInput, @r###"
31069 - ⋮ arguments: None,
31073 - ⋮ tokens: `= r" See the std::result module documentation for details."`,
31080 - ⋮ ident: "must_use",
31081 - ⋮ arguments: None,
31088 - ⋮ vis: Visibility::Public,
31089 - ⋮ ident: "Result",
31090 - ⋮ generics: Generics {
31091 - ⋮ lt_token: Some,
31093 - ⋮ Type(TypeParam {
31096 - ⋮ Type(TypeParam {
31100 - ⋮ gt_token: Some,
31102 - ⋮ data: Data::Enum {
31106 - ⋮ fields: Fields::Unnamed {
31109 - ⋮ vis: Inherited,
31110 - ⋮ ty: Type::Path {
31115 - ⋮ arguments: None,
31126 - ⋮ fields: Fields::Unnamed {
31129 - ⋮ vis: Inherited,
31130 - ⋮ ty: Type::Path {
31135 - ⋮ arguments: None,
31145 - ⋮ ident: "Surprise",
31147 - ⋮ discriminant: Some(Expr::Lit {
31152 - ⋮ ident: "ProcMacroHack",
31154 - ⋮ discriminant: Some(Expr::Field {
31155 - ⋮ base: Expr::Tuple {
31165 - ⋮ member: Unnamed(Index {
31185 + tokens: TokenStream(`= r" See the std::result module documentation for details."`),
31192 + ident: "must_use",
31197 + tokens: TokenStream(``),
31200 + vis: Visibility::Public,
31202 + generics: Generics {
31214 + data: Data::Enum {
31218 + fields: Fields::Unnamed {
31238 + fields: Fields::Unnamed {
31257 + ident: "Surprise",
31259 + discriminant: Some(Expr::Lit {
31264 + ident: "ProcMacroHack",
31266 + discriminant: Some(Expr::Field {
31267 + base: Expr::Tuple {
31277 + member: Unnamed(Index {
31287 let meta_items: Vec<_> = input
31290 .map(|attr| attr.parse_meta().unwrap())
31293 snapshot!(meta_items, @r###"
31295 - ⋮ Meta::NameValue {
31300 - ⋮ arguments: None,
31304 - ⋮ lit: " See the std::result module documentation for details.",
31309 - ⋮ ident: "must_use",
31310 - ⋮ arguments: None,
31316 + Meta::NameValue {
31325 + lit: " See the std::result module documentation for details.",
31330 + ident: "must_use",
31340 fn test_attr_with_path() {
31341 let input = quote! {
31342 #[::attr_args::identity
31343 fn main() { assert_eq!(foo(), "Hello, world!"); }]
31347 snapshot!(input as DeriveInput, @r###"
31353 - ⋮ leading_colon: Some,
31356 - ⋮ ident: "attr_args",
31357 - ⋮ arguments: None,
31360 - ⋮ ident: "identity",
31361 - ⋮ arguments: None,
31365 - ⋮ tokens: `fn main ( ) { assert_eq ! ( foo ( ) , "Hello, world!" ) ; }`,
31368 - ⋮ vis: Inherited,
31369 - ⋮ ident: "Dummy",
31370 - ⋮ generics: Generics,
31371 - ⋮ data: Data::Struct {
31373 - ⋮ semi_token: Some,
31381 + leading_colon: Some,
31384 + ident: "attr_args",
31388 + ident: "identity",
31393 + tokens: TokenStream(`fn main () { assert_eq ! (foo () , "Hello, world!") ; }`),
31398 + generics: Generics,
31399 + data: Data::Struct {
31401 + semi_token: Some,
31406 assert!(input.attrs[0].parse_meta().is_err());
31410 fn test_attr_with_non_mod_style_path() {
31411 let input = quote! {
31416 snapshot!(input as DeriveInput, @r###"
31424 - ⋮ ident: "inert",
31425 - ⋮ arguments: None,
31429 - ⋮ tokens: `< T >`,
31432 - ⋮ vis: Inherited,
31434 - ⋮ generics: Generics,
31435 - ⋮ data: Data::Struct {
31437 - ⋮ semi_token: Some,
31452 + tokens: TokenStream(`< T >`),
31457 + generics: Generics,
31458 + data: Data::Struct {
31460 + semi_token: Some,
31465 assert!(input.attrs[0].parse_meta().is_err());
31469 fn test_attr_with_mod_style_path_with_self() {
31470 let input = quote! {
31475 snapshot!(input as DeriveInput, @r###"
31484 - ⋮ arguments: None,
31488 - ⋮ arguments: None,
31495 - ⋮ vis: Inherited,
31497 - ⋮ generics: Generics,
31498 - ⋮ data: Data::Struct {
31500 - ⋮ semi_token: Some,
31519 + tokens: TokenStream(``),
31524 + generics: Generics,
31525 + data: Data::Struct {
31527 + semi_token: Some,
31532 snapshot!(input.attrs[0].parse_meta().unwrap(), @r###"
31537 - ⋮ arguments: None,
31541 - ⋮ arguments: None,
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);
31567 snapshot!(input as DeriveInput, @r###"
31569 - ⋮ vis: Visibility::Restricted {
31570 - ⋮ in_token: Some,
31575 - ⋮ arguments: None,
31581 - ⋮ generics: Generics,
31582 - ⋮ data: Data::Struct {
31583 - ⋮ fields: Fields::Unnamed {
31586 - ⋮ vis: Visibility::Restricted {
31587 - ⋮ in_token: Some,
31592 - ⋮ arguments: None,
31596 - ⋮ arguments: None,
31601 - ⋮ ty: Type::Path {
31606 - ⋮ arguments: None,
31614 - ⋮ semi_token: Some,
31618 + vis: Visibility::Restricted {
31630 + generics: Generics,
31631 + data: Data::Struct {
31632 + fields: Fields::Unnamed {
31635 + vis: Visibility::Restricted {
31663 + semi_token: Some,
31670 fn test_vis_crate() {
31671 let input = quote! {
31675 snapshot!(input as DeriveInput, @r###"
31677 - ⋮ vis: Visibility::Crate,
31679 - ⋮ generics: Generics,
31680 - ⋮ data: Data::Struct {
31682 - ⋮ semi_token: Some,
31686 + vis: Visibility::Crate,
31688 + generics: Generics,
31689 + data: Data::Struct {
31691 + semi_token: Some,
31698 fn test_pub_restricted_crate() {
31699 let input = quote! {
31700 pub(crate) struct S;
31703 snapshot!(input as DeriveInput, @r###"
31705 - ⋮ vis: Visibility::Restricted {
31709 - ⋮ ident: "crate",
31710 - ⋮ arguments: None,
31716 - ⋮ generics: Generics,
31717 - ⋮ data: Data::Struct {
31719 - ⋮ semi_token: Some,
31723 + vis: Visibility::Restricted {
31734 + generics: Generics,
31735 + data: Data::Struct {
31737 + semi_token: Some,
31744 fn test_pub_restricted_super() {
31745 let input = quote! {
31746 pub(super) struct S;
31749 snapshot!(input as DeriveInput, @r###"
31751 - ⋮ vis: Visibility::Restricted {
31755 - ⋮ ident: "super",
31756 - ⋮ arguments: None,
31762 - ⋮ generics: Generics,
31763 - ⋮ data: Data::Struct {
31765 - ⋮ semi_token: Some,
31769 + vis: Visibility::Restricted {
31780 + generics: Generics,
31781 + data: Data::Struct {
31783 + semi_token: Some,
31790 fn test_pub_restricted_in_super() {
31791 let input = quote! {
31792 pub(in super) struct S;
31795 snapshot!(input as DeriveInput, @r###"
31797 - ⋮ vis: Visibility::Restricted {
31798 - ⋮ in_token: Some,
31802 - ⋮ ident: "super",
31803 - ⋮ arguments: None,
31809 - ⋮ generics: Generics,
31810 - ⋮ data: Data::Struct {
31812 - ⋮ semi_token: Some,
31816 + vis: Visibility::Restricted {
31828 + generics: Generics,
31829 + data: Data::Struct {
31831 + semi_token: Some,
31838 fn test_fields_on_unit_struct() {
31839 let input = quote! {
31843 snapshot!(input as DeriveInput, @r###"
31845 - ⋮ vis: Inherited,
31847 - ⋮ generics: Generics,
31848 - ⋮ data: Data::Struct {
31850 - ⋮ semi_token: Some,
31856 + generics: Generics,
31857 + data: Data::Struct {
31859 + semi_token: Some,
31864 let data = match input.data {
31865 Data::Struct(data) => data,
31866 _ => panic!("expected a struct"),
31869 assert_eq!(0, data.fields.iter().count());
31870 @@ -683,215 +678,215 @@ fn test_fields_on_named_struct() {
31871 let input = quote! {
31878 snapshot!(input as DeriveInput, @r###"
31880 - ⋮ vis: Inherited,
31882 - ⋮ generics: Generics,
31883 - ⋮ data: Data::Struct {
31884 - ⋮ fields: Fields::Named {
31887 - ⋮ vis: Inherited,
31888 - ⋮ ident: Some("foo"),
31889 - ⋮ colon_token: Some,
31890 - ⋮ ty: Type::Path {
31895 - ⋮ arguments: None,
31902 - ⋮ vis: Visibility::Public,
31903 - ⋮ ident: Some("bar"),
31904 - ⋮ colon_token: Some,
31905 - ⋮ ty: Type::Path {
31909 - ⋮ ident: "String",
31910 - ⋮ arguments: None,
31923 + generics: Generics,
31924 + data: Data::Struct {
31925 + fields: Fields::Named {
31929 + ident: Some("foo"),
31930 + colon_token: Some,
31943 + vis: Visibility::Public,
31944 + ident: Some("bar"),
31945 + colon_token: Some,
31963 let data = match input.data {
31964 Data::Struct(data) => data,
31965 _ => panic!("expected a struct"),
31968 snapshot!(data.fields.into_iter().collect::<Vec<_>>(), @r###"
31971 - ⋮ vis: Inherited,
31972 - ⋮ ident: Some("foo"),
31973 - ⋮ colon_token: Some,
31974 - ⋮ ty: Type::Path {
31979 - ⋮ arguments: None,
31986 - ⋮ vis: Visibility::Public,
31987 - ⋮ ident: Some("bar"),
31988 - ⋮ colon_token: Some,
31989 - ⋮ ty: Type::Path {
31993 - ⋮ ident: "String",
31994 - ⋮ arguments: None,
32004 + ident: Some("foo"),
32005 + colon_token: Some,
32018 + vis: Visibility::Public,
32019 + ident: Some("bar"),
32020 + colon_token: Some,
32037 fn test_fields_on_tuple_struct() {
32038 let input = quote! {
32039 struct S(i32, pub String);
32042 snapshot!(input as DeriveInput, @r###"
32044 - ⋮ vis: Inherited,
32046 - ⋮ generics: Generics,
32047 - ⋮ data: Data::Struct {
32048 - ⋮ fields: Fields::Unnamed {
32051 - ⋮ vis: Inherited,
32052 - ⋮ ty: Type::Path {
32057 - ⋮ arguments: None,
32064 - ⋮ vis: Visibility::Public,
32065 - ⋮ ty: Type::Path {
32069 - ⋮ ident: "String",
32070 - ⋮ arguments: None,
32078 - ⋮ semi_token: Some,
32084 + generics: Generics,
32085 + data: Data::Struct {
32086 + fields: Fields::Unnamed {
32102 + vis: Visibility::Public,
32116 + semi_token: Some,
32121 let data = match input.data {
32122 Data::Struct(data) => data,
32123 _ => panic!("expected a struct"),
32126 snapshot!(data.fields.iter().collect::<Vec<_>>(), @r###"
32129 - ⋮ vis: Inherited,
32130 - ⋮ ty: Type::Path {
32135 - ⋮ arguments: None,
32142 - ⋮ vis: Visibility::Public,
32143 - ⋮ ty: Type::Path {
32147 - ⋮ ident: "String",
32148 - ⋮ arguments: None,
32170 + vis: Visibility::Public,
32187 fn test_ambiguous_crate() {
32188 let input = quote! {
32189 // The field type is `(crate::X)` not `crate (::X)`.
32190 struct S(crate::X);
32193 snapshot!(input as DeriveInput, @r###"
32195 - ⋮ vis: Inherited,
32197 - ⋮ generics: Generics,
32198 - ⋮ data: Data::Struct {
32199 - ⋮ fields: Fields::Unnamed {
32202 - ⋮ vis: Inherited,
32203 - ⋮ ty: Type::Path {
32207 - ⋮ ident: "crate",
32208 - ⋮ arguments: None,
32212 - ⋮ arguments: None,
32220 - ⋮ semi_token: Some,
32226 + generics: Generics,
32227 + data: Data::Struct {
32228 + fields: Fields::Unnamed {
32249 + semi_token: Some,
32254 diff --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
32258 -extern crate proc_macro2;
32264 -use std::str::FromStr;
32266 -use proc_macro2::TokenStream;
32267 +use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
32269 +use std::iter::FromIterator;
32270 use syn::{Expr, ExprRange};
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###"
32282 + limits: HalfOpen,
32283 + to: Some(Expr::Lit {
32289 + let tokens = quote!(..100u32);
32290 + snapshot!(tokens as ExprRange, @r###"
32292 + limits: HalfOpen,
32293 + to: Some(Expr::Lit {
32302 // Must not parse as Expr::Field.
32303 - let expr = syn::parse_str::<Expr>("fut.await").unwrap();
32304 + let tokens = quote!(fut.await);
32306 - snapshot!(expr, @r###"
32308 - ⋮ base: Expr::Path {
32313 - ⋮ arguments: None,
32319 + snapshot!(tokens as Expr, @r###"
32321 + base: Expr::Path {
32337 +fn test_tuple_multi_index() {
32346 + snapshot!(input as Expr, @r###"
32348 + base: Expr::Field {
32349 + base: Expr::Path {
32359 + member: Unnamed(Index {
32363 + member: Unnamed(Index {
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),
32378 + snapshot!(tokens as Expr, @r###"
32380 + base: Expr::Field {
32381 + base: Expr::Path {
32391 + member: Unnamed(Index {
32395 + member: Unnamed(Index {
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())),
32411 + snapshot!(tokens as Expr, @r###"
32413 + func: Expr::Group {
32414 + expr: Expr::Path {
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())),
32435 + snapshot!(tokens as Expr, @r###"
32443 + ident: "outside",
32448 + tokens: TokenStream(``),
32451 + func: Expr::Group {
32452 + expr: Expr::Path {
32464 + tokens: TokenStream(``),
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())),
32490 + snapshot!(tokens as Expr, @r###"
32501 + delimiter: Paren,
32502 + tokens: TokenStream(``),
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())),
32516 + snapshot!(tokens as Expr, @r###"
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] () })),
32547 + snapshot!(tokens as Expr, @r###"
32549 + expr: Expr::Path {
32562 + body: Expr::Group {
32563 + expr: Expr::Tuple {
32575 + tokens: TokenStream(``),
32585 diff --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;
32598 use syn::{DeriveInput, ItemFn, TypeParamBound, WhereClause, WherePredicate};
32601 fn test_split_for_impl() {
32602 let input = quote! {
32603 struct S<'a, 'b: 'a, #[may_dangle] T: 'a = ()> where T: Debug;
32606 snapshot!(input as DeriveInput, @r###"
32608 - ⋮ vis: Inherited,
32610 - ⋮ generics: Generics {
32611 - ⋮ lt_token: Some,
32613 - ⋮ Lifetime(LifetimeDef {
32614 - ⋮ lifetime: Lifetime {
32618 - ⋮ Lifetime(LifetimeDef {
32619 - ⋮ lifetime: Lifetime {
32622 - ⋮ colon_token: Some,
32629 - ⋮ Type(TypeParam {
32636 - ⋮ ident: "may_dangle",
32637 - ⋮ arguments: None,
32645 - ⋮ colon_token: Some,
32647 - ⋮ Lifetime(Lifetime {
32651 - ⋮ eq_token: Some,
32652 - ⋮ default: Some(Type::Tuple),
32655 - ⋮ gt_token: Some,
32656 - ⋮ where_clause: Some(WhereClause {
32658 - ⋮ Type(PredicateType {
32659 - ⋮ bounded_ty: Type::Path {
32664 - ⋮ arguments: None,
32670 - ⋮ Trait(TraitBound {
32671 - ⋮ modifier: None,
32675 - ⋮ ident: "Debug",
32676 - ⋮ arguments: None,
32686 - ⋮ data: Data::Struct {
32688 - ⋮ semi_token: Some,
32694 + generics: Generics {
32697 + Lifetime(LifetimeDef {
32698 + lifetime: Lifetime {
32702 + Lifetime(LifetimeDef {
32703 + lifetime: Lifetime {
32706 + colon_token: Some,
32720 + ident: "may_dangle",
32725 + tokens: TokenStream(``),
32729 + colon_token: Some,
32731 + Lifetime(Lifetime {
32736 + default: Some(Type::Tuple),
32740 + where_clause: Some(WhereClause {
32742 + Type(PredicateType {
32743 + bounded_ty: Type::Path {
32754 + Trait(TraitBound {
32770 + data: Data::Struct {
32772 + semi_token: Some,
32777 let generics = input.generics;
32778 let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
32780 let generated = quote! {
32781 impl #impl_generics MyTrait for Test #ty_generics #where_clause {}
32783 @@ -126,156 +121,156 @@ fn test_split_for_impl() {
32785 assert_eq!(generated.to_string(), expected.to_string());
32789 fn test_ty_param_bound() {
32790 let tokens = quote!('a);
32791 snapshot!(tokens as TypeParamBound, @r###"
32792 - ⋮Lifetime(Lifetime {
32795 + Lifetime(Lifetime {
32800 let tokens = quote!('_);
32801 snapshot!(tokens as TypeParamBound, @r###"
32802 - ⋮Lifetime(Lifetime {
32805 + Lifetime(Lifetime {
32810 let tokens = quote!(Debug);
32811 snapshot!(tokens as TypeParamBound, @r###"
32812 - ⋮Trait(TraitBound {
32813 - ⋮ modifier: None,
32817 - ⋮ ident: "Debug",
32818 - ⋮ arguments: None,
32823 + Trait(TraitBound {
32836 let tokens = quote!(?Sized);
32837 snapshot!(tokens as TypeParamBound, @r###"
32838 - ⋮Trait(TraitBound {
32839 - ⋮ modifier: Maybe,
32843 - ⋮ ident: "Sized",
32844 - ⋮ arguments: None,
32849 + Trait(TraitBound {
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! {
32870 G: FnOnce() -> i32 + Send,
32875 snapshot!(input as ItemFn, @r###"
32877 - ⋮ vis: Inherited,
32878 - ⋮ sig: Signature {
32880 - ⋮ generics: Generics {
32881 - ⋮ lt_token: Some,
32883 - ⋮ Type(TypeParam {
32887 - ⋮ gt_token: Some,
32888 - ⋮ where_clause: Some(WhereClause {
32890 - ⋮ Type(PredicateType {
32891 - ⋮ bounded_ty: Type::Path {
32896 - ⋮ arguments: None,
32902 - ⋮ Trait(TraitBound {
32903 - ⋮ modifier: None,
32907 - ⋮ ident: "FnOnce",
32908 - ⋮ arguments: PathArguments::Parenthesized {
32915 - ⋮ arguments: None,
32926 - ⋮ Trait(TraitBound {
32927 - ⋮ modifier: None,
32932 - ⋮ arguments: None,
32942 - ⋮ output: Default,
32950 + generics: Generics {
32958 + where_clause: Some(WhereClause {
32960 + Type(PredicateType {
32961 + bounded_ty: Type::Path {
32972 + Trait(TraitBound {
32978 + arguments: PathArguments::Parenthesized {
32996 + Trait(TraitBound {
33018 let where_clause = input.sig.generics.where_clause.as_ref().unwrap();
33019 assert_eq!(where_clause.predicates.len(), 1);
33021 let predicate = match &where_clause.predicates[0] {
33022 WherePredicate::Type(pred) => pred,
33023 _ => panic!("wrong predicate kind"),
33026 assert_eq!(predicate.bounds.len(), 2, "{:#?}", predicate.bounds);
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");
33032 let second_bound = &predicate.bounds[1];
33033 assert_eq!(quote!(#second_bound).to_string(), "Send");
33037 fn test_where_clause_at_end_of_input() {
33038 let input = quote! {
33039 diff --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
33043 -extern crate proc_macro2;
33051 use proc_macro2::{Delimiter, Group, Literal, Punct, Spacing, TokenStream, TokenTree};
33054 use std::iter::FromIterator;
33056 @@ -23,36 +18,36 @@ fn test_grouping() {
33057 TokenTree::Punct(Punct::new('+', Spacing::Alone)),
33058 TokenTree::Literal(Literal::i32_suffixed(3)),
33061 TokenTree::Punct(Punct::new('*', Spacing::Alone)),
33062 TokenTree::Literal(Literal::i32_suffixed(4)),
33065 - assert_eq!(tokens.to_string(), "1i32 + 2i32 + 3i32 * 4i32");
33066 + assert_eq!(tokens.to_string(), "1i32 + 2i32 + 3i32 * 4i32");
33068 snapshot!(tokens as Expr, @r###"
33070 - ⋮ left: Expr::Lit {
33074 - ⋮ right: Expr::Binary {
33075 - ⋮ left: Expr::Group {
33076 - ⋮ expr: Expr::Binary {
33077 - ⋮ left: Expr::Lit {
33081 - ⋮ right: Expr::Lit {
33087 - ⋮ right: Expr::Lit {
33093 + left: Expr::Lit {
33097 + right: Expr::Binary {
33098 + left: Expr::Group {
33099 + expr: Expr::Binary {
33100 + left: Expr::Lit {
33104 + right: Expr::Lit {
33110 + right: Expr::Lit {
33117 diff --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
33121 -extern crate proc_macro2;
33126 use proc_macro2::{Ident, Span, TokenStream};
33127 use std::str::FromStr;
33130 fn parse(s: &str) -> Result<Ident> {
33131 syn::parse2(TokenStream::from_str(s).unwrap())
33134 diff --git a/third_party/rust/syn/tests/test_item.rs b/third_party/rust/syn/tests/test_item.rs
33135 new file mode 100644
33137 +++ b/third_party/rust/syn/tests/test_item.rs
33142 +use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
33144 +use std::iter::FromIterator;
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())),
33158 + snapshot!(tokens as Item, @r###"
33171 + tokens: TokenStream(``),
33177 + generics: Generics,
33184 diff --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
33188 use syn::punctuated::{Pair, Punctuated};
33190 -extern crate quote;
33200 macro_rules! check_exact_size_iterator {
33203 let size_hint = iter.size_hint();
33204 diff --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
33208 -extern crate proc_macro2;
33209 -extern crate quote;
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;
33222 +use syn::{Lit, LitFloat, LitInt};
33224 fn lit(s: &str) -> Lit {
33225 match TokenStream::from_str(s)
33231 @@ -45,16 +43,19 @@ fn strings() {
33232 test_string("\"'\"", "'");
33233 test_string("\"\"", "");
33234 test_string("\"\\u{1F415}\"", "\u{1F415}");
33236 "\"contains\nnewlines\\\nescaped newlines\"",
33237 "contains\nnewlinesescaped newlines",
33239 test_string("r\"raw\nstring\\\nhere\"", "raw\nstring\\\nhere");
33240 + test_string("\"...\"q", "...");
33241 + test_string("r\"...\"q", "...");
33242 + test_string("r##\"...\"##q", "...");
33246 fn byte_strings() {
33247 fn test_byte_string(s: &str, value: &[u8]) {
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"");
33256 "b\"contains\nnewlines\\\nescaped newlines\"",
33257 b"contains\nnewlinesescaped newlines",
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"...");
33267 fn test_byte(s: &str, value: u8) {
33269 Lit::Byte(lit) => {
33270 assert_eq!(lit.value(), value);
33271 @@ -95,16 +99,17 @@ fn bytes() {
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');
33285 fn test_char(s: &str, value: char) {
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');
33303 fn test_int(s: &str, value: u64, suffix: &str) {
33306 assert_eq!(lit.base10_digits().parse::<u64>().unwrap(), value);
33307 @@ -180,9 +186,64 @@ fn floats() {
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");
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());
33334 + fn get_suffix(token: &str) -> String {
33335 + let lit = syn::parse_str::<Lit>(token).unwrap();
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!(),
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");
33361 +fn test_deep_group_empty() {
33362 + let tokens = TokenStream::from_iter(vec![TokenTree::Group(Group::new(
33364 + TokenStream::from_iter(vec![TokenTree::Group(Group::new(
33366 + TokenStream::from_iter(vec![TokenTree::Literal(Literal::string("hi"))]),
33370 + snapshot!(tokens as Lit, @r#""hi""# );
33372 diff --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 @@
33383 use syn::{Meta, MetaList, MetaNameValue, NestedMeta};
33386 fn test_parse_meta_item_word() {
33387 let input = "hello";
33389 snapshot!(input as Meta, @r###"
33393 - ⋮ ident: "hello",
33394 - ⋮ arguments: None,
33410 fn test_parse_meta_name_value() {
33411 let input = "foo = 5";
33412 let (inner, meta) = (input, input);
33414 snapshot!(inner as MetaNameValue, @r###"
33420 - ⋮ arguments: None,
33439 snapshot!(meta as Meta, @r###"
33440 - ⋮Meta::NameValue {
33445 - ⋮ arguments: None,
33451 + Meta::NameValue {
33464 assert_eq!(meta, inner.into());
33468 fn test_parse_meta_name_value_with_keyword() {
33469 let input = "static = 5";
33470 let (inner, meta) = (input, input);
33472 snapshot!(inner as MetaNameValue, @r###"
33477 - ⋮ ident: "static",
33478 - ⋮ arguments: None,
33497 snapshot!(meta as Meta, @r###"
33498 - ⋮Meta::NameValue {
33502 - ⋮ ident: "static",
33503 - ⋮ arguments: None,
33509 + Meta::NameValue {
33522 assert_eq!(meta, inner.into());
33526 fn test_parse_meta_name_value_with_bool() {
33527 let input = "true = 5";
33528 let (inner, meta) = (input, input);
33530 snapshot!(inner as MetaNameValue, @r###"
33536 - ⋮ arguments: None,
33555 snapshot!(meta as Meta, @r###"
33556 - ⋮Meta::NameValue {
33561 - ⋮ arguments: None,
33567 + Meta::NameValue {
33580 assert_eq!(meta, inner.into());
33584 fn test_parse_meta_item_list_lit() {
33585 let input = "foo(5)";
33586 let (inner, meta) = (input, input);
33588 snapshot!(inner as MetaList, @r###"
33594 - ⋮ arguments: None,
33617 snapshot!(meta as Meta, @r###"
33623 - ⋮ arguments: None,
33646 assert_eq!(meta, inner.into());
33650 fn test_parse_meta_item_multiple() {
33651 let input = "foo(word, name = 5, list(name2 = 6), word2)";
33652 let (inner, meta) = (input, input);
33654 snapshot!(inner as MetaList, @r###"
33660 - ⋮ arguments: None,
33665 - ⋮ Meta(Path(Path {
33669 - ⋮ arguments: None,
33673 - ⋮ Meta(Meta::NameValue {
33678 - ⋮ arguments: None,
33684 - ⋮ Meta(Meta::List {
33689 - ⋮ arguments: None,
33694 - ⋮ Meta(Meta::NameValue {
33698 - ⋮ ident: "name2",
33699 - ⋮ arguments: None,
33707 - ⋮ Meta(Path(Path {
33710 - ⋮ ident: "word2",
33711 - ⋮ arguments: None,
33735 + Meta(Meta::NameValue {
33746 + Meta(Meta::List {
33756 + Meta(Meta::NameValue {
33781 snapshot!(meta as Meta, @r###"
33787 - ⋮ arguments: None,
33792 - ⋮ Meta(Path(Path {
33796 - ⋮ arguments: None,
33800 - ⋮ Meta(Meta::NameValue {
33805 - ⋮ arguments: None,
33811 - ⋮ Meta(Meta::List {
33816 - ⋮ arguments: None,
33821 - ⋮ Meta(Meta::NameValue {
33825 - ⋮ ident: "name2",
33826 - ⋮ arguments: None,
33834 - ⋮ Meta(Path(Path {
33837 - ⋮ ident: "word2",
33838 - ⋮ arguments: None,
33862 + Meta(Meta::NameValue {
33873 + Meta(Meta::List {
33883 + Meta(Meta::NameValue {
33908 assert_eq!(meta, inner.into());
33912 fn test_parse_nested_meta() {
33914 snapshot!(input as NestedMeta, @"Lit(5)");
33916 let input = "list(name2 = 6)";
33917 snapshot!(input as NestedMeta, @r###"
33918 - ⋮Meta(Meta::List {
33923 - ⋮ arguments: None,
33928 - ⋮ Meta(Meta::NameValue {
33932 - ⋮ ident: "name2",
33933 - ⋮ arguments: None,
33941 + Meta(Meta::List {
33951 + Meta(Meta::NameValue {
33966 diff --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
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};
33979 #[should_panic(expected = "Fork was not derived from the advancing parse stream")]
33980 fn smuggled_speculative_cursor_between_sources() {
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);
33992 syn::parse_str::<BreakRules>("()").unwrap();
33996 +fn trailing_empty_none_group() {
33997 + fn parse(input: ParseStream) -> Result<()> {
33998 + input.parse::<Token![+]>()?;
34001 + parenthesized!(content in input);
34002 + content.parse::<Token![+]>()?;
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())),
34017 + TokenTree::Group(Group::new(Delimiter::None, TokenStream::new())),
34018 + TokenTree::Group(Group::new(
34020 + TokenStream::from_iter(vec![TokenTree::Group(Group::new(
34022 + TokenStream::new(),
34027 + parse.parse2(tokens).unwrap();
34029 diff --git a/third_party/rust/syn/tests/test_parse_stream.rs b/third_party/rust/syn/tests/test_parse_stream.rs
34030 new file mode 100644
34032 +++ b/third_party/rust/syn/tests/test_parse_stream.rs
34034 +use syn::ext::IdentExt;
34035 +use syn::parse::ParseStream;
34036 +use syn::{Ident, Token};
34040 + let _ = |input: ParseStream| {
34041 + let _ = input.peek(Ident);
34042 + let _ = input.peek(Ident::peek_any);
34043 + let _ = input.peek(Token![::]);
34046 diff --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
34050 -extern crate quote;
34057 +use syn::{Item, Pat, Stmt};
34060 fn test_pat_ident() {
34061 match syn::parse2(quote!(self)).unwrap() {
34062 Pat::Ident(_) => (),
34063 value => panic!("expected PatIdent, got {:?}", value),
34068 fn test_pat_path() {
34069 match syn::parse2(quote!(self::CONST)).unwrap() {
34070 Pat::Path(_) => (),
34071 value => panic!("expected PatPath, got {:?}", value),
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
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();
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();
34094 diff --git a/third_party/rust/syn/tests/test_path.rs b/third_party/rust/syn/tests/test_path.rs
34095 new file mode 100644
34097 +++ b/third_party/rust/syn/tests/test_path.rs
34102 +use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
34104 +use std::iter::FromIterator;
34105 +use syn::{Expr, Type};
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())),
34117 + snapshot!(tokens.clone() as Expr, @r###"
34134 + snapshot!(tokens as Type, @r###"
34151 diff --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
34155 #![cfg(not(syn_disable_nightly_tests))]
34156 #![recursion_limit = "1024"]
34157 #![feature(rustc_private)]
34159 //! The tests in this module do the following:
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`
34167 //! 3. Serialize the `syn` expression back into a string, and re-parse it with
34170 //! 4. Respan all of the expressions, replacing the spans with the default
34172 //! 5. Compare the expressions with one another, if they are not equal fail.
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;
34181 -extern crate syntax;
34182 -extern crate syntax_pos;
34183 -extern crate walkdir;
34186 +extern crate rustc_span;
34189 use rayon::iter::{IntoParallelIterator, ParallelIterator};
34191 -use smallvec::smallvec;
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};
34203 use std::sync::atomic::{AtomicUsize, Ordering};
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) {
34215 - let pf = match test_expressions(vec![expr]) {
34216 + let pf = match test_expressions(Edition::Edition2018, vec![expr]) {
34217 (1, 0) => "passed",
34222 _ => unreachable!(),
34224 errorf!("=== {}: {}\n", input, pf);
34225 @@ -86,18 +77,18 @@ fn test_simple_precedence() {
34228 panic!("Failed {} tests", failed);
34232 /// Test expressions from rustc, like in `test_round_trip`.
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");
34243 let passed = AtomicUsize::new(0);
34244 let failed = AtomicUsize::new(0);
34245 @@ -113,34 +104,26 @@ fn test_rustc_precedence() {
34248 .for_each(|entry| {
34249 let path = entry.path();
34254 - // Our version of `libsyntax` can't parse this tests
34258 - .ends_with("optional_comma_in_match_arm.rs")
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");
34268 let (l_passed, l_failed) = match syn::parse_file(&content) {
34270 + let edition = repo::edition(path).parse().unwrap();
34271 let exprs = collect_exprs(file);
34272 - test_expressions(exprs)
34273 + test_expressions(edition, exprs)
34276 errorf!("syn failed to parse\n{:?}\n", msg);
34282 @@ -164,147 +147,182 @@ fn test_rustc_precedence() {
34283 errorf!("\n===== Precedence Test Results =====\n");
34284 errorf!("{} passed | {} failed\n", passed, failed);
34287 panic!("{} failures", failed);
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;
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();
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) {
34306 - errorf!("\nFAIL - libsyntax failed to parse raw\n");
34307 + errorf!("\nFAIL - librustc failed to parse raw\n");
34311 let syn_expr = syn_brackets(expr);
34312 - let syn_ast = if let Some(e) = parse::libsyntax_expr("e!(#syn_expr).to_string()) {
34313 + let syn_ast = if let Some(e) = parse::librustc_expr("e!(#syn_expr).to_string()) {
34317 - errorf!("\nFAIL - libsyntax failed to parse bracketed\n");
34318 + errorf!("\nFAIL - librustc failed to parse bracketed\n");
34322 - if SpanlessEq::eq(&syn_ast, &libsyntax_ast) {
34323 + if SpanlessEq::eq(&syn_ast, &librustc_ast) {
34327 - errorf!("\nFAIL\n{:?}\n!=\n{:?}\n", syn_ast, libsyntax_ast);
34328 + errorf!("\nFAIL\n{:?}\n!=\n{:?}\n", syn_ast, librustc_ast);
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)
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.
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,
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;
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;
34363 struct BracketsVisitor {
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);
34371 + vis.visit_expr(&mut f.expr);
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)
34383 + StmtKind::Semi(mut e) => {
34384 + noop_visit_expr(&mut e, vis);
34385 + StmtKind::Semi(e)
34390 + vec![Stmt { kind, ..stmt }]
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);
34405 + _ => noop_visit_expr(e, vis),
34409 impl MutVisitor for BracketsVisitor {
34410 fn visit_expr(&mut self, e: &mut P<Expr>) {
34411 noop_visit_expr(e, self);
34414 ExprKind::If(..) | ExprKind::Block(..) | ExprKind::Let(..) => {}
34416 let inner = mem::replace(
34419 id: ast::DUMMY_NODE_ID,
34420 - node: ExprKind::Err,
34421 + kind: ExprKind::Err,
34423 attrs: ThinVec::new(),
34427 - e.node = ExprKind::Paren(inner);
34428 + e.kind = ExprKind::Paren(inner);
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);
34437 - self.visit_expr(&mut f.expr);
34438 + fn visit_generic_arg(&mut self, arg: &mut GenericArg) {
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),
34444 - SmallVec::from([f])
34447 + fn visit_block(&mut self, block: &mut P<Block>) {
34448 + self.visit_id(&mut block.id);
34451 + .flat_map_in_place(|stmt| flat_map_stmt(stmt, self));
34452 + self.visit_span(&mut block.span);
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>) {
34462 fn visit_ty(&mut self, ty: &mut P<Ty>) {
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)
34473 - StmtKind::Semi(mut e) => {
34474 - noop_visit_expr(&mut e, self);
34475 - StmtKind::Semi(e)
34480 - smallvec![Stmt { node, ..stmt }]
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
34495 let mut folder = BracketsVisitor { failed: false };
34496 - folder.visit_expr(&mut libsyntax_expr);
34497 + folder.visit_expr(&mut librustc_expr);
34501 - Some(libsyntax_expr)
34502 + Some(librustc_expr)
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 {
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 {
34516 Expr::Group(_) => unreachable!(),
34517 Expr::If(..) | Expr::Unsafe(..) | Expr::Block(..) | Expr::Let(..) => {
34518 fold_expr(self, expr)
34520 - node => Expr::Paren(ExprParen {
34521 + _ => Expr::Paren(ExprParen {
34523 - expr: Box::new(fold_expr(self, node)),
34524 + expr: Box::new(fold_expr(self, expr)),
34525 paren_token: token::Paren::default(),
34530 + fn fold_generic_argument(&mut self, arg: GenericArgument) -> GenericArgument {
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),
34538 + fn fold_generic_method_argument(
34540 + arg: GenericMethodArgument,
34541 + ) -> GenericMethodArgument {
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),
34549 fn fold_stmt(&mut self, stmt: Stmt) -> 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),
34557 @@ -355,17 +392,20 @@ fn syn_brackets(syn_expr: syn::Expr) ->
34558 fn collect_exprs(file: syn::File) -> Vec<syn::Expr> {
34560 use syn::punctuated::Punctuated;
34563 struct CollectExprs(Vec<Expr>);
34564 impl Fold for CollectExprs {
34565 fn fold_expr(&mut self, expr: Expr) -> Expr {
34566 - self.0.push(expr);
34568 + Expr::Verbatim(tokens) if tokens.is_empty() => {}
34569 + _ => self.0.push(expr),
34572 Expr::Tuple(ExprTuple {
34574 elems: Punctuated::new(),
34575 paren_token: token::Paren::default(),
34579 diff --git a/third_party/rust/syn/tests/test_receiver.rs b/third_party/rust/syn/tests/test_receiver.rs
34580 new file mode 100644
34582 +++ b/third_party/rust/syn/tests/test_receiver.rs
34584 +use syn::{parse_quote, FnArg, Receiver, TraitItemMethod};
34587 +fn test_by_value() {
34588 + let TraitItemMethod { sig, .. } = parse_quote! {
34589 + fn by_value(self: Self);
34591 + match sig.receiver() {
34592 + Some(FnArg::Typed(_)) => (),
34593 + value => panic!("expected FnArg::Typed, got {:?}", value),
34598 +fn test_by_mut_value() {
34599 + let TraitItemMethod { sig, .. } = parse_quote! {
34600 + fn by_mut(mut self: Self);
34602 + match sig.receiver() {
34603 + Some(FnArg::Typed(_)) => (),
34604 + value => panic!("expected FnArg::Typed, got {:?}", value),
34609 +fn test_by_ref() {
34610 + let TraitItemMethod { sig, .. } = parse_quote! {
34611 + fn by_ref(self: &Self);
34613 + match sig.receiver() {
34614 + Some(FnArg::Typed(_)) => (),
34615 + value => panic!("expected FnArg::Typed, got {:?}", value),
34620 +fn test_by_box() {
34621 + let TraitItemMethod { sig, .. } = parse_quote! {
34622 + fn by_box(self: Box<Self>);
34624 + match sig.receiver() {
34625 + Some(FnArg::Typed(_)) => (),
34626 + value => panic!("expected FnArg::Typed, got {:?}", value),
34631 +fn test_by_pin() {
34632 + let TraitItemMethod { sig, .. } = parse_quote! {
34633 + fn by_pin(self: Pin<Self>);
34635 + match sig.receiver() {
34636 + Some(FnArg::Typed(_)) => (),
34637 + value => panic!("expected FnArg::Typed, got {:?}", value),
34642 +fn test_explicit_type() {
34643 + let TraitItemMethod { sig, .. } = parse_quote! {
34644 + fn explicit_type(self: Pin<MyType>);
34646 + match sig.receiver() {
34647 + Some(FnArg::Typed(_)) => (),
34648 + value => panic!("expected FnArg::Typed, got {:?}", value),
34653 +fn test_value_shorthand() {
34654 + let TraitItemMethod { sig, .. } = parse_quote! {
34655 + fn value_shorthand(self);
34657 + match sig.receiver() {
34658 + Some(FnArg::Receiver(Receiver {
34660 + mutability: None,
34663 + value => panic!("expected FnArg::Receiver without ref/mut, got {:?}", value),
34668 +fn test_mut_value_shorthand() {
34669 + let TraitItemMethod { sig, .. } = parse_quote! {
34670 + fn mut_value_shorthand(mut self);
34672 + match sig.receiver() {
34673 + Some(FnArg::Receiver(Receiver {
34675 + mutability: Some(_),
34678 + value => panic!("expected FnArg::Receiver with mut, got {:?}", value),
34683 +fn test_ref_shorthand() {
34684 + let TraitItemMethod { sig, .. } = parse_quote! {
34685 + fn ref_shorthand(&self);
34687 + match sig.receiver() {
34688 + Some(FnArg::Receiver(Receiver {
34689 + reference: Some(_),
34690 + mutability: None,
34693 + value => panic!("expected FnArg::Receiver with ref, got {:?}", value),
34698 +fn test_ref_mut_shorthand() {
34699 + let TraitItemMethod { sig, .. } = parse_quote! {
34700 + fn ref_mut_shorthand(&mut self);
34702 + match sig.receiver() {
34703 + Some(FnArg::Receiver(Receiver {
34704 + reference: Some(_),
34705 + mutability: Some(_),
34708 + value => panic!("expected FnArg::Receiver with ref+mut, got {:?}", value),
34711 diff --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
34715 #![cfg(not(syn_disable_nightly_tests))]
34716 #![recursion_limit = "1024"]
34717 #![feature(rustc_private)]
34719 -extern crate quote;
34720 -extern crate rayon;
34722 -extern crate syntax;
34723 -extern crate syntax_pos;
34724 -extern crate walkdir;
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;
34735 use rayon::iter::{IntoParallelIterator, ParallelIterator};
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};
34752 use std::sync::atomic::{AtomicUsize, Ordering};
34753 use std::time::Instant;
34754 @@ -33,18 +31,18 @@ mod macros;
34755 #[allow(dead_code)]
34760 use common::eq::SpanlessEq;
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");
34772 let failed = AtomicUsize::new(0);
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 {
34782 let back = quote!(#krate).to_string();
34783 + let edition = repo::edition(path).parse().unwrap();
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();
34796 .starts_with("file not found for module")
34798 errorf!("=== {}: ignore\n", path.display());
34801 - "=== {}: ignore - libsyntax failed to parse original content: {}\n",
34802 + "=== {}: ignore - librustc failed to parse original content: {}\n",
34804 diagnostic.message()
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());
34821 if SpanlessEq::eq(&before, &after) {
34823 "=== {}: pass in {}ms\n",
34824 @@ -125,29 +124,29 @@ fn test_round_trip() {
34833 - Err(_) => errorf!("=== {}: ignoring libsyntax panic\n", path.display()),
34834 + Err(_) => errorf!("=== {}: ignoring librustc panic\n", path.display()),
34837 let prev_failed = failed.fetch_add(1, Ordering::SeqCst);
34838 if prev_failed + 1 >= abort_after {
34845 let failed = failed.load(Ordering::SeqCst);
34847 panic!("{} failures", failed);
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)
34856 diff --git a/third_party/rust/syn/tests/test_shebang.rs b/third_party/rust/syn/tests/test_shebang.rs
34857 new file mode 100644
34859 +++ b/third_party/rust/syn/tests/test_shebang.rs
34866 + let content = "#!/usr/bin/env rustx\nfn main() {}";
34867 + let file = syn::parse_file(content).unwrap();
34868 + snapshot!(file, @r###"
34870 + shebang: Some("#!/usr/bin/env rustx"),
34876 + generics: Generics,
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###"
34903 + tokens: TokenStream(`(dead_code)`),
34911 + generics: Generics,
34920 diff --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
34928 macro_rules! should_parse {
34929 ($name:ident, { $($in:tt)* }) => {
34932 // Make sure we can parse the file!
34933 syn::parse_file(stringify!($($in)*)).unwrap();
34936 diff --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
34940 #![cfg(target_pointer_width = "64")]
34948 fn test_expr_size() {
34949 assert_eq!(mem::size_of::<Expr>(), 280);
34952 diff --git a/third_party/rust/syn/tests/test_stmt.rs b/third_party/rust/syn/tests/test_stmt.rs
34953 new file mode 100644
34955 +++ b/third_party/rust/syn/tests/test_stmt.rs
34963 +fn test_raw_operator() {
34964 + let stmt = syn::parse_str::<Stmt>("let _ = &raw const x;").unwrap();
34966 + snapshot!(stmt, @r###"
34969 + init: Some(Verbatim(`& raw const x`)),
34975 +fn test_raw_variable() {
34976 + let stmt = syn::parse_str::<Stmt>("let _ = &raw;").unwrap();
34978 + snapshot!(stmt, @r###"
34981 + init: Some(Expr::Reference {
34982 + expr: Expr::Path {
34998 +fn test_raw_invalid() {
34999 + assert!(syn::parse_str::<Stmt>("let _ = &raw x;").is_err());
35001 diff --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
35005 -extern crate proc_macro2;
35006 -extern crate quote;
35014 use proc_macro2::TokenStream;
35019 @@ -16,17 +10,21 @@ fn test_struct() {
35021 #[derive(Debug, Clone)]
35024 pub attrs: Vec<Attribute>,
35028 - snapshot!(input as TokenStream, @"`# [ derive ( Debug , Clone ) ] pub struct Item { pub ident : Ident , pub attrs : Vec < Attribute >, }`");
35029 + snapshot!(input as TokenStream, @r###"
35031 + `# [derive (Debug , Clone)] pub struct Item { pub ident : Ident , pub attrs : Vec < Attribute >, }`,
35037 fn test_literal_mangling() {
35039 let parsed: Lit = syn::parse_str(code).unwrap();
35040 assert_eq!(code, quote!(#parsed).to_string());
35042 diff --git a/third_party/rust/syn/tests/test_ty.rs b/third_party/rust/syn/tests/test_ty.rs
35043 new file mode 100644
35045 +++ b/third_party/rust/syn/tests/test_ty.rs
35050 +use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
35052 +use std::iter::FromIterator;
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();
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)),
35074 + snapshot!(tokens as Type, @r###"
35080 + arguments: PathArguments::AngleBracketed {
35082 + Type(Type::Path {
35100 diff --git a/third_party/rust/syn/tests/test_visibility.rs b/third_party/rust/syn/tests/test_visibility.rs
35101 new file mode 100644
35103 +++ b/third_party/rust/syn/tests/test_visibility.rs
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};
35116 + rest: TokenStream,
35119 +impl Parse for VisRest {
35120 + fn parse(input: ParseStream) -> Result<Self> {
35122 + vis: input.parse()?,
35123 + rest: input.parse()?,
35128 +macro_rules! assert_vis_parse {
35129 + ($input:expr, Ok($p:pat)) => {
35130 + assert_vis_parse!($input, Ok($p) + "");
35133 + ($input:expr, Ok($p:pat) + $rest:expr) => {
35134 + let expected = $rest.parse::<TokenStream>().unwrap();
35135 + let parse: VisRest = syn::parse_str($input).unwrap();
35137 + match parse.vis {
35139 + _ => panic!("Expected {}, got {:?}", stringify!($p), parse.vis),
35142 + // NOTE: Round-trips through `to_string` to avoid potential whitespace
35144 + assert_eq!(parse.rest.to_string(), expected.to_string());
35147 + ($input:expr, Err) => {
35148 + syn::parse2::<VisRest>($input.parse().unwrap()).unwrap_err();
35154 + assert_vis_parse!("pub", Ok(Visibility::Public(_)));
35159 + assert_vis_parse!("crate", Ok(Visibility::Crate(_)));
35163 +fn test_inherited() {
35164 + assert_vis_parse!("", Ok(Visibility::Inherited));
35169 + assert_vis_parse!("pub(in foo::bar)", Ok(Visibility::Restricted(_)));
35173 +fn test_pub_crate() {
35174 + assert_vis_parse!("pub(crate)", Ok(Visibility::Restricted(_)));
35178 +fn test_pub_self() {
35179 + assert_vis_parse!("pub(self)", Ok(Visibility::Restricted(_)));
35183 +fn test_pub_super() {
35184 + assert_vis_parse!("pub(super)", Ok(Visibility::Restricted(_)));
35188 +fn test_missing_in() {
35189 + assert_vis_parse!("pub(foo::bar)", Ok(Visibility::Public(_)) + "(foo::bar)");
35193 +fn test_missing_in_path() {
35194 + assert_vis_parse!("pub(in)", Err);
35198 +fn test_crate_path() {
35199 + assert_vis_parse!("pub(crate::A, crate::B)", Ok(Visibility::Public(_)) + "(crate::A, crate::B)");
35203 +fn test_junk_after_in() {
35204 + assert_vis_parse!("pub(in some::path @@garbage)", Err);
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(
35219 + TokenStream::from_iter(vec![TokenTree::Ident(Ident::new(
35221 + Span::call_site(),
35224 + TokenTree::Punct(Punct::new(':', Spacing::Alone)),
35225 + TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
35230 + snapshot!(tokens as DeriveInput, @r###"
35234 + generics: Generics,
35235 + data: Data::Struct {
35236 + fields: Fields::Named {
35240 + ident: Some("f"),
35241 + colon_token: Some,
35250 diff --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
35254 #![cfg(syn_disable_nightly_tests)]
35256 -extern crate termcolor;
35258 use std::io::{self, Write};
35259 use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
35261 const MSG: &str = "\
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.
35273 fn notice() -> io::Result<()> {
35274 let header = "WARNING";
35275 let index_of_header = MSG.find(header).unwrap();