diff options
author | David LeGare <legare@google.com> | 2022-03-02 16:21:07 +0000 |
---|---|---|
committer | David LeGare <legare@google.com> | 2022-03-02 16:21:07 +0000 |
commit | ec387697a0898027894f5cf86a4f64f2aa12c4f0 (patch) | |
tree | a7fee2c2ec02db084d4df2f593166efb269355a2 | |
parent | 4440ee7350f0db16a126a92f6a5d0f33a76c1613 (diff) | |
download | syn-ec387697a0898027894f5cf86a4f64f2aa12c4f0.tar.gz |
Update syn to 1.0.86
Test: cd external/rust/crates && atest --host -c
Change-Id: Ic90473100d7363ea70c8de3e1480d4d7131c2206
49 files changed, 1354 insertions, 1073 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 225992b2..cb0b7f12 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,6 @@ { "git": { - "sha1": "8820d7320f98befc3715d651edc33463393967d3" - } -} + "sha1": "7ff292d5ac9802a3cc7908c5641a060bd5cf0d78" + }, + "path_in_vcs": "" +}
\ No newline at end of file @@ -41,7 +41,7 @@ rust_library_host { name: "libsyn", crate_name: "syn", cargo_env_compat: true, - cargo_pkg_version: "1.0.76", + cargo_pkg_version: "1.0.86", srcs: ["src/lib.rs"], edition: "2018", features: [ @@ -11,8 +11,9 @@ [package] edition = "2018" +rust-version = "1.31" name = "syn" -version = "1.0.76" +version = "1.0.86" authors = ["David Tolnay <dtolnay@gmail.com>"] include = ["/benches/**", "/build.rs", "/Cargo.toml", "/LICENSE-APACHE", "/LICENSE-MIT", "/README.md", "/src/**", "/tests/**"] description = "Parser for Rust source code" @@ -38,7 +39,7 @@ required-features = ["full", "parsing"] name = "file" required-features = ["full", "parsing"] [dependencies.proc-macro2] -version = "1.0.26" +version = "1.0.32" default-features = false [dependencies.quote] @@ -51,6 +52,9 @@ version = "0.2" [dev-dependencies.anyhow] version = "1.0" +[dev-dependencies.automod] +version = "1.0" + [dev-dependencies.flate2] version = "1.0" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index ed6e1821..b6fc02a3 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "syn" -version = "1.0.76" # don't forget to update html_root_url and syn.json +version = "1.0.86" # don't forget to update html_root_url and syn.json authors = ["David Tolnay <dtolnay@gmail.com>"] license = "MIT OR Apache-2.0" description = "Parser for Rust source code" @@ -19,6 +19,7 @@ include = [ "/tests/**", ] edition = "2018" +rust-version = "1.31" [features] default = ["derive", "parsing", "printing", "clone-impls", "proc-macro"] @@ -35,12 +36,13 @@ proc-macro = ["proc-macro2/proc-macro", "quote/proc-macro"] test = ["syn-test-suite/all-features"] [dependencies] -proc-macro2 = { version = "1.0.26", default-features = false } +proc-macro2 = { version = "1.0.32", default-features = false } quote = { version = "1.0", optional = true, default-features = false } unicode-xid = "0.2" [dev-dependencies] anyhow = "1.0" +automod = "1.0" flate2 = "1.0" insta = "1.0" rayon = "1.0" @@ -70,4 +72,4 @@ rustdoc-args = ["--cfg", "doc_cfg"] features = ["full", "visit", "visit-mut", "fold", "extra-traits"] [workspace] -members = ["dev", "json", "tests/features"] +members = ["dev", "json", "tests/crates", "tests/features"] @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/syn/syn-1.0.76.crate" + value: "https://static.crates.io/crates/syn/syn-1.0.86.crate" } - version: "1.0.76" + version: "1.0.86" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 9 - day: 22 + year: 2022 + month: 3 + day: 1 } } diff --git a/benches/file.rs b/benches/file.rs index 33d201c1..86204df2 100644 --- a/benches/file.rs +++ b/benches/file.rs @@ -2,6 +2,7 @@ #![feature(rustc_private, test)] #![recursion_limit = "1024"] +#![allow(clippy::missing_panics_doc, clippy::must_use_candidate)] extern crate test; diff --git a/benches/rust.rs b/benches/rust.rs index 28dff947..54542932 100644 --- a/benches/rust.rs +++ b/benches/rust.rs @@ -5,6 +5,7 @@ #![cfg_attr(not(syn_only), feature(rustc_private))] #![recursion_limit = "1024"] +#![allow(clippy::cast_lossless, clippy::unnecessary_wraps)] #[macro_use] #[path = "../tests/macros/mod.rs"] @@ -116,7 +117,7 @@ fn main() { macro_rules! testcases { ($($(#[$cfg:meta])* $name:ident,)*) => { - vec![ + [ $( $(#[$cfg])* (stringify!($name), $name::bench as fn(&str) -> Result<(), ()>), @@ -19,6 +19,10 @@ fn main() { println!("cargo:rustc-cfg=syn_no_const_vec_new"); } + if compiler.minor < 56 { + println!("cargo:rustc-cfg=syn_no_negative_literal_parse"); + } + if !compiler.nightly { println!("cargo:rustc-cfg=syn_disable_nightly_tests"); } @@ -38,6 +42,6 @@ fn rustc_version() -> Option<Compiler> { return None; } let minor = pieces.next()?.parse().ok()?; - let nightly = version.contains("nightly"); + let nightly = version.contains("nightly") || version.ends_with("-dev"); Some(Compiler { minor, nightly }) } diff --git a/src/attr.rs b/src/attr.rs index 5d6877ae..bace94f4 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -2,6 +2,7 @@ use super::*; use crate::punctuated::Punctuated; use proc_macro2::TokenStream; use std::iter; +use std::slice; #[cfg(feature = "parsing")] use crate::parse::{Parse, ParseBuffer, ParseStream, Parser, Result}; @@ -469,11 +470,8 @@ pub trait FilterAttrs<'a> { fn inner(self) -> Self::Ret; } -impl<'a, T> FilterAttrs<'a> for T -where - T: IntoIterator<Item = &'a Attribute>, -{ - type Ret = iter::Filter<T::IntoIter, fn(&&Attribute) -> bool>; +impl<'a> FilterAttrs<'a> for &'a [Attribute] { + type Ret = iter::Filter<slice::Iter<'a, Attribute>, fn(&&Attribute) -> bool>; fn outer(self) -> Self::Ret { fn is_outer(attr: &&Attribute) -> bool { @@ -482,7 +480,7 @@ where AttrStyle::Inner(_) => false, } } - self.into_iter().filter(is_outer) + self.iter().filter(is_outer) } fn inner(self) -> Self::Ret { @@ -492,7 +490,7 @@ where AttrStyle::Outer => false, } } - self.into_iter().filter(is_inner) + self.iter().filter(is_inner) } } diff --git a/src/buffer.rs b/src/buffer.rs index ec172259..43e77e97 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -16,6 +16,7 @@ use crate::Lifetime; use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; use std::marker::PhantomData; use std::ptr; +use std::slice; /// Internal type which is used instead of `TokenTree` to represent a token tree /// within a `TokenBuffer`. @@ -36,20 +37,30 @@ enum Entry { /// /// *This type is available only if Syn is built with the `"parsing"` feature.* pub struct TokenBuffer { - // NOTE: Do not derive clone on this - there are raw pointers inside which - // will be messed up. Moving the `TokenBuffer` itself is safe as the actual - // backing slices won't be moved. - data: Box<[Entry]>, + // NOTE: Do not implement clone on this - there are raw pointers inside + // these entries which will be messed up. Moving the `TokenBuffer` itself is + // safe as the data pointed to won't be moved. + ptr: *const Entry, + len: usize, +} + +impl Drop for TokenBuffer { + fn drop(&mut self) { + unsafe { + let slice = slice::from_raw_parts_mut(self.ptr as *mut Entry, self.len); + let _ = Box::from_raw(slice); + } + } } impl TokenBuffer { - // NOTE: DO NOT MUTATE THE `Vec` RETURNED FROM THIS FUNCTION ONCE IT - // RETURNS, THE ADDRESS OF ITS BACKING MEMORY MUST REMAIN STABLE. + // NOTE: Do not mutate the Vec returned from this function once it returns; + // the address of its backing memory must remain stable. fn inner_new(stream: TokenStream, up: *const Entry) -> TokenBuffer { // Build up the entries list, recording the locations of any Groups // in the list to be processed later. let mut entries = Vec::new(); - let mut seqs = Vec::new(); + let mut groups = Vec::new(); for tt in stream { match tt { TokenTree::Ident(sym) => { @@ -63,8 +74,8 @@ impl TokenBuffer { } TokenTree::Group(g) => { // Record the index of the interesting entry, and store an - // `End(null)` there temporarially. - seqs.push((entries.len(), g)); + // `End(null)` there temporarily. + groups.push((entries.len(), g)); entries.push(Entry::End(ptr::null())); } } @@ -78,23 +89,28 @@ impl TokenBuffer { // constant address after this point, as we are going to store a raw // pointer into it. let mut entries = entries.into_boxed_slice(); - for (idx, group) in seqs { + for (idx, group) in groups { // We know that this index refers to one of the temporary // `End(null)` entries, and we know that the last entry is // `End(up)`, so the next index is also valid. - let seq_up = &entries[idx + 1] as *const Entry; + let group_up = unsafe { entries.as_ptr().add(idx + 1) }; // The end entry stored at the end of this Entry::Group should // point to the Entry which follows the Group in the list. - let inner = Self::inner_new(group.stream(), seq_up); + let inner = Self::inner_new(group.stream(), group_up); entries[idx] = Entry::Group(group, inner); } - TokenBuffer { data: entries } + let len = entries.len(); + let ptr = Box::into_raw(entries); + TokenBuffer { + ptr: ptr as *const Entry, + len, + } } /// Creates a `TokenBuffer` containing all the tokens from the input - /// `TokenStream`. + /// `proc_macro::TokenStream`. /// /// *This method is available only if Syn is built with both the `"parsing"` and /// `"proc-macro"` features.* @@ -102,20 +118,20 @@ impl TokenBuffer { not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))), feature = "proc-macro" ))] - pub fn new(stream: pm::TokenStream) -> TokenBuffer { + pub fn new(stream: pm::TokenStream) -> Self { Self::new2(stream.into()) } /// Creates a `TokenBuffer` containing all the tokens from the input - /// `TokenStream`. - pub fn new2(stream: TokenStream) -> TokenBuffer { + /// `proc_macro2::TokenStream`. + pub fn new2(stream: TokenStream) -> Self { Self::inner_new(stream, ptr::null()) } /// Creates a cursor referencing the first token in the buffer and able to /// traverse until the end of the buffer. pub fn begin(&self) -> Cursor { - unsafe { Cursor::create(&self.data[0], &self.data[self.data.len() - 1]) } + unsafe { Cursor::create(self.ptr, self.ptr.add(self.len - 1)) } } } @@ -210,7 +226,7 @@ impl<'a> Cursor<'a> { // situations where we should immediately exit the span after // entering it are handled correctly. unsafe { - *self = Cursor::create(&buf.data[0], self.scope); + *self = Cursor::create(buf.ptr, self.scope); } } else { break; @@ -254,7 +270,7 @@ impl<'a> Cursor<'a> { } } - /// If the cursor is pointing at an `Punct`, returns it along with a cursor + /// If the cursor is pointing at a `Punct`, returns it along with a cursor /// pointing at the next `TokenTree`. pub fn punct(mut self) -> Option<(Punct, Cursor<'a>)> { self.ignore_none(); @@ -321,9 +337,7 @@ impl<'a> Cursor<'a> { Entry::Literal(lit) => lit.clone().into(), Entry::Ident(ident) => ident.clone().into(), Entry::Punct(op) => op.clone().into(), - Entry::End(..) => { - return None; - } + Entry::End(..) => return None, }; Some((tree, unsafe { self.bump() })) diff --git a/src/error.rs b/src/error.rs index e2f23821..b505b894 100644 --- a/src/error.rs +++ b/src/error.rs @@ -47,10 +47,11 @@ pub type Result<T> = std::result::Result<T, Error>; /// ``` /// /// For errors that arise later than the initial parsing stage, the -/// [`.to_compile_error()`] method can be used to perform an explicit conversion -/// to `compile_error!`. +/// [`.to_compile_error()`] or [`.into_compile_error()`] methods can be used to +/// perform an explicit conversion to `compile_error!`. /// /// [`.to_compile_error()`]: Error::to_compile_error +/// [`.into_compile_error()`]: Error::into_compile_error /// /// ``` /// # extern crate proc_macro; @@ -66,7 +67,7 @@ pub type Result<T> = std::result::Result<T, Error>; /// /// // fn(DeriveInput) -> syn::Result<proc_macro2::TokenStream> /// expand::my_derive(input) -/// .unwrap_or_else(|err| err.to_compile_error()) +/// .unwrap_or_else(syn::Error::into_compile_error) /// .into() /// } /// # diff --git a/src/export.rs b/src/export.rs index 601a214b..d3a08784 100644 --- a/src/export.rs +++ b/src/export.rs @@ -1,6 +1,5 @@ pub use std::clone::Clone; pub use std::cmp::{Eq, PartialEq}; -pub use std::convert::From; pub use std::default::Default; pub use std::fmt::{self, Debug, Formatter}; pub use std::hash::{Hash, Hasher}; diff --git a/src/expr.rs b/src/expr.rs index d9319ddd..95da0908 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -403,8 +403,8 @@ ast_struct! { #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprClosure #full { pub attrs: Vec<Attribute>, - pub asyncness: Option<Token![async]>, pub movability: Option<Token![static]>, + pub asyncness: Option<Token![async]>, pub capture: Option<Token![move]>, pub or1_token: Token![|], pub inputs: Punctuated<Pat, Token![,]>, @@ -2112,7 +2112,11 @@ pub(crate) mod parsing { let_token: input.parse()?, pat: pat::parsing::multi_pat_with_leading_vert(input)?, eq_token: input.parse()?, - expr: Box::new(input.call(Expr::parse_without_eager_brace)?), + expr: Box::new({ + let allow_struct = AllowStruct(false); + let lhs = unary_expr(input, allow_struct)?; + parse_expr(input, lhs, allow_struct, Precedence::Compare)? + }), }) } } @@ -2397,12 +2401,8 @@ pub(crate) mod parsing { #[cfg(feature = "full")] fn expr_closure(input: ParseStream, allow_struct: AllowStruct) -> Result<ExprClosure> { + let movability: Option<Token![static]> = input.parse()?; let asyncness: Option<Token![async]> = input.parse()?; - let movability: Option<Token![static]> = if asyncness.is_none() { - input.parse()? - } else { - None - }; let capture: Option<Token![move]> = input.parse()?; let or1_token: Token![|] = input.parse()?; @@ -2440,8 +2440,8 @@ pub(crate) mod parsing { Ok(ExprClosure { attrs: Vec::new(), - asyncness, movability, + asyncness, capture, or1_token, inputs, @@ -3223,8 +3223,8 @@ pub(crate) mod printing { impl ToTokens for ExprClosure { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.asyncness.to_tokens(tokens); self.movability.to_tokens(tokens); + self.asyncness.to_tokens(tokens); self.capture.to_tokens(tokens); self.or1_token.to_tokens(tokens); self.inputs.to_tokens(tokens); diff --git a/src/gen/clone.rs b/src/gen/clone.rs index 37670f22..1c8814d6 100644 --- a/src/gen/clone.rs +++ b/src/gen/clone.rs @@ -412,8 +412,8 @@ impl Clone for ExprClosure { fn clone(&self) -> Self { ExprClosure { attrs: self.attrs.clone(), - asyncness: self.asyncness.clone(), movability: self.movability.clone(), + asyncness: self.asyncness.clone(), capture: self.capture.clone(), or1_token: self.or1_token.clone(), inputs: self.inputs.clone(), @@ -1662,7 +1662,9 @@ impl Clone for PathArguments { fn clone(&self) -> Self { match self { PathArguments::None => PathArguments::None, - PathArguments::AngleBracketed(v0) => PathArguments::AngleBracketed(v0.clone()), + PathArguments::AngleBracketed(v0) => { + PathArguments::AngleBracketed(v0.clone()) + } PathArguments::Parenthesized(v0) => PathArguments::Parenthesized(v0.clone()), } } @@ -1962,9 +1964,7 @@ impl Clone for TypeInfer { #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for TypeMacro { fn clone(&self) -> Self { - TypeMacro { - mac: self.mac.clone(), - } + TypeMacro { mac: self.mac.clone() } } } #[cfg(any(feature = "derive", feature = "full"))] diff --git a/src/gen/debug.rs b/src/gen/debug.rs index 3efa2788..11e197ea 100644 --- a/src/gen/debug.rs +++ b/src/gen/debug.rs @@ -726,8 +726,8 @@ impl Debug for ExprClosure { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { let mut formatter = formatter.debug_struct("ExprClosure"); formatter.field("attrs", &self.attrs); - formatter.field("asyncness", &self.asyncness); formatter.field("movability", &self.movability); + formatter.field("asyncness", &self.asyncness); formatter.field("capture", &self.capture); formatter.field("or1_token", &self.or1_token); formatter.field("inputs", &self.inputs); diff --git a/src/gen/eq.rs b/src/gen/eq.rs index e6e85323..40fed0b8 100644 --- a/src/gen/eq.rs +++ b/src/gen/eq.rs @@ -31,11 +31,8 @@ impl Eq for Arm {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Arm { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.pat == other.pat - && self.guard == other.guard - && self.body == other.body - && self.comma == other.comma + self.attrs == other.attrs && self.pat == other.pat && self.guard == other.guard + && self.body == other.body && self.comma == other.comma } } #[cfg(any(feature = "derive", feature = "full"))] @@ -59,8 +56,7 @@ impl Eq for Attribute {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Attribute { fn eq(&self, other: &Self) -> bool { - self.style == other.style - && self.path == other.path + self.style == other.style && self.path == other.path && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens) } } @@ -151,11 +147,8 @@ impl Eq for ConstParam {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ConstParam { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.ty == other.ty - && self.eq_token == other.eq_token - && self.default == other.default + self.attrs == other.attrs && self.ident == other.ident && self.ty == other.ty + && self.eq_token == other.eq_token && self.default == other.default } } #[cfg(any(feature = "derive", feature = "full"))] @@ -220,11 +213,8 @@ impl Eq for DeriveInput {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for DeriveInput { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.data == other.data + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.data == other.data } } #[cfg(any(feature = "derive", feature = "full"))] @@ -338,9 +328,7 @@ impl Eq for ExprAssignOp {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprAssignOp { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.left == other.left - && self.op == other.op + self.attrs == other.attrs && self.left == other.left && self.op == other.op && self.right == other.right } } @@ -351,7 +339,8 @@ impl Eq for ExprAsync {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprAsync { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.capture == other.capture && self.block == other.block + self.attrs == other.attrs && self.capture == other.capture + && self.block == other.block } } #[cfg(feature = "full")] @@ -371,9 +360,7 @@ impl Eq for ExprBinary {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprBinary { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.left == other.left - && self.op == other.op + self.attrs == other.attrs && self.left == other.left && self.op == other.op && self.right == other.right } } @@ -384,7 +371,8 @@ impl Eq for ExprBlock {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprBlock { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.label == other.label && self.block == other.block + self.attrs == other.attrs && self.label == other.label + && self.block == other.block } } #[cfg(feature = "full")] @@ -434,12 +422,9 @@ impl Eq for ExprClosure {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprClosure { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.asyncness == other.asyncness - && self.movability == other.movability - && self.capture == other.capture - && self.inputs == other.inputs - && self.output == other.output + self.attrs == other.attrs && self.movability == other.movability + && self.asyncness == other.asyncness && self.capture == other.capture + && self.inputs == other.inputs && self.output == other.output && self.body == other.body } } @@ -460,7 +445,8 @@ impl Eq for ExprField {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprField { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.base == other.base && self.member == other.member + self.attrs == other.attrs && self.base == other.base + && self.member == other.member } } #[cfg(feature = "full")] @@ -470,11 +456,8 @@ impl Eq for ExprForLoop {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprForLoop { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.label == other.label - && self.pat == other.pat - && self.expr == other.expr - && self.body == other.body + self.attrs == other.attrs && self.label == other.label && self.pat == other.pat + && self.expr == other.expr && self.body == other.body } } #[cfg(feature = "full")] @@ -494,8 +477,7 @@ impl Eq for ExprIf {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprIf { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.cond == other.cond + self.attrs == other.attrs && self.cond == other.cond && self.then_branch == other.then_branch && self.else_branch == other.else_branch } @@ -567,10 +549,8 @@ impl Eq for ExprMethodCall {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprMethodCall { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.receiver == other.receiver - && self.method == other.method - && self.turbofish == other.turbofish + self.attrs == other.attrs && self.receiver == other.receiver + && self.method == other.method && self.turbofish == other.turbofish && self.args == other.args } } @@ -601,10 +581,8 @@ impl Eq for ExprRange {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprRange { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.from == other.from - && self.limits == other.limits - && self.to == other.to + self.attrs == other.attrs && self.from == other.from + && self.limits == other.limits && self.to == other.to } } #[cfg(feature = "full")] @@ -614,7 +592,8 @@ impl Eq for ExprReference {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprReference { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mutability == other.mutability && self.expr == other.expr + self.attrs == other.attrs && self.mutability == other.mutability + && self.expr == other.expr } } #[cfg(feature = "full")] @@ -644,10 +623,8 @@ impl Eq for ExprStruct {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprStruct { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.path == other.path - && self.fields == other.fields - && self.dot2_token == other.dot2_token + self.attrs == other.attrs && self.path == other.path + && self.fields == other.fields && self.dot2_token == other.dot2_token && self.rest == other.rest } } @@ -718,9 +695,7 @@ impl Eq for ExprWhile {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprWhile { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.label == other.label - && self.cond == other.cond + self.attrs == other.attrs && self.label == other.label && self.cond == other.cond && self.body == other.body } } @@ -741,11 +716,8 @@ impl Eq for Field {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Field { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.colon_token == other.colon_token - && self.ty == other.ty + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.colon_token == other.colon_token && self.ty == other.ty } } #[cfg(feature = "full")] @@ -755,10 +727,8 @@ impl Eq for FieldPat {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for FieldPat { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.member == other.member - && self.colon_token == other.colon_token - && self.pat == other.pat + self.attrs == other.attrs && self.member == other.member + && self.colon_token == other.colon_token && self.pat == other.pat } } #[cfg(feature = "full")] @@ -768,10 +738,8 @@ impl Eq for FieldValue {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for FieldValue { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.member == other.member - && self.colon_token == other.colon_token - && self.expr == other.expr + self.attrs == other.attrs && self.member == other.member + && self.colon_token == other.colon_token && self.expr == other.expr } } #[cfg(any(feature = "derive", feature = "full"))] @@ -816,7 +784,8 @@ impl Eq for File {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for File { fn eq(&self, other: &Self) -> bool { - self.shebang == other.shebang && self.attrs == other.attrs && self.items == other.items + self.shebang == other.shebang && self.attrs == other.attrs + && self.items == other.items } } #[cfg(feature = "full")] @@ -869,7 +838,8 @@ impl Eq for ForeignItemMacro {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ForeignItemMacro { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mac == other.mac && self.semi_token == other.semi_token + self.attrs == other.attrs && self.mac == other.mac + && self.semi_token == other.semi_token } } #[cfg(feature = "full")] @@ -879,10 +849,8 @@ impl Eq for ForeignItemStatic {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ForeignItemStatic { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.mutability == other.mutability - && self.ident == other.ident + self.attrs == other.attrs && self.vis == other.vis + && self.mutability == other.mutability && self.ident == other.ident && self.ty == other.ty } } @@ -907,12 +875,18 @@ impl PartialEq for GenericArgument { (GenericArgument::Lifetime(self0), GenericArgument::Lifetime(other0)) => { self0 == other0 } - (GenericArgument::Type(self0), GenericArgument::Type(other0)) => self0 == other0, - (GenericArgument::Binding(self0), GenericArgument::Binding(other0)) => self0 == other0, + (GenericArgument::Type(self0), GenericArgument::Type(other0)) => { + self0 == other0 + } + (GenericArgument::Binding(self0), GenericArgument::Binding(other0)) => { + self0 == other0 + } (GenericArgument::Constraint(self0), GenericArgument::Constraint(other0)) => { self0 == other0 } - (GenericArgument::Const(self0), GenericArgument::Const(other0)) => self0 == other0, + (GenericArgument::Const(self0), GenericArgument::Const(other0)) => { + self0 == other0 + } _ => false, } } @@ -928,9 +902,10 @@ impl PartialEq for GenericMethodArgument { (GenericMethodArgument::Type(self0), GenericMethodArgument::Type(other0)) => { self0 == other0 } - (GenericMethodArgument::Const(self0), GenericMethodArgument::Const(other0)) => { - self0 == other0 - } + ( + GenericMethodArgument::Const(self0), + GenericMethodArgument::Const(other0), + ) => self0 == other0, _ => false, } } @@ -944,7 +919,9 @@ impl PartialEq for GenericParam { fn eq(&self, other: &Self) -> bool { match (self, other) { (GenericParam::Type(self0), GenericParam::Type(other0)) => self0 == other0, - (GenericParam::Lifetime(self0), GenericParam::Lifetime(other0)) => self0 == other0, + (GenericParam::Lifetime(self0), GenericParam::Lifetime(other0)) => { + self0 == other0 + } (GenericParam::Const(self0), GenericParam::Const(other0)) => self0 == other0, _ => false, } @@ -957,10 +934,8 @@ impl Eq for Generics {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Generics { fn eq(&self, other: &Self) -> bool { - self.lt_token == other.lt_token - && self.params == other.params - && self.gt_token == other.gt_token - && self.where_clause == other.where_clause + self.lt_token == other.lt_token && self.params == other.params + && self.gt_token == other.gt_token && self.where_clause == other.where_clause } } #[cfg(feature = "full")] @@ -989,12 +964,9 @@ impl Eq for ImplItemConst {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ImplItemConst { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.defaultness == other.defaultness - && self.ident == other.ident - && self.ty == other.ty - && self.expr == other.expr + self.attrs == other.attrs && self.vis == other.vis + && self.defaultness == other.defaultness && self.ident == other.ident + && self.ty == other.ty && self.expr == other.expr } } #[cfg(feature = "full")] @@ -1004,7 +976,8 @@ impl Eq for ImplItemMacro {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ImplItemMacro { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mac == other.mac && self.semi_token == other.semi_token + self.attrs == other.attrs && self.mac == other.mac + && self.semi_token == other.semi_token } } #[cfg(feature = "full")] @@ -1014,10 +987,8 @@ impl Eq for ImplItemMethod {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ImplItemMethod { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.defaultness == other.defaultness - && self.sig == other.sig + self.attrs == other.attrs && self.vis == other.vis + && self.defaultness == other.defaultness && self.sig == other.sig && self.block == other.block } } @@ -1028,12 +999,9 @@ impl Eq for ImplItemType {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ImplItemType { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.defaultness == other.defaultness - && self.ident == other.ident - && self.generics == other.generics - && self.ty == other.ty + self.attrs == other.attrs && self.vis == other.vis + && self.defaultness == other.defaultness && self.ident == other.ident + && self.generics == other.generics && self.ty == other.ty } } #[cfg(feature = "full")] @@ -1074,11 +1042,8 @@ impl Eq for ItemConst {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemConst { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.ty == other.ty - && self.expr == other.expr + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.ty == other.ty && self.expr == other.expr } } #[cfg(feature = "full")] @@ -1088,11 +1053,8 @@ impl Eq for ItemEnum {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemEnum { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.variants == other.variants + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.variants == other.variants } } #[cfg(feature = "full")] @@ -1102,9 +1064,7 @@ impl Eq for ItemExternCrate {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemExternCrate { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident && self.rename == other.rename } } @@ -1115,9 +1075,7 @@ impl Eq for ItemFn {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemFn { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.sig == other.sig + self.attrs == other.attrs && self.vis == other.vis && self.sig == other.sig && self.block == other.block } } @@ -1138,12 +1096,9 @@ impl Eq for ItemImpl {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemImpl { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.defaultness == other.defaultness - && self.unsafety == other.unsafety - && self.generics == other.generics - && self.trait_ == other.trait_ - && self.self_ty == other.self_ty + self.attrs == other.attrs && self.defaultness == other.defaultness + && self.unsafety == other.unsafety && self.generics == other.generics + && self.trait_ == other.trait_ && self.self_ty == other.self_ty && self.items == other.items } } @@ -1154,9 +1109,7 @@ impl Eq for ItemMacro {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemMacro { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.mac == other.mac + self.attrs == other.attrs && self.ident == other.ident && self.mac == other.mac && self.semi_token == other.semi_token } } @@ -1167,9 +1120,7 @@ impl Eq for ItemMacro2 {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemMacro2 { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident && TokenStreamHelper(&self.rules) == TokenStreamHelper(&other.rules) } } @@ -1180,11 +1131,8 @@ impl Eq for ItemMod {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemMod { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.content == other.content - && self.semi == other.semi + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.content == other.content && self.semi == other.semi } } #[cfg(feature = "full")] @@ -1194,12 +1142,9 @@ impl Eq for ItemStatic {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemStatic { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.mutability == other.mutability - && self.ident == other.ident - && self.ty == other.ty - && self.expr == other.expr + self.attrs == other.attrs && self.vis == other.vis + && self.mutability == other.mutability && self.ident == other.ident + && self.ty == other.ty && self.expr == other.expr } } #[cfg(feature = "full")] @@ -1209,11 +1154,8 @@ impl Eq for ItemStruct {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemStruct { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.fields == other.fields + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.fields == other.fields && self.semi_token == other.semi_token } } @@ -1224,15 +1166,11 @@ impl Eq for ItemTrait {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemTrait { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.unsafety == other.unsafety - && self.auto_token == other.auto_token - && self.ident == other.ident - && self.generics == other.generics + self.attrs == other.attrs && self.vis == other.vis + && self.unsafety == other.unsafety && self.auto_token == other.auto_token + && self.ident == other.ident && self.generics == other.generics && self.colon_token == other.colon_token - && self.supertraits == other.supertraits - && self.items == other.items + && self.supertraits == other.supertraits && self.items == other.items } } #[cfg(feature = "full")] @@ -1242,11 +1180,8 @@ impl Eq for ItemTraitAlias {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemTraitAlias { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.bounds == other.bounds + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.bounds == other.bounds } } #[cfg(feature = "full")] @@ -1256,11 +1191,8 @@ impl Eq for ItemType {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemType { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.ty == other.ty + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.ty == other.ty } } #[cfg(feature = "full")] @@ -1270,11 +1202,8 @@ impl Eq for ItemUnion {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemUnion { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.fields == other.fields + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.fields == other.fields } } #[cfg(feature = "full")] @@ -1284,10 +1213,8 @@ impl Eq for ItemUse {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemUse { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.leading_colon == other.leading_colon - && self.tree == other.tree + self.attrs == other.attrs && self.vis == other.vis + && self.leading_colon == other.leading_colon && self.tree == other.tree } } #[cfg(feature = "full")] @@ -1307,10 +1234,8 @@ impl Eq for LifetimeDef {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for LifetimeDef { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.lifetime == other.lifetime - && self.colon_token == other.colon_token - && self.bounds == other.bounds + self.attrs == other.attrs && self.lifetime == other.lifetime + && self.colon_token == other.colon_token && self.bounds == other.bounds } } #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -1370,8 +1295,7 @@ impl Eq for Macro {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Macro { fn eq(&self, other: &Self) -> bool { - self.path == other.path - && self.delimiter == other.delimiter + self.path == other.path && self.delimiter == other.delimiter && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens) } } @@ -1506,10 +1430,8 @@ impl Eq for PatIdent {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatIdent { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.by_ref == other.by_ref - && self.mutability == other.mutability - && self.ident == other.ident + self.attrs == other.attrs && self.by_ref == other.by_ref + && self.mutability == other.mutability && self.ident == other.ident && self.subpat == other.subpat } } @@ -1540,8 +1462,7 @@ impl Eq for PatOr {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatOr { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.leading_vert == other.leading_vert + self.attrs == other.attrs && self.leading_vert == other.leading_vert && self.cases == other.cases } } @@ -1562,9 +1483,7 @@ impl Eq for PatRange {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatRange { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.lo == other.lo - && self.limits == other.limits + self.attrs == other.attrs && self.lo == other.lo && self.limits == other.limits && self.hi == other.hi } } @@ -1575,7 +1494,8 @@ impl Eq for PatReference {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatReference { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mutability == other.mutability && self.pat == other.pat + self.attrs == other.attrs && self.mutability == other.mutability + && self.pat == other.pat } } #[cfg(feature = "full")] @@ -1605,10 +1525,8 @@ impl Eq for PatStruct {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatStruct { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.path == other.path - && self.fields == other.fields - && self.dot2_token == other.dot2_token + self.attrs == other.attrs && self.path == other.path + && self.fields == other.fields && self.dot2_token == other.dot2_token } } #[cfg(feature = "full")] @@ -1670,12 +1588,14 @@ impl PartialEq for PathArguments { fn eq(&self, other: &Self) -> bool { match (self, other) { (PathArguments::None, PathArguments::None) => true, - (PathArguments::AngleBracketed(self0), PathArguments::AngleBracketed(other0)) => { - self0 == other0 - } - (PathArguments::Parenthesized(self0), PathArguments::Parenthesized(other0)) => { - self0 == other0 - } + ( + PathArguments::AngleBracketed(self0), + PathArguments::AngleBracketed(other0), + ) => self0 == other0, + ( + PathArguments::Parenthesized(self0), + PathArguments::Parenthesized(other0), + ) => self0 == other0, _ => false, } } @@ -1717,8 +1637,7 @@ impl Eq for PredicateType {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PredicateType { fn eq(&self, other: &Self) -> bool { - self.lifetimes == other.lifetimes - && self.bounded_ty == other.bounded_ty + self.lifetimes == other.lifetimes && self.bounded_ty == other.bounded_ty && self.bounds == other.bounds } } @@ -1729,7 +1648,8 @@ impl Eq for QSelf {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for QSelf { fn eq(&self, other: &Self) -> bool { - self.ty == other.ty && self.position == other.position && self.as_token == other.as_token + self.ty == other.ty && self.position == other.position + && self.as_token == other.as_token } } #[cfg(feature = "full")] @@ -1753,8 +1673,7 @@ impl Eq for Receiver {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Receiver { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.reference == other.reference + self.attrs == other.attrs && self.reference == other.reference && self.mutability == other.mutability } } @@ -1779,14 +1698,10 @@ impl Eq for Signature {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Signature { fn eq(&self, other: &Self) -> bool { - self.constness == other.constness - && self.asyncness == other.asyncness - && self.unsafety == other.unsafety - && self.abi == other.abi - && self.ident == other.ident - && self.generics == other.generics - && self.inputs == other.inputs - && self.variadic == other.variadic + self.constness == other.constness && self.asyncness == other.asyncness + && self.unsafety == other.unsafety && self.abi == other.abi + && self.ident == other.ident && self.generics == other.generics + && self.inputs == other.inputs && self.variadic == other.variadic && self.output == other.output } } @@ -1813,10 +1728,8 @@ impl Eq for TraitBound {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TraitBound { fn eq(&self, other: &Self) -> bool { - self.paren_token == other.paren_token - && self.modifier == other.modifier - && self.lifetimes == other.lifetimes - && self.path == other.path + self.paren_token == other.paren_token && self.modifier == other.modifier + && self.lifetimes == other.lifetimes && self.path == other.path } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1859,9 +1772,7 @@ impl Eq for TraitItemConst {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TraitItemConst { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.ty == other.ty + self.attrs == other.attrs && self.ident == other.ident && self.ty == other.ty && self.default == other.default } } @@ -1872,7 +1783,8 @@ impl Eq for TraitItemMacro {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TraitItemMacro { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mac == other.mac && self.semi_token == other.semi_token + self.attrs == other.attrs && self.mac == other.mac + && self.semi_token == other.semi_token } } #[cfg(feature = "full")] @@ -1882,10 +1794,8 @@ impl Eq for TraitItemMethod {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TraitItemMethod { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.sig == other.sig - && self.default == other.default - && self.semi_token == other.semi_token + self.attrs == other.attrs && self.sig == other.sig + && self.default == other.default && self.semi_token == other.semi_token } } #[cfg(feature = "full")] @@ -1895,12 +1805,9 @@ impl Eq for TraitItemType {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TraitItemType { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.generics == other.generics - && self.colon_token == other.colon_token - && self.bounds == other.bounds - && self.default == other.default + self.attrs == other.attrs && self.ident == other.ident + && self.generics == other.generics && self.colon_token == other.colon_token + && self.bounds == other.bounds && self.default == other.default } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1949,12 +1856,9 @@ impl Eq for TypeBareFn {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TypeBareFn { fn eq(&self, other: &Self) -> bool { - self.lifetimes == other.lifetimes - && self.unsafety == other.unsafety - && self.abi == other.abi - && self.inputs == other.inputs - && self.variadic == other.variadic - && self.output == other.output + self.lifetimes == other.lifetimes && self.unsafety == other.unsafety + && self.abi == other.abi && self.inputs == other.inputs + && self.variadic == other.variadic && self.output == other.output } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2014,12 +1918,9 @@ impl Eq for TypeParam {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TypeParam { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.colon_token == other.colon_token - && self.bounds == other.bounds - && self.eq_token == other.eq_token - && self.default == other.default + self.attrs == other.attrs && self.ident == other.ident + && self.colon_token == other.colon_token && self.bounds == other.bounds + && self.eq_token == other.eq_token && self.default == other.default } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2030,8 +1931,12 @@ impl Eq for TypeParamBound {} impl PartialEq for TypeParamBound { fn eq(&self, other: &Self) -> bool { match (self, other) { - (TypeParamBound::Trait(self0), TypeParamBound::Trait(other0)) => self0 == other0, - (TypeParamBound::Lifetime(self0), TypeParamBound::Lifetime(other0)) => self0 == other0, + (TypeParamBound::Trait(self0), TypeParamBound::Trait(other0)) => { + self0 == other0 + } + (TypeParamBound::Lifetime(self0), TypeParamBound::Lifetime(other0)) => { + self0 == other0 + } _ => false, } } @@ -2063,8 +1968,7 @@ impl Eq for TypePtr {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TypePtr { fn eq(&self, other: &Self) -> bool { - self.const_token == other.const_token - && self.mutability == other.mutability + self.const_token == other.const_token && self.mutability == other.mutability && self.elem == other.elem } } @@ -2075,8 +1979,7 @@ impl Eq for TypeReference {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TypeReference { fn eq(&self, other: &Self) -> bool { - self.lifetime == other.lifetime - && self.mutability == other.mutability + self.lifetime == other.lifetime && self.mutability == other.mutability && self.elem == other.elem } } @@ -2209,10 +2112,8 @@ impl Eq for Variant {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Variant { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.fields == other.fields - && self.discriminant == other.discriminant + self.attrs == other.attrs && self.ident == other.ident + && self.fields == other.fields && self.discriminant == other.discriminant } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2255,7 +2156,9 @@ impl PartialEq for Visibility { match (self, other) { (Visibility::Public(self0), Visibility::Public(other0)) => self0 == other0, (Visibility::Crate(self0), Visibility::Crate(other0)) => self0 == other0, - (Visibility::Restricted(self0), Visibility::Restricted(other0)) => self0 == other0, + (Visibility::Restricted(self0), Visibility::Restricted(other0)) => { + self0 == other0 + } (Visibility::Inherited, Visibility::Inherited) => true, _ => false, } @@ -2279,8 +2182,12 @@ impl Eq for WherePredicate {} impl PartialEq for WherePredicate { fn eq(&self, other: &Self) -> bool { match (self, other) { - (WherePredicate::Type(self0), WherePredicate::Type(other0)) => self0 == other0, - (WherePredicate::Lifetime(self0), WherePredicate::Lifetime(other0)) => self0 == other0, + (WherePredicate::Type(self0), WherePredicate::Type(other0)) => { + self0 == other0 + } + (WherePredicate::Lifetime(self0), WherePredicate::Lifetime(other0)) => { + self0 == other0 + } (WherePredicate::Eq(self0), WherePredicate::Eq(other0)) => self0 == other0, _ => false, } diff --git a/src/gen/fold.rs b/src/gen/fold.rs index d9dd32a4..7916a620 100644 --- a/src/gen/fold.rs +++ b/src/gen/fold.rs @@ -18,7 +18,7 @@ macro_rules! full { #[cfg(all(feature = "derive", not(feature = "full")))] macro_rules! full { ($e:expr) => { - unreachable!() + unreachable ! () }; } /// Syntax tree traversal to transform the nodes of an owned syntax tree. @@ -317,7 +317,10 @@ pub trait Fold { fold_generic_argument(self, i) } #[cfg(feature = "full")] - fn fold_generic_method_argument(&mut self, i: GenericMethodArgument) -> GenericMethodArgument { + fn fold_generic_method_argument( + &mut self, + i: GenericMethodArgument, + ) -> GenericMethodArgument { fold_generic_method_argument(self, i) } #[cfg(any(feature = "derive", feature = "full"))] @@ -621,7 +624,10 @@ pub trait Fold { fold_trait_bound(self, i) } #[cfg(any(feature = "derive", feature = "full"))] - fn fold_trait_bound_modifier(&mut self, i: TraitBoundModifier) -> TraitBoundModifier { + fn fold_trait_bound_modifier( + &mut self, + i: TraitBoundModifier, + ) -> TraitBoundModifier { fold_trait_bound_modifier(self, i) } #[cfg(feature = "full")] @@ -792,10 +798,11 @@ where F: Fold + ?Sized, { AngleBracketedGenericArguments { - colon2_token: (node.colon2_token).map(|it| Token ! [::](tokens_helper(f, &it.spans))), - lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), + colon2_token: (node.colon2_token) + .map(|it| Token![::](tokens_helper(f, &it.spans))), + lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), args: FoldHelper::lift(node.args, |it| f.fold_generic_argument(it)), - gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), + gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), } } #[cfg(feature = "full")] @@ -806,15 +813,14 @@ where Arm { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), pat: f.fold_pat(node.pat), - guard: (node.guard).map(|it| { - ( + guard: (node.guard) + .map(|it| ( Token![if](tokens_helper(f, &(it).0.span)), Box::new(f.fold_expr(*(it).1)), - ) - }), - fat_arrow_token: Token ! [=>](tokens_helper(f, &node.fat_arrow_token.spans)), + )), + fat_arrow_token: Token![=>](tokens_helper(f, &node.fat_arrow_token.spans)), body: Box::new(f.fold_expr(*node.body)), - comma: (node.comma).map(|it| Token ! [,](tokens_helper(f, &it.spans))), + comma: (node.comma).map(|it| Token![,](tokens_helper(f, &it.spans))), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -835,7 +841,7 @@ where F: Fold + ?Sized, { Attribute { - pound_token: Token ! [#](tokens_helper(f, &node.pound_token.spans)), + pound_token: Token![#](tokens_helper(f, &node.pound_token.spans)), style: f.fold_attr_style(node.style), bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), path: f.fold_path(node.path), @@ -849,12 +855,11 @@ where { BareFnArg { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - name: (node.name).map(|it| { - ( + name: (node.name) + .map(|it| ( f.fold_ident((it).0), - Token ! [:](tokens_helper(f, &(it).1.spans)), - ) - }), + Token![:](tokens_helper(f, &(it).1.spans)), + )), ty: f.fold_type(node.ty), } } @@ -864,47 +869,89 @@ where F: Fold + ?Sized, { match node { - BinOp::Add(_binding_0) => BinOp::Add(Token ! [+](tokens_helper(f, &_binding_0.spans))), - BinOp::Sub(_binding_0) => BinOp::Sub(Token ! [-](tokens_helper(f, &_binding_0.spans))), - BinOp::Mul(_binding_0) => BinOp::Mul(Token ! [*](tokens_helper(f, &_binding_0.spans))), - BinOp::Div(_binding_0) => BinOp::Div(Token ! [/](tokens_helper(f, &_binding_0.spans))), - BinOp::Rem(_binding_0) => BinOp::Rem(Token ! [%](tokens_helper(f, &_binding_0.spans))), - BinOp::And(_binding_0) => BinOp::And(Token ! [&&](tokens_helper(f, &_binding_0.spans))), - BinOp::Or(_binding_0) => BinOp::Or(Token ! [||](tokens_helper(f, &_binding_0.spans))), + BinOp::Add(_binding_0) => { + BinOp::Add(Token![+](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Sub(_binding_0) => { + BinOp::Sub(Token![-](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Mul(_binding_0) => { + BinOp::Mul(Token![*](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Div(_binding_0) => { + BinOp::Div(Token![/](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Rem(_binding_0) => { + BinOp::Rem(Token![%](tokens_helper(f, &_binding_0.spans))) + } + BinOp::And(_binding_0) => { + BinOp::And(Token![&&](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Or(_binding_0) => { + BinOp::Or(Token![||](tokens_helper(f, &_binding_0.spans))) + } BinOp::BitXor(_binding_0) => { - BinOp::BitXor(Token ! [^](tokens_helper(f, &_binding_0.spans))) + BinOp::BitXor(Token![^](tokens_helper(f, &_binding_0.spans))) } BinOp::BitAnd(_binding_0) => { - BinOp::BitAnd(Token ! [&](tokens_helper(f, &_binding_0.spans))) - } - BinOp::BitOr(_binding_0) => BinOp::BitOr(Token ! [|](tokens_helper(f, &_binding_0.spans))), - BinOp::Shl(_binding_0) => BinOp::Shl(Token ! [<<](tokens_helper(f, &_binding_0.spans))), - BinOp::Shr(_binding_0) => BinOp::Shr(Token ! [>>](tokens_helper(f, &_binding_0.spans))), - BinOp::Eq(_binding_0) => BinOp::Eq(Token ! [==](tokens_helper(f, &_binding_0.spans))), - BinOp::Lt(_binding_0) => BinOp::Lt(Token ! [<](tokens_helper(f, &_binding_0.spans))), - BinOp::Le(_binding_0) => BinOp::Le(Token ! [<=](tokens_helper(f, &_binding_0.spans))), - BinOp::Ne(_binding_0) => BinOp::Ne(Token ! [!=](tokens_helper(f, &_binding_0.spans))), - BinOp::Ge(_binding_0) => BinOp::Ge(Token ! [>=](tokens_helper(f, &_binding_0.spans))), - BinOp::Gt(_binding_0) => BinOp::Gt(Token ! [>](tokens_helper(f, &_binding_0.spans))), - BinOp::AddEq(_binding_0) => BinOp::AddEq(Token ! [+=](tokens_helper(f, &_binding_0.spans))), - BinOp::SubEq(_binding_0) => BinOp::SubEq(Token ! [-=](tokens_helper(f, &_binding_0.spans))), - BinOp::MulEq(_binding_0) => BinOp::MulEq(Token ! [*=](tokens_helper(f, &_binding_0.spans))), - BinOp::DivEq(_binding_0) => BinOp::DivEq(Token ! [/=](tokens_helper(f, &_binding_0.spans))), - BinOp::RemEq(_binding_0) => BinOp::RemEq(Token ! [%=](tokens_helper(f, &_binding_0.spans))), + BinOp::BitAnd(Token![&](tokens_helper(f, &_binding_0.spans))) + } + BinOp::BitOr(_binding_0) => { + BinOp::BitOr(Token![|](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Shl(_binding_0) => { + BinOp::Shl(Token![<<](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Shr(_binding_0) => { + BinOp::Shr(Token![>>](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Eq(_binding_0) => { + BinOp::Eq(Token![==](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Lt(_binding_0) => { + BinOp::Lt(Token![<](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Le(_binding_0) => { + BinOp::Le(Token![<=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Ne(_binding_0) => { + BinOp::Ne(Token![!=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Ge(_binding_0) => { + BinOp::Ge(Token![>=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Gt(_binding_0) => { + BinOp::Gt(Token![>](tokens_helper(f, &_binding_0.spans))) + } + BinOp::AddEq(_binding_0) => { + BinOp::AddEq(Token![+=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::SubEq(_binding_0) => { + BinOp::SubEq(Token![-=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::MulEq(_binding_0) => { + BinOp::MulEq(Token![*=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::DivEq(_binding_0) => { + BinOp::DivEq(Token![/=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::RemEq(_binding_0) => { + BinOp::RemEq(Token![%=](tokens_helper(f, &_binding_0.spans))) + } BinOp::BitXorEq(_binding_0) => { - BinOp::BitXorEq(Token ! [^=](tokens_helper(f, &_binding_0.spans))) + BinOp::BitXorEq(Token![^=](tokens_helper(f, &_binding_0.spans))) } BinOp::BitAndEq(_binding_0) => { - BinOp::BitAndEq(Token ! [&=](tokens_helper(f, &_binding_0.spans))) + BinOp::BitAndEq(Token![&=](tokens_helper(f, &_binding_0.spans))) } BinOp::BitOrEq(_binding_0) => { - BinOp::BitOrEq(Token ! [|=](tokens_helper(f, &_binding_0.spans))) + BinOp::BitOrEq(Token![|=](tokens_helper(f, &_binding_0.spans))) } BinOp::ShlEq(_binding_0) => { - BinOp::ShlEq(Token ! [<<=](tokens_helper(f, &_binding_0.spans))) + BinOp::ShlEq(Token![<<=](tokens_helper(f, &_binding_0.spans))) } BinOp::ShrEq(_binding_0) => { - BinOp::ShrEq(Token ! [>>=](tokens_helper(f, &_binding_0.spans))) + BinOp::ShrEq(Token![>>=](tokens_helper(f, &_binding_0.spans))) } } } @@ -915,7 +962,7 @@ where { Binding { ident: f.fold_ident(node.ident), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), ty: f.fold_type(node.ty), } } @@ -936,9 +983,9 @@ where { BoundLifetimes { for_token: Token![for](tokens_helper(f, &node.for_token.span)), - lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), + lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), lifetimes: FoldHelper::lift(node.lifetimes, |it| f.fold_lifetime_def(it)), - gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), + gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -950,9 +997,9 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), const_token: Token![const](tokens_helper(f, &node.const_token.span)), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: f.fold_type(node.ty), - eq_token: (node.eq_token).map(|it| Token ! [=](tokens_helper(f, &it.spans))), + eq_token: (node.eq_token).map(|it| Token![=](tokens_helper(f, &it.spans))), default: (node.default).map(|it| f.fold_expr(it)), } } @@ -963,7 +1010,7 @@ where { Constraint { ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), } } @@ -997,7 +1044,7 @@ where DataStruct { struct_token: Token![struct](tokens_helper(f, &node.struct_token.span)), fields: f.fold_fields(node.fields), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "derive")] @@ -1031,7 +1078,9 @@ where match node { Expr::Array(_binding_0) => Expr::Array(full!(f.fold_expr_array(_binding_0))), Expr::Assign(_binding_0) => Expr::Assign(full!(f.fold_expr_assign(_binding_0))), - Expr::AssignOp(_binding_0) => Expr::AssignOp(full!(f.fold_expr_assign_op(_binding_0))), + Expr::AssignOp(_binding_0) => { + Expr::AssignOp(full!(f.fold_expr_assign_op(_binding_0))) + } Expr::Async(_binding_0) => Expr::Async(full!(f.fold_expr_async(_binding_0))), Expr::Await(_binding_0) => Expr::Await(full!(f.fold_expr_await(_binding_0))), Expr::Binary(_binding_0) => Expr::Binary(f.fold_expr_binary(_binding_0)), @@ -1040,10 +1089,16 @@ where Expr::Break(_binding_0) => Expr::Break(full!(f.fold_expr_break(_binding_0))), Expr::Call(_binding_0) => Expr::Call(f.fold_expr_call(_binding_0)), Expr::Cast(_binding_0) => Expr::Cast(f.fold_expr_cast(_binding_0)), - Expr::Closure(_binding_0) => Expr::Closure(full!(f.fold_expr_closure(_binding_0))), - Expr::Continue(_binding_0) => Expr::Continue(full!(f.fold_expr_continue(_binding_0))), + Expr::Closure(_binding_0) => { + Expr::Closure(full!(f.fold_expr_closure(_binding_0))) + } + Expr::Continue(_binding_0) => { + Expr::Continue(full!(f.fold_expr_continue(_binding_0))) + } Expr::Field(_binding_0) => Expr::Field(f.fold_expr_field(_binding_0)), - Expr::ForLoop(_binding_0) => Expr::ForLoop(full!(f.fold_expr_for_loop(_binding_0))), + Expr::ForLoop(_binding_0) => { + Expr::ForLoop(full!(f.fold_expr_for_loop(_binding_0))) + } Expr::Group(_binding_0) => Expr::Group(full!(f.fold_expr_group(_binding_0))), Expr::If(_binding_0) => Expr::If(full!(f.fold_expr_if(_binding_0))), Expr::Index(_binding_0) => Expr::Index(f.fold_expr_index(_binding_0)), @@ -1058,12 +1113,16 @@ where Expr::Paren(_binding_0) => Expr::Paren(f.fold_expr_paren(_binding_0)), Expr::Path(_binding_0) => Expr::Path(f.fold_expr_path(_binding_0)), Expr::Range(_binding_0) => Expr::Range(full!(f.fold_expr_range(_binding_0))), - Expr::Reference(_binding_0) => Expr::Reference(full!(f.fold_expr_reference(_binding_0))), + Expr::Reference(_binding_0) => { + Expr::Reference(full!(f.fold_expr_reference(_binding_0))) + } Expr::Repeat(_binding_0) => Expr::Repeat(full!(f.fold_expr_repeat(_binding_0))), Expr::Return(_binding_0) => Expr::Return(full!(f.fold_expr_return(_binding_0))), Expr::Struct(_binding_0) => Expr::Struct(full!(f.fold_expr_struct(_binding_0))), Expr::Try(_binding_0) => Expr::Try(full!(f.fold_expr_try(_binding_0))), - Expr::TryBlock(_binding_0) => Expr::TryBlock(full!(f.fold_expr_try_block(_binding_0))), + Expr::TryBlock(_binding_0) => { + Expr::TryBlock(full!(f.fold_expr_try_block(_binding_0))) + } Expr::Tuple(_binding_0) => Expr::Tuple(full!(f.fold_expr_tuple(_binding_0))), Expr::Type(_binding_0) => Expr::Type(full!(f.fold_expr_type(_binding_0))), Expr::Unary(_binding_0) => Expr::Unary(f.fold_expr_unary(_binding_0)), @@ -1093,7 +1152,7 @@ where ExprAssign { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), left: Box::new(f.fold_expr(*node.left)), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), right: Box::new(f.fold_expr(*node.right)), } } @@ -1129,7 +1188,7 @@ where ExprAwait { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), base: Box::new(f.fold_expr(*node.base)), - dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)), + dot_token: Token![.](tokens_helper(f, &node.dot_token.spans)), await_token: crate::token::Await(tokens_helper(f, &node.await_token.span)), } } @@ -1210,12 +1269,13 @@ where { ExprClosure { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), + movability: (node.movability) + .map(|it| Token![static](tokens_helper(f, &it.span))), asyncness: (node.asyncness).map(|it| Token![async](tokens_helper(f, &it.span))), - movability: (node.movability).map(|it| Token![static](tokens_helper(f, &it.span))), capture: (node.capture).map(|it| Token![move](tokens_helper(f, &it.span))), - or1_token: Token ! [|](tokens_helper(f, &node.or1_token.spans)), + or1_token: Token![|](tokens_helper(f, &node.or1_token.spans)), inputs: FoldHelper::lift(node.inputs, |it| f.fold_pat(it)), - or2_token: Token ! [|](tokens_helper(f, &node.or2_token.spans)), + or2_token: Token![|](tokens_helper(f, &node.or2_token.spans)), output: f.fold_return_type(node.output), body: Box::new(f.fold_expr(*node.body)), } @@ -1239,7 +1299,7 @@ where ExprField { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), base: Box::new(f.fold_expr(*node.base)), - dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)), + dot_token: Token![.](tokens_helper(f, &node.dot_token.spans)), member: f.fold_member(node.member), } } @@ -1279,12 +1339,11 @@ where if_token: Token![if](tokens_helper(f, &node.if_token.span)), cond: Box::new(f.fold_expr(*node.cond)), then_branch: f.fold_block(node.then_branch), - else_branch: (node.else_branch).map(|it| { - ( + else_branch: (node.else_branch) + .map(|it| ( Token![else](tokens_helper(f, &(it).0.span)), Box::new(f.fold_expr(*(it).1)), - ) - }), + )), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1308,7 +1367,7 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), let_token: Token![let](tokens_helper(f, &node.let_token.span)), pat: f.fold_pat(node.pat), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), expr: Box::new(f.fold_expr(*node.expr)), } } @@ -1365,7 +1424,7 @@ where ExprMethodCall { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), receiver: Box::new(f.fold_expr(*node.receiver)), - dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)), + dot_token: Token![.](tokens_helper(f, &node.dot_token.spans)), method: f.fold_ident(node.method), turbofish: (node.turbofish).map(|it| f.fold_method_turbofish(it)), paren_token: Paren(tokens_helper(f, &node.paren_token.span)), @@ -1413,7 +1472,7 @@ where { ExprReference { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)), + and_token: Token![&](tokens_helper(f, &node.and_token.spans)), raw: node.raw, mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), expr: Box::new(f.fold_expr(*node.expr)), @@ -1428,7 +1487,7 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), expr: Box::new(f.fold_expr(*node.expr)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), len: Box::new(f.fold_expr(*node.len)), } } @@ -1465,7 +1524,7 @@ where ExprTry { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), expr: Box::new(f.fold_expr(*node.expr)), - question_token: Token ! [?](tokens_helper(f, &node.question_token.spans)), + question_token: Token![?](tokens_helper(f, &node.question_token.spans)), } } #[cfg(feature = "full")] @@ -1498,7 +1557,7 @@ where ExprType { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), expr: Box::new(f.fold_expr(*node.expr)), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: Box::new(f.fold_type(*node.ty)), } } @@ -1557,7 +1616,7 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), ident: (node.ident).map(|it| f.fold_ident(it)), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), ty: f.fold_type(node.ty), } } @@ -1569,7 +1628,7 @@ where FieldPat { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), member: f.fold_member(node.member), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), pat: Box::new(f.fold_pat(*node.pat)), } } @@ -1581,7 +1640,7 @@ where FieldValue { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), member: f.fold_member(node.member), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), expr: f.fold_expr(node.expr), } } @@ -1643,12 +1702,18 @@ where F: Fold + ?Sized, { match node { - ForeignItem::Fn(_binding_0) => ForeignItem::Fn(f.fold_foreign_item_fn(_binding_0)), + ForeignItem::Fn(_binding_0) => { + ForeignItem::Fn(f.fold_foreign_item_fn(_binding_0)) + } ForeignItem::Static(_binding_0) => { ForeignItem::Static(f.fold_foreign_item_static(_binding_0)) } - ForeignItem::Type(_binding_0) => ForeignItem::Type(f.fold_foreign_item_type(_binding_0)), - ForeignItem::Macro(_binding_0) => ForeignItem::Macro(f.fold_foreign_item_macro(_binding_0)), + ForeignItem::Type(_binding_0) => { + ForeignItem::Type(f.fold_foreign_item_type(_binding_0)) + } + ForeignItem::Macro(_binding_0) => { + ForeignItem::Macro(f.fold_foreign_item_macro(_binding_0)) + } ForeignItem::Verbatim(_binding_0) => ForeignItem::Verbatim(_binding_0), _ => unreachable!(), } @@ -1662,7 +1727,7 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), sig: f.fold_signature(node.sig), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -1673,11 +1738,14 @@ where ForeignItemMacro { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] -pub fn fold_foreign_item_static<F>(f: &mut F, node: ForeignItemStatic) -> ForeignItemStatic +pub fn fold_foreign_item_static<F>( + f: &mut F, + node: ForeignItemStatic, +) -> ForeignItemStatic where F: Fold + ?Sized, { @@ -1687,9 +1755,9 @@ where static_token: Token![static](tokens_helper(f, &node.static_token.span)), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: Box::new(f.fold_type(*node.ty)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -1702,7 +1770,7 @@ where vis: f.fold_visibility(node.vis), type_token: Token![type](tokens_helper(f, &node.type_token.span)), ident: f.fold_ident(node.ident), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1714,14 +1782,18 @@ where GenericArgument::Lifetime(_binding_0) => { GenericArgument::Lifetime(f.fold_lifetime(_binding_0)) } - GenericArgument::Type(_binding_0) => GenericArgument::Type(f.fold_type(_binding_0)), + GenericArgument::Type(_binding_0) => { + GenericArgument::Type(f.fold_type(_binding_0)) + } GenericArgument::Binding(_binding_0) => { GenericArgument::Binding(f.fold_binding(_binding_0)) } GenericArgument::Constraint(_binding_0) => { GenericArgument::Constraint(f.fold_constraint(_binding_0)) } - GenericArgument::Const(_binding_0) => GenericArgument::Const(f.fold_expr(_binding_0)), + GenericArgument::Const(_binding_0) => { + GenericArgument::Const(f.fold_expr(_binding_0)) + } } } #[cfg(feature = "full")] @@ -1747,11 +1819,15 @@ where F: Fold + ?Sized, { match node { - GenericParam::Type(_binding_0) => GenericParam::Type(f.fold_type_param(_binding_0)), + GenericParam::Type(_binding_0) => { + GenericParam::Type(f.fold_type_param(_binding_0)) + } GenericParam::Lifetime(_binding_0) => { GenericParam::Lifetime(f.fold_lifetime_def(_binding_0)) } - GenericParam::Const(_binding_0) => GenericParam::Const(f.fold_const_param(_binding_0)), + GenericParam::Const(_binding_0) => { + GenericParam::Const(f.fold_const_param(_binding_0)) + } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1760,9 +1836,9 @@ where F: Fold + ?Sized, { Generics { - lt_token: (node.lt_token).map(|it| Token ! [<](tokens_helper(f, &it.spans))), + lt_token: (node.lt_token).map(|it| Token![<](tokens_helper(f, &it.spans))), params: FoldHelper::lift(node.params, |it| f.fold_generic_param(it)), - gt_token: (node.gt_token).map(|it| Token ! [>](tokens_helper(f, &it.spans))), + gt_token: (node.gt_token).map(|it| Token![>](tokens_helper(f, &it.spans))), where_clause: (node.where_clause).map(|it| f.fold_where_clause(it)), } } @@ -1781,10 +1857,16 @@ where F: Fold + ?Sized, { match node { - ImplItem::Const(_binding_0) => ImplItem::Const(f.fold_impl_item_const(_binding_0)), - ImplItem::Method(_binding_0) => ImplItem::Method(f.fold_impl_item_method(_binding_0)), + ImplItem::Const(_binding_0) => { + ImplItem::Const(f.fold_impl_item_const(_binding_0)) + } + ImplItem::Method(_binding_0) => { + ImplItem::Method(f.fold_impl_item_method(_binding_0)) + } ImplItem::Type(_binding_0) => ImplItem::Type(f.fold_impl_item_type(_binding_0)), - ImplItem::Macro(_binding_0) => ImplItem::Macro(f.fold_impl_item_macro(_binding_0)), + ImplItem::Macro(_binding_0) => { + ImplItem::Macro(f.fold_impl_item_macro(_binding_0)) + } ImplItem::Verbatim(_binding_0) => ImplItem::Verbatim(_binding_0), _ => unreachable!(), } @@ -1797,14 +1879,15 @@ where ImplItemConst { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), + defaultness: (node.defaultness) + .map(|it| Token![default](tokens_helper(f, &it.span))), const_token: Token![const](tokens_helper(f, &node.const_token.span)), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: f.fold_type(node.ty), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), expr: f.fold_expr(node.expr), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -1815,7 +1898,7 @@ where ImplItemMacro { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -1826,7 +1909,8 @@ where ImplItemMethod { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), + defaultness: (node.defaultness) + .map(|it| Token![default](tokens_helper(f, &it.span))), sig: f.fold_signature(node.sig), block: f.fold_block(node.block), } @@ -1839,13 +1923,14 @@ where ImplItemType { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), + defaultness: (node.defaultness) + .map(|it| Token![default](tokens_helper(f, &it.span))), type_token: Token![type](tokens_helper(f, &node.type_token.span)), ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), ty: f.fold_type(node.ty), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1866,9 +1951,13 @@ where match node { Item::Const(_binding_0) => Item::Const(f.fold_item_const(_binding_0)), Item::Enum(_binding_0) => Item::Enum(f.fold_item_enum(_binding_0)), - Item::ExternCrate(_binding_0) => Item::ExternCrate(f.fold_item_extern_crate(_binding_0)), + Item::ExternCrate(_binding_0) => { + Item::ExternCrate(f.fold_item_extern_crate(_binding_0)) + } Item::Fn(_binding_0) => Item::Fn(f.fold_item_fn(_binding_0)), - Item::ForeignMod(_binding_0) => Item::ForeignMod(f.fold_item_foreign_mod(_binding_0)), + Item::ForeignMod(_binding_0) => { + Item::ForeignMod(f.fold_item_foreign_mod(_binding_0)) + } Item::Impl(_binding_0) => Item::Impl(f.fold_item_impl(_binding_0)), Item::Macro(_binding_0) => Item::Macro(f.fold_item_macro(_binding_0)), Item::Macro2(_binding_0) => Item::Macro2(f.fold_item_macro2(_binding_0)), @@ -1876,7 +1965,9 @@ where Item::Static(_binding_0) => Item::Static(f.fold_item_static(_binding_0)), Item::Struct(_binding_0) => Item::Struct(f.fold_item_struct(_binding_0)), Item::Trait(_binding_0) => Item::Trait(f.fold_item_trait(_binding_0)), - Item::TraitAlias(_binding_0) => Item::TraitAlias(f.fold_item_trait_alias(_binding_0)), + Item::TraitAlias(_binding_0) => { + Item::TraitAlias(f.fold_item_trait_alias(_binding_0)) + } Item::Type(_binding_0) => Item::Type(f.fold_item_type(_binding_0)), Item::Union(_binding_0) => Item::Union(f.fold_item_union(_binding_0)), Item::Use(_binding_0) => Item::Use(f.fold_item_use(_binding_0)), @@ -1894,11 +1985,11 @@ where vis: f.fold_visibility(node.vis), const_token: Token![const](tokens_helper(f, &node.const_token.span)), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: Box::new(f.fold_type(*node.ty)), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), expr: Box::new(f.fold_expr(*node.expr)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -1927,13 +2018,12 @@ where extern_token: Token![extern](tokens_helper(f, &node.extern_token.span)), crate_token: Token![crate](tokens_helper(f, &node.crate_token.span)), ident: f.fold_ident(node.ident), - rename: (node.rename).map(|it| { - ( + rename: (node.rename) + .map(|it| ( Token![as](tokens_helper(f, &(it).0.span)), f.fold_ident((it).1), - ) - }), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + )), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -1967,17 +2057,17 @@ where { ItemImpl { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), + defaultness: (node.defaultness) + .map(|it| Token![default](tokens_helper(f, &it.span))), unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))), impl_token: Token![impl](tokens_helper(f, &node.impl_token.span)), generics: f.fold_generics(node.generics), - trait_: (node.trait_).map(|it| { - ( + trait_: (node.trait_) + .map(|it| ( ((it).0).map(|it| Token![!](tokens_helper(f, &it.spans))), f.fold_path((it).1), Token![for](tokens_helper(f, &(it).2.span)), - ) - }), + )), self_ty: Box::new(f.fold_type(*node.self_ty)), brace_token: Brace(tokens_helper(f, &node.brace_token.span)), items: FoldHelper::lift(node.items, |it| f.fold_impl_item(it)), @@ -1992,7 +2082,7 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), ident: (node.ident).map(|it| f.fold_ident(it)), mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -2018,13 +2108,12 @@ where vis: f.fold_visibility(node.vis), mod_token: Token![mod](tokens_helper(f, &node.mod_token.span)), ident: f.fold_ident(node.ident), - content: (node.content).map(|it| { - ( + content: (node.content) + .map(|it| ( Brace(tokens_helper(f, &(it).0.span)), FoldHelper::lift((it).1, |it| f.fold_item(it)), - ) - }), - semi: (node.semi).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + )), + semi: (node.semi).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -2038,11 +2127,11 @@ where static_token: Token![static](tokens_helper(f, &node.static_token.span)), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: Box::new(f.fold_type(*node.ty)), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), expr: Box::new(f.fold_expr(*node.expr)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -2057,7 +2146,7 @@ where ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), fields: f.fold_fields(node.fields), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -2073,8 +2162,11 @@ where trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)), ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), - supertraits: FoldHelper::lift(node.supertraits, |it| f.fold_type_param_bound(it)), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), + supertraits: FoldHelper::lift( + node.supertraits, + |it| f.fold_type_param_bound(it), + ), brace_token: Brace(tokens_helper(f, &node.brace_token.span)), items: FoldHelper::lift(node.items, |it| f.fold_trait_item(it)), } @@ -2090,9 +2182,9 @@ where trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)), ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -2106,9 +2198,9 @@ where type_token: Token![type](tokens_helper(f, &node.type_token.span)), ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), ty: Box::new(f.fold_type(*node.ty)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -2134,9 +2226,10 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), use_token: Token![use](tokens_helper(f, &node.use_token.span)), - leading_colon: (node.leading_colon).map(|it| Token ! [::](tokens_helper(f, &it.spans))), + leading_colon: (node.leading_colon) + .map(|it| Token![::](tokens_helper(f, &it.spans))), tree: f.fold_use_tree(node.tree), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -2146,7 +2239,7 @@ where { Label { name: f.fold_lifetime(node.name), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), } } pub fn fold_lifetime<F>(f: &mut F, node: Lifetime) -> Lifetime @@ -2166,7 +2259,7 @@ where LifetimeDef { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), lifetime: f.fold_lifetime(node.lifetime), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)), } } @@ -2257,13 +2350,12 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), let_token: Token![let](tokens_helper(f, &node.let_token.span)), pat: f.fold_pat(node.pat), - init: (node.init).map(|it| { - ( - Token ! [=](tokens_helper(f, &(it).0.spans)), + init: (node.init) + .map(|it| ( + Token![=](tokens_helper(f, &(it).0.spans)), Box::new(f.fold_expr(*(it).1)), - ) - }), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + )), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2313,7 +2405,9 @@ where match node { Meta::Path(_binding_0) => Meta::Path(f.fold_path(_binding_0)), Meta::List(_binding_0) => Meta::List(f.fold_meta_list(_binding_0)), - Meta::NameValue(_binding_0) => Meta::NameValue(f.fold_meta_name_value(_binding_0)), + Meta::NameValue(_binding_0) => { + Meta::NameValue(f.fold_meta_name_value(_binding_0)) + } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2334,7 +2428,7 @@ where { MetaNameValue { path: f.fold_path(node.path), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), lit: f.fold_lit(node.lit), } } @@ -2344,10 +2438,10 @@ where F: Fold + ?Sized, { MethodTurbofish { - colon2_token: Token ! [::](tokens_helper(f, &node.colon2_token.spans)), - lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), + colon2_token: Token![::](tokens_helper(f, &node.colon2_token.spans)), + lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), args: FoldHelper::lift(node.args, |it| f.fold_generic_method_argument(it)), - gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), + gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2392,7 +2486,9 @@ where Pat::Slice(_binding_0) => Pat::Slice(f.fold_pat_slice(_binding_0)), Pat::Struct(_binding_0) => Pat::Struct(f.fold_pat_struct(_binding_0)), Pat::Tuple(_binding_0) => Pat::Tuple(f.fold_pat_tuple(_binding_0)), - Pat::TupleStruct(_binding_0) => Pat::TupleStruct(f.fold_pat_tuple_struct(_binding_0)), + Pat::TupleStruct(_binding_0) => { + Pat::TupleStruct(f.fold_pat_tuple_struct(_binding_0)) + } Pat::Type(_binding_0) => Pat::Type(f.fold_pat_type(_binding_0)), Pat::Verbatim(_binding_0) => Pat::Verbatim(_binding_0), Pat::Wild(_binding_0) => Pat::Wild(f.fold_pat_wild(_binding_0)), @@ -2420,12 +2516,11 @@ where by_ref: (node.by_ref).map(|it| Token![ref](tokens_helper(f, &it.span))), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), ident: f.fold_ident(node.ident), - subpat: (node.subpat).map(|it| { - ( - Token ! [@](tokens_helper(f, &(it).0.spans)), + subpat: (node.subpat) + .map(|it| ( + Token![@](tokens_helper(f, &(it).0.spans)), Box::new(f.fold_pat(*(it).1)), - ) - }), + )), } } #[cfg(feature = "full")] @@ -2455,7 +2550,8 @@ where { PatOr { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - leading_vert: (node.leading_vert).map(|it| Token ! [|](tokens_helper(f, &it.spans))), + leading_vert: (node.leading_vert) + .map(|it| Token![|](tokens_helper(f, &it.spans))), cases: FoldHelper::lift(node.cases, |it| f.fold_pat(it)), } } @@ -2489,7 +2585,7 @@ where { PatReference { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)), + and_token: Token![&](tokens_helper(f, &node.and_token.spans)), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), pat: Box::new(f.fold_pat(*node.pat)), } @@ -2558,7 +2654,7 @@ where PatType { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), pat: Box::new(f.fold_pat(*node.pat)), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: Box::new(f.fold_type(*node.ty)), } } @@ -2578,7 +2674,8 @@ where F: Fold + ?Sized, { Path { - leading_colon: (node.leading_colon).map(|it| Token ! [::](tokens_helper(f, &it.spans))), + leading_colon: (node.leading_colon) + .map(|it| Token![::](tokens_helper(f, &it.spans))), segments: FoldHelper::lift(node.segments, |it| f.fold_path_segment(it)), } } @@ -2590,10 +2687,14 @@ where match node { PathArguments::None => PathArguments::None, PathArguments::AngleBracketed(_binding_0) => { - PathArguments::AngleBracketed(f.fold_angle_bracketed_generic_arguments(_binding_0)) + PathArguments::AngleBracketed( + f.fold_angle_bracketed_generic_arguments(_binding_0), + ) } PathArguments::Parenthesized(_binding_0) => { - PathArguments::Parenthesized(f.fold_parenthesized_generic_arguments(_binding_0)) + PathArguments::Parenthesized( + f.fold_parenthesized_generic_arguments(_binding_0), + ) } } } @@ -2614,18 +2715,21 @@ where { PredicateEq { lhs_ty: f.fold_type(node.lhs_ty), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), rhs_ty: f.fold_type(node.rhs_ty), } } #[cfg(any(feature = "derive", feature = "full"))] -pub fn fold_predicate_lifetime<F>(f: &mut F, node: PredicateLifetime) -> PredicateLifetime +pub fn fold_predicate_lifetime<F>( + f: &mut F, + node: PredicateLifetime, +) -> PredicateLifetime where F: Fold + ?Sized, { PredicateLifetime { lifetime: f.fold_lifetime(node.lifetime), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)), } } @@ -2637,7 +2741,7 @@ where PredicateType { lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)), bounded_ty: f.fold_type(node.bounded_ty), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), } } @@ -2647,11 +2751,11 @@ where F: Fold + ?Sized, { QSelf { - lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), + lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), ty: Box::new(f.fold_type(*node.ty)), position: node.position, as_token: (node.as_token).map(|it| Token![as](tokens_helper(f, &it.span))), - gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), + gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), } } #[cfg(feature = "full")] @@ -2664,7 +2768,7 @@ where RangeLimits::HalfOpen(Token![..](tokens_helper(f, &_binding_0.spans))) } RangeLimits::Closed(_binding_0) => { - RangeLimits::Closed(Token ! [..=](tokens_helper(f, &_binding_0.spans))) + RangeLimits::Closed(Token![..=](tokens_helper(f, &_binding_0.spans))) } } } @@ -2675,12 +2779,11 @@ where { Receiver { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - reference: (node.reference).map(|it| { - ( - Token ! [&](tokens_helper(f, &(it).0.spans)), + reference: (node.reference) + .map(|it| ( + Token![&](tokens_helper(f, &(it).0.spans)), ((it).1).map(|it| f.fold_lifetime(it)), - ) - }), + )), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), self_token: Token![self](tokens_helper(f, &node.self_token.span)), } @@ -2692,10 +2795,12 @@ where { match node { ReturnType::Default => ReturnType::Default, - ReturnType::Type(_binding_0, _binding_1) => ReturnType::Type( - Token ! [->](tokens_helper(f, &_binding_0.spans)), - Box::new(f.fold_type(*_binding_1)), - ), + ReturnType::Type(_binding_0, _binding_1) => { + ReturnType::Type( + Token![->](tokens_helper(f, &_binding_0.spans)), + Box::new(f.fold_type(*_binding_1)), + ) + } } } #[cfg(feature = "full")] @@ -2732,10 +2837,12 @@ where Stmt::Local(_binding_0) => Stmt::Local(f.fold_local(_binding_0)), Stmt::Item(_binding_0) => Stmt::Item(f.fold_item(_binding_0)), Stmt::Expr(_binding_0) => Stmt::Expr(f.fold_expr(_binding_0)), - Stmt::Semi(_binding_0, _binding_1) => Stmt::Semi( - f.fold_expr(_binding_0), - Token ! [;](tokens_helper(f, &_binding_1.spans)), - ), + Stmt::Semi(_binding_0, _binding_1) => { + Stmt::Semi( + f.fold_expr(_binding_0), + Token![;](tokens_helper(f, &_binding_1.spans)), + ) + } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2751,14 +2858,17 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] -pub fn fold_trait_bound_modifier<F>(f: &mut F, node: TraitBoundModifier) -> TraitBoundModifier +pub fn fold_trait_bound_modifier<F>( + f: &mut F, + node: TraitBoundModifier, +) -> TraitBoundModifier where F: Fold + ?Sized, { match node { TraitBoundModifier::None => TraitBoundModifier::None, TraitBoundModifier::Maybe(_binding_0) => { - TraitBoundModifier::Maybe(Token ! [?](tokens_helper(f, &_binding_0.spans))) + TraitBoundModifier::Maybe(Token![?](tokens_helper(f, &_binding_0.spans))) } } } @@ -2768,10 +2878,18 @@ where F: Fold + ?Sized, { match node { - TraitItem::Const(_binding_0) => TraitItem::Const(f.fold_trait_item_const(_binding_0)), - TraitItem::Method(_binding_0) => TraitItem::Method(f.fold_trait_item_method(_binding_0)), - TraitItem::Type(_binding_0) => TraitItem::Type(f.fold_trait_item_type(_binding_0)), - TraitItem::Macro(_binding_0) => TraitItem::Macro(f.fold_trait_item_macro(_binding_0)), + TraitItem::Const(_binding_0) => { + TraitItem::Const(f.fold_trait_item_const(_binding_0)) + } + TraitItem::Method(_binding_0) => { + TraitItem::Method(f.fold_trait_item_method(_binding_0)) + } + TraitItem::Type(_binding_0) => { + TraitItem::Type(f.fold_trait_item_type(_binding_0)) + } + TraitItem::Macro(_binding_0) => { + TraitItem::Macro(f.fold_trait_item_macro(_binding_0)) + } TraitItem::Verbatim(_binding_0) => TraitItem::Verbatim(_binding_0), _ => unreachable!(), } @@ -2785,15 +2903,11 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), const_token: Token![const](tokens_helper(f, &node.const_token.span)), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: f.fold_type(node.ty), - default: (node.default).map(|it| { - ( - Token ! [=](tokens_helper(f, &(it).0.spans)), - f.fold_expr((it).1), - ) - }), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + default: (node.default) + .map(|it| (Token![=](tokens_helper(f, &(it).0.spans)), f.fold_expr((it).1))), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -2804,7 +2918,7 @@ where TraitItemMacro { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -2816,7 +2930,7 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), sig: f.fold_signature(node.sig), default: (node.default).map(|it| f.fold_block(it)), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -2829,15 +2943,11 @@ where type_token: Token![type](tokens_helper(f, &node.type_token.span)), ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), - default: (node.default).map(|it| { - ( - Token ! [=](tokens_helper(f, &(it).0.spans)), - f.fold_type((it).1), - ) - }), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + default: (node.default) + .map(|it| (Token![=](tokens_helper(f, &(it).0.spans)), f.fold_type((it).1))), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2849,7 +2959,9 @@ where Type::Array(_binding_0) => Type::Array(f.fold_type_array(_binding_0)), Type::BareFn(_binding_0) => Type::BareFn(f.fold_type_bare_fn(_binding_0)), Type::Group(_binding_0) => Type::Group(f.fold_type_group(_binding_0)), - Type::ImplTrait(_binding_0) => Type::ImplTrait(f.fold_type_impl_trait(_binding_0)), + Type::ImplTrait(_binding_0) => { + Type::ImplTrait(f.fold_type_impl_trait(_binding_0)) + } Type::Infer(_binding_0) => Type::Infer(f.fold_type_infer(_binding_0)), Type::Macro(_binding_0) => Type::Macro(f.fold_type_macro(_binding_0)), Type::Never(_binding_0) => Type::Never(f.fold_type_never(_binding_0)), @@ -2858,7 +2970,9 @@ where Type::Ptr(_binding_0) => Type::Ptr(f.fold_type_ptr(_binding_0)), Type::Reference(_binding_0) => Type::Reference(f.fold_type_reference(_binding_0)), Type::Slice(_binding_0) => Type::Slice(f.fold_type_slice(_binding_0)), - Type::TraitObject(_binding_0) => Type::TraitObject(f.fold_type_trait_object(_binding_0)), + Type::TraitObject(_binding_0) => { + Type::TraitObject(f.fold_type_trait_object(_binding_0)) + } Type::Tuple(_binding_0) => Type::Tuple(f.fold_type_tuple(_binding_0)), Type::Verbatim(_binding_0) => Type::Verbatim(_binding_0), _ => unreachable!(), @@ -2872,7 +2986,7 @@ where TypeArray { bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), elem: Box::new(f.fold_type(*node.elem)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), len: f.fold_expr(node.len), } } @@ -2947,9 +3061,9 @@ where TypeParam { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), ident: f.fold_ident(node.ident), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), - eq_token: (node.eq_token).map(|it| Token ! [=](tokens_helper(f, &it.spans))), + eq_token: (node.eq_token).map(|it| Token![=](tokens_helper(f, &it.spans))), default: (node.default).map(|it| f.fold_type(it)), } } @@ -2959,7 +3073,9 @@ where F: Fold + ?Sized, { match node { - TypeParamBound::Trait(_binding_0) => TypeParamBound::Trait(f.fold_trait_bound(_binding_0)), + TypeParamBound::Trait(_binding_0) => { + TypeParamBound::Trait(f.fold_trait_bound(_binding_0)) + } TypeParamBound::Lifetime(_binding_0) => { TypeParamBound::Lifetime(f.fold_lifetime(_binding_0)) } @@ -2991,8 +3107,9 @@ where F: Fold + ?Sized, { TypePtr { - star_token: Token ! [*](tokens_helper(f, &node.star_token.spans)), - const_token: (node.const_token).map(|it| Token![const](tokens_helper(f, &it.span))), + star_token: Token![*](tokens_helper(f, &node.star_token.spans)), + const_token: (node.const_token) + .map(|it| Token![const](tokens_helper(f, &it.span))), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), elem: Box::new(f.fold_type(*node.elem)), } @@ -3003,7 +3120,7 @@ where F: Fold + ?Sized, { TypeReference { - and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)), + and_token: Token![&](tokens_helper(f, &node.and_token.spans)), lifetime: (node.lifetime).map(|it| f.fold_lifetime(it)), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), elem: Box::new(f.fold_type(*node.elem)), @@ -3045,9 +3162,15 @@ where F: Fold + ?Sized, { match node { - UnOp::Deref(_binding_0) => UnOp::Deref(Token ! [*](tokens_helper(f, &_binding_0.spans))), - UnOp::Not(_binding_0) => UnOp::Not(Token![!](tokens_helper(f, &_binding_0.spans))), - UnOp::Neg(_binding_0) => UnOp::Neg(Token ! [-](tokens_helper(f, &_binding_0.spans))), + UnOp::Deref(_binding_0) => { + UnOp::Deref(Token![*](tokens_helper(f, &_binding_0.spans))) + } + UnOp::Not(_binding_0) => { + UnOp::Not(Token![!](tokens_helper(f, &_binding_0.spans))) + } + UnOp::Neg(_binding_0) => { + UnOp::Neg(Token![-](tokens_helper(f, &_binding_0.spans))) + } } } #[cfg(feature = "full")] @@ -3056,7 +3179,7 @@ where F: Fold + ?Sized, { UseGlob { - star_token: Token ! [*](tokens_helper(f, &node.star_token.spans)), + star_token: Token![*](tokens_helper(f, &node.star_token.spans)), } } #[cfg(feature = "full")] @@ -3085,7 +3208,7 @@ where { UsePath { ident: f.fold_ident(node.ident), - colon2_token: Token ! [::](tokens_helper(f, &node.colon2_token.spans)), + colon2_token: Token![::](tokens_helper(f, &node.colon2_token.spans)), tree: Box::new(f.fold_use_tree(*node.tree)), } } @@ -3120,7 +3243,7 @@ where { Variadic { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - dots: Token ! [...](tokens_helper(f, &node.dots.spans)), + dots: Token![...](tokens_helper(f, &node.dots.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3132,12 +3255,8 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), ident: f.fold_ident(node.ident), fields: f.fold_fields(node.fields), - discriminant: (node.discriminant).map(|it| { - ( - Token ! [=](tokens_helper(f, &(it).0.spans)), - f.fold_expr((it).1), - ) - }), + discriminant: (node.discriminant) + .map(|it| (Token![=](tokens_helper(f, &(it).0.spans)), f.fold_expr((it).1))), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3176,7 +3295,9 @@ where F: Fold + ?Sized, { match node { - Visibility::Public(_binding_0) => Visibility::Public(f.fold_vis_public(_binding_0)), + Visibility::Public(_binding_0) => { + Visibility::Public(f.fold_vis_public(_binding_0)) + } Visibility::Crate(_binding_0) => Visibility::Crate(f.fold_vis_crate(_binding_0)), Visibility::Restricted(_binding_0) => { Visibility::Restricted(f.fold_vis_restricted(_binding_0)) @@ -3200,10 +3321,14 @@ where F: Fold + ?Sized, { match node { - WherePredicate::Type(_binding_0) => WherePredicate::Type(f.fold_predicate_type(_binding_0)), + WherePredicate::Type(_binding_0) => { + WherePredicate::Type(f.fold_predicate_type(_binding_0)) + } WherePredicate::Lifetime(_binding_0) => { WherePredicate::Lifetime(f.fold_predicate_lifetime(_binding_0)) } - WherePredicate::Eq(_binding_0) => WherePredicate::Eq(f.fold_predicate_eq(_binding_0)), + WherePredicate::Eq(_binding_0) => { + WherePredicate::Eq(f.fold_predicate_eq(_binding_0)) + } } } diff --git a/src/gen/hash.rs b/src/gen/hash.rs index 7247174a..686ed865 100644 --- a/src/gen/hash.rs +++ b/src/gen/hash.rs @@ -641,8 +641,8 @@ impl Hash for ExprClosure { H: Hasher, { self.attrs.hash(state); - self.asyncness.hash(state); self.movability.hash(state); + self.asyncness.hash(state); self.capture.hash(state); self.inputs.hash(state); self.output.hash(state); @@ -2520,8 +2520,7 @@ impl Hash for TypeInfer { fn hash<H>(&self, _state: &mut H) where H: Hasher, - { - } + {} } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -2539,8 +2538,7 @@ impl Hash for TypeNever { fn hash<H>(&self, _state: &mut H) where H: Hasher, - { - } + {} } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -2678,8 +2676,7 @@ impl Hash for UseGlob { fn hash<H>(&self, _state: &mut H) where H: Hasher, - { - } + {} } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -2783,8 +2780,7 @@ impl Hash for VisCrate { fn hash<H>(&self, _state: &mut H) where H: Hasher, - { - } + {} } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -2792,8 +2788,7 @@ impl Hash for VisPublic { fn hash<H>(&self, _state: &mut H) where H: Hasher, - { - } + {} } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] diff --git a/src/gen/visit.rs b/src/gen/visit.rs index 6eaee24c..d84e4310 100644 --- a/src/gen/visit.rs +++ b/src/gen/visit.rs @@ -17,7 +17,7 @@ macro_rules! full { #[cfg(all(feature = "derive", not(feature = "full")))] macro_rules! full { ($e:expr) => { - unreachable!() + unreachable ! () }; } macro_rules! skip { @@ -36,7 +36,10 @@ pub trait Visit<'ast> { visit_abi(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_angle_bracketed_generic_arguments(&mut self, i: &'ast AngleBracketedGenericArguments) { + fn visit_angle_bracketed_generic_arguments( + &mut self, + i: &'ast AngleBracketedGenericArguments, + ) { visit_angle_bracketed_generic_arguments(self, i); } #[cfg(feature = "full")] @@ -494,7 +497,10 @@ pub trait Visit<'ast> { visit_nested_meta(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_parenthesized_generic_arguments(&mut self, i: &'ast ParenthesizedGenericArguments) { + fn visit_parenthesized_generic_arguments( + &mut self, + i: &'ast ParenthesizedGenericArguments, + ) { visit_parenthesized_generic_arguments(self, i); } #[cfg(feature = "full")] @@ -777,18 +783,19 @@ where tokens_helper(v, &node.extern_token.span); if let Some(it) = &node.name { v.visit_lit_str(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_angle_bracketed_generic_arguments<'ast, V>( v: &mut V, node: &'ast AngleBracketedGenericArguments, -) where +) +where V: Visit<'ast> + ?Sized, { if let Some(it) = &node.colon2_token { tokens_helper(v, &it.spans); - }; + } tokens_helper(v, &node.lt_token.spans); for el in Punctuated::pairs(&node.args) { let (it, p) = el.into_tuple(); @@ -811,12 +818,12 @@ where if let Some(it) = &node.guard { tokens_helper(v, &(it).0.span); v.visit_expr(&*(it).1); - }; + } tokens_helper(v, &node.fat_arrow_token.spans); v.visit_expr(&*node.body); if let Some(it) = &node.comma { tokens_helper(v, &it.spans); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_attr_style<'ast, V>(v: &mut V, node: &'ast AttrStyle) @@ -852,7 +859,7 @@ where if let Some(it) = &node.name { v.visit_ident(&(it).0); tokens_helper(v, &(it).1.spans); - }; + } v.visit_type(&node.ty); } #[cfg(any(feature = "derive", feature = "full"))] @@ -996,10 +1003,10 @@ where v.visit_type(&node.ty); if let Some(it) = &node.eq_token { tokens_helper(v, &it.spans); - }; + } if let Some(it) = &node.default { v.visit_expr(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_constraint<'ast, V>(v: &mut V, node: &'ast Constraint) @@ -1057,7 +1064,7 @@ where v.visit_fields(&node.fields); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "derive")] pub fn visit_data_union<'ast, V>(v: &mut V, node: &'ast DataUnion) @@ -1261,7 +1268,7 @@ where tokens_helper(v, &node.async_token.span); if let Some(it) = &node.capture { tokens_helper(v, &it.span); - }; + } v.visit_block(&node.block); } #[cfg(feature = "full")] @@ -1298,7 +1305,7 @@ where } if let Some(it) = &node.label { v.visit_label(it); - }; + } v.visit_block(&node.block); } #[cfg(feature = "full")] @@ -1323,10 +1330,10 @@ where tokens_helper(v, &node.break_token.span); if let Some(it) = &node.label { v.visit_lifetime(it); - }; + } if let Some(it) = &node.expr { v.visit_expr(&**it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_call<'ast, V>(v: &mut V, node: &'ast ExprCall) @@ -1366,15 +1373,15 @@ where for it in &node.attrs { v.visit_attribute(it); } - if let Some(it) = &node.asyncness { - tokens_helper(v, &it.span); - }; if let Some(it) = &node.movability { tokens_helper(v, &it.span); - }; + } + if let Some(it) = &node.asyncness { + tokens_helper(v, &it.span); + } if let Some(it) = &node.capture { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.or1_token.spans); for el in Punctuated::pairs(&node.inputs) { let (it, p) = el.into_tuple(); @@ -1398,7 +1405,7 @@ where tokens_helper(v, &node.continue_token.span); if let Some(it) = &node.label { v.visit_lifetime(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_field<'ast, V>(v: &mut V, node: &'ast ExprField) @@ -1422,7 +1429,7 @@ where } if let Some(it) = &node.label { v.visit_label(it); - }; + } tokens_helper(v, &node.for_token.span); v.visit_pat(&node.pat); tokens_helper(v, &node.in_token.span); @@ -1454,7 +1461,7 @@ where if let Some(it) = &node.else_branch { tokens_helper(v, &(it).0.span); v.visit_expr(&*(it).1); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_index<'ast, V>(v: &mut V, node: &'ast ExprIndex) @@ -1501,7 +1508,7 @@ where } if let Some(it) = &node.label { v.visit_label(it); - }; + } tokens_helper(v, &node.loop_token.span); v.visit_block(&node.body); } @@ -1543,7 +1550,7 @@ where v.visit_ident(&node.method); if let Some(it) = &node.turbofish { v.visit_method_turbofish(it); - }; + } tokens_helper(v, &node.paren_token.span); for el in Punctuated::pairs(&node.args) { let (it, p) = el.into_tuple(); @@ -1574,7 +1581,7 @@ where } if let Some(it) = &node.qself { v.visit_qself(it); - }; + } v.visit_path(&node.path); } #[cfg(feature = "full")] @@ -1587,11 +1594,11 @@ where } if let Some(it) = &node.from { v.visit_expr(&**it); - }; + } v.visit_range_limits(&node.limits); if let Some(it) = &node.to { v.visit_expr(&**it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_reference<'ast, V>(v: &mut V, node: &'ast ExprReference) @@ -1604,7 +1611,7 @@ where tokens_helper(v, &node.and_token.spans); if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_expr(&*node.expr); } #[cfg(feature = "full")] @@ -1631,7 +1638,7 @@ where tokens_helper(v, &node.return_token.span); if let Some(it) = &node.expr { v.visit_expr(&**it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_struct<'ast, V>(v: &mut V, node: &'ast ExprStruct) @@ -1652,10 +1659,10 @@ where } if let Some(it) = &node.dot2_token { tokens_helper(v, &it.spans); - }; + } if let Some(it) = &node.rest { v.visit_expr(&**it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_try<'ast, V>(v: &mut V, node: &'ast ExprTry) @@ -1740,7 +1747,7 @@ where } if let Some(it) = &node.label { v.visit_label(it); - }; + } tokens_helper(v, &node.while_token.span); v.visit_expr(&*node.cond); v.visit_block(&node.body); @@ -1756,7 +1763,7 @@ where tokens_helper(v, &node.yield_token.span); if let Some(it) = &node.expr { v.visit_expr(&**it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_field<'ast, V>(v: &mut V, node: &'ast Field) @@ -1769,10 +1776,10 @@ where v.visit_visibility(&node.vis); if let Some(it) = &node.ident { v.visit_ident(it); - }; + } if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } v.visit_type(&node.ty); } #[cfg(feature = "full")] @@ -1786,7 +1793,7 @@ where v.visit_member(&node.member); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } v.visit_pat(&*node.pat); } #[cfg(feature = "full")] @@ -1800,7 +1807,7 @@ where v.visit_member(&node.member); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } v.visit_expr(&node.expr); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1920,7 +1927,7 @@ where v.visit_macro(&node.mac); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_foreign_item_static<'ast, V>(v: &mut V, node: &'ast ForeignItemStatic) @@ -1934,7 +1941,7 @@ where tokens_helper(v, &node.static_token.span); if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_ident(&node.ident); tokens_helper(v, &node.colon_token.spans); v.visit_type(&*node.ty); @@ -1977,7 +1984,10 @@ where } } #[cfg(feature = "full")] -pub fn visit_generic_method_argument<'ast, V>(v: &mut V, node: &'ast GenericMethodArgument) +pub fn visit_generic_method_argument<'ast, V>( + v: &mut V, + node: &'ast GenericMethodArgument, +) where V: Visit<'ast> + ?Sized, { @@ -2014,7 +2024,7 @@ where { if let Some(it) = &node.lt_token { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.params) { let (it, p) = el.into_tuple(); v.visit_generic_param(it); @@ -2024,10 +2034,10 @@ where } if let Some(it) = &node.gt_token { tokens_helper(v, &it.spans); - }; + } if let Some(it) = &node.where_clause { v.visit_where_clause(it); - }; + } } pub fn visit_ident<'ast, V>(v: &mut V, node: &'ast Ident) where @@ -2070,7 +2080,7 @@ where v.visit_visibility(&node.vis); if let Some(it) = &node.defaultness { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.const_token.span); v.visit_ident(&node.ident); tokens_helper(v, &node.colon_token.spans); @@ -2090,7 +2100,7 @@ where v.visit_macro(&node.mac); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_impl_item_method<'ast, V>(v: &mut V, node: &'ast ImplItemMethod) @@ -2103,7 +2113,7 @@ where v.visit_visibility(&node.vis); if let Some(it) = &node.defaultness { tokens_helper(v, &it.span); - }; + } v.visit_signature(&node.sig); v.visit_block(&node.block); } @@ -2118,7 +2128,7 @@ where v.visit_visibility(&node.vis); if let Some(it) = &node.defaultness { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.type_token.span); v.visit_ident(&node.ident); v.visit_generics(&node.generics); @@ -2247,7 +2257,7 @@ where if let Some(it) = &node.rename { tokens_helper(v, &(it).0.span); v.visit_ident(&(it).1); - }; + } tokens_helper(v, &node.semi_token.spans); } #[cfg(feature = "full")] @@ -2286,19 +2296,19 @@ where } if let Some(it) = &node.defaultness { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.unsafety { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.impl_token.span); v.visit_generics(&node.generics); if let Some(it) = &node.trait_ { if let Some(it) = &(it).0 { tokens_helper(v, &it.spans); - }; + } v.visit_path(&(it).1); tokens_helper(v, &(it).2.span); - }; + } v.visit_type(&*node.self_ty); tokens_helper(v, &node.brace_token.span); for it in &node.items { @@ -2315,11 +2325,11 @@ where } if let Some(it) = &node.ident { v.visit_ident(it); - }; + } v.visit_macro(&node.mac); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_macro2<'ast, V>(v: &mut V, node: &'ast ItemMacro2) @@ -2350,10 +2360,10 @@ where for it in &(it).1 { v.visit_item(it); } - }; + } if let Some(it) = &node.semi { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_static<'ast, V>(v: &mut V, node: &'ast ItemStatic) @@ -2367,7 +2377,7 @@ where tokens_helper(v, &node.static_token.span); if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_ident(&node.ident); tokens_helper(v, &node.colon_token.spans); v.visit_type(&*node.ty); @@ -2390,7 +2400,7 @@ where v.visit_fields(&node.fields); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_trait<'ast, V>(v: &mut V, node: &'ast ItemTrait) @@ -2403,16 +2413,16 @@ where v.visit_visibility(&node.vis); if let Some(it) = &node.unsafety { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.auto_token { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.trait_token.span); v.visit_ident(&node.ident); v.visit_generics(&node.generics); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.supertraits) { let (it, p) = el.into_tuple(); v.visit_type_param_bound(it); @@ -2489,7 +2499,7 @@ where tokens_helper(v, &node.use_token.span); if let Some(it) = &node.leading_colon { tokens_helper(v, &it.spans); - }; + } v.visit_use_tree(&node.tree); tokens_helper(v, &node.semi_token.spans); } @@ -2519,7 +2529,7 @@ where v.visit_lifetime(&node.lifetime); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.bounds) { let (it, p) = el.into_tuple(); v.visit_lifetime(it); @@ -2569,33 +2579,27 @@ where pub fn visit_lit_byte<'ast, V>(v: &mut V, node: &'ast LitByte) where V: Visit<'ast> + ?Sized, -{ -} +{} pub fn visit_lit_byte_str<'ast, V>(v: &mut V, node: &'ast LitByteStr) where V: Visit<'ast> + ?Sized, -{ -} +{} pub fn visit_lit_char<'ast, V>(v: &mut V, node: &'ast LitChar) where V: Visit<'ast> + ?Sized, -{ -} +{} pub fn visit_lit_float<'ast, V>(v: &mut V, node: &'ast LitFloat) where V: Visit<'ast> + ?Sized, -{ -} +{} pub fn visit_lit_int<'ast, V>(v: &mut V, node: &'ast LitInt) where V: Visit<'ast> + ?Sized, -{ -} +{} pub fn visit_lit_str<'ast, V>(v: &mut V, node: &'ast LitStr) where V: Visit<'ast> + ?Sized, -{ -} +{} #[cfg(feature = "full")] pub fn visit_local<'ast, V>(v: &mut V, node: &'ast Local) where @@ -2609,7 +2613,7 @@ where if let Some(it) = &node.init { tokens_helper(v, &(it).0.spans); v.visit_expr(&*(it).1); - }; + } tokens_helper(v, &node.semi_token.spans); } #[cfg(any(feature = "derive", feature = "full"))] @@ -2728,7 +2732,8 @@ where pub fn visit_parenthesized_generic_arguments<'ast, V>( v: &mut V, node: &'ast ParenthesizedGenericArguments, -) where +) +where V: Visit<'ast> + ?Sized, { tokens_helper(v, &node.paren_token.span); @@ -2819,15 +2824,15 @@ where } if let Some(it) = &node.by_ref { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_ident(&node.ident); if let Some(it) = &node.subpat { tokens_helper(v, &(it).0.spans); v.visit_pat(&*(it).1); - }; + } } #[cfg(feature = "full")] pub fn visit_pat_lit<'ast, V>(v: &mut V, node: &'ast PatLit) @@ -2859,7 +2864,7 @@ where } if let Some(it) = &node.leading_vert { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.cases) { let (it, p) = el.into_tuple(); v.visit_pat(it); @@ -2878,7 +2883,7 @@ where } if let Some(it) = &node.qself { v.visit_qself(it); - }; + } v.visit_path(&node.path); } #[cfg(feature = "full")] @@ -2904,7 +2909,7 @@ where tokens_helper(v, &node.and_token.spans); if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_pat(&*node.pat); } #[cfg(feature = "full")] @@ -2953,7 +2958,7 @@ where } if let Some(it) = &node.dot2_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_pat_tuple<'ast, V>(v: &mut V, node: &'ast PatTuple) @@ -3012,7 +3017,7 @@ where { if let Some(it) = &node.leading_colon { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.segments) { let (it, p) = el.into_tuple(); v.visit_path_segment(it); @@ -3075,7 +3080,7 @@ where { if let Some(it) = &node.lifetimes { v.visit_bound_lifetimes(it); - }; + } v.visit_type(&node.bounded_ty); tokens_helper(v, &node.colon_token.spans); for el in Punctuated::pairs(&node.bounds) { @@ -3096,7 +3101,7 @@ where skip!(node.position); if let Some(it) = &node.as_token { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.gt_token.spans); } #[cfg(feature = "full")] @@ -3125,11 +3130,11 @@ where tokens_helper(v, &(it).0.spans); if let Some(it) = &(it).1 { v.visit_lifetime(it); - }; - }; + } + } if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.self_token.span); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3152,16 +3157,16 @@ where { if let Some(it) = &node.constness { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.asyncness { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.unsafety { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.abi { v.visit_abi(it); - }; + } tokens_helper(v, &node.fn_token.span); v.visit_ident(&node.ident); v.visit_generics(&node.generics); @@ -3175,14 +3180,13 @@ where } if let Some(it) = &node.variadic { v.visit_variadic(it); - }; + } v.visit_return_type(&node.output); } pub fn visit_span<'ast, V>(v: &mut V, node: &Span) where V: Visit<'ast> + ?Sized, -{ -} +{} #[cfg(feature = "full")] pub fn visit_stmt<'ast, V>(v: &mut V, node: &'ast Stmt) where @@ -3211,11 +3215,11 @@ where { if let Some(it) = &node.paren_token { tokens_helper(v, &it.span); - }; + } v.visit_trait_bound_modifier(&node.modifier); if let Some(it) = &node.lifetimes { v.visit_bound_lifetimes(it); - }; + } v.visit_path(&node.path); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3269,7 +3273,7 @@ where if let Some(it) = &node.default { tokens_helper(v, &(it).0.spans); v.visit_expr(&(it).1); - }; + } tokens_helper(v, &node.semi_token.spans); } #[cfg(feature = "full")] @@ -3283,7 +3287,7 @@ where v.visit_macro(&node.mac); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_trait_item_method<'ast, V>(v: &mut V, node: &'ast TraitItemMethod) @@ -3296,10 +3300,10 @@ where v.visit_signature(&node.sig); if let Some(it) = &node.default { v.visit_block(it); - }; + } if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_trait_item_type<'ast, V>(v: &mut V, node: &'ast TraitItemType) @@ -3314,7 +3318,7 @@ where v.visit_generics(&node.generics); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound(it); @@ -3325,7 +3329,7 @@ where if let Some(it) = &node.default { tokens_helper(v, &(it).0.spans); v.visit_type(&(it).1); - }; + } tokens_helper(v, &node.semi_token.spans); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3399,13 +3403,13 @@ where { if let Some(it) = &node.lifetimes { v.visit_bound_lifetimes(it); - }; + } if let Some(it) = &node.unsafety { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.abi { v.visit_abi(it); - }; + } tokens_helper(v, &node.fn_token.span); tokens_helper(v, &node.paren_token.span); for el in Punctuated::pairs(&node.inputs) { @@ -3417,7 +3421,7 @@ where } if let Some(it) = &node.variadic { v.visit_variadic(it); - }; + } v.visit_return_type(&node.output); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3474,7 +3478,7 @@ where v.visit_ident(&node.ident); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound(it); @@ -3484,10 +3488,10 @@ where } if let Some(it) = &node.eq_token { tokens_helper(v, &it.spans); - }; + } if let Some(it) = &node.default { v.visit_type(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_type_param_bound<'ast, V>(v: &mut V, node: &'ast TypeParamBound) @@ -3518,7 +3522,7 @@ where { if let Some(it) = &node.qself { v.visit_qself(it); - }; + } v.visit_path(&node.path); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3529,10 +3533,10 @@ where tokens_helper(v, &node.star_token.spans); if let Some(it) = &node.const_token { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3543,10 +3547,10 @@ where tokens_helper(v, &node.and_token.spans); if let Some(it) = &node.lifetime { v.visit_lifetime(it); - }; + } if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3564,7 +3568,7 @@ where { if let Some(it) = &node.dyn_token { tokens_helper(v, &it.span); - }; + } for el in Punctuated::pairs(&node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound(it); @@ -3696,7 +3700,7 @@ where if let Some(it) = &node.discriminant { tokens_helper(v, &(it).0.spans); v.visit_expr(&(it).1); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_vis_crate<'ast, V>(v: &mut V, node: &'ast VisCrate) @@ -3721,7 +3725,7 @@ where tokens_helper(v, &node.paren_token.span); if let Some(it) = &node.in_token { tokens_helper(v, &it.span); - }; + } v.visit_path(&*node.path); } #[cfg(any(feature = "derive", feature = "full"))] diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs index 1de0c95e..51e10b60 100644 --- a/src/gen/visit_mut.rs +++ b/src/gen/visit_mut.rs @@ -17,7 +17,7 @@ macro_rules! full { #[cfg(all(feature = "derive", not(feature = "full")))] macro_rules! full { ($e:expr) => { - unreachable!() + unreachable ! () }; } macro_rules! skip { @@ -498,7 +498,10 @@ pub trait VisitMut { visit_nested_meta_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_parenthesized_generic_arguments_mut(&mut self, i: &mut ParenthesizedGenericArguments) { + fn visit_parenthesized_generic_arguments_mut( + &mut self, + i: &mut ParenthesizedGenericArguments, + ) { visit_parenthesized_generic_arguments_mut(self, i); } #[cfg(feature = "full")] @@ -781,18 +784,19 @@ where tokens_helper(v, &mut node.extern_token.span); if let Some(it) = &mut node.name { v.visit_lit_str_mut(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_angle_bracketed_generic_arguments_mut<V>( v: &mut V, node: &mut AngleBracketedGenericArguments, -) where +) +where V: VisitMut + ?Sized, { if let Some(it) = &mut node.colon2_token { tokens_helper(v, &mut it.spans); - }; + } tokens_helper(v, &mut node.lt_token.spans); for el in Punctuated::pairs_mut(&mut node.args) { let (it, p) = el.into_tuple(); @@ -815,12 +819,12 @@ where if let Some(it) = &mut node.guard { tokens_helper(v, &mut (it).0.span); v.visit_expr_mut(&mut *(it).1); - }; + } tokens_helper(v, &mut node.fat_arrow_token.spans); v.visit_expr_mut(&mut *node.body); if let Some(it) = &mut node.comma { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_attr_style_mut<V>(v: &mut V, node: &mut AttrStyle) @@ -856,7 +860,7 @@ where if let Some(it) = &mut node.name { v.visit_ident_mut(&mut (it).0); tokens_helper(v, &mut (it).1.spans); - }; + } v.visit_type_mut(&mut node.ty); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1000,10 +1004,10 @@ where v.visit_type_mut(&mut node.ty); if let Some(it) = &mut node.eq_token { tokens_helper(v, &mut it.spans); - }; + } if let Some(it) = &mut node.default { v.visit_expr_mut(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_constraint_mut<V>(v: &mut V, node: &mut Constraint) @@ -1061,7 +1065,7 @@ where v.visit_fields_mut(&mut node.fields); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "derive")] pub fn visit_data_union_mut<V>(v: &mut V, node: &mut DataUnion) @@ -1265,7 +1269,7 @@ where tokens_helper(v, &mut node.async_token.span); if let Some(it) = &mut node.capture { tokens_helper(v, &mut it.span); - }; + } v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] @@ -1302,7 +1306,7 @@ where } if let Some(it) = &mut node.label { v.visit_label_mut(it); - }; + } v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] @@ -1327,10 +1331,10 @@ where tokens_helper(v, &mut node.break_token.span); if let Some(it) = &mut node.label { v.visit_lifetime_mut(it); - }; + } if let Some(it) = &mut node.expr { v.visit_expr_mut(&mut **it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_call_mut<V>(v: &mut V, node: &mut ExprCall) @@ -1370,15 +1374,15 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - if let Some(it) = &mut node.asyncness { - tokens_helper(v, &mut it.span); - }; if let Some(it) = &mut node.movability { tokens_helper(v, &mut it.span); - }; + } + if let Some(it) = &mut node.asyncness { + tokens_helper(v, &mut it.span); + } if let Some(it) = &mut node.capture { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.or1_token.spans); for el in Punctuated::pairs_mut(&mut node.inputs) { let (it, p) = el.into_tuple(); @@ -1402,7 +1406,7 @@ where tokens_helper(v, &mut node.continue_token.span); if let Some(it) = &mut node.label { v.visit_lifetime_mut(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_field_mut<V>(v: &mut V, node: &mut ExprField) @@ -1426,7 +1430,7 @@ where } if let Some(it) = &mut node.label { v.visit_label_mut(it); - }; + } tokens_helper(v, &mut node.for_token.span); v.visit_pat_mut(&mut node.pat); tokens_helper(v, &mut node.in_token.span); @@ -1458,7 +1462,7 @@ where if let Some(it) = &mut node.else_branch { tokens_helper(v, &mut (it).0.span); v.visit_expr_mut(&mut *(it).1); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_index_mut<V>(v: &mut V, node: &mut ExprIndex) @@ -1505,7 +1509,7 @@ where } if let Some(it) = &mut node.label { v.visit_label_mut(it); - }; + } tokens_helper(v, &mut node.loop_token.span); v.visit_block_mut(&mut node.body); } @@ -1547,7 +1551,7 @@ where v.visit_ident_mut(&mut node.method); if let Some(it) = &mut node.turbofish { v.visit_method_turbofish_mut(it); - }; + } tokens_helper(v, &mut node.paren_token.span); for el in Punctuated::pairs_mut(&mut node.args) { let (it, p) = el.into_tuple(); @@ -1578,7 +1582,7 @@ where } if let Some(it) = &mut node.qself { v.visit_qself_mut(it); - }; + } v.visit_path_mut(&mut node.path); } #[cfg(feature = "full")] @@ -1591,11 +1595,11 @@ where } if let Some(it) = &mut node.from { v.visit_expr_mut(&mut **it); - }; + } v.visit_range_limits_mut(&mut node.limits); if let Some(it) = &mut node.to { v.visit_expr_mut(&mut **it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_reference_mut<V>(v: &mut V, node: &mut ExprReference) @@ -1608,7 +1612,7 @@ where tokens_helper(v, &mut node.and_token.spans); if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_expr_mut(&mut *node.expr); } #[cfg(feature = "full")] @@ -1635,7 +1639,7 @@ where tokens_helper(v, &mut node.return_token.span); if let Some(it) = &mut node.expr { v.visit_expr_mut(&mut **it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_struct_mut<V>(v: &mut V, node: &mut ExprStruct) @@ -1656,10 +1660,10 @@ where } if let Some(it) = &mut node.dot2_token { tokens_helper(v, &mut it.spans); - }; + } if let Some(it) = &mut node.rest { v.visit_expr_mut(&mut **it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_try_mut<V>(v: &mut V, node: &mut ExprTry) @@ -1744,7 +1748,7 @@ where } if let Some(it) = &mut node.label { v.visit_label_mut(it); - }; + } tokens_helper(v, &mut node.while_token.span); v.visit_expr_mut(&mut *node.cond); v.visit_block_mut(&mut node.body); @@ -1760,7 +1764,7 @@ where tokens_helper(v, &mut node.yield_token.span); if let Some(it) = &mut node.expr { v.visit_expr_mut(&mut **it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_field_mut<V>(v: &mut V, node: &mut Field) @@ -1773,10 +1777,10 @@ where v.visit_visibility_mut(&mut node.vis); if let Some(it) = &mut node.ident { v.visit_ident_mut(it); - }; + } if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } v.visit_type_mut(&mut node.ty); } #[cfg(feature = "full")] @@ -1790,7 +1794,7 @@ where v.visit_member_mut(&mut node.member); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } v.visit_pat_mut(&mut *node.pat); } #[cfg(feature = "full")] @@ -1804,7 +1808,7 @@ where v.visit_member_mut(&mut node.member); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } v.visit_expr_mut(&mut node.expr); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1924,7 +1928,7 @@ where v.visit_macro_mut(&mut node.mac); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_foreign_item_static_mut<V>(v: &mut V, node: &mut ForeignItemStatic) @@ -1938,7 +1942,7 @@ where tokens_helper(v, &mut node.static_token.span); if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_ident_mut(&mut node.ident); tokens_helper(v, &mut node.colon_token.spans); v.visit_type_mut(&mut *node.ty); @@ -2018,7 +2022,7 @@ where { if let Some(it) = &mut node.lt_token { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.params) { let (it, p) = el.into_tuple(); v.visit_generic_param_mut(it); @@ -2028,10 +2032,10 @@ where } if let Some(it) = &mut node.gt_token { tokens_helper(v, &mut it.spans); - }; + } if let Some(it) = &mut node.where_clause { v.visit_where_clause_mut(it); - }; + } } pub fn visit_ident_mut<V>(v: &mut V, node: &mut Ident) where @@ -2076,7 +2080,7 @@ where v.visit_visibility_mut(&mut node.vis); if let Some(it) = &mut node.defaultness { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.const_token.span); v.visit_ident_mut(&mut node.ident); tokens_helper(v, &mut node.colon_token.spans); @@ -2096,7 +2100,7 @@ where v.visit_macro_mut(&mut node.mac); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_impl_item_method_mut<V>(v: &mut V, node: &mut ImplItemMethod) @@ -2109,7 +2113,7 @@ where v.visit_visibility_mut(&mut node.vis); if let Some(it) = &mut node.defaultness { tokens_helper(v, &mut it.span); - }; + } v.visit_signature_mut(&mut node.sig); v.visit_block_mut(&mut node.block); } @@ -2124,7 +2128,7 @@ where v.visit_visibility_mut(&mut node.vis); if let Some(it) = &mut node.defaultness { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.type_token.span); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); @@ -2253,7 +2257,7 @@ where if let Some(it) = &mut node.rename { tokens_helper(v, &mut (it).0.span); v.visit_ident_mut(&mut (it).1); - }; + } tokens_helper(v, &mut node.semi_token.spans); } #[cfg(feature = "full")] @@ -2292,19 +2296,19 @@ where } if let Some(it) = &mut node.defaultness { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.unsafety { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.impl_token.span); v.visit_generics_mut(&mut node.generics); if let Some(it) = &mut node.trait_ { if let Some(it) = &mut (it).0 { tokens_helper(v, &mut it.spans); - }; + } v.visit_path_mut(&mut (it).1); tokens_helper(v, &mut (it).2.span); - }; + } v.visit_type_mut(&mut *node.self_ty); tokens_helper(v, &mut node.brace_token.span); for it in &mut node.items { @@ -2321,11 +2325,11 @@ where } if let Some(it) = &mut node.ident { v.visit_ident_mut(it); - }; + } v.visit_macro_mut(&mut node.mac); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_macro2_mut<V>(v: &mut V, node: &mut ItemMacro2) @@ -2356,10 +2360,10 @@ where for it in &mut (it).1 { v.visit_item_mut(it); } - }; + } if let Some(it) = &mut node.semi { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_static_mut<V>(v: &mut V, node: &mut ItemStatic) @@ -2373,7 +2377,7 @@ where tokens_helper(v, &mut node.static_token.span); if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_ident_mut(&mut node.ident); tokens_helper(v, &mut node.colon_token.spans); v.visit_type_mut(&mut *node.ty); @@ -2396,7 +2400,7 @@ where v.visit_fields_mut(&mut node.fields); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_trait_mut<V>(v: &mut V, node: &mut ItemTrait) @@ -2409,16 +2413,16 @@ where v.visit_visibility_mut(&mut node.vis); if let Some(it) = &mut node.unsafety { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.auto_token { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.trait_token.span); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.supertraits) { let (it, p) = el.into_tuple(); v.visit_type_param_bound_mut(it); @@ -2495,7 +2499,7 @@ where tokens_helper(v, &mut node.use_token.span); if let Some(it) = &mut node.leading_colon { tokens_helper(v, &mut it.spans); - }; + } v.visit_use_tree_mut(&mut node.tree); tokens_helper(v, &mut node.semi_token.spans); } @@ -2525,7 +2529,7 @@ where v.visit_lifetime_mut(&mut node.lifetime); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.bounds) { let (it, p) = el.into_tuple(); v.visit_lifetime_mut(it); @@ -2575,33 +2579,27 @@ where pub fn visit_lit_byte_mut<V>(v: &mut V, node: &mut LitByte) where V: VisitMut + ?Sized, -{ -} +{} pub fn visit_lit_byte_str_mut<V>(v: &mut V, node: &mut LitByteStr) where V: VisitMut + ?Sized, -{ -} +{} pub fn visit_lit_char_mut<V>(v: &mut V, node: &mut LitChar) where V: VisitMut + ?Sized, -{ -} +{} pub fn visit_lit_float_mut<V>(v: &mut V, node: &mut LitFloat) where V: VisitMut + ?Sized, -{ -} +{} pub fn visit_lit_int_mut<V>(v: &mut V, node: &mut LitInt) where V: VisitMut + ?Sized, -{ -} +{} pub fn visit_lit_str_mut<V>(v: &mut V, node: &mut LitStr) where V: VisitMut + ?Sized, -{ -} +{} #[cfg(feature = "full")] pub fn visit_local_mut<V>(v: &mut V, node: &mut Local) where @@ -2615,7 +2613,7 @@ where if let Some(it) = &mut node.init { tokens_helper(v, &mut (it).0.spans); v.visit_expr_mut(&mut *(it).1); - }; + } tokens_helper(v, &mut node.semi_token.spans); } #[cfg(any(feature = "derive", feature = "full"))] @@ -2734,7 +2732,8 @@ where pub fn visit_parenthesized_generic_arguments_mut<V>( v: &mut V, node: &mut ParenthesizedGenericArguments, -) where +) +where V: VisitMut + ?Sized, { tokens_helper(v, &mut node.paren_token.span); @@ -2825,15 +2824,15 @@ where } if let Some(it) = &mut node.by_ref { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_ident_mut(&mut node.ident); if let Some(it) = &mut node.subpat { tokens_helper(v, &mut (it).0.spans); v.visit_pat_mut(&mut *(it).1); - }; + } } #[cfg(feature = "full")] pub fn visit_pat_lit_mut<V>(v: &mut V, node: &mut PatLit) @@ -2865,7 +2864,7 @@ where } if let Some(it) = &mut node.leading_vert { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.cases) { let (it, p) = el.into_tuple(); v.visit_pat_mut(it); @@ -2884,7 +2883,7 @@ where } if let Some(it) = &mut node.qself { v.visit_qself_mut(it); - }; + } v.visit_path_mut(&mut node.path); } #[cfg(feature = "full")] @@ -2910,7 +2909,7 @@ where tokens_helper(v, &mut node.and_token.spans); if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_pat_mut(&mut *node.pat); } #[cfg(feature = "full")] @@ -2959,7 +2958,7 @@ where } if let Some(it) = &mut node.dot2_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_pat_tuple_mut<V>(v: &mut V, node: &mut PatTuple) @@ -3018,7 +3017,7 @@ where { if let Some(it) = &mut node.leading_colon { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.segments) { let (it, p) = el.into_tuple(); v.visit_path_segment_mut(it); @@ -3081,7 +3080,7 @@ where { if let Some(it) = &mut node.lifetimes { v.visit_bound_lifetimes_mut(it); - }; + } v.visit_type_mut(&mut node.bounded_ty); tokens_helper(v, &mut node.colon_token.spans); for el in Punctuated::pairs_mut(&mut node.bounds) { @@ -3102,7 +3101,7 @@ where skip!(node.position); if let Some(it) = &mut node.as_token { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.gt_token.spans); } #[cfg(feature = "full")] @@ -3131,11 +3130,11 @@ where tokens_helper(v, &mut (it).0.spans); if let Some(it) = &mut (it).1 { v.visit_lifetime_mut(it); - }; - }; + } + } if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.self_token.span); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3158,16 +3157,16 @@ where { if let Some(it) = &mut node.constness { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.asyncness { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.unsafety { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.abi { v.visit_abi_mut(it); - }; + } tokens_helper(v, &mut node.fn_token.span); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); @@ -3181,14 +3180,13 @@ where } if let Some(it) = &mut node.variadic { v.visit_variadic_mut(it); - }; + } v.visit_return_type_mut(&mut node.output); } pub fn visit_span_mut<V>(v: &mut V, node: &mut Span) where V: VisitMut + ?Sized, -{ -} +{} #[cfg(feature = "full")] pub fn visit_stmt_mut<V>(v: &mut V, node: &mut Stmt) where @@ -3217,11 +3215,11 @@ where { if let Some(it) = &mut node.paren_token { tokens_helper(v, &mut it.span); - }; + } v.visit_trait_bound_modifier_mut(&mut node.modifier); if let Some(it) = &mut node.lifetimes { v.visit_bound_lifetimes_mut(it); - }; + } v.visit_path_mut(&mut node.path); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3275,7 +3273,7 @@ where if let Some(it) = &mut node.default { tokens_helper(v, &mut (it).0.spans); v.visit_expr_mut(&mut (it).1); - }; + } tokens_helper(v, &mut node.semi_token.spans); } #[cfg(feature = "full")] @@ -3289,7 +3287,7 @@ where v.visit_macro_mut(&mut node.mac); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_trait_item_method_mut<V>(v: &mut V, node: &mut TraitItemMethod) @@ -3302,10 +3300,10 @@ where v.visit_signature_mut(&mut node.sig); if let Some(it) = &mut node.default { v.visit_block_mut(it); - }; + } if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_trait_item_type_mut<V>(v: &mut V, node: &mut TraitItemType) @@ -3320,7 +3318,7 @@ where v.visit_generics_mut(&mut node.generics); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound_mut(it); @@ -3331,7 +3329,7 @@ where if let Some(it) = &mut node.default { tokens_helper(v, &mut (it).0.spans); v.visit_type_mut(&mut (it).1); - }; + } tokens_helper(v, &mut node.semi_token.spans); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3405,13 +3403,13 @@ where { if let Some(it) = &mut node.lifetimes { v.visit_bound_lifetimes_mut(it); - }; + } if let Some(it) = &mut node.unsafety { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.abi { v.visit_abi_mut(it); - }; + } tokens_helper(v, &mut node.fn_token.span); tokens_helper(v, &mut node.paren_token.span); for el in Punctuated::pairs_mut(&mut node.inputs) { @@ -3423,7 +3421,7 @@ where } if let Some(it) = &mut node.variadic { v.visit_variadic_mut(it); - }; + } v.visit_return_type_mut(&mut node.output); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3480,7 +3478,7 @@ where v.visit_ident_mut(&mut node.ident); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound_mut(it); @@ -3490,10 +3488,10 @@ where } if let Some(it) = &mut node.eq_token { tokens_helper(v, &mut it.spans); - }; + } if let Some(it) = &mut node.default { v.visit_type_mut(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_type_param_bound_mut<V>(v: &mut V, node: &mut TypeParamBound) @@ -3524,7 +3522,7 @@ where { if let Some(it) = &mut node.qself { v.visit_qself_mut(it); - }; + } v.visit_path_mut(&mut node.path); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3535,10 +3533,10 @@ where tokens_helper(v, &mut node.star_token.spans); if let Some(it) = &mut node.const_token { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3549,10 +3547,10 @@ where tokens_helper(v, &mut node.and_token.spans); if let Some(it) = &mut node.lifetime { v.visit_lifetime_mut(it); - }; + } if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3570,7 +3568,7 @@ where { if let Some(it) = &mut node.dyn_token { tokens_helper(v, &mut it.span); - }; + } for el in Punctuated::pairs_mut(&mut node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound_mut(it); @@ -3702,7 +3700,7 @@ where if let Some(it) = &mut node.discriminant { tokens_helper(v, &mut (it).0.spans); v.visit_expr_mut(&mut (it).1); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_vis_crate_mut<V>(v: &mut V, node: &mut VisCrate) @@ -3727,7 +3725,7 @@ where tokens_helper(v, &mut node.paren_token.span); if let Some(it) = &mut node.in_token { tokens_helper(v, &mut it.span); - }; + } v.visit_path_mut(&mut *node.path); } #[cfg(any(feature = "derive", feature = "full"))] diff --git a/src/generics.rs b/src/generics.rs index 9df6b405..9c2802f8 100644 --- a/src/generics.rs +++ b/src/generics.rs @@ -831,15 +831,43 @@ pub mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for TraitBound { fn parse(input: ParseStream) -> Result<Self> { + #[cfg(feature = "full")] + let tilde_const = if input.peek(Token![~]) && input.peek2(Token![const]) { + let tilde_token = input.parse::<Token![~]>()?; + let const_token = input.parse::<Token![const]>()?; + Some((tilde_token, const_token)) + } else { + None + }; + let modifier: TraitBoundModifier = input.parse()?; let lifetimes: Option<BoundLifetimes> = input.parse()?; let mut path: Path = input.parse()?; - if path.segments.last().unwrap().arguments.is_empty() && input.peek(token::Paren) { - let parenthesized = PathArguments::Parenthesized(input.parse()?); + if path.segments.last().unwrap().arguments.is_empty() + && (input.peek(token::Paren) || input.peek(Token![::]) && input.peek3(token::Paren)) + { + input.parse::<Option<Token![::]>>()?; + let args: ParenthesizedGenericArguments = input.parse()?; + let parenthesized = PathArguments::Parenthesized(args); path.segments.last_mut().unwrap().arguments = parenthesized; } + #[cfg(feature = "full")] + { + if let Some((tilde_token, const_token)) = tilde_const { + path.segments.insert( + 0, + PathSegment { + ident: Ident::new("const", const_token.span), + arguments: PathArguments::None, + }, + ); + let (_const, punct) = path.segments.pairs_mut().next().unwrap().into_tuple(); + *punct.unwrap() = Token![::](tilde_token.span); + } + } + Ok(TraitBound { paren_token: None, modifier, @@ -994,6 +1022,8 @@ mod printing { use super::*; use crate::attr::FilterAttrs; use crate::print::TokensOrDefault; + #[cfg(feature = "full")] + use crate::punctuated::Pair; use proc_macro2::TokenStream; #[cfg(feature = "full")] use proc_macro2::TokenTree; @@ -1214,9 +1244,26 @@ mod printing { impl ToTokens for TraitBound { fn to_tokens(&self, tokens: &mut TokenStream) { let to_tokens = |tokens: &mut TokenStream| { + #[cfg(feature = "full")] + let skip = match self.path.segments.pairs().next() { + Some(Pair::Punctuated(t, p)) if t.ident == "const" => { + Token![~](p.spans[0]).to_tokens(tokens); + t.to_tokens(tokens); + 1 + } + _ => 0, + }; self.modifier.to_tokens(tokens); self.lifetimes.to_tokens(tokens); - self.path.to_tokens(tokens); + #[cfg(feature = "full")] + { + self.path.leading_colon.to_tokens(tokens); + tokens.append_all(self.path.segments.pairs().skip(skip)); + } + #[cfg(not(feature = "full"))] + { + self.path.to_tokens(tokens); + } }; match &self.paren_token { Some(paren) => paren.surround(tokens, to_tokens), diff --git a/src/item.rs b/src/item.rs index 0fd1226a..917d4f1f 100644 --- a/src/item.rs +++ b/src/item.rs @@ -985,7 +985,6 @@ pub mod parsing { use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenTree}; use std::iter::{self, FromIterator}; - crate::custom_keyword!(existential); crate::custom_keyword!(macro_rules); #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] @@ -1123,8 +1122,6 @@ pub mod parsing { input.parse().map(Item::Mod) } else if lookahead.peek(Token![type]) { parse_item_type(begin, input) - } else if lookahead.peek(existential) { - input.call(item_existential).map(Item::Verbatim) } else if lookahead.peek(Token![struct]) { input.parse().map(Item::Struct) } else if lookahead.peek(Token![enum]) { @@ -1959,53 +1956,6 @@ pub mod parsing { } } - #[cfg(not(feature = "printing"))] - fn item_existential(input: ParseStream) -> Result<TokenStream> { - Err(input.error("existential type is not supported")) - } - - #[cfg(feature = "printing")] - fn item_existential(input: ParseStream) -> Result<TokenStream> { - use crate::attr::FilterAttrs; - use quote::{ToTokens, TokenStreamExt}; - - let attrs = input.call(Attribute::parse_outer)?; - let vis: Visibility = input.parse()?; - let existential_token: existential = input.parse()?; - let type_token: Token![type] = input.parse()?; - let ident: Ident = input.parse()?; - - let mut generics: Generics = input.parse()?; - generics.where_clause = input.parse()?; - - let colon_token: Token![:] = input.parse()?; - - let mut bounds = Punctuated::new(); - while !input.peek(Token![;]) { - if !bounds.is_empty() { - bounds.push_punct(input.parse::<Token![+]>()?); - } - bounds.push_value(input.parse::<TypeParamBound>()?); - } - - let semi_token: Token![;] = input.parse()?; - - let mut tokens = TokenStream::new(); - tokens.append_all(attrs.outer()); - vis.to_tokens(&mut tokens); - existential_token.to_tokens(&mut tokens); - type_token.to_tokens(&mut tokens); - ident.to_tokens(&mut tokens); - generics.to_tokens(&mut tokens); - generics.where_clause.to_tokens(&mut tokens); - if !bounds.is_empty() { - colon_token.to_tokens(&mut tokens); - bounds.to_tokens(&mut tokens); - } - semi_token.to_tokens(&mut tokens); - Ok(tokens) - } - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ItemStruct { fn parse(input: ParseStream) -> Result<Self> { @@ -2505,7 +2455,7 @@ pub mod parsing { while let Type::Group(ty) = first_ty_ref { first_ty_ref = &ty.elem; } - if let Type::Path(_) = first_ty_ref { + if let Type::Path(TypePath { qself: None, .. }) = first_ty_ref { while let Type::Group(ty) = first_ty { first_ty = *ty.elem; } @@ -2609,8 +2559,6 @@ pub mod parsing { } } else if lookahead.peek(Token![type]) { parse_impl_item_type(begin, input) - } else if vis.is_inherited() && defaultness.is_none() && lookahead.peek(existential) { - input.call(item_existential).map(ImplItem::Verbatim) } else if vis.is_inherited() && defaultness.is_none() && (lookahead.peek(Ident) @@ -250,22 +250,26 @@ //! dynamic library libproc_macro from rustc toolchain. // Syn types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/syn/1.0.76")] +#![doc(html_root_url = "https://docs.rs/syn/1.0.86")] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![allow(non_camel_case_types)] // Ignored clippy lints. #![allow( + clippy::cast_lossless, clippy::collapsible_match, // https://github.com/rust-lang/rust-clippy/issues/7575 clippy::doc_markdown, clippy::eval_order_dependence, clippy::inherent_to_string, clippy::large_enum_variant, + clippy::let_underscore_drop, + clippy::manual_assert, clippy::manual_map, // https://github.com/rust-lang/rust-clippy/issues/6795 clippy::match_on_vec_items, clippy::missing_panics_doc, clippy::needless_doctest_main, clippy::needless_pass_by_value, clippy::never_loop, + clippy::return_self_not_must_use, clippy::too_many_arguments, clippy::trivially_copy_pass_by_ref, clippy::unnecessary_unwrap, @@ -281,6 +285,8 @@ clippy::empty_enum, clippy::expl_impl_clone_on_copy, clippy::if_not_else, + // clippy bug: https://github.com/rust-lang/rust-clippy/issues/8285 + clippy::iter_not_returning_iterator, clippy::match_same_arms, // clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984 clippy::match_wildcard_for_single_variants, @@ -823,6 +829,7 @@ mod verbatim; #[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))] mod print; +#[cfg(any(feature = "full", feature = "derive"))] use crate::__private::private; //////////////////////////////////////////////////////////////////////////////// @@ -3,12 +3,9 @@ use crate::lookahead; #[cfg(feature = "parsing")] use crate::parse::{Parse, Parser}; use crate::{Error, Result}; -#[cfg(feature = "printing")] -use proc_macro2::Ident; +use proc_macro2::{Ident, Literal, Span}; #[cfg(feature = "parsing")] -use proc_macro2::TokenStream; -use proc_macro2::TokenTree; -use proc_macro2::{Literal, Span}; +use proc_macro2::{TokenStream, TokenTree}; use std::fmt::{self, Display}; #[cfg(feature = "extra-traits")] use std::hash::{Hash, Hasher}; @@ -244,6 +241,10 @@ impl LitStr { pub fn suffix(&self) -> &str { &self.repr.suffix } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl LitByteStr { @@ -275,6 +276,10 @@ impl LitByteStr { pub fn suffix(&self) -> &str { &self.repr.suffix } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl LitByte { @@ -306,6 +311,10 @@ impl LitByte { pub fn suffix(&self) -> &str { &self.repr.suffix } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl LitChar { @@ -337,6 +346,10 @@ impl LitChar { pub fn suffix(&self) -> &str { &self.repr.suffix } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl LitInt { @@ -408,6 +421,10 @@ impl LitInt { pub fn set_span(&mut self, span: Span) { self.repr.token.set_span(span); } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl From<Literal> for LitInt { @@ -480,6 +497,10 @@ impl LitFloat { pub fn set_span(&mut self, span: Span) { self.repr.token.set_span(span); } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl From<Literal> for LitFloat { @@ -521,6 +542,11 @@ impl LitBool { pub fn set_span(&mut self, span: Span) { self.span = span; } + + pub fn token(&self) -> Ident { + let s = if self.value { "true" } else { "false" }; + Ident::new(s, self.span) + } } #[cfg(feature = "extra-traits")] @@ -916,8 +942,7 @@ mod printing { #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for LitBool { fn to_tokens(&self, tokens: &mut TokenStream) { - let s = if self.value { "true" } else { "false" }; - tokens.append(Ident::new(s, self.span)); + tokens.append(self.token()); } } } @@ -925,7 +950,6 @@ mod printing { mod value { use super::*; use crate::bigint::BigInt; - use proc_macro2::TokenStream; use std::char; use std::ops::{Index, RangeFrom}; @@ -1540,35 +1564,37 @@ mod value { } } + #[allow(clippy::unnecessary_wraps)] pub fn to_literal(repr: &str, digits: &str, suffix: &str) -> Option<Literal> { - if repr.starts_with('-') { - let f64_parse_finite = || digits.parse().ok().filter(|x: &f64| x.is_finite()); - let f32_parse_finite = || digits.parse().ok().filter(|x: &f32| x.is_finite()); - if suffix == "f64" { - f64_parse_finite().map(Literal::f64_suffixed) - } else if suffix == "f32" { - f32_parse_finite().map(Literal::f32_suffixed) - } else if suffix == "i64" { - digits.parse().ok().map(Literal::i64_suffixed) - } else if suffix == "i32" { - digits.parse().ok().map(Literal::i32_suffixed) - } else if suffix == "i16" { - digits.parse().ok().map(Literal::i16_suffixed) - } else if suffix == "i8" { - digits.parse().ok().map(Literal::i8_suffixed) - } else if !suffix.is_empty() { - None - } else if digits.contains('.') { - f64_parse_finite().map(Literal::f64_unsuffixed) - } else { - digits.parse().ok().map(Literal::i64_unsuffixed) - } - } else { - let stream = repr.parse::<TokenStream>().unwrap(); - match stream.into_iter().next().unwrap() { - TokenTree::Literal(l) => Some(l), - _ => unreachable!(), + #[cfg(syn_no_negative_literal_parse)] + { + // Rustc older than https://github.com/rust-lang/rust/pull/87262. + if repr.starts_with('-') { + let f64_parse_finite = || digits.parse().ok().filter(|x: &f64| x.is_finite()); + let f32_parse_finite = || digits.parse().ok().filter(|x: &f32| x.is_finite()); + return if suffix == "f64" { + f64_parse_finite().map(Literal::f64_suffixed) + } else if suffix == "f32" { + f32_parse_finite().map(Literal::f32_suffixed) + } else if suffix == "i64" { + digits.parse().ok().map(Literal::i64_suffixed) + } else if suffix == "i32" { + digits.parse().ok().map(Literal::i32_suffixed) + } else if suffix == "i16" { + digits.parse().ok().map(Literal::i16_suffixed) + } else if suffix == "i8" { + digits.parse().ok().map(Literal::i8_suffixed) + } else if !suffix.is_empty() { + None + } else if digits.contains('.') { + f64_parse_finite().map(Literal::f64_unsuffixed) + } else { + digits.parse().ok().map(Literal::i64_unsuffixed) + }; } } + let _ = digits; + let _ = suffix; + Some(repr.parse::<Literal>().unwrap()) } } diff --git a/src/parse_quote.rs b/src/parse_quote.rs index ec551ef9..8deae4e5 100644 --- a/src/parse_quote.rs +++ b/src/parse_quote.rs @@ -58,7 +58,6 @@ /// `P` with optional trailing punctuation /// - [`Vec<Stmt>`] — parses the same as `Block::parse_within` /// -/// [`Punctuated<T, P>`]: crate::punctuated::Punctuated /// [`Vec<Stmt>`]: Block::parse_within /// /// # Panics @@ -66,18 +65,43 @@ /// Panics if the tokens fail to parse as the expected syntax tree type. The /// caller is responsible for ensuring that the input tokens are syntactically /// valid. -// -// TODO: allow Punctuated to be inferred as intra doc link, currently blocked on -// https://github.com/rust-lang/rust/issues/62834 #[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "printing"))))] #[macro_export] macro_rules! parse_quote { ($($tt:tt)*) => { - $crate::parse_quote::parse( - $crate::__private::From::from( - $crate::__private::quote::quote!($($tt)*) - ) - ) + $crate::parse_quote::parse($crate::__private::quote::quote!($($tt)*)) + }; +} + +/// This macro is [`parse_quote!`] + [`quote_spanned!`][quote::quote_spanned]. +/// +/// Please refer to each of their documentation. +/// +/// # Example +/// +/// ``` +/// use quote::{quote, quote_spanned}; +/// use syn::spanned::Spanned; +/// use syn::{parse_quote_spanned, ReturnType, Signature}; +/// +/// // Changes `fn()` to `fn() -> Pin<Box<dyn Future<Output = ()>>>`, +/// // and `fn() -> T` to `fn() -> Pin<Box<dyn Future<Output = T>>>`, +/// // without introducing any call_site() spans. +/// fn make_ret_pinned_future(sig: &mut Signature) { +/// let ret = match &sig.output { +/// ReturnType::Default => quote_spanned!(sig.paren_token.span=> ()), +/// ReturnType::Type(_, ret) => quote!(#ret), +/// }; +/// sig.output = parse_quote_spanned! {ret.span()=> +/// -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = #ret>>> +/// }; +/// } +/// ``` +#[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "printing"))))] +#[macro_export] +macro_rules! parse_quote_spanned { + ($span:expr=> $($tt:tt)*) => { + $crate::parse_quote::parse($crate::__private::quote::quote_spanned!($span=> $($tt)*)) }; } diff --git a/src/path.rs b/src/path.rs index 37e41bc4..48673177 100644 --- a/src/path.rs +++ b/src/path.rs @@ -589,7 +589,7 @@ pub mod parsing { path: &mut Self, expr_style: bool, ) -> Result<()> { - while input.peek(Token![::]) { + while input.peek(Token![::]) && !input.peek3(token::Paren) { let punct: Token![::] = input.parse()?; path.segments.push_punct(punct); let value = PathSegment::parse_helper(input, expr_style)?; diff --git a/src/punctuated.rs b/src/punctuated.rs index 5cf5235e..5e9a34bd 100644 --- a/src/punctuated.rs +++ b/src/punctuated.rs @@ -193,7 +193,7 @@ impl<T, P> Punctuated<T, P> { if self.last.is_some() { self.last.take().map(|t| Pair::End(*t)) } else { - self.inner.pop().map(|(t, d)| Pair::Punctuated(t, d)) + self.inner.pop().map(|(t, p)| Pair::Punctuated(t, p)) } } @@ -937,16 +937,16 @@ impl<T, P> Pair<T, P> { /// the final one and there is no trailing punctuation. pub fn punct(&self) -> Option<&P> { match self { - Pair::Punctuated(_, d) => Some(d), + Pair::Punctuated(_, p) => Some(p), Pair::End(_) => None, } } /// Creates a punctuated pair out of a syntax tree node and an optional /// following punctuation. - pub fn new(t: T, d: Option<P>) -> Self { - match d { - Some(d) => Pair::Punctuated(t, d), + pub fn new(t: T, p: Option<P>) -> Self { + match p { + Some(p) => Pair::Punctuated(t, p), None => Pair::End(t), } } @@ -955,7 +955,7 @@ impl<T, P> Pair<T, P> { /// optional following punctuation. pub fn into_tuple(self) -> (T, Option<P>) { match self { - Pair::Punctuated(t, d) => (t, Some(d)), + Pair::Punctuated(t, p) => (t, Some(p)), Pair::End(t) => (t, None), } } diff --git a/src/stmt.rs b/src/stmt.rs index abdefaae..3e2c71bd 100644 --- a/src/stmt.rs +++ b/src/stmt.rs @@ -50,7 +50,7 @@ ast_struct! { pub mod parsing { use super::*; use crate::parse::discouraged::Speculative; - use crate::parse::{Parse, ParseStream, Result}; + use crate::parse::{Parse, ParseBuffer, ParseStream, Result}; use proc_macro2::TokenStream; impl Block { @@ -152,20 +152,25 @@ pub mod parsing { } fn parse_stmt(input: ParseStream, allow_nosemi: bool) -> Result<Stmt> { + let begin = input.fork(); let mut attrs = input.call(Attribute::parse_outer)?; // brace-style macros; paren and bracket macros get parsed as // expression statements. let ahead = input.fork(); if let Ok(path) = ahead.call(Path::parse_mod_style) { - if ahead.peek(Token![!]) && (ahead.peek2(token::Brace) || ahead.peek2(Ident)) { + if ahead.peek(Token![!]) + && (ahead.peek2(token::Brace) + && !(ahead.peek3(Token![.]) || ahead.peek3(Token![?])) + || ahead.peek2(Ident)) + { input.advance_to(&ahead); return stmt_mac(input, attrs, path); } } if input.peek(Token![let]) { - stmt_local(input, attrs) + stmt_local(input, attrs, begin) } else if input.peek(Token![pub]) || input.peek(Token![crate]) && !input.peek2(Token![::]) || input.peek(Token![extern]) @@ -180,7 +185,6 @@ pub mod parsing { || input.peek(Token![fn]) || input.peek(Token![mod]) || input.peek(Token![type]) - || input.peek(item::parsing::existential) && input.peek2(Token![type]) || input.peek(Token![struct]) || input.peek(Token![enum]) || input.peek(Token![union]) && input.peek2(Ident) @@ -219,9 +223,7 @@ pub mod parsing { }))) } - fn stmt_local(input: ParseStream, attrs: Vec<Attribute>) -> Result<Stmt> { - let begin = input.fork(); - + fn stmt_local(input: ParseStream, attrs: Vec<Attribute>, begin: ParseBuffer) -> Result<Stmt> { let let_token: Token![let] = input.parse()?; let mut pat: Pat = pat::parsing::multi_pat_with_leading_vert(input)?; @@ -541,7 +541,7 @@ pub mod parsing { || lookahead.peek(Token![<]) { if input.peek(Token![dyn]) { - let trait_object: TypeTraitObject = input.parse()?; + let trait_object = TypeTraitObject::parse(input, allow_plus)?; return Ok(Type::TraitObject(trait_object)); } @@ -586,7 +586,12 @@ pub mod parsing { if allow_plus { while input.peek(Token![+]) { bounds.push_punct(input.parse()?); - if input.peek(Token![>]) { + if !(input.peek(Ident::peek_any) + || input.peek(Token![::]) + || input.peek(Token![?]) + || input.peek(Lifetime) + || input.peek(token::Paren)) + { break; } bounds.push_value(input.parse()?); @@ -623,7 +628,7 @@ pub mod parsing { } else if lookahead.peek(Token![!]) && !input.peek(Token![=]) { input.parse().map(Type::Never) } else if lookahead.peek(Token![impl]) { - input.parse().map(Type::ImplTrait) + TypeImplTrait::parse(input, allow_plus).map(Type::ImplTrait) } else if lookahead.peek(Token![_]) { input.parse().map(Type::Infer) } else if lookahead.peek(Lifetime) { @@ -816,7 +821,10 @@ pub mod parsing { fn parse(input: ParseStream) -> Result<Self> { let (qself, mut path) = path::parsing::qpath(input, false)?; - if path.segments.last().unwrap().arguments.is_empty() && input.peek(token::Paren) { + if path.segments.last().unwrap().arguments.is_empty() + && (input.peek(token::Paren) || input.peek(Token![::]) && input.peek3(token::Paren)) + { + input.parse::<Option<Token![::]>>()?; let args: ParenthesizedGenericArguments = input.parse()?; let parenthesized = PathArguments::Parenthesized(args); path.segments.last_mut().unwrap().arguments = parenthesized; @@ -827,13 +835,13 @@ pub mod parsing { } impl ReturnType { + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn without_plus(input: ParseStream) -> Result<Self> { let allow_plus = false; Self::parse(input, allow_plus) } - #[doc(hidden)] - pub fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> { + pub(crate) fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> { if input.peek(Token![->]) { let arrow = input.parse()?; let ty = ambig_ty(input, allow_plus)?; @@ -847,14 +855,16 @@ pub mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ReturnType { fn parse(input: ParseStream) -> Result<Self> { - Self::parse(input, true) + let allow_plus = true; + Self::parse(input, allow_plus) } } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for TypeTraitObject { fn parse(input: ParseStream) -> Result<Self> { - Self::parse(input, true) + let allow_plus = true; + Self::parse(input, allow_plus) } } @@ -868,60 +878,67 @@ pub mod parsing { } impl TypeTraitObject { + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn without_plus(input: ParseStream) -> Result<Self> { let allow_plus = false; Self::parse(input, allow_plus) } // Only allow multiple trait references if allow_plus is true. - #[doc(hidden)] - pub fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> { + pub(crate) fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> { Ok(TypeTraitObject { dyn_token: input.parse()?, - bounds: { - let mut bounds = Punctuated::new(); - if allow_plus { - loop { - bounds.push_value(input.parse()?); - if !input.peek(Token![+]) { - break; - } - bounds.push_punct(input.parse()?); - if input.peek(Token![>]) { - break; - } - } - } else { - bounds.push_value(input.parse()?); - } - // Just lifetimes like `'a + 'b` is not a TraitObject. - if !at_least_one_type(&bounds) { - return Err(input.error("expected at least one type")); - } - bounds - }, + bounds: Self::parse_bounds(input, allow_plus)?, }) } + + fn parse_bounds( + input: ParseStream, + allow_plus: bool, + ) -> Result<Punctuated<TypeParamBound, Token![+]>> { + let mut bounds = Punctuated::new(); + loop { + bounds.push_value(input.parse()?); + if !(allow_plus && input.peek(Token![+])) { + break; + } + bounds.push_punct(input.parse()?); + if !(input.peek(Ident::peek_any) + || input.peek(Token![::]) + || input.peek(Token![?]) + || input.peek(Lifetime) + || input.peek(token::Paren)) + { + break; + } + } + // Just lifetimes like `'a + 'b` is not a TraitObject. + if !at_least_one_type(&bounds) { + return Err(input.error("expected at least one type")); + } + Ok(bounds) + } } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for TypeImplTrait { fn parse(input: ParseStream) -> Result<Self> { + let allow_plus = true; + Self::parse(input, allow_plus) + } + } + + impl TypeImplTrait { + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + pub fn without_plus(input: ParseStream) -> Result<Self> { + let allow_plus = false; + Self::parse(input, allow_plus) + } + + pub(crate) fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> { Ok(TypeImplTrait { impl_token: input.parse()?, - // NOTE: rust-lang/rust#34511 includes discussion about whether - // or not + should be allowed in ImplTrait directly without (). - bounds: { - let mut bounds = Punctuated::new(); - loop { - bounds.push_value(input.parse()?); - if !input.peek(Token![+]) { - break; - } - bounds.push_punct(input.parse()?); - } - bounds - }, + bounds: TypeTraitObject::parse_bounds(input, allow_plus)?, }) } } diff --git a/tests/common/eq.rs b/tests/common/eq.rs index 3ece45b3..5e3dd443 100644 --- a/tests/common/eq.rs +++ b/tests/common/eq.rs @@ -3,22 +3,21 @@ extern crate rustc_data_structures; extern crate rustc_span; use rustc_ast::ast::{ - AngleBracketedArg, AngleBracketedArgs, AnonConst, Arm, AssocItemKind, AssocTyConstraint, - AssocTyConstraintKind, Async, AttrId, AttrItem, AttrKind, AttrStyle, Attribute, BareFnTy, - BinOpKind, BindingMode, Block, BlockCheckMode, BorrowKind, CaptureBy, Const, Crate, CrateSugar, - Defaultness, EnumDef, Expr, ExprField, ExprKind, Extern, FieldDef, FloatTy, FnDecl, FnHeader, - FnKind, FnRetTy, FnSig, ForeignItemKind, ForeignMod, GenericArg, GenericArgs, GenericBound, - GenericParam, GenericParamKind, Generics, ImplKind, ImplPolarity, Inline, InlineAsm, + AngleBracketedArg, AngleBracketedArgs, AnonConst, Arm, AssocConstraint, AssocConstraintKind, + AssocItemKind, Async, AttrId, AttrItem, AttrKind, AttrStyle, Attribute, BareFnTy, BinOpKind, + BindingMode, Block, BlockCheckMode, BorrowKind, CaptureBy, Const, Crate, CrateSugar, + Defaultness, EnumDef, Expr, ExprField, ExprKind, Extern, FieldDef, FloatTy, Fn, FnDecl, + FnHeader, FnRetTy, FnSig, ForeignItemKind, ForeignMod, GenericArg, GenericArgs, GenericBound, + GenericParam, GenericParamKind, Generics, Impl, ImplPolarity, Inline, InlineAsm, InlineAsmOperand, InlineAsmOptions, InlineAsmRegOrRegClass, InlineAsmTemplatePiece, IntTy, - IsAuto, Item, ItemKind, Label, Lifetime, Lit, LitFloatType, LitIntType, LitKind, - LlvmAsmDialect, LlvmInlineAsm, LlvmInlineAsmOutput, Local, LocalKind, MacArgs, MacCall, - MacCallStmt, MacDelimiter, MacStmtStyle, MacroDef, ModKind, Movability, MutTy, Mutability, - NodeId, Param, ParenthesizedArgs, Pat, PatField, PatKind, Path, PathSegment, PolyTraitRef, - QSelf, RangeEnd, RangeLimits, RangeSyntax, Stmt, StmtKind, StrLit, StrStyle, StructExpr, - StructRest, TraitBoundModifier, TraitKind, TraitObjectSyntax, TraitRef, Ty, TyAliasKind, - TyKind, UintTy, UnOp, Unsafe, UnsafeSource, UseTree, UseTreeKind, Variant, VariantData, - Visibility, VisibilityKind, WhereBoundPredicate, WhereClause, WhereEqPredicate, WherePredicate, - WhereRegionPredicate, + IsAuto, Item, ItemKind, Label, Lifetime, Lit, LitFloatType, LitIntType, LitKind, Local, + LocalKind, MacArgs, MacCall, MacCallStmt, MacDelimiter, MacStmtStyle, MacroDef, ModKind, + Movability, MutTy, Mutability, NodeId, Param, ParenthesizedArgs, Pat, PatField, PatKind, Path, + PathSegment, PolyTraitRef, QSelf, RangeEnd, RangeLimits, RangeSyntax, Stmt, StmtKind, StrLit, + StrStyle, StructExpr, StructRest, Term, Trait, TraitBoundModifier, TraitObjectSyntax, TraitRef, + Ty, TyAlias, TyKind, UintTy, UnOp, Unsafe, UnsafeSource, UseTree, UseTreeKind, Variant, + VariantData, Visibility, VisibilityKind, WhereBoundPredicate, WhereClause, WhereEqPredicate, + WherePredicate, WhereRegionPredicate, }; use rustc_ast::ptr::P; use rustc_ast::token::{self, CommentKind, DelimToken, Nonterminal, Token, TokenKind}; @@ -296,33 +295,31 @@ macro_rules! spanless_eq_enum { spanless_eq_struct!(AngleBracketedArgs; span args); spanless_eq_struct!(AnonConst; id value); spanless_eq_struct!(Arm; attrs pat guard body span id is_placeholder); -spanless_eq_struct!(AssocTyConstraint; id ident gen_args kind span); +spanless_eq_struct!(AssocConstraint; id ident gen_args kind span); spanless_eq_struct!(AttrAnnotatedTokenStream; 0); spanless_eq_struct!(AttrItem; path args tokens); spanless_eq_struct!(Attribute; kind id style span); spanless_eq_struct!(AttributesData; attrs tokens); spanless_eq_struct!(BareFnTy; unsafety ext generic_params decl); -spanless_eq_struct!(Block; stmts id rules span tokens); -spanless_eq_struct!(Crate; attrs items span proc_macros); +spanless_eq_struct!(Block; stmts id rules span tokens could_be_bare_literal); +spanless_eq_struct!(Crate; attrs items span id is_placeholder); spanless_eq_struct!(EnumDef; variants); spanless_eq_struct!(Expr; id kind span attrs !tokens); spanless_eq_struct!(ExprField; attrs id span ident expr is_shorthand is_placeholder); spanless_eq_struct!(FieldDef; attrs id span vis ident ty is_placeholder); spanless_eq_struct!(FnDecl; inputs output); spanless_eq_struct!(FnHeader; constness asyncness unsafety ext); -spanless_eq_struct!(FnKind; 0 1 2 3); +spanless_eq_struct!(Fn; defaultness generics sig body); spanless_eq_struct!(FnSig; header decl span); spanless_eq_struct!(ForeignMod; unsafety abi items); spanless_eq_struct!(GenericParam; id ident attrs bounds is_placeholder kind); spanless_eq_struct!(Generics; params where_clause span); -spanless_eq_struct!(ImplKind; unsafety polarity defaultness constness generics of_trait self_ty items); -spanless_eq_struct!(InlineAsm; template template_strs operands clobber_abi options line_spans); +spanless_eq_struct!(Impl; defaultness unsafety generics constness polarity of_trait self_ty items); +spanless_eq_struct!(InlineAsm; template template_strs operands clobber_abis options line_spans); spanless_eq_struct!(Item<K>; attrs id span vis ident kind !tokens); spanless_eq_struct!(Label; ident); spanless_eq_struct!(Lifetime; id ident); spanless_eq_struct!(Lit; token kind span); -spanless_eq_struct!(LlvmInlineAsm; asm asm_str_style outputs inputs clobbers volatile alignstack dialect); -spanless_eq_struct!(LlvmInlineAsmOutput; constraint expr is_rw is_indirect); spanless_eq_struct!(Local; pat ty kind id span attrs !tokens); spanless_eq_struct!(MacCall; path args prior_type_ascription); spanless_eq_struct!(MacCallStmt; mac style attrs tokens); @@ -339,10 +336,10 @@ spanless_eq_struct!(Stmt; id kind span); spanless_eq_struct!(StrLit; style symbol suffix span symbol_unescaped); spanless_eq_struct!(StructExpr; qself path fields rest); spanless_eq_struct!(Token; kind span); -spanless_eq_struct!(TraitKind; 0 1 2 3 4); +spanless_eq_struct!(Trait; unsafety is_auto generics bounds items); spanless_eq_struct!(TraitRef; path ref_id); spanless_eq_struct!(Ty; id kind span tokens); -spanless_eq_struct!(TyAliasKind; 0 1 2 3); +spanless_eq_struct!(TyAlias; defaultness generics bounds ty); spanless_eq_struct!(UseTree; prefix kind span); spanless_eq_struct!(Variant; attrs id span !vis ident data disr_expr is_placeholder); spanless_eq_struct!(Visibility; kind span tokens); @@ -353,7 +350,7 @@ spanless_eq_struct!(WhereRegionPredicate; span lifetime bounds); spanless_eq_struct!(token::Lit; kind symbol suffix); spanless_eq_enum!(AngleBracketedArg; Arg(0) Constraint(0)); spanless_eq_enum!(AssocItemKind; Const(0 1 2) Fn(0) TyAlias(0) MacCall(0)); -spanless_eq_enum!(AssocTyConstraintKind; Equality(ty) Bound(bounds)); +spanless_eq_enum!(AssocConstraintKind; Equality(term) Bound(bounds)); spanless_eq_enum!(Async; Yes(span closure_id return_impl_trait_id) No); spanless_eq_enum!(AttrAnnotatedTokenTree; Token(0) Delimited(0 1 2) Attributes(0)); spanless_eq_enum!(AttrStyle; Outer Inner); @@ -381,7 +378,6 @@ spanless_eq_enum!(IntTy; Isize I8 I16 I32 I64 I128); spanless_eq_enum!(IsAuto; Yes No); spanless_eq_enum!(LitFloatType; Suffixed(0) Unsuffixed); spanless_eq_enum!(LitIntType; Signed(0) Unsigned(0) Unsuffixed); -spanless_eq_enum!(LlvmAsmDialect; Att Intel); spanless_eq_enum!(LocalKind; Decl Init(0) InitElse(0 1)); spanless_eq_enum!(MacArgs; Empty Delimited(0 1 2) Eq(0 1)); spanless_eq_enum!(MacDelimiter; Parenthesis Bracket Brace); @@ -394,6 +390,7 @@ spanless_eq_enum!(RangeLimits; HalfOpen Closed); spanless_eq_enum!(StmtKind; Local(0) Item(0) Expr(0) Semi(0) Empty MacCall(0)); spanless_eq_enum!(StrStyle; Cooked Raw(0)); spanless_eq_enum!(StructRest; Base(0) Rest(0) None); +spanless_eq_enum!(Term; Ty(0) Const(0)); spanless_eq_enum!(TokenTree; Token(0) Delimited(0 1 2)); spanless_eq_enum!(TraitBoundModifier; None Maybe MaybeConst MaybeConstMaybe); spanless_eq_enum!(TraitObjectSyntax; Dyn None); @@ -411,8 +408,7 @@ spanless_eq_enum!(ExprKind; Box(0) Array(0) ConstBlock(0) Call(0 1) Closure(0 1 2 3 4 5) Block(0 1) Async(0 1 2) Await(0) TryBlock(0) Assign(0 1 2) AssignOp(0 1 2) Field(0 1) Index(0 1) Underscore Range(0 1 2) Path(0 1) AddrOf(0 1 2) Break(0 1) Continue(0) Ret(0) InlineAsm(0) - LlvmInlineAsm(0) MacCall(0) Struct(0) Repeat(0 1) Paren(0) Try(0) Yield(0) - Err); + MacCall(0) Struct(0) Repeat(0 1) Paren(0) Try(0) Yield(0) Err); spanless_eq_enum!(InlineAsmOperand; In(reg expr) Out(reg late expr) InOut(reg late expr) SplitInOut(reg late in_expr out_expr) Const(anon_const) Sym(expr)); @@ -425,9 +421,8 @@ spanless_eq_enum!(PatKind; Wild Ident(0 1 2) Struct(0 1 2 3) TupleStruct(0 1 2) Or(0) Path(0 1) Tuple(0) Box(0) Ref(0 1) Lit(0) Range(0 1 2) Slice(0) Rest Paren(0) MacCall(0)); spanless_eq_enum!(TyKind; Slice(0) Array(0 1) Ptr(0) Rptr(0 1) BareFn(0) Never - Tup(0) AnonymousStruct(0 1) AnonymousUnion(0 1) Path(0 1) TraitObject(0 1) - ImplTrait(0 1) Paren(0) Typeof(0) Infer ImplicitSelf MacCall(0) Err - CVarArgs); + Tup(0) Path(0 1) TraitObject(0 1) ImplTrait(0 1) Paren(0) Typeof(0) Infer + ImplicitSelf MacCall(0) Err CVarArgs); impl SpanlessEq for Ident { fn eq(&self, other: &Self) -> bool { @@ -529,7 +524,7 @@ impl SpanlessEq for TokenStream { } } -fn doc_comment<'a>( +fn doc_comment( style: AttrStyle, unescaped: Symbol, trees: &mut impl Iterator<Item = TokenTree>, diff --git a/tests/common/mod.rs b/tests/common/mod.rs index a1cc80a1..2156530b 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,4 +1,5 @@ #![allow(dead_code)] +#![allow(clippy::module_name_repetitions, clippy::shadow_unrelated)] use rayon::ThreadPoolBuilder; use std::env; diff --git a/tests/debug/gen.rs b/tests/debug/gen.rs index 1eae327b..a49ee6c9 100644 --- a/tests/debug/gen.rs +++ b/tests/debug/gen.rs @@ -591,29 +591,29 @@ impl Debug for Lite<syn::Expr> { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.asyncness { + if let Some(val) = &_val.movability { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Async); + struct Print(syn::token::Static); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("Some")?; Ok(()) } } - formatter.field("asyncness", Print::ref_cast(val)); + formatter.field("movability", Print::ref_cast(val)); } - if let Some(val) = &_val.movability { + if let Some(val) = &_val.asyncness { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Static); + struct Print(syn::token::Async); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("Some")?; Ok(()) } } - formatter.field("movability", Print::ref_cast(val)); + formatter.field("asyncness", Print::ref_cast(val)); } if let Some(val) = &_val.capture { #[derive(RefCast)] @@ -1294,29 +1294,29 @@ impl Debug for Lite<syn::ExprClosure> { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.asyncness { + if let Some(val) = &_val.movability { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Async); + struct Print(syn::token::Static); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("Some")?; Ok(()) } } - formatter.field("asyncness", Print::ref_cast(val)); + formatter.field("movability", Print::ref_cast(val)); } - if let Some(val) = &_val.movability { + if let Some(val) = &_val.asyncness { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Static); + struct Print(syn::token::Async); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("Some")?; Ok(()) } } - formatter.field("movability", Print::ref_cast(val)); + formatter.field("asyncness", Print::ref_cast(val)); } if let Some(val) = &_val.capture { #[derive(RefCast)] @@ -2672,8 +2672,7 @@ impl Debug for Lite<syn::Item> { fn fmt( &self, formatter: &mut fmt::Formatter, - ) -> fmt::Result - { + ) -> fmt::Result { match &self.0 { Some(_val) => { formatter.write_str("Some")?; @@ -3082,7 +3081,10 @@ impl Debug for Lite<syn::ItemImpl> { #[repr(transparent)] struct Print(Option<syn::token::Bang>); impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt( + &self, + formatter: &mut fmt::Formatter, + ) -> fmt::Result { match &self.0 { Some(_val) => { formatter.write_str("Some")?; @@ -3424,24 +3426,12 @@ impl Debug for Lite<syn::Lit> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { let _val = &self.value; match _val { - syn::Lit::Str(_val) => { - write!(formatter, "{:?}", _val.value()) - } - syn::Lit::ByteStr(_val) => { - write!(formatter, "{:?}", _val.value()) - } - syn::Lit::Byte(_val) => { - write!(formatter, "{:?}", _val.value()) - } - syn::Lit::Char(_val) => { - write!(formatter, "{:?}", _val.value()) - } - syn::Lit::Int(_val) => { - write!(formatter, "{}", _val) - } - syn::Lit::Float(_val) => { - write!(formatter, "{}", _val) - } + syn::Lit::Str(_val) => write!(formatter, "{:?}", _val.value()), + syn::Lit::ByteStr(_val) => write!(formatter, "{:?}", _val.value()), + syn::Lit::Byte(_val) => write!(formatter, "{:?}", _val.value()), + syn::Lit::Char(_val) => write!(formatter, "{:?}", _val.value()), + syn::Lit::Int(_val) => write!(formatter, "{}", _val), + syn::Lit::Float(_val) => write!(formatter, "{}", _val), syn::Lit::Bool(_val) => { let mut formatter = formatter.debug_struct("Lit::Bool"); formatter.field("value", Lite(&_val.value)); @@ -4202,7 +4192,8 @@ impl Debug for Lite<syn::PathArguments> { match _val { syn::PathArguments::None => formatter.write_str("None"), syn::PathArguments::AngleBracketed(_val) => { - let mut formatter = formatter.debug_struct("PathArguments::AngleBracketed"); + let mut formatter = formatter + .debug_struct("PathArguments::AngleBracketed"); if let Some(val) = &_val.colon2_token { #[derive(RefCast)] #[repr(transparent)] @@ -4221,7 +4212,8 @@ impl Debug for Lite<syn::PathArguments> { formatter.finish() } syn::PathArguments::Parenthesized(_val) => { - let mut formatter = formatter.debug_struct("PathArguments::Parenthesized"); + let mut formatter = formatter + .debug_struct("PathArguments::Parenthesized"); if !_val.inputs.is_empty() { formatter.field("inputs", Lite(&_val.inputs)); } @@ -4345,7 +4337,10 @@ impl Debug for Lite<syn::Receiver> { #[repr(transparent)] struct Print(Option<syn::Lifetime>); impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt( + &self, + formatter: &mut fmt::Formatter, + ) -> fmt::Result { match &self.0 { Some(_val) => { formatter.write_str("Some")?; diff --git a/tests/debug/mod.rs b/tests/debug/mod.rs index cefebace..05de6126 100644 --- a/tests/debug/mod.rs +++ b/tests/debug/mod.rs @@ -1,3 +1,10 @@ +#![allow( + clippy::no_effect_underscore_binding, + clippy::too_many_lines, + clippy::used_underscore_binding +)] + +#[rustfmt::skip] mod gen; use proc_macro2::{Ident, Literal, TokenStream}; diff --git a/tests/macros/mod.rs b/tests/macros/mod.rs index db90818e..86cdb5f6 100644 --- a/tests/macros/mod.rs +++ b/tests/macros/mod.rs @@ -39,18 +39,24 @@ macro_rules! snapshot_impl { (($expr:ident) as $t:ty, @$snapshot:literal) => { let $expr = crate::macros::Tokens::parse::<$t>($expr).unwrap(); let debug = crate::macros::debug::Lite(&$expr); - insta::assert_debug_snapshot!(debug, @$snapshot); + if !cfg!(miri) { + insta::assert_debug_snapshot!(debug, @$snapshot); + } }; (($($expr:tt)*) as $t:ty, @$snapshot:literal) => {{ let syntax_tree = crate::macros::Tokens::parse::<$t>($($expr)*).unwrap(); let debug = crate::macros::debug::Lite(&syntax_tree); - insta::assert_debug_snapshot!(debug, @$snapshot); + if !cfg!(miri) { + insta::assert_debug_snapshot!(debug, @$snapshot); + } syntax_tree }}; (($($expr:tt)*) , @$snapshot:literal) => {{ let syntax_tree = $($expr)*; let debug = crate::macros::debug::Lite(&syntax_tree); - insta::assert_debug_snapshot!(debug, @$snapshot); + if !cfg!(miri) { + insta::assert_debug_snapshot!(debug, @$snapshot); + } syntax_tree }}; (($($expr:tt)*) $next:tt $($rest:tt)*) => { diff --git a/tests/regression.rs b/tests/regression.rs new file mode 100644 index 00000000..8311a91b --- /dev/null +++ b/tests/regression.rs @@ -0,0 +1,5 @@ +#![allow(clippy::let_underscore_drop)] + +mod regression { + automod::dir!("tests/regression"); +} diff --git a/tests/regression/issue1108.rs b/tests/regression/issue1108.rs new file mode 100644 index 00000000..11a82ada --- /dev/null +++ b/tests/regression/issue1108.rs @@ -0,0 +1,5 @@ +#[test] +fn issue1108() { + let data = "impl<x<>>::x for"; + let _ = syn::parse_file(data); +} diff --git a/tests/repo/mod.rs b/tests/repo/mod.rs index b819a3aa..79e3018b 100644 --- a/tests/repo/mod.rs +++ b/tests/repo/mod.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_assert)] + mod progress; use self::progress::Progress; @@ -8,24 +10,14 @@ use std::path::Path; use tar::Archive; use walkdir::DirEntry; -const REVISION: &str = "50171c310cd15e1b2d3723766ce64e2e4d6696fc"; +const REVISION: &str = "5e57faa78aa7661c6000204591558f6665f11abc"; #[rustfmt::skip] static EXCLUDE: &[&str] = &[ - // TODO: anonymous structs/unions - // type A = struct { field: u8 }; - // https://github.com/dtolnay/syn/issues/1049 - "src/test/pretty/anonymous-types.rs", - // TODO: impl ~const T {} // https://github.com/dtolnay/syn/issues/1051 "src/test/ui/rfc-2632-const-trait-impl/syntax.rs", - // TODO: ~const in where-clause - // https://github.com/dtolnay/syn/issues/1051 - "src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs", - "src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs", - // Compile-fail expr parameter in const generic position: f::<1 + 2>() "src/test/ui/const-generics/early/closing-args-token.rs", "src/test/ui/const-generics/early/const-expression-parameter.rs", @@ -54,16 +46,31 @@ static EXCLUDE: &[&str] = &[ "src/tools/rustfmt/tests/target/configs/spaces_around_ranges/true.rs", "src/tools/rustfmt/tests/target/type.rs", + // Clippy lint lists represented as expressions + "src/tools/clippy/clippy_lints/src/lib.deprecated.rs", + "src/tools/clippy/clippy_lints/src/lib.register_all.rs", + "src/tools/clippy/clippy_lints/src/lib.register_cargo.rs", + "src/tools/clippy/clippy_lints/src/lib.register_complexity.rs", + "src/tools/clippy/clippy_lints/src/lib.register_correctness.rs", + "src/tools/clippy/clippy_lints/src/lib.register_internal.rs", + "src/tools/clippy/clippy_lints/src/lib.register_lints.rs", + "src/tools/clippy/clippy_lints/src/lib.register_nursery.rs", + "src/tools/clippy/clippy_lints/src/lib.register_pedantic.rs", + "src/tools/clippy/clippy_lints/src/lib.register_perf.rs", + "src/tools/clippy/clippy_lints/src/lib.register_restriction.rs", + "src/tools/clippy/clippy_lints/src/lib.register_style.rs", + "src/tools/clippy/clippy_lints/src/lib.register_suspicious.rs", + // Not actually test cases "src/test/rustdoc-ui/test-compile-fail2.rs", "src/test/rustdoc-ui/test-compile-fail3.rs", - "src/test/ui/include-single-expr-helper.rs", - "src/test/ui/include-single-expr-helper-1.rs", "src/test/ui/json-bom-plus-crlf-multifile-aux.rs", "src/test/ui/lint/expansion-time-include.rs", "src/test/ui/macros/auxiliary/macro-comma-support.rs", "src/test/ui/macros/auxiliary/macro-include-items-expr.rs", - "src/test/ui/parser/auxiliary/issue-21146-inc.rs", + "src/test/ui/macros/include-single-expr-helper.rs", + "src/test/ui/macros/include-single-expr-helper-1.rs", + "src/test/ui/parser/issues/auxiliary/issue-21146-inc.rs", ]; pub fn base_dir_filter(entry: &DirEntry) -> bool { @@ -71,7 +78,7 @@ pub fn base_dir_filter(entry: &DirEntry) -> bool { if path.is_dir() { return true; // otherwise walkdir does not visit the files } - if path.extension().map(|e| e != "rs").unwrap_or(true) { + if path.extension().map_or(true, |e| e != "rs") { return false; } diff --git a/tests/test_derive_input.rs b/tests/test_derive_input.rs index bf1ebdb6..93634e57 100644 --- a/tests/test_derive_input.rs +++ b/tests/test_derive_input.rs @@ -1,3 +1,5 @@ +#![allow(clippy::too_many_lines)] + #[macro_use] mod macros; diff --git a/tests/test_generics.rs b/tests/test_generics.rs index b29434a1..330f02f4 100644 --- a/tests/test_generics.rs +++ b/tests/test_generics.rs @@ -1,3 +1,5 @@ +#![allow(clippy::too_many_lines)] + #[macro_use] mod macros; diff --git a/tests/test_item.rs b/tests/test_item.rs index a991e62d..96df4b1a 100644 --- a/tests/test_item.rs +++ b/tests/test_item.rs @@ -299,3 +299,38 @@ fn test_impl_type_parameter_defaults() { self_ty: Type::Tuple, }"###); } + +#[test] +fn test_impl_trait_trailing_plus() { + let tokens = quote! { + fn f() -> impl Sized + {} + }; + + snapshot!(tokens as Item, @r###" + Item::Fn { + vis: Inherited, + sig: Signature { + ident: "f", + generics: Generics, + output: Type( + Type::ImplTrait { + bounds: [ + Trait(TraitBound { + modifier: None, + path: Path { + segments: [ + PathSegment { + ident: "Sized", + arguments: None, + }, + ], + }, + }), + ], + }, + ), + }, + block: Block, + } + "###); +} diff --git a/tests/test_lit.rs b/tests/test_lit.rs index 099daf10..ebe077c6 100644 --- a/tests/test_lit.rs +++ b/tests/test_lit.rs @@ -1,3 +1,5 @@ +#![allow(clippy::float_cmp, clippy::non_ascii_literal)] + #[macro_use] mod macros; @@ -176,7 +178,6 @@ fn ints() { #[test] fn floats() { - #[cfg_attr(feature = "cargo-clippy", allow(float_cmp))] fn test_float(s: &str, value: f64, suffix: &str) { match lit(s) { Lit::Float(lit) => { @@ -215,12 +216,6 @@ fn negative() { } #[test] -fn negative_overflow() { - assert!(syn::parse_str::<LitFloat>("-1.0e99f64").is_ok()); - assert!(syn::parse_str::<LitFloat>("-1.0e999f64").is_err()); -} - -#[test] fn suffix() { fn get_suffix(token: &str) -> String { let lit = syn::parse_str::<Lit>(token).unwrap(); diff --git a/tests/test_meta.rs b/tests/test_meta.rs index de6cc4da..9b3f30de 100644 --- a/tests/test_meta.rs +++ b/tests/test_meta.rs @@ -1,3 +1,5 @@ +#![allow(clippy::shadow_unrelated, clippy::too_many_lines)] + #[macro_use] mod macros; diff --git a/tests/test_parse_buffer.rs b/tests/test_parse_buffer.rs index 57a3c7c3..cc23e9ba 100644 --- a/tests/test_parse_buffer.rs +++ b/tests/test_parse_buffer.rs @@ -1,3 +1,5 @@ +#![allow(clippy::non_ascii_literal)] + use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenStream, TokenTree}; use std::iter::FromIterator; use syn::parse::{discouraged::Speculative, Parse, ParseStream, Parser, Result}; @@ -10,7 +12,7 @@ fn smuggled_speculative_cursor_between_sources() { impl Parse for BreakRules { fn parse(input1: ParseStream) -> Result<Self> { let nested = |input2: ParseStream| { - input1.advance_to(&input2); + input1.advance_to(input2); Ok(Self) }; nested.parse_str("") diff --git a/tests/test_path.rs b/tests/test_path.rs index e05b52ee..c732eff7 100644 --- a/tests/test_path.rs +++ b/tests/test_path.rs @@ -102,3 +102,25 @@ fn print_incomplete_qpath() { "###); assert!(ty.path.segments.pop().is_none()); } + +#[test] +fn parse_parenthesized_path_arguments_with_disambiguator() { + #[rustfmt::skip] + let tokens = quote!(FnOnce::() -> !); + snapshot!(tokens as Type, @r###" + Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "FnOnce", + arguments: PathArguments::Parenthesized { + output: Type( + Type::Never, + ), + }, + }, + ], + }, + } + "###); +} diff --git a/tests/test_precedence.rs b/tests/test_precedence.rs index 8d212b03..7f8128e6 100644 --- a/tests/test_precedence.rs +++ b/tests/test_precedence.rs @@ -1,6 +1,13 @@ #![cfg(not(syn_disable_nightly_tests))] +#![cfg(not(miri))] #![recursion_limit = "1024"] #![feature(rustc_private)] +#![allow( + clippy::explicit_deref_methods, + clippy::manual_assert, + clippy::match_wildcard_for_single_variants, + clippy::too_many_lines +)] //! The tests in this module do the following: //! @@ -128,16 +135,16 @@ fn test_rustc_precedence() { l_failed ); - passed.fetch_add(l_passed, Ordering::SeqCst); - let prev_failed = failed.fetch_add(l_failed, Ordering::SeqCst); + passed.fetch_add(l_passed, Ordering::Relaxed); + let prev_failed = failed.fetch_add(l_failed, Ordering::Relaxed); if prev_failed + l_failed >= abort_after { process::exit(1); } }); - let passed = passed.load(Ordering::SeqCst); - let failed = failed.load(Ordering::SeqCst); + let passed = passed.load(Ordering::Relaxed); + let failed = failed.load(Ordering::Relaxed); errorf!("\n===== Precedence Test Results =====\n"); errorf!("{} passed | {} failed\n", passed, failed); @@ -340,8 +347,8 @@ fn librustc_brackets(mut librustc_expr: P<ast::Expr>) -> Option<P<ast::Expr>> { /// reveal the precedence of the parsed expressions, and produce a stringified /// form of the resulting expression. fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr { - use syn::fold::*; - use syn::*; + use syn::fold::{fold_expr, fold_generic_argument, fold_generic_method_argument, Fold}; + use syn::{token, Expr, ExprParen, GenericArgument, GenericMethodArgument, Pat, Stmt, Type}; struct ParenthesizeEveryExpr; impl Fold for ParenthesizeEveryExpr { @@ -417,9 +424,9 @@ fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr { /// Walk through a crate collecting all expressions we can find in it. fn collect_exprs(file: syn::File) -> Vec<syn::Expr> { - use syn::fold::*; + use syn::fold::Fold; use syn::punctuated::Punctuated; - use syn::*; + use syn::{token, Expr, ExprTuple}; struct CollectExprs(Vec<Expr>); impl Fold for CollectExprs { diff --git a/tests/test_round_trip.rs b/tests/test_round_trip.rs index f350c3fa..6c1cf222 100644 --- a/tests/test_round_trip.rs +++ b/tests/test_round_trip.rs @@ -1,6 +1,8 @@ #![cfg(not(syn_disable_nightly_tests))] +#![cfg(not(miri))] #![recursion_limit = "1024"] #![feature(rustc_private)] +#![allow(clippy::manual_assert)] extern crate rustc_ast; extern crate rustc_errors; @@ -62,7 +64,7 @@ fn test_round_trip() { } }); - let failed = failed.load(Ordering::SeqCst); + let failed = failed.load(Ordering::Relaxed); if failed > 0 { panic!("{} failures", failed); } @@ -76,7 +78,7 @@ fn test(path: &Path, failed: &AtomicUsize, abort_after: usize) { Ok(krate) => (krate, start.elapsed()), Err(msg) => { errorf!("=== {}: syn failed to parse\n{:?}\n", path.display(), msg); - let prev_failed = failed.fetch_add(1, Ordering::SeqCst); + let prev_failed = failed.fetch_add(1, Ordering::Relaxed); if prev_failed + 1 >= abort_after { process::exit(1); } @@ -145,7 +147,7 @@ fn test(path: &Path, failed: &AtomicUsize, abort_after: usize) { } }; if !equal { - let prev_failed = failed.fetch_add(1, Ordering::SeqCst); + let prev_failed = failed.fetch_add(1, Ordering::Relaxed); if prev_failed + 1 >= abort_after { process::exit(1); } diff --git a/tests/test_size.rs b/tests/test_size.rs index 01e84011..e172df2b 100644 --- a/tests/test_size.rs +++ b/tests/test_size.rs @@ -1,7 +1,7 @@ #![cfg(target_pointer_width = "64")] use std::mem; -use syn::*; +use syn::{Expr, Item, Lit, Pat, Type}; #[test] fn test_expr_size() { diff --git a/tests/test_stmt.rs b/tests/test_stmt.rs index 943d856e..dbe1c765 100644 --- a/tests/test_stmt.rs +++ b/tests/test_stmt.rs @@ -1,3 +1,5 @@ +#![allow(clippy::non_ascii_literal)] + #[macro_use] mod macros; diff --git a/tests/test_ty.rs b/tests/test_ty.rs index 907fb201..a03abaa3 100644 --- a/tests/test_ty.rs +++ b/tests/test_ty.rs @@ -285,3 +285,67 @@ fn test_trait_object() { syn::parse_str::<Type>("for<'a> dyn Trait<'a>").unwrap_err(); syn::parse_str::<Type>("dyn for<'a> 'a + Trait").unwrap_err(); } + +#[test] +fn test_trailing_plus() { + #[rustfmt::skip] + let tokens = quote!(impl Trait +); + snapshot!(tokens as Type, @r###" + Type::ImplTrait { + bounds: [ + Trait(TraitBound { + modifier: None, + path: Path { + segments: [ + PathSegment { + ident: "Trait", + arguments: None, + }, + ], + }, + }), + ], + } + "###); + + #[rustfmt::skip] + let tokens = quote!(dyn Trait +); + snapshot!(tokens as Type, @r###" + Type::TraitObject { + dyn_token: Some, + bounds: [ + Trait(TraitBound { + modifier: None, + path: Path { + segments: [ + PathSegment { + ident: "Trait", + arguments: None, + }, + ], + }, + }), + ], + } + "###); + + #[rustfmt::skip] + let tokens = quote!(Trait +); + snapshot!(tokens as Type, @r###" + Type::TraitObject { + bounds: [ + Trait(TraitBound { + modifier: None, + path: Path { + segments: [ + PathSegment { + ident: "Trait", + arguments: None, + }, + ], + }, + }), + ], + } + "###); +} |