From 631cd5845e8de329d0e227aaa707d7ea228b8f8f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:20:29 +0200 Subject: Merging upstream version 1.70.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/syn/tests/common/eq.rs | 97 +- vendor/syn/tests/common/parse.rs | 5 +- vendor/syn/tests/debug/gen.rs | 3861 +++++++++++------------------- vendor/syn/tests/debug/mod.rs | 18 + vendor/syn/tests/regression.rs | 2 + vendor/syn/tests/regression/issue1108.rs | 2 +- vendor/syn/tests/repo/mod.rs | 150 +- vendor/syn/tests/test_asyncness.rs | 8 +- vendor/syn/tests/test_attribute.rs | 171 +- vendor/syn/tests/test_derive_input.rs | 277 +-- vendor/syn/tests/test_expr.rs | 64 +- vendor/syn/tests/test_generics.rs | 69 +- vendor/syn/tests/test_grouping.rs | 9 +- vendor/syn/tests/test_item.rs | 54 +- vendor/syn/tests/test_iterators.rs | 2 + vendor/syn/tests/test_lit.rs | 11 +- vendor/syn/tests/test_meta.rs | 271 +-- vendor/syn/tests/test_parse_buffer.rs | 1 - vendor/syn/tests/test_parse_stream.rs | 10 +- vendor/syn/tests/test_pat.rs | 52 +- vendor/syn/tests/test_path.rs | 38 +- vendor/syn/tests/test_precedence.rs | 189 +- vendor/syn/tests/test_receiver.rs | 328 ++- vendor/syn/tests/test_round_trip.rs | 24 +- vendor/syn/tests/test_shebang.rs | 30 +- vendor/syn/tests/test_size.rs | 15 +- vendor/syn/tests/test_stmt.rs | 187 +- vendor/syn/tests/test_token_trees.rs | 2 + vendor/syn/tests/test_ty.rs | 53 +- vendor/syn/tests/test_visibility.rs | 12 +- 30 files changed, 2546 insertions(+), 3466 deletions(-) (limited to 'vendor/syn/tests') diff --git a/vendor/syn/tests/common/eq.rs b/vendor/syn/tests/common/eq.rs index 41d6d4118..70a533768 100644 --- a/vendor/syn/tests/common/eq.rs +++ b/vendor/syn/tests/common/eq.rs @@ -2,6 +2,7 @@ extern crate rustc_ast; extern crate rustc_data_structures; +extern crate rustc_driver; extern crate rustc_span; extern crate thin_vec; @@ -48,6 +49,20 @@ use rustc_ast::ast::FnRetTy; use rustc_ast::ast::FnSig; use rustc_ast::ast::ForeignItemKind; use rustc_ast::ast::ForeignMod; +use rustc_ast::ast::FormatAlignment; +use rustc_ast::ast::FormatArgPosition; +use rustc_ast::ast::FormatArgPositionKind; +use rustc_ast::ast::FormatArgs; +use rustc_ast::ast::FormatArgsPiece; +use rustc_ast::ast::FormatArgument; +use rustc_ast::ast::FormatArgumentKind; +use rustc_ast::ast::FormatArguments; +use rustc_ast::ast::FormatCount; +use rustc_ast::ast::FormatDebugHex; +use rustc_ast::ast::FormatOptions; +use rustc_ast::ast::FormatPlaceholder; +use rustc_ast::ast::FormatSign; +use rustc_ast::ast::FormatTrait; use rustc_ast::ast::GenericArg; use rustc_ast::ast::GenericArgs; use rustc_ast::ast::GenericBound; @@ -140,6 +155,8 @@ use rustc_data_structures::sync::Lrc; use rustc_span::source_map::Spanned; use rustc_span::symbol::{sym, Ident}; use rustc_span::{Span, Symbol, SyntaxContext, DUMMY_SP}; +use std::collections::HashMap; +use std::hash::{BuildHasher, Hash}; use thin_vec::ThinVec; pub trait SpanlessEq { @@ -174,6 +191,16 @@ impl SpanlessEq for Option { } } +impl SpanlessEq for Result { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Ok(this), Ok(other)) => SpanlessEq::eq(this, other), + (Err(this), Err(other)) => SpanlessEq::eq(this, other), + _ => false, + } + } +} + impl SpanlessEq for [T] { fn eq(&self, other: &Self) -> bool { self.len() == other.len() && self.iter().zip(other).all(|(a, b)| SpanlessEq::eq(a, b)) @@ -196,6 +223,17 @@ impl SpanlessEq for ThinVec { } } +impl SpanlessEq for HashMap { + fn eq(&self, other: &Self) -> bool { + self.len() == other.len() + && self.iter().all(|(key, this_v)| { + other + .get(key) + .map_or(false, |other_v| SpanlessEq::eq(this_v, other_v)) + }) + } +} + impl SpanlessEq for Spanned { fn eq(&self, other: &Self) -> bool { SpanlessEq::eq(&self.node, &other.node) @@ -246,6 +284,7 @@ macro_rules! spanless_eq_partial_eq { spanless_eq_partial_eq!(bool); spanless_eq_partial_eq!(u8); spanless_eq_partial_eq!(u16); +spanless_eq_partial_eq!(u32); spanless_eq_partial_eq!(u128); spanless_eq_partial_eq!(usize); spanless_eq_partial_eq!(char); @@ -414,18 +453,23 @@ spanless_eq_struct!(AttributesData; attrs tokens); spanless_eq_struct!(BareFnTy; unsafety ext generic_params decl decl_span); spanless_eq_struct!(BindingAnnotation; 0 1); spanless_eq_struct!(Block; stmts id rules span tokens could_be_bare_literal); -spanless_eq_struct!(Closure; binder capture_clause asyncness movability fn_decl body !fn_decl_span); +spanless_eq_struct!(Closure; binder capture_clause constness asyncness movability fn_decl body !fn_decl_span !fn_arg_span); spanless_eq_struct!(Crate; attrs items spans id is_placeholder); spanless_eq_struct!(DelimArgs; dspan delim tokens); 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!(Fn; defaultness generics sig body); spanless_eq_struct!(FnDecl; inputs output); spanless_eq_struct!(FnHeader; constness asyncness unsafety ext); -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!(FormatArgPosition; index kind span); +spanless_eq_struct!(FormatArgs; span template arguments); +spanless_eq_struct!(FormatArgument; kind expr); +spanless_eq_struct!(FormatOptions; width precision alignment fill sign alternate zero_pad debug_hex); +spanless_eq_struct!(FormatPlaceholder; argument span format_trait format_options); spanless_eq_struct!(GenericParam; id ident attrs bounds is_placeholder kind !colon_span); spanless_eq_struct!(Generics; params where_clause span); spanless_eq_struct!(Impl; defaultness unsafety generics constness polarity of_trait self_ty items); @@ -439,7 +483,7 @@ 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); spanless_eq_struct!(MacroDef; body macro_rules); -spanless_eq_struct!(MetaItemLit; token_lit kind span); +spanless_eq_struct!(MetaItemLit; symbol suffix kind span); spanless_eq_struct!(MethodCall; seg receiver args !span); spanless_eq_struct!(ModSpans; !inner_span !inject_use_span); spanless_eq_struct!(MutTy; ty mutbl); @@ -452,7 +496,7 @@ spanless_eq_struct!(PathSegment; ident id args); spanless_eq_struct!(PolyTraitRef; bound_generic_params trait_ref span); spanless_eq_struct!(QSelf; ty path_span position); spanless_eq_struct!(Stmt; id kind span); -spanless_eq_struct!(StrLit; style symbol suffix span symbol_unescaped); +spanless_eq_struct!(StrLit; symbol suffix symbol_unescaped style span); spanless_eq_struct!(StructExpr; qself path fields rest); spanless_eq_struct!(Token; kind span); spanless_eq_struct!(Trait; unsafety is_auto generics bounds items); @@ -468,8 +512,8 @@ spanless_eq_struct!(WhereClause; has_where_token predicates span); spanless_eq_struct!(WhereEqPredicate; span lhs_ty rhs_ty); spanless_eq_struct!(WhereRegionPredicate; span lifetime bounds); spanless_eq_enum!(AngleBracketedArg; Arg(0) Constraint(0)); -spanless_eq_enum!(AssocItemKind; Const(0 1 2) Fn(0) Type(0) MacCall(0)); spanless_eq_enum!(AssocConstraintKind; Equality(term) Bound(bounds)); +spanless_eq_enum!(AssocItemKind; Const(0 1 2) Fn(0) Type(0) MacCall(0)); spanless_eq_enum!(Async; Yes(span closure_id return_impl_trait_id) No); spanless_eq_enum!(AttrArgs; Empty Delimited(0) Eq(0 1)); spanless_eq_enum!(AttrArgsEq; Ast(0) Hir(0)); @@ -487,6 +531,14 @@ spanless_eq_enum!(Extern; None Implicit(0) Explicit(0 1)); spanless_eq_enum!(FloatTy; F32 F64); spanless_eq_enum!(FnRetTy; Default(0) Ty(0)); spanless_eq_enum!(ForeignItemKind; Static(0 1 2) Fn(0) TyAlias(0) MacCall(0)); +spanless_eq_enum!(FormatAlignment; Left Right Center); +spanless_eq_enum!(FormatArgPositionKind; Implicit Number Named); +spanless_eq_enum!(FormatArgsPiece; Literal(0) Placeholder(0)); +spanless_eq_enum!(FormatArgumentKind; Normal Named(0) Captured(0)); +spanless_eq_enum!(FormatCount; Literal(0) Argument(0)); +spanless_eq_enum!(FormatDebugHex; Lower Upper); +spanless_eq_enum!(FormatSign; Plus Minus); +spanless_eq_enum!(FormatTrait; Display Debug LowerExp UpperExp Octal Pointer Binary LowerHex UpperHex); spanless_eq_enum!(GenericArg; Lifetime(0) Type(0) Const(0)); spanless_eq_enum!(GenericArgs; AngleBracketed(0) Parenthesized(0)); spanless_eq_enum!(GenericBound; Trait(0 1) Outlives(0)); @@ -522,26 +574,25 @@ spanless_eq_enum!(UseTreeKind; Simple(0) Nested(0) Glob); spanless_eq_enum!(VariantData; Struct(0 1) Tuple(0 1) Unit(0)); spanless_eq_enum!(VisibilityKind; Public Restricted(path id shorthand) Inherited); spanless_eq_enum!(WherePredicate; BoundPredicate(0) RegionPredicate(0) EqPredicate(0)); -spanless_eq_enum!(ExprKind; Box(0) Array(0) ConstBlock(0) Call(0 1) - MethodCall(0) Tup(0) Binary(0 1 2) Unary(0 1) Lit(0) Cast(0 1) Type(0 1) - Let(0 1 2) If(0 1 2) While(0 1 2) ForLoop(0 1 2 3) Loop(0 1 2) Match(0 1) - Closure(0) 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) MacCall(0) - Struct(0) Repeat(0 1) Paren(0) Try(0) Yield(0) Yeet(0) IncludedBytes(0) - Err); +spanless_eq_enum!(ExprKind; Array(0) ConstBlock(0) Call(0 1) MethodCall(0) + Tup(0) Binary(0 1 2) Unary(0 1) Lit(0) Cast(0 1) Type(0 1) Let(0 1 2) + If(0 1 2) While(0 1 2) ForLoop(0 1 2 3) Loop(0 1 2) Match(0 1) Closure(0) + 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) MacCall(0) Struct(0) Repeat(0 1) + Paren(0) Try(0) Yield(0) Yeet(0) IncludedBytes(0) FormatArgs(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(sym)); spanless_eq_enum!(ItemKind; ExternCrate(0) Use(0) Static(0 1 2) Const(0 1 2) Fn(0) Mod(0 1) ForeignMod(0) GlobalAsm(0) TyAlias(0) Enum(0 1) Struct(0 1) Union(0 1) Trait(0) TraitAlias(0 1) Impl(0) MacCall(0) MacroDef(0)); -spanless_eq_enum!(LitKind; Str(0 1) ByteStr(0) Byte(0) Char(0) Int(0 1) +spanless_eq_enum!(LitKind; Str(0 1) ByteStr(0 1) Byte(0) Char(0) Int(0 1) Float(0 1) Bool(0) Err); 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 +spanless_eq_enum!(TyKind; Slice(0) Array(0 1) Ptr(0) Ref(0 1) BareFn(0) Never Tup(0) Path(0 1) TraitObject(0 1) ImplTrait(0 1) Paren(0) Typeof(0) Infer ImplicitSelf MacCall(0) Err CVarArgs); @@ -591,7 +642,7 @@ impl SpanlessEq for TokenKind { fn eq(&self, other: &Self) -> bool { match (self, other) { (TokenKind::Literal(this), TokenKind::Literal(other)) => SpanlessEq::eq(this, other), - (TokenKind::DotDotEq, _) | (TokenKind::DotDotDot, _) => match other { + (TokenKind::DotDotEq | TokenKind::DotDotDot, _) => match other { TokenKind::DotDotEq | TokenKind::DotDotDot => true, _ => false, }, @@ -734,12 +785,8 @@ fn is_escaped_literal_attr_args(value: &AttrArgsEq, unescaped: Symbol) -> bool { fn is_escaped_literal_meta_item_lit(lit: &MetaItemLit, unescaped: Symbol) -> bool { match lit { MetaItemLit { - token_lit: - Lit { - kind: token::LitKind::Str, - symbol: _, - suffix: None, - }, + symbol: _, + suffix: None, kind, span: _, } => is_escaped_lit_kind(kind, unescaped), @@ -804,3 +851,9 @@ impl SpanlessEq for AttrKind { } } } + +impl SpanlessEq for FormatArguments { + fn eq(&self, other: &Self) -> bool { + SpanlessEq::eq(self.all_args(), other.all_args()) + } +} diff --git a/vendor/syn/tests/common/parse.rs b/vendor/syn/tests/common/parse.rs index 636d0a37a..73be10186 100644 --- a/vendor/syn/tests/common/parse.rs +++ b/vendor/syn/tests/common/parse.rs @@ -1,4 +1,5 @@ extern crate rustc_ast; +extern crate rustc_driver; extern crate rustc_expand; extern crate rustc_parse as parse; extern crate rustc_session; @@ -13,7 +14,9 @@ use std::panic; pub fn librustc_expr(input: &str) -> Option> { match panic::catch_unwind(|| { - let sess = ParseSess::new(FilePathMapping::empty()); + let locale_resources = rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(); + let file_path_mapping = FilePathMapping::empty(); + let sess = ParseSess::new(locale_resources, file_path_mapping); let e = parse::new_parser_from_source_str( &sess, FileName::Custom("test_precedence".to_string()), diff --git a/vendor/syn/tests/debug/gen.rs b/vendor/syn/tests/debug/gen.rs index cfd63d117..b64cc3e7e 100644 --- a/vendor/syn/tests/debug/gen.rs +++ b/vendor/syn/tests/debug/gen.rs @@ -1,22 +1,21 @@ // This file is @generated by syn-internal-codegen. // It is not intended for manual editing. -use super::{Lite, RefCast}; +#![allow(clippy::match_wildcard_for_single_variants)] +use super::{Lite, Present}; +use ref_cast::RefCast; use std::fmt::{self, Debug, Display}; impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Abi"); - if let Some(val) = &_val.name { + if let Some(val) = &self.value.name { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::LitStr); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -28,73 +27,94 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("AngleBracketedGenericArguments"); - if let Some(val) = &_val.colon2_token { + if self.value.colon2_token.is_some() { + formatter.field("colon2_token", &Present); + } + if !self.value.args.is_empty() { + formatter.field("args", Lite(&self.value.args)); + } + formatter.finish() + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("Arm"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + formatter.field("pat", Lite(&self.value.pat)); + if let Some(val) = &self.value.guard { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Colon2); + struct Print((syn::token::If, Box)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("colon2_token", Print::ref_cast(val)); + formatter.field("guard", Print::ref_cast(val)); } - if !_val.args.is_empty() { - formatter.field("args", Lite(&_val.args)); + formatter.field("body", Lite(&self.value.body)); + if self.value.comma.is_some() { + formatter.field("comma", &Present); } formatter.finish() } } -impl Debug for Lite { +impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("Arm"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("pat", Lite(&_val.pat)); - if let Some(val) = &_val.guard { + let mut formatter = formatter.debug_struct("AssocConst"); + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.generics { #[derive(RefCast)] #[repr(transparent)] - struct Print((syn::token::If, Box)); + struct Print(syn::AngleBracketedGenericArguments); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } - formatter.field("guard", Print::ref_cast(val)); + formatter.field("generics", Print::ref_cast(val)); } - formatter.field("body", Lite(&_val.body)); - if let Some(val) = &_val.comma { + formatter.field("value", Lite(&self.value.value)); + formatter.finish() + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("AssocType"); + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.generics { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Comma); + struct Print(syn::AngleBracketedGenericArguments); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("comma", Print::ref_cast(val)); + formatter.field("generics", Print::ref_cast(val)); } + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::AttrStyle::Outer => formatter.write_str("Outer"), + match &self.value { + syn::AttrStyle::Outer => formatter.write_str("AttrStyle::Outer"), syn::AttrStyle::Inner(_val) => { - formatter.write_str("Inner")?; + formatter.write_str("AttrStyle::Inner")?; Ok(()) } } @@ -102,220 +122,218 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Attribute"); - formatter.field("style", Lite(&_val.style)); - formatter.field("path", Lite(&_val.path)); - formatter.field("tokens", Lite(&_val.tokens)); + formatter.field("style", Lite(&self.value.style)); + formatter.field("meta", Lite(&self.value.meta)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("BareFnArg"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + if let Some(val) = &self.value.name { + #[derive(RefCast)] + #[repr(transparent)] + struct Print((proc_macro2::Ident, syn::token::Colon)); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("name", Print::ref_cast(val)); + } + formatter.field("ty", Lite(&self.value.ty)); + formatter.finish() + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("BareVariadic"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.name { + if let Some(val) = &self.value.name { #[derive(RefCast)] #[repr(transparent)] struct Print((proc_macro2::Ident, syn::token::Colon)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.0), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("name", Print::ref_cast(val)); } - formatter.field("ty", Lite(&_val.ty)); + if self.value.comma.is_some() { + formatter.field("comma", &Present); + } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::BinOp::Add(_val) => { - formatter.write_str("Add")?; + formatter.write_str("BinOp::Add")?; Ok(()) } syn::BinOp::Sub(_val) => { - formatter.write_str("Sub")?; + formatter.write_str("BinOp::Sub")?; Ok(()) } syn::BinOp::Mul(_val) => { - formatter.write_str("Mul")?; + formatter.write_str("BinOp::Mul")?; Ok(()) } syn::BinOp::Div(_val) => { - formatter.write_str("Div")?; + formatter.write_str("BinOp::Div")?; Ok(()) } syn::BinOp::Rem(_val) => { - formatter.write_str("Rem")?; + formatter.write_str("BinOp::Rem")?; Ok(()) } syn::BinOp::And(_val) => { - formatter.write_str("And")?; + formatter.write_str("BinOp::And")?; Ok(()) } syn::BinOp::Or(_val) => { - formatter.write_str("Or")?; + formatter.write_str("BinOp::Or")?; Ok(()) } syn::BinOp::BitXor(_val) => { - formatter.write_str("BitXor")?; + formatter.write_str("BinOp::BitXor")?; Ok(()) } syn::BinOp::BitAnd(_val) => { - formatter.write_str("BitAnd")?; + formatter.write_str("BinOp::BitAnd")?; Ok(()) } syn::BinOp::BitOr(_val) => { - formatter.write_str("BitOr")?; + formatter.write_str("BinOp::BitOr")?; Ok(()) } syn::BinOp::Shl(_val) => { - formatter.write_str("Shl")?; + formatter.write_str("BinOp::Shl")?; Ok(()) } syn::BinOp::Shr(_val) => { - formatter.write_str("Shr")?; + formatter.write_str("BinOp::Shr")?; Ok(()) } syn::BinOp::Eq(_val) => { - formatter.write_str("Eq")?; + formatter.write_str("BinOp::Eq")?; Ok(()) } syn::BinOp::Lt(_val) => { - formatter.write_str("Lt")?; + formatter.write_str("BinOp::Lt")?; Ok(()) } syn::BinOp::Le(_val) => { - formatter.write_str("Le")?; + formatter.write_str("BinOp::Le")?; Ok(()) } syn::BinOp::Ne(_val) => { - formatter.write_str("Ne")?; + formatter.write_str("BinOp::Ne")?; Ok(()) } syn::BinOp::Ge(_val) => { - formatter.write_str("Ge")?; + formatter.write_str("BinOp::Ge")?; Ok(()) } syn::BinOp::Gt(_val) => { - formatter.write_str("Gt")?; + formatter.write_str("BinOp::Gt")?; Ok(()) } - syn::BinOp::AddEq(_val) => { - formatter.write_str("AddEq")?; + syn::BinOp::AddAssign(_val) => { + formatter.write_str("BinOp::AddAssign")?; Ok(()) } - syn::BinOp::SubEq(_val) => { - formatter.write_str("SubEq")?; + syn::BinOp::SubAssign(_val) => { + formatter.write_str("BinOp::SubAssign")?; Ok(()) } - syn::BinOp::MulEq(_val) => { - formatter.write_str("MulEq")?; + syn::BinOp::MulAssign(_val) => { + formatter.write_str("BinOp::MulAssign")?; Ok(()) } - syn::BinOp::DivEq(_val) => { - formatter.write_str("DivEq")?; + syn::BinOp::DivAssign(_val) => { + formatter.write_str("BinOp::DivAssign")?; Ok(()) } - syn::BinOp::RemEq(_val) => { - formatter.write_str("RemEq")?; + syn::BinOp::RemAssign(_val) => { + formatter.write_str("BinOp::RemAssign")?; Ok(()) } - syn::BinOp::BitXorEq(_val) => { - formatter.write_str("BitXorEq")?; + syn::BinOp::BitXorAssign(_val) => { + formatter.write_str("BinOp::BitXorAssign")?; Ok(()) } - syn::BinOp::BitAndEq(_val) => { - formatter.write_str("BitAndEq")?; + syn::BinOp::BitAndAssign(_val) => { + formatter.write_str("BinOp::BitAndAssign")?; Ok(()) } - syn::BinOp::BitOrEq(_val) => { - formatter.write_str("BitOrEq")?; + syn::BinOp::BitOrAssign(_val) => { + formatter.write_str("BinOp::BitOrAssign")?; Ok(()) } - syn::BinOp::ShlEq(_val) => { - formatter.write_str("ShlEq")?; + syn::BinOp::ShlAssign(_val) => { + formatter.write_str("BinOp::ShlAssign")?; Ok(()) } - syn::BinOp::ShrEq(_val) => { - formatter.write_str("ShrEq")?; + syn::BinOp::ShrAssign(_val) => { + formatter.write_str("BinOp::ShrAssign")?; Ok(()) } + _ => unreachable!(), } } } -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("Binding"); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - formatter.finish() - } -} impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Block"); - if !_val.stmts.is_empty() { - formatter.field("stmts", Lite(&_val.stmts)); + if !self.value.stmts.is_empty() { + formatter.field("stmts", Lite(&self.value.stmts)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("BoundLifetimes"); - if !_val.lifetimes.is_empty() { - formatter.field("lifetimes", Lite(&_val.lifetimes)); + if !self.value.lifetimes.is_empty() { + formatter.field("lifetimes", Lite(&self.value.lifetimes)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ConstParam"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - if let Some(val) = &_val.eq_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Eq); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("eq_token", Print::ref_cast(val)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("ty", Lite(&self.value.ty)); + if self.value.eq_token.is_some() { + formatter.field("eq_token", &Present); } - if let Some(val) = &_val.default { + if let Some(val) = &self.value.default { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Expr); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -327,33 +345,36 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Constraint"); - formatter.field("ident", Lite(&_val.ident)); - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.generics { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::AngleBracketedGenericArguments); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("generics", Print::ref_cast(val)); + } + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Data::Struct(_val) => { let mut formatter = formatter.debug_struct("Data::Struct"); formatter.field("fields", Lite(&_val.fields)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } @@ -374,60 +395,46 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("DataEnum"); - if !_val.variants.is_empty() { - formatter.field("variants", Lite(&_val.variants)); + if !self.value.variants.is_empty() { + formatter.field("variants", Lite(&self.value.variants)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("DataStruct"); - formatter.field("fields", Lite(&_val.fields)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + formatter.field("fields", Lite(&self.value.fields)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("DataUnion"); - formatter.field("fields", Lite(&_val.fields)); + formatter.field("fields", Lite(&self.value.fields)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("DeriveInput"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - formatter.field("data", Lite(&_val.data)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("data", Lite(&self.value.data)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Expr::Array(_val) => { let mut formatter = formatter.debug_struct("Expr::Array"); if !_val.attrs.is_empty() { @@ -447,32 +454,13 @@ impl Debug for Lite { formatter.field("right", Lite(&_val.right)); formatter.finish() } - syn::Expr::AssignOp(_val) => { - let mut formatter = formatter.debug_struct("Expr::AssignOp"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("left", Lite(&_val.left)); - formatter.field("op", Lite(&_val.op)); - formatter.field("right", Lite(&_val.right)); - formatter.finish() - } syn::Expr::Async(_val) => { let mut formatter = formatter.debug_struct("Expr::Async"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.capture { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Move); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("capture", Print::ref_cast(val)); + if _val.capture.is_some() { + formatter.field("capture", &Present); } formatter.field("block", Lite(&_val.block)); formatter.finish() @@ -506,10 +494,8 @@ impl Debug for Lite { struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -519,14 +505,6 @@ impl Debug for Lite { formatter.field("block", Lite(&_val.block)); formatter.finish() } - syn::Expr::Box(_val) => { - let mut formatter = formatter.debug_struct("Expr::Box"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("expr", Lite(&_val.expr)); - formatter.finish() - } syn::Expr::Break(_val) => { let mut formatter = formatter.debug_struct("Expr::Break"); if !_val.attrs.is_empty() { @@ -538,10 +516,8 @@ impl Debug for Lite { struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -554,10 +530,8 @@ impl Debug for Lite { struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -591,41 +565,31 @@ impl Debug for Lite { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.movability { + if let Some(val) = &_val.lifetimes { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Static); + struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("movability", Print::ref_cast(val)); + formatter.field("lifetimes", Print::ref_cast(val)); } - if let Some(val) = &_val.asyncness { - #[derive(RefCast)] - #[repr(transparent)] - 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("asyncness", Print::ref_cast(val)); + if _val.constness.is_some() { + formatter.field("constness", &Present); } - if let Some(val) = &_val.capture { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Move); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("capture", Print::ref_cast(val)); + if _val.movability.is_some() { + formatter.field("movability", &Present); + } + if _val.asyncness.is_some() { + formatter.field("asyncness", &Present); + } + if _val.capture.is_some() { + formatter.field("capture", &Present); } if !_val.inputs.is_empty() { formatter.field("inputs", Lite(&_val.inputs)); @@ -634,6 +598,14 @@ impl Debug for Lite { formatter.field("body", Lite(&_val.body)); formatter.finish() } + syn::Expr::Const(_val) => { + let mut formatter = formatter.debug_struct("Expr::Const"); + if !_val.attrs.is_empty() { + formatter.field("attrs", Lite(&_val.attrs)); + } + formatter.field("block", Lite(&_val.block)); + formatter.finish() + } syn::Expr::Continue(_val) => { let mut formatter = formatter.debug_struct("Expr::Continue"); if !_val.attrs.is_empty() { @@ -645,10 +617,8 @@ impl Debug for Lite { struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -677,10 +647,8 @@ impl Debug for Lite { struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -713,10 +681,8 @@ impl Debug for Lite { struct Print((syn::token::Else, Box)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -734,6 +700,13 @@ impl Debug for Lite { formatter.field("index", Lite(&_val.index)); formatter.finish() } + syn::Expr::Infer(_val) => { + let mut formatter = formatter.debug_struct("Expr::Infer"); + if !_val.attrs.is_empty() { + formatter.field("attrs", Lite(&_val.attrs)); + } + formatter.finish() + } syn::Expr::Let(_val) => { let mut formatter = formatter.debug_struct("Expr::Let"); if !_val.attrs.is_empty() { @@ -762,10 +735,8 @@ impl Debug for Lite { struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -804,13 +775,11 @@ impl Debug for Lite { if let Some(val) = &_val.turbofish { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::MethodTurbofish); + struct Print(syn::AngleBracketedGenericArguments); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -841,10 +810,8 @@ impl Debug for Lite { struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -859,38 +826,34 @@ impl Debug for Lite { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.from { + if let Some(val) = &_val.start { #[derive(RefCast)] #[repr(transparent)] struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } - formatter.field("from", Print::ref_cast(val)); + formatter.field("start", Print::ref_cast(val)); } formatter.field("limits", Lite(&_val.limits)); - if let Some(val) = &_val.to { + if let Some(val) = &_val.end { #[derive(RefCast)] #[repr(transparent)] struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } - formatter.field("to", Print::ref_cast(val)); + formatter.field("end", Print::ref_cast(val)); } formatter.finish() } @@ -899,17 +862,8 @@ impl Debug for Lite { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if _val.mutability.is_some() { + formatter.field("mutability", &Present); } formatter.field("expr", Lite(&_val.expr)); formatter.finish() @@ -934,10 +888,8 @@ impl Debug for Lite { struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -951,21 +903,26 @@ impl Debug for Lite { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - formatter.field("path", Lite(&_val.path)); - if !_val.fields.is_empty() { - formatter.field("fields", Lite(&_val.fields)); - } - if let Some(val) = &_val.dot2_token { + if let Some(val) = &_val.qself { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Dot2); + struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("dot2_token", Print::ref_cast(val)); + formatter.field("qself", Print::ref_cast(val)); + } + formatter.field("path", Lite(&_val.path)); + if !_val.fields.is_empty() { + formatter.field("fields", Lite(&_val.fields)); + } + if _val.dot2_token.is_some() { + formatter.field("dot2_token", &Present); } if let Some(val) = &_val.rest { #[derive(RefCast)] @@ -973,10 +930,8 @@ impl Debug for Lite { struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1011,15 +966,6 @@ impl Debug for Lite { } formatter.finish() } - syn::Expr::Type(_val) => { - let mut formatter = formatter.debug_struct("Expr::Type"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("expr", Lite(&_val.expr)); - formatter.field("ty", Lite(&_val.ty)); - formatter.finish() - } syn::Expr::Unary(_val) => { let mut formatter = formatter.debug_struct("Expr::Unary"); if !_val.attrs.is_empty() { @@ -1038,7 +984,7 @@ impl Debug for Lite { formatter.finish() } syn::Expr::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("Expr::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -1055,10 +1001,8 @@ impl Debug for Lite { struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1080,10 +1024,8 @@ impl Debug for Lite { struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1098,160 +1040,114 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprArray"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if !_val.elems.is_empty() { - formatter.field("elems", Lite(&_val.elems)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprAssign"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("left", Lite(&_val.left)); - formatter.field("right", Lite(&_val.right)); - formatter.finish() - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ExprAssignOp"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("left", Lite(&_val.left)); - formatter.field("op", Lite(&_val.op)); - formatter.field("right", Lite(&_val.right)); + formatter.field("left", Lite(&self.value.left)); + formatter.field("right", Lite(&self.value.right)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprAsync"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.capture { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Move); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("capture", Print::ref_cast(val)); + if self.value.capture.is_some() { + formatter.field("capture", &Present); } - formatter.field("block", Lite(&_val.block)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprAwait"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("base", Lite(&_val.base)); + formatter.field("base", Lite(&self.value.base)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprBinary"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("left", Lite(&_val.left)); - formatter.field("op", Lite(&_val.op)); - formatter.field("right", Lite(&_val.right)); + formatter.field("left", Lite(&self.value.left)); + formatter.field("op", Lite(&self.value.op)); + formatter.field("right", Lite(&self.value.right)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprBlock"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("label", Print::ref_cast(val)); } - formatter.field("block", Lite(&_val.block)); - formatter.finish() - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ExprBox"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprBreak"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("label", Print::ref_cast(val)); } - if let Some(val) = &_val.expr { + if let Some(val) = &self.value.expr { #[derive(RefCast)] #[repr(transparent)] struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1263,98 +1159,92 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprCall"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("func", Lite(&_val.func)); - if !_val.args.is_empty() { - formatter.field("args", Lite(&_val.args)); + formatter.field("func", Lite(&self.value.func)); + if !self.value.args.is_empty() { + formatter.field("args", Lite(&self.value.args)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprCast"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); - formatter.field("ty", Lite(&_val.ty)); + formatter.field("expr", Lite(&self.value.expr)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprClosure"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.movability { + if let Some(val) = &self.value.lifetimes { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Static); + struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("movability", Print::ref_cast(val)); + formatter.field("lifetimes", Print::ref_cast(val)); } - if let Some(val) = &_val.asyncness { - #[derive(RefCast)] - #[repr(transparent)] - 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("asyncness", Print::ref_cast(val)); + if self.value.constness.is_some() { + formatter.field("constness", &Present); } - if let Some(val) = &_val.capture { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Move); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("capture", Print::ref_cast(val)); + if self.value.movability.is_some() { + formatter.field("movability", &Present); + } + if self.value.asyncness.is_some() { + formatter.field("asyncness", &Present); } - if !_val.inputs.is_empty() { - formatter.field("inputs", Lite(&_val.inputs)); + if self.value.capture.is_some() { + formatter.field("capture", &Present); + } + if !self.value.inputs.is_empty() { + formatter.field("inputs", Lite(&self.value.inputs)); + } + formatter.field("output", Lite(&self.value.output)); + formatter.field("body", Lite(&self.value.body)); + formatter.finish() + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("ExprConst"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("output", Lite(&_val.output)); - formatter.field("body", Lite(&_val.body)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprContinue"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1366,75 +1256,67 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprField"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("base", Lite(&_val.base)); - formatter.field("member", Lite(&_val.member)); + formatter.field("base", Lite(&self.value.base)); + formatter.field("member", Lite(&self.value.member)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprForLoop"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("label", Print::ref_cast(val)); } - formatter.field("pat", Lite(&_val.pat)); - formatter.field("expr", Lite(&_val.expr)); - formatter.field("body", Lite(&_val.body)); + formatter.field("pat", Lite(&self.value.pat)); + formatter.field("expr", Lite(&self.value.expr)); + formatter.field("body", Lite(&self.value.body)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprGroup"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprIf"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("cond", Lite(&_val.cond)); - formatter.field("then_branch", Lite(&_val.then_branch)); - if let Some(val) = &_val.else_branch { + formatter.field("cond", Lite(&self.value.cond)); + formatter.field("then_branch", Lite(&self.value.then_branch)); + if let Some(val) = &self.value.else_branch { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::Else, Box)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1446,255 +1328,230 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprIndex"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + formatter.field("expr", Lite(&self.value.expr)); + formatter.field("index", Lite(&self.value.index)); + formatter.finish() + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("ExprInfer"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); - formatter.field("index", Lite(&_val.index)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprLet"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("pat", Lite(&_val.pat)); - formatter.field("expr", Lite(&_val.expr)); + formatter.field("pat", Lite(&self.value.pat)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprLit"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("lit", Lite(&_val.lit)); + formatter.field("lit", Lite(&self.value.lit)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprLoop"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("label", Print::ref_cast(val)); } - formatter.field("body", Lite(&_val.body)); + formatter.field("body", Lite(&self.value.body)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("mac", Lite(&_val.mac)); + formatter.field("mac", Lite(&self.value.mac)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprMatch"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); - if !_val.arms.is_empty() { - formatter.field("arms", Lite(&_val.arms)); + formatter.field("expr", Lite(&self.value.expr)); + if !self.value.arms.is_empty() { + formatter.field("arms", Lite(&self.value.arms)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprMethodCall"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("receiver", Lite(&_val.receiver)); - formatter.field("method", Lite(&_val.method)); - if let Some(val) = &_val.turbofish { + formatter.field("receiver", Lite(&self.value.receiver)); + formatter.field("method", Lite(&self.value.method)); + if let Some(val) = &self.value.turbofish { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::MethodTurbofish); + struct Print(syn::AngleBracketedGenericArguments); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("turbofish", Print::ref_cast(val)); } - if !_val.args.is_empty() { - formatter.field("args", Lite(&_val.args)); + if !self.value.args.is_empty() { + formatter.field("args", Lite(&self.value.args)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprParen"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprPath"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.qself { + if let Some(val) = &self.value.qself { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("qself", Print::ref_cast(val)); } - formatter.field("path", Lite(&_val.path)); + formatter.field("path", Lite(&self.value.path)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprRange"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.from { + if let Some(val) = &self.value.start { #[derive(RefCast)] #[repr(transparent)] struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } - formatter.field("from", Print::ref_cast(val)); + formatter.field("start", Print::ref_cast(val)); } - formatter.field("limits", Lite(&_val.limits)); - if let Some(val) = &_val.to { + formatter.field("limits", Lite(&self.value.limits)); + if let Some(val) = &self.value.end { #[derive(RefCast)] #[repr(transparent)] struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } - formatter.field("to", Print::ref_cast(val)); + formatter.field("end", Print::ref_cast(val)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprReference"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprRepeat"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); - formatter.field("len", Lite(&_val.len)); + formatter.field("expr", Lite(&self.value.expr)); + formatter.field("len", Lite(&self.value.len)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprReturn"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.expr { + if let Some(val) = &self.value.expr { #[derive(RefCast)] #[repr(transparent)] struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1706,37 +1563,39 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprStruct"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("path", Lite(&_val.path)); - if !_val.fields.is_empty() { - formatter.field("fields", Lite(&_val.fields)); - } - if let Some(val) = &_val.dot2_token { + if let Some(val) = &self.value.qself { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Dot2); + struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("dot2_token", Print::ref_cast(val)); + formatter.field("qself", Print::ref_cast(val)); + } + formatter.field("path", Lite(&self.value.path)); + if !self.value.fields.is_empty() { + formatter.field("fields", Lite(&self.value.fields)); + } + if self.value.dot2_token.is_some() { + formatter.field("dot2_token", &Present); } - if let Some(val) = &_val.rest { + if let Some(val) = &self.value.rest { #[derive(RefCast)] #[repr(transparent)] struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1748,119 +1607,96 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprTry"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprTryBlock"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("block", Lite(&_val.block)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprTuple"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if !_val.elems.is_empty() { - formatter.field("elems", Lite(&_val.elems)); - } - formatter.finish() - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ExprType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } - formatter.field("expr", Lite(&_val.expr)); - formatter.field("ty", Lite(&_val.ty)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprUnary"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("op", Lite(&_val.op)); - formatter.field("expr", Lite(&_val.expr)); + formatter.field("op", Lite(&self.value.op)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprUnsafe"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("block", Lite(&_val.block)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprWhile"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("label", Print::ref_cast(val)); } - formatter.field("cond", Lite(&_val.cond)); - formatter.field("body", Lite(&_val.body)); + formatter.field("cond", Lite(&self.value.cond)); + formatter.field("body", Lite(&self.value.body)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprYield"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.expr { + if let Some(val) = &self.value.expr { #[derive(RefCast)] #[repr(transparent)] struct Print(Box); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1872,96 +1708,77 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Field"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + formatter.field("vis", Lite(&self.value.vis)); + match self.value.mutability { + syn::FieldMutability::None => {} + _ => { + formatter.field("mutability", Lite(&self.value.mutability)); + } } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.ident { + if let Some(val) = &self.value.ident { #[derive(RefCast)] #[repr(transparent)] struct Print(proc_macro2::Ident); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("ident", Print::ref_cast(val)); } - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - formatter.field("ty", Lite(&_val.ty)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + match &self.value { + syn::FieldMutability::None => formatter.write_str("FieldMutability::None"), + _ => unreachable!(), + } + } +} impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("FieldPat"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("member", Lite(&_val.member)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("member", Lite(&self.value.member)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - formatter.field("pat", Lite(&_val.pat)); + formatter.field("pat", Lite(&self.value.pat)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("FieldValue"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("member", Lite(&_val.member)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("member", Lite(&self.value.member)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Fields::Named(_val) => { let mut formatter = formatter.debug_struct("Fields::Named"); if !_val.named.is_empty() { @@ -1976,72 +1793,66 @@ impl Debug for Lite { } formatter.finish() } - syn::Fields::Unit => formatter.write_str("Unit"), + syn::Fields::Unit => formatter.write_str("Fields::Unit"), } } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("FieldsNamed"); - if !_val.named.is_empty() { - formatter.field("named", Lite(&_val.named)); + if !self.value.named.is_empty() { + formatter.field("named", Lite(&self.value.named)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("FieldsUnnamed"); - if !_val.unnamed.is_empty() { - formatter.field("unnamed", Lite(&_val.unnamed)); + if !self.value.unnamed.is_empty() { + formatter.field("unnamed", Lite(&self.value.unnamed)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("File"); - if let Some(val) = &_val.shebang { + if let Some(val) = &self.value.shebang { #[derive(RefCast)] #[repr(transparent)] struct Print(String); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("shebang", Print::ref_cast(val)); } - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if !_val.items.is_empty() { - formatter.field("items", Lite(&_val.items)); + if !self.value.items.is_empty() { + formatter.field("items", Lite(&self.value.items)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::FnArg::Receiver(_val) => { - formatter.write_str("Receiver")?; + formatter.write_str("FnArg::Receiver")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::FnArg::Typed(_val) => { - formatter.write_str("Typed")?; + formatter.write_str("FnArg::Typed")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; @@ -2052,8 +1863,7 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::ForeignItem::Fn(_val) => { let mut formatter = formatter.debug_struct("ForeignItem::Fn"); if !_val.attrs.is_empty() { @@ -2069,17 +1879,11 @@ impl Debug for Lite { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } + match _val.mutability { + syn::StaticMutability::None => {} + _ => { + formatter.field("mutability", Lite(&_val.mutability)); } - formatter.field("mutability", Print::ref_cast(val)); } formatter.field("ident", Lite(&_val.ident)); formatter.field("ty", Lite(&_val.ty)); @@ -2092,6 +1896,7 @@ impl Debug for Lite { } formatter.field("vis", Lite(&_val.vis)); formatter.field("ident", Lite(&_val.ident)); + formatter.field("generics", Lite(&_val.generics)); formatter.finish() } syn::ForeignItem::Macro(_val) => { @@ -2100,22 +1905,13 @@ impl Debug for Lite { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } syn::ForeignItem::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("ForeignItem::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -2127,159 +1923,126 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ForeignItemFn"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("sig", Lite(&_val.sig)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("sig", Lite(&self.value.sig)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ForeignItemMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + formatter.field("mac", Lite(&self.value.mac)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ForeignItemStatic"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } + formatter.field("vis", Lite(&self.value.vis)); + match self.value.mutability { + syn::StaticMutability::None => {} + _ => { + formatter.field("mutability", Lite(&self.value.mutability)); } - formatter.field("mutability", Print::ref_cast(val)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ForeignItemType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::GenericArgument::Lifetime(_val) => { - formatter.write_str("Lifetime")?; + formatter.write_str("GenericArgument::Lifetime")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::GenericArgument::Type(_val) => { - formatter.write_str("Type")?; + formatter.write_str("GenericArgument::Type")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::GenericArgument::Const(_val) => { - formatter.write_str("Const")?; + formatter.write_str("GenericArgument::Const")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::GenericArgument::Binding(_val) => { - formatter.write_str("Binding")?; + syn::GenericArgument::AssocType(_val) => { + formatter.write_str("GenericArgument::AssocType")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::GenericArgument::Constraint(_val) => { - formatter.write_str("Constraint")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - } - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::GenericMethodArgument::Type(_val) => { - formatter.write_str("Type")?; + syn::GenericArgument::AssocConst(_val) => { + formatter.write_str("GenericArgument::AssocConst")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::GenericMethodArgument::Const(_val) => { - formatter.write_str("Const")?; + syn::GenericArgument::Constraint(_val) => { + formatter.write_str("GenericArgument::Constraint")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } + _ => unreachable!(), } } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::GenericParam::Type(_val) => { - formatter.write_str("Type")?; + match &self.value { + syn::GenericParam::Lifetime(_val) => { + formatter.write_str("GenericParam::Lifetime")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::GenericParam::Lifetime(_val) => { - formatter.write_str("Lifetime")?; + syn::GenericParam::Type(_val) => { + formatter.write_str("GenericParam::Type")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::GenericParam::Const(_val) => { - formatter.write_str("Const")?; + formatter.write_str("GenericParam::Const")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; @@ -2290,45 +2053,24 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Generics"); - if let Some(val) = &_val.lt_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Lt); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("lt_token", Print::ref_cast(val)); + if self.value.lt_token.is_some() { + formatter.field("lt_token", &Present); } - if !_val.params.is_empty() { - formatter.field("params", Lite(&_val.params)); + if !self.value.params.is_empty() { + formatter.field("params", Lite(&self.value.params)); } - if let Some(val) = &_val.gt_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Gt); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("gt_token", Print::ref_cast(val)); + if self.value.gt_token.is_some() { + formatter.field("gt_token", &Present); } - if let Some(val) = &_val.where_clause { + if let Some(val) = &self.value.where_clause { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::WhereClause); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -2340,48 +2082,30 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::ImplItem::Const(_val) => { let mut formatter = formatter.debug_struct("ImplItem::Const"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + if _val.defaultness.is_some() { + formatter.field("defaultness", &Present); } formatter.field("ident", Lite(&_val.ident)); + formatter.field("generics", Lite(&_val.generics)); formatter.field("ty", Lite(&_val.ty)); formatter.field("expr", Lite(&_val.expr)); formatter.finish() } - syn::ImplItem::Method(_val) => { - let mut formatter = formatter.debug_struct("ImplItem::Method"); + syn::ImplItem::Fn(_val) => { + let mut formatter = formatter.debug_struct("ImplItem::Fn"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + if _val.defaultness.is_some() { + formatter.field("defaultness", &Present); } formatter.field("sig", Lite(&_val.sig)); formatter.field("block", Lite(&_val.block)); @@ -2393,17 +2117,8 @@ impl Debug for Lite { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + if _val.defaultness.is_some() { + formatter.field("defaultness", &Present); } formatter.field("ident", Lite(&_val.ident)); formatter.field("generics", Lite(&_val.generics)); @@ -2416,22 +2131,13 @@ impl Debug for Lite { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } syn::ImplItem::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("ImplItem::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -2443,116 +2149,80 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ImplItemConst"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + formatter.field("vis", Lite(&self.value.vis)); + if self.value.defaultness.is_some() { + formatter.field("defaultness", &Present); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - formatter.field("expr", Lite(&_val.expr)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("ty", Lite(&self.value.ty)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } -impl Debug for Lite { +impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ImplItemMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + let mut formatter = formatter.debug_struct("ImplItemFn"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + formatter.field("vis", Lite(&self.value.vis)); + if self.value.defaultness.is_some() { + formatter.field("defaultness", &Present); } + formatter.field("sig", Lite(&self.value.sig)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } -impl Debug for Lite { +impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ImplItemMethod"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + let mut formatter = formatter.debug_struct("ImplItemMacro"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + formatter.field("mac", Lite(&self.value.mac)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } - formatter.field("sig", Lite(&_val.sig)); - formatter.field("block", Lite(&_val.block)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ImplItemType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + formatter.field("vis", Lite(&self.value.vis)); + if self.value.defaultness.is_some() { + formatter.field("defaultness", &Present); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - formatter.field("ty", Lite(&_val.ty)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } +impl Debug for Lite { + fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { + unreachable!() + } +} impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Index"); - formatter.field("index", Lite(&_val.index)); + formatter.field("index", Lite(&self.value.index)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Item::Const(_val) => { let mut formatter = formatter.debug_struct("Item::Const"); if !_val.attrs.is_empty() { @@ -2560,6 +2230,7 @@ impl Debug for Lite { } formatter.field("vis", Lite(&_val.vis)); formatter.field("ident", Lite(&_val.ident)); + formatter.field("generics", Lite(&_val.generics)); formatter.field("ty", Lite(&_val.ty)); formatter.field("expr", Lite(&_val.expr)); formatter.finish() @@ -2590,10 +2261,8 @@ impl Debug for Lite { struct Print((syn::token::As, proc_macro2::Ident)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -2617,6 +2286,9 @@ impl Debug for Lite { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } + if _val.unsafety.is_some() { + formatter.field("unsafety", &Present); + } formatter.field("abi", Lite(&_val.abi)); if !_val.items.is_empty() { formatter.field("items", Lite(&_val.items)); @@ -2628,63 +2300,26 @@ impl Debug for Lite { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + if _val.defaultness.is_some() { + formatter.field("defaultness", &Present); } - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + if _val.unsafety.is_some() { + formatter.field("unsafety", &Present); } formatter.field("generics", Lite(&_val.generics)); if let Some(val) = &_val.trait_ { #[derive(RefCast)] #[repr(transparent)] - struct Print((Option, syn::Path, syn::token::For)); + struct Print((Option, syn::Path, syn::token::For)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; + formatter.write_str("Some(")?; Debug::fmt( &( - { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(Option); - impl Debug for Print { - fn fmt( - &self, - formatter: &mut fmt::Formatter, - ) -> fmt::Result { - match &self.0 { - Some(_val) => { - formatter.write_str("Some")?; - Ok(()) - } - None => formatter.write_str("None"), - } - } - } - Print::ref_cast(&_val.0) + &super::Option { + present: self.0.0.is_some(), }, - Lite(&_val.1), + Lite(&self.0.1), ), formatter, )?; @@ -2711,10 +2346,8 @@ impl Debug for Lite { struct Print(proc_macro2::Ident); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -2722,28 +2355,9 @@ impl Debug for Lite { formatter.field("ident", Print::ref_cast(val)); } formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); - } - formatter.finish() - } - syn::Item::Macro2(_val) => { - let mut formatter = formatter.debug_struct("Item::Macro2"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("rules", Lite(&_val.rules)); formatter.finish() } syn::Item::Mod(_val) => { @@ -2752,6 +2366,9 @@ impl Debug for Lite { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); + if _val.unsafety.is_some() { + formatter.field("unsafety", &Present); + } formatter.field("ident", Lite(&_val.ident)); if let Some(val) = &_val.content { #[derive(RefCast)] @@ -2759,27 +2376,16 @@ impl Debug for Lite { struct Print((syn::token::Brace, Vec)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("content", Print::ref_cast(val)); } - if let Some(val) = &_val.semi { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi", Print::ref_cast(val)); + if _val.semi.is_some() { + formatter.field("semi", &Present); } formatter.finish() } @@ -2789,17 +2395,11 @@ impl Debug for Lite { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } + match _val.mutability { + syn::StaticMutability::None => {} + _ => { + formatter.field("mutability", Lite(&_val.mutability)); } - formatter.field("mutability", Print::ref_cast(val)); } formatter.field("ident", Lite(&_val.ident)); formatter.field("ty", Lite(&_val.ty)); @@ -2815,17 +2415,8 @@ impl Debug for Lite { formatter.field("ident", Lite(&_val.ident)); formatter.field("generics", Lite(&_val.generics)); formatter.field("fields", Lite(&_val.fields)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } @@ -2835,43 +2426,30 @@ impl Debug for Lite { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + if _val.unsafety.is_some() { + formatter.field("unsafety", &Present); } - if let Some(val) = &_val.auto_token { + if _val.auto_token.is_some() { + formatter.field("auto_token", &Present); + } + if let Some(val) = &_val.restriction { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Auto); + struct Print(syn::ImplRestriction); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("auto_token", Print::ref_cast(val)); + formatter.field("restriction", Print::ref_cast(val)); } formatter.field("ident", Lite(&_val.ident)); formatter.field("generics", Lite(&_val.generics)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + if _val.colon_token.is_some() { + formatter.field("colon_token", &Present); } if !_val.supertraits.is_empty() { formatter.field("supertraits", Lite(&_val.supertraits)); @@ -2922,23 +2500,14 @@ impl Debug for Lite { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.leading_colon { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon2); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("leading_colon", Print::ref_cast(val)); + if _val.leading_colon.is_some() { + formatter.field("leading_colon", &Present); } formatter.field("tree", Lite(&_val.tree)); formatter.finish() } syn::Item::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("Item::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -2950,53 +2519,49 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemConst"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - formatter.field("expr", Lite(&_val.expr)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("ty", Lite(&self.value.ty)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemEnum"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - if !_val.variants.is_empty() { - formatter.field("variants", Lite(&_val.variants)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + if !self.value.variants.is_empty() { + formatter.field("variants", Lite(&self.value.variants)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemExternCrate"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - if let Some(val) = &_val.rename { + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.rename { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::As, proc_macro2::Ident)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -3008,95 +2573,58 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemFn"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("sig", Lite(&_val.sig)); - formatter.field("block", Lite(&_val.block)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("sig", Lite(&self.value.sig)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemForeignMod"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("abi", Lite(&_val.abi)); - if !_val.items.is_empty() { - formatter.field("items", Lite(&_val.items)); + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); + } + formatter.field("abi", Lite(&self.value.abi)); + if !self.value.items.is_empty() { + formatter.field("items", Lite(&self.value.items)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemImpl"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + if self.value.defaultness.is_some() { + formatter.field("defaultness", &Present); } - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); } - formatter.field("generics", Lite(&_val.generics)); - if let Some(val) = &_val.trait_ { + formatter.field("generics", Lite(&self.value.generics)); + if let Some(val) = &self.value.trait_ { #[derive(RefCast)] #[repr(transparent)] - struct Print((Option, syn::Path, syn::token::For)); + struct Print((Option, syn::Path, syn::token::For)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; + formatter.write_str("Some(")?; Debug::fmt( &( - { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(Option); - impl Debug for Print { - fn fmt( - &self, - formatter: &mut fmt::Formatter, - ) -> fmt::Result { - match &self.0 { - Some(_val) => { - formatter.write_str("Some")?; - Ok(()) - } - None => formatter.write_str("None"), - } - } - } - Print::ref_cast(&_val.0) + &super::Option { + present: self.0.0.is_some(), }, - Lite(&_val.1), + Lite(&self.0.1), ), formatter, )?; @@ -3106,326 +2634,235 @@ impl Debug for Lite { } formatter.field("trait_", Print::ref_cast(val)); } - formatter.field("self_ty", Lite(&_val.self_ty)); - if !_val.items.is_empty() { - formatter.field("items", Lite(&_val.items)); + formatter.field("self_ty", Lite(&self.value.self_ty)); + if !self.value.items.is_empty() { + formatter.field("items", Lite(&self.value.items)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.ident { + if let Some(val) = &self.value.ident { #[derive(RefCast)] #[repr(transparent)] struct Print(proc_macro2::Ident); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("ident", Print::ref_cast(val)); } - formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); - } - formatter.finish() - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ItemMacro2"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + formatter.field("mac", Lite(&self.value.mac)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("rules", Lite(&_val.rules)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemMod"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - if let Some(val) = &_val.content { + formatter.field("vis", Lite(&self.value.vis)); + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); + } + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.content { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::Brace, Vec)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("content", Print::ref_cast(val)); } - if let Some(val) = &_val.semi { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi", Print::ref_cast(val)); + if self.value.semi.is_some() { + formatter.field("semi", &Present); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemStatic"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } + formatter.field("vis", Lite(&self.value.vis)); + match self.value.mutability { + syn::StaticMutability::None => {} + _ => { + formatter.field("mutability", Lite(&self.value.mutability)); } - formatter.field("mutability", Print::ref_cast(val)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - formatter.field("expr", Lite(&_val.expr)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("ty", Lite(&self.value.ty)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemStruct"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - formatter.field("fields", Lite(&_val.fields)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("fields", Lite(&self.value.fields)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemTrait"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + formatter.field("vis", Lite(&self.value.vis)); + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); } - if let Some(val) = &_val.auto_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Auto); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("auto_token", Print::ref_cast(val)); + if self.value.auto_token.is_some() { + formatter.field("auto_token", &Present); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - if let Some(val) = &_val.colon_token { + if let Some(val) = &self.value.restriction { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Colon); + struct Print(syn::ImplRestriction); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("restriction", Print::ref_cast(val)); + } + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - if !_val.supertraits.is_empty() { - formatter.field("supertraits", Lite(&_val.supertraits)); + if !self.value.supertraits.is_empty() { + formatter.field("supertraits", Lite(&self.value.supertraits)); } - if !_val.items.is_empty() { - formatter.field("items", Lite(&_val.items)); + if !self.value.items.is_empty() { + formatter.field("items", Lite(&self.value.items)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemTraitAlias"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - formatter.field("ty", Lite(&_val.ty)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemUnion"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - formatter.field("fields", Lite(&_val.fields)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("fields", Lite(&self.value.fields)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemUse"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.leading_colon { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon2); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("leading_colon", Print::ref_cast(val)); + formatter.field("vis", Lite(&self.value.vis)); + if self.value.leading_colon.is_some() { + formatter.field("leading_colon", &Present); } - formatter.field("tree", Lite(&_val.tree)); + formatter.field("tree", Lite(&self.value.tree)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Label"); - formatter.field("name", Lite(&_val.name)); + formatter.field("name", Lite(&self.value.name)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Lifetime"); - formatter.field("ident", Lite(&_val.ident)); + formatter.field("ident", Lite(&self.value.ident)); formatter.finish() } } -impl Debug for Lite { +impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("LifetimeDef"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + let mut formatter = formatter.debug_struct("LifetimeParam"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("lifetime", Lite(&_val.lifetime)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("lifetime", Lite(&self.value.lifetime)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Lit::Str(_val) => write!(formatter, "{:?}", _val.value()), syn::Lit::ByteStr(_val) => write!(formatter, "{:?}", _val.value()), syn::Lit::Byte(_val) => write!(formatter, "{:?}", _val.value()), @@ -3438,77 +2875,68 @@ impl Debug for Lite { formatter.finish() } syn::Lit::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("Lit::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; Ok(()) } + _ => unreachable!(), } } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("LitBool"); - formatter.field("value", Lite(&_val.value)); + formatter.field("value", Lite(&self.value.value)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{:?}", _val.value()) + write!(formatter, "{:?}", self.value.value()) } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{:?}", _val.value()) + write!(formatter, "{:?}", self.value.value()) } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{:?}", _val.value()) + write!(formatter, "{:?}", self.value.value()) } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{}", _val) + write!(formatter, "{}", & self.value) } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{}", _val) + write!(formatter, "{}", & self.value) } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{:?}", _val.value()) + write!(formatter, "{:?}", self.value.value()) } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Local"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("pat", Lite(&_val.pat)); - if let Some(val) = &_val.init { + formatter.field("pat", Lite(&self.value.pat)); + if let Some(val) = &self.value.init { #[derive(RefCast)] #[repr(transparent)] - struct Print((syn::token::Eq, Box)); + struct Print(syn::LocalInit); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -3518,30 +2946,49 @@ impl Debug for Lite { formatter.finish() } } +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("LocalInit"); + formatter.field("expr", Lite(&self.value.expr)); + if let Some(val) = &self.value.diverge { + #[derive(RefCast)] + #[repr(transparent)] + struct Print((syn::token::Else, Box)); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("diverge", Print::ref_cast(val)); + } + formatter.finish() + } +} impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Macro"); - formatter.field("path", Lite(&_val.path)); - formatter.field("delimiter", Lite(&_val.delimiter)); - formatter.field("tokens", Lite(&_val.tokens)); + formatter.field("path", Lite(&self.value.path)); + formatter.field("delimiter", Lite(&self.value.delimiter)); + formatter.field("tokens", Lite(&self.value.tokens)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::MacroDelimiter::Paren(_val) => { - formatter.write_str("Paren")?; + formatter.write_str("MacroDelimiter::Paren")?; Ok(()) } syn::MacroDelimiter::Brace(_val) => { - formatter.write_str("Brace")?; + formatter.write_str("MacroDelimiter::Brace")?; Ok(()) } syn::MacroDelimiter::Bracket(_val) => { - formatter.write_str("Bracket")?; + formatter.write_str("MacroDelimiter::Bracket")?; Ok(()) } } @@ -3549,17 +2996,16 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Member::Named(_val) => { - formatter.write_str("Named")?; + formatter.write_str("Member::Named")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::Member::Unnamed(_val) => { - formatter.write_str("Unnamed")?; + formatter.write_str("Member::Unnamed")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; @@ -3570,27 +3016,28 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Meta::Path(_val) => { - formatter.write_str("Path")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) + let mut formatter = formatter.debug_struct("Meta::Path"); + if _val.leading_colon.is_some() { + formatter.field("leading_colon", &Present); + } + if !_val.segments.is_empty() { + formatter.field("segments", Lite(&_val.segments)); + } + formatter.finish() } syn::Meta::List(_val) => { let mut formatter = formatter.debug_struct("Meta::List"); formatter.field("path", Lite(&_val.path)); - if !_val.nested.is_empty() { - formatter.field("nested", Lite(&_val.nested)); - } + formatter.field("delimiter", Lite(&_val.delimiter)); + formatter.field("tokens", Lite(&_val.tokens)); formatter.finish() } syn::Meta::NameValue(_val) => { let mut formatter = formatter.debug_struct("Meta::NameValue"); formatter.field("path", Lite(&_val.path)); - formatter.field("lit", Lite(&_val.lit)); + formatter.field("value", Lite(&_val.value)); formatter.finish() } } @@ -3598,106 +3045,51 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("MetaList"); - formatter.field("path", Lite(&_val.path)); - if !_val.nested.is_empty() { - formatter.field("nested", Lite(&_val.nested)); - } + formatter.field("path", Lite(&self.value.path)); + formatter.field("delimiter", Lite(&self.value.delimiter)); + formatter.field("tokens", Lite(&self.value.tokens)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("MetaNameValue"); - formatter.field("path", Lite(&_val.path)); - formatter.field("lit", Lite(&_val.lit)); + formatter.field("path", Lite(&self.value.path)); + formatter.field("value", Lite(&self.value.value)); formatter.finish() } } -impl Debug for Lite { +impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("MethodTurbofish"); - if !_val.args.is_empty() { - formatter.field("args", Lite(&_val.args)); + let mut formatter = formatter.debug_struct("ParenthesizedGenericArguments"); + if !self.value.inputs.is_empty() { + formatter.field("inputs", Lite(&self.value.inputs)); } + formatter.field("output", Lite(&self.value.output)); formatter.finish() } } -impl Debug for Lite { +impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::NestedMeta::Meta(_val) => { - formatter.write_str("Meta")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - syn::NestedMeta::Lit(_val) => { - formatter.write_str("Lit")?; + match &self.value { + syn::Pat::Const(_val) => { + formatter.write_str("Pat::Const")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - } - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ParenthesizedGenericArguments"); - if !_val.inputs.is_empty() { - formatter.field("inputs", Lite(&_val.inputs)); - } - formatter.field("output", Lite(&_val.output)); - formatter.finish() - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::Pat::Box(_val) => { - let mut formatter = formatter.debug_struct("Pat::Box"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("pat", Lite(&_val.pat)); - formatter.finish() - } syn::Pat::Ident(_val) => { let mut formatter = formatter.debug_struct("Pat::Ident"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.by_ref { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Ref); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("by_ref", Print::ref_cast(val)); + if _val.by_ref.is_some() { + formatter.field("by_ref", &Present); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if _val.mutability.is_some() { + formatter.field("mutability", &Present); } formatter.field("ident", Lite(&_val.ident)); if let Some(val) = &_val.subpat { @@ -3706,10 +3098,8 @@ impl Debug for Lite { struct Print((syn::token::At, Box)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -3719,93 +3109,61 @@ impl Debug for Lite { formatter.finish() } syn::Pat::Lit(_val) => { - let mut formatter = formatter.debug_struct("Pat::Lit"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("expr", Lite(&_val.expr)); - formatter.finish() + formatter.write_str("Pat::Lit")?; + formatter.write_str("(")?; + Debug::fmt(Lite(_val), formatter)?; + formatter.write_str(")")?; + Ok(()) } syn::Pat::Macro(_val) => { - let mut formatter = formatter.debug_struct("Pat::Macro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("mac", Lite(&_val.mac)); - formatter.finish() + formatter.write_str("Pat::Macro")?; + formatter.write_str("(")?; + Debug::fmt(Lite(_val), formatter)?; + formatter.write_str(")")?; + Ok(()) } syn::Pat::Or(_val) => { let mut formatter = formatter.debug_struct("Pat::Or"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.leading_vert { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Or); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("leading_vert", Print::ref_cast(val)); + if _val.leading_vert.is_some() { + formatter.field("leading_vert", &Present); } if !_val.cases.is_empty() { formatter.field("cases", Lite(&_val.cases)); } formatter.finish() } - syn::Pat::Path(_val) => { - let mut formatter = formatter.debug_struct("Pat::Path"); + syn::Pat::Paren(_val) => { + let mut formatter = formatter.debug_struct("Pat::Paren"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.qself { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::QSelf); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - } - formatter.field("qself", Print::ref_cast(val)); - } - formatter.field("path", Lite(&_val.path)); + formatter.field("pat", Lite(&_val.pat)); formatter.finish() } + syn::Pat::Path(_val) => { + formatter.write_str("Pat::Path")?; + formatter.write_str("(")?; + Debug::fmt(Lite(_val), formatter)?; + formatter.write_str(")")?; + Ok(()) + } syn::Pat::Range(_val) => { - let mut formatter = formatter.debug_struct("Pat::Range"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("lo", Lite(&_val.lo)); - formatter.field("limits", Lite(&_val.limits)); - formatter.field("hi", Lite(&_val.hi)); - formatter.finish() + formatter.write_str("Pat::Range")?; + formatter.write_str("(")?; + Debug::fmt(Lite(_val), formatter)?; + formatter.write_str(")")?; + Ok(()) } syn::Pat::Reference(_val) => { let mut formatter = formatter.debug_struct("Pat::Reference"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if _val.mutability.is_some() { + formatter.field("mutability", &Present); } formatter.field("pat", Lite(&_val.pat)); formatter.finish() @@ -3832,21 +3190,37 @@ impl Debug for Lite { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } + if let Some(val) = &_val.qself { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::QSelf); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("qself", Print::ref_cast(val)); + } formatter.field("path", Lite(&_val.path)); if !_val.fields.is_empty() { formatter.field("fields", Lite(&_val.fields)); } - if let Some(val) = &_val.dot2_token { + if let Some(val) = &_val.rest { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Dot2); + struct Print(syn::PatRest); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("dot2_token", Print::ref_cast(val)); + formatter.field("rest", Print::ref_cast(val)); } formatter.finish() } @@ -3865,8 +3239,24 @@ impl Debug for Lite { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } + if let Some(val) = &_val.qself { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::QSelf); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("qself", Print::ref_cast(val)); + } formatter.field("path", Lite(&_val.path)); - formatter.field("pat", Lite(&_val.pat)); + if !_val.elems.is_empty() { + formatter.field("elems", Lite(&_val.elems)); + } formatter.finish() } syn::Pat::Type(_val) => { @@ -3879,7 +3269,7 @@ impl Debug for Lite { formatter.finish() } syn::Pat::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("Pat::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -3896,59 +3286,27 @@ impl Debug for Lite { } } } -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PatBox"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("pat", Lite(&_val.pat)); - formatter.finish() - } -} impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatIdent"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.by_ref { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Ref); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("by_ref", Print::ref_cast(val)); + if self.value.by_ref.is_some() { + formatter.field("by_ref", &Present); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } - formatter.field("ident", Lite(&_val.ident)); - if let Some(val) = &_val.subpat { + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.subpat { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::At, Box)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -3958,253 +3316,186 @@ impl Debug for Lite { formatter.finish() } } -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PatLit"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("expr", Lite(&_val.expr)); - formatter.finish() - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PatMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("mac", Lite(&_val.mac)); - formatter.finish() - } -} impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatOr"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - if let Some(val) = &_val.leading_vert { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Or); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("leading_vert", Print::ref_cast(val)); - } - if !_val.cases.is_empty() { - formatter.field("cases", Lite(&_val.cases)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.finish() - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PatPath"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if self.value.leading_vert.is_some() { + formatter.field("leading_vert", &Present); } - if let Some(val) = &_val.qself { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::QSelf); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - } - formatter.field("qself", Print::ref_cast(val)); + if !self.value.cases.is_empty() { + formatter.field("cases", Lite(&self.value.cases)); } - formatter.field("path", Lite(&_val.path)); formatter.finish() } } -impl Debug for Lite { +impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PatRange"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + let mut formatter = formatter.debug_struct("PatParen"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("lo", Lite(&_val.lo)); - formatter.field("limits", Lite(&_val.limits)); - formatter.field("hi", Lite(&_val.hi)); + formatter.field("pat", Lite(&self.value.pat)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatReference"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } - formatter.field("pat", Lite(&_val.pat)); + formatter.field("pat", Lite(&self.value.pat)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatRest"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatSlice"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if !_val.elems.is_empty() { - formatter.field("elems", Lite(&_val.elems)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatStruct"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + if let Some(val) = &self.value.qself { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::QSelf); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("qself", Print::ref_cast(val)); } - formatter.field("path", Lite(&_val.path)); - if !_val.fields.is_empty() { - formatter.field("fields", Lite(&_val.fields)); + formatter.field("path", Lite(&self.value.path)); + if !self.value.fields.is_empty() { + formatter.field("fields", Lite(&self.value.fields)); } - if let Some(val) = &_val.dot2_token { + if let Some(val) = &self.value.rest { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Dot2); + struct Print(syn::PatRest); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("dot2_token", Print::ref_cast(val)); + formatter.field("rest", Print::ref_cast(val)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatTuple"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if !_val.elems.is_empty() { - formatter.field("elems", Lite(&_val.elems)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatTupleStruct"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + if let Some(val) = &self.value.qself { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::QSelf); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("qself", Print::ref_cast(val)); + } + formatter.field("path", Lite(&self.value.path)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } - formatter.field("path", Lite(&_val.path)); - formatter.field("pat", Lite(&_val.pat)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("pat", Lite(&_val.pat)); - formatter.field("ty", Lite(&_val.ty)); + formatter.field("pat", Lite(&self.value.pat)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatWild"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Path"); - if let Some(val) = &_val.leading_colon { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon2); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("leading_colon", Print::ref_cast(val)); + if self.value.leading_colon.is_some() { + formatter.field("leading_colon", &Present); } - if !_val.segments.is_empty() { - formatter.field("segments", Lite(&_val.segments)); + if !self.value.segments.is_empty() { + formatter.field("segments", Lite(&self.value.segments)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::PathArguments::None => formatter.write_str("None"), + match &self.value { + syn::PathArguments::None => formatter.write_str("PathArguments::None"), syn::PathArguments::AngleBracketed(_val) => { let mut formatter = formatter .debug_struct("PathArguments::AngleBracketed"); - if let Some(val) = &_val.colon2_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon2); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon2_token", Print::ref_cast(val)); + if _val.colon2_token.is_some() { + formatter.field("colon2_token", &Present); } if !_val.args.is_empty() { formatter.field("args", Lite(&_val.args)); @@ -4225,91 +3516,71 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PathSegment"); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("arguments", Lite(&_val.arguments)); - formatter.finish() - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PredicateEq"); - formatter.field("lhs_ty", Lite(&_val.lhs_ty)); - formatter.field("rhs_ty", Lite(&_val.rhs_ty)); + formatter.field("ident", Lite(&self.value.ident)); + match self.value.arguments { + syn::PathArguments::None => {} + _ => { + formatter.field("arguments", Lite(&self.value.arguments)); + } + } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PredicateLifetime"); - formatter.field("lifetime", Lite(&_val.lifetime)); - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + formatter.field("lifetime", Lite(&self.value.lifetime)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PredicateType"); - if let Some(val) = &_val.lifetimes { + if let Some(val) = &self.value.lifetimes { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetimes", Print::ref_cast(val)); } - formatter.field("bounded_ty", Lite(&_val.bounded_ty)); - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + formatter.field("bounded_ty", Lite(&self.value.bounded_ty)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("QSelf"); - formatter.field("ty", Lite(&_val.ty)); - formatter.field("position", Lite(&_val.position)); - if let Some(val) = &_val.as_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::As); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("as_token", Print::ref_cast(val)); + formatter.field("ty", Lite(&self.value.ty)); + formatter.field("position", Lite(&self.value.position)); + if self.value.as_token.is_some() { + formatter.field("as_token", &Present); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::RangeLimits::HalfOpen(_val) => { - formatter.write_str("HalfOpen")?; + formatter.write_str("RangeLimits::HalfOpen")?; Ok(()) } syn::RangeLimits::Closed(_val) => { - formatter.write_str("Closed")?; + formatter.write_str("RangeLimits::Closed")?; Ok(()) } } @@ -4317,20 +3588,17 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Receiver"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.reference { + if let Some(val) = &self.value.reference { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::And, Option)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; + formatter.write_str("Some(")?; Debug::fmt( { #[derive(RefCast)] @@ -4343,8 +3611,7 @@ impl Debug for Lite { ) -> fmt::Result { match &self.0 { Some(_val) => { - formatter.write_str("Some")?; - formatter.write_str("(")?; + formatter.write_str("Some(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) @@ -4353,7 +3620,7 @@ impl Debug for Lite { } } } - Print::ref_cast(&_val.1) + Print::ref_cast(&self.0.1) }, formatter, )?; @@ -4363,192 +3630,197 @@ impl Debug for Lite { } formatter.field("reference", Print::ref_cast(val)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); + } + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::ReturnType::Default => formatter.write_str("Default"), + match &self.value { + syn::ReturnType::Default => formatter.write_str("ReturnType::Default"), syn::ReturnType::Type(_v0, _v1) => { - let mut formatter = formatter.debug_tuple("Type"); + let mut formatter = formatter.debug_tuple("ReturnType::Type"); formatter.field(Lite(_v1)); - formatter.finish() - } - } - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("Signature"); - if let Some(val) = &_val.constness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Const); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("constness", Print::ref_cast(val)); - } - if let Some(val) = &_val.asyncness { - #[derive(RefCast)] - #[repr(transparent)] - 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("asyncness", Print::ref_cast(val)); - } - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } + formatter.finish() } - formatter.field("unsafety", Print::ref_cast(val)); } - if let Some(val) = &_val.abi { + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("Signature"); + if self.value.constness.is_some() { + formatter.field("constness", &Present); + } + if self.value.asyncness.is_some() { + formatter.field("asyncness", &Present); + } + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); + } + if let Some(val) = &self.value.abi { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Abi); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("abi", Print::ref_cast(val)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - if !_val.inputs.is_empty() { - formatter.field("inputs", Lite(&_val.inputs)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + if !self.value.inputs.is_empty() { + formatter.field("inputs", Lite(&self.value.inputs)); } - if let Some(val) = &_val.variadic { + if let Some(val) = &self.value.variadic { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Variadic); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("variadic", Print::ref_cast(val)); } - formatter.field("output", Lite(&_val.output)); + formatter.field("output", Lite(&self.value.output)); formatter.finish() } } +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + match &self.value { + syn::StaticMutability::Mut(_val) => { + formatter.write_str("StaticMutability::Mut")?; + Ok(()) + } + syn::StaticMutability::None => formatter.write_str("StaticMutability::None"), + _ => unreachable!(), + } + } +} impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Stmt::Local(_val) => { - formatter.write_str("Local")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) + let mut formatter = formatter.debug_struct("Stmt::Local"); + if !_val.attrs.is_empty() { + formatter.field("attrs", Lite(&_val.attrs)); + } + formatter.field("pat", Lite(&_val.pat)); + if let Some(val) = &_val.init { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::LocalInit); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("init", Print::ref_cast(val)); + } + formatter.finish() } syn::Stmt::Item(_val) => { - formatter.write_str("Item")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - syn::Stmt::Expr(_val) => { - formatter.write_str("Expr")?; + formatter.write_str("Stmt::Item")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::Stmt::Semi(_v0, _v1) => { - let mut formatter = formatter.debug_tuple("Semi"); + syn::Stmt::Expr(_v0, _v1) => { + let mut formatter = formatter.debug_tuple("Stmt::Expr"); formatter.field(Lite(_v0)); + formatter + .field( + &super::Option { + present: _v1.is_some(), + }, + ); formatter.finish() } + syn::Stmt::Macro(_val) => { + let mut formatter = formatter.debug_struct("Stmt::Macro"); + if !_val.attrs.is_empty() { + formatter.field("attrs", Lite(&_val.attrs)); + } + formatter.field("mac", Lite(&_val.mac)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); + } + formatter.finish() + } + } + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("StmtMacro"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + formatter.field("mac", Lite(&self.value.mac)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } + formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TraitBound"); - if let Some(val) = &_val.paren_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Paren); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } + if self.value.paren_token.is_some() { + formatter.field("paren_token", &Present); + } + match self.value.modifier { + syn::TraitBoundModifier::None => {} + _ => { + formatter.field("modifier", Lite(&self.value.modifier)); } - formatter.field("paren_token", Print::ref_cast(val)); } - formatter.field("modifier", Lite(&_val.modifier)); - if let Some(val) = &_val.lifetimes { + if let Some(val) = &self.value.lifetimes { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetimes", Print::ref_cast(val)); } - formatter.field("path", Lite(&_val.path)); + formatter.field("path", Lite(&self.value.path)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::TraitBoundModifier::None => formatter.write_str("None"), + match &self.value { + syn::TraitBoundModifier::None => { + formatter.write_str("TraitBoundModifier::None") + } syn::TraitBoundModifier::Maybe(_val) => { - formatter.write_str("Maybe")?; + formatter.write_str("TraitBoundModifier::Maybe")?; Ok(()) } } @@ -4556,14 +3828,14 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::TraitItem::Const(_val) => { let mut formatter = formatter.debug_struct("TraitItem::Const"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("ident", Lite(&_val.ident)); + formatter.field("generics", Lite(&_val.generics)); formatter.field("ty", Lite(&_val.ty)); if let Some(val) = &_val.default { #[derive(RefCast)] @@ -4571,10 +3843,8 @@ impl Debug for Lite { struct Print((syn::token::Eq, syn::Expr)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4583,8 +3853,8 @@ impl Debug for Lite { } formatter.finish() } - syn::TraitItem::Method(_val) => { - let mut formatter = formatter.debug_struct("TraitItem::Method"); + syn::TraitItem::Fn(_val) => { + let mut formatter = formatter.debug_struct("TraitItem::Fn"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } @@ -4595,27 +3865,16 @@ impl Debug for Lite { struct Print(syn::Block); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("default", Print::ref_cast(val)); } - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } @@ -4626,17 +3885,8 @@ impl Debug for Lite { } formatter.field("ident", Lite(&_val.ident)); formatter.field("generics", Lite(&_val.generics)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + if _val.colon_token.is_some() { + formatter.field("colon_token", &Present); } if !_val.bounds.is_empty() { formatter.field("bounds", Lite(&_val.bounds)); @@ -4647,10 +3897,8 @@ impl Debug for Lite { struct Print((syn::token::Eq, syn::Type)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4665,22 +3913,13 @@ impl Debug for Lite { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } syn::TraitItem::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("TraitItem::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -4692,23 +3931,21 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TraitItemConst"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - if let Some(val) = &_val.default { + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("ty", Lite(&self.value.ty)); + if let Some(val) = &self.value.default { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::Eq, syn::Expr)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4718,102 +3955,68 @@ impl Debug for Lite { formatter.finish() } } -impl Debug for Lite { +impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("TraitItemMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + let mut formatter = formatter.debug_struct("TraitItemFn"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { + formatter.field("sig", Lite(&self.value.sig)); + if let Some(val) = &self.value.default { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Semi); + struct Print(syn::Block); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("semi_token", Print::ref_cast(val)); + formatter.field("default", Print::ref_cast(val)); + } + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } } -impl Debug for Lite { +impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("TraitItemMethod"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("sig", Lite(&_val.sig)); - if let Some(val) = &_val.default { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::Block); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - } - formatter.field("default", Print::ref_cast(val)); + let mut formatter = formatter.debug_struct("TraitItemMacro"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + formatter.field("mac", Lite(&self.value.mac)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TraitItemType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } - if let Some(val) = &_val.default { + if let Some(val) = &self.value.default { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::Eq, syn::Type)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4825,8 +4028,7 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Type::Array(_val) => { let mut formatter = formatter.debug_struct("Type::Array"); formatter.field("elem", Lite(&_val.elem)); @@ -4841,27 +4043,16 @@ impl Debug for Lite { struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetimes", Print::ref_cast(val)); } - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + if _val.unsafety.is_some() { + formatter.field("unsafety", &Present); } if let Some(val) = &_val.abi { #[derive(RefCast)] @@ -4869,10 +4060,8 @@ impl Debug for Lite { struct Print(syn::Abi); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4885,13 +4074,11 @@ impl Debug for Lite { if let Some(val) = &_val.variadic { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::Variadic); + struct Print(syn::BareVariadic); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4939,10 +4126,8 @@ impl Debug for Lite { struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4954,29 +4139,11 @@ impl Debug for Lite { } syn::Type::Ptr(_val) => { let mut formatter = formatter.debug_struct("Type::Ptr"); - if let Some(val) = &_val.const_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Const); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("const_token", Print::ref_cast(val)); + if _val.const_token.is_some() { + formatter.field("const_token", &Present); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if _val.mutability.is_some() { + formatter.field("mutability", &Present); } formatter.field("elem", Lite(&_val.elem)); formatter.finish() @@ -4989,27 +4156,16 @@ impl Debug for Lite { struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetime", Print::ref_cast(val)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if _val.mutability.is_some() { + formatter.field("mutability", &Present); } formatter.field("elem", Lite(&_val.elem)); formatter.finish() @@ -5021,17 +4177,8 @@ impl Debug for Lite { } syn::Type::TraitObject(_val) => { let mut formatter = formatter.debug_struct("Type::TraitObject"); - if let Some(val) = &_val.dyn_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Dyn); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("dyn_token", Print::ref_cast(val)); + if _val.dyn_token.is_some() { + formatter.field("dyn_token", &Present); } if !_val.bounds.is_empty() { formatter.field("bounds", Lite(&_val.bounds)); @@ -5046,7 +4193,7 @@ impl Debug for Lite { formatter.finish() } syn::Type::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("Type::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -5058,169 +4205,126 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeArray"); - formatter.field("elem", Lite(&_val.elem)); - formatter.field("len", Lite(&_val.len)); + formatter.field("elem", Lite(&self.value.elem)); + formatter.field("len", Lite(&self.value.len)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeBareFn"); - if let Some(val) = &_val.lifetimes { + if let Some(val) = &self.value.lifetimes { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetimes", Print::ref_cast(val)); } - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); } - if let Some(val) = &_val.abi { + if let Some(val) = &self.value.abi { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Abi); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("abi", Print::ref_cast(val)); } - if !_val.inputs.is_empty() { - formatter.field("inputs", Lite(&_val.inputs)); + if !self.value.inputs.is_empty() { + formatter.field("inputs", Lite(&self.value.inputs)); } - if let Some(val) = &_val.variadic { + if let Some(val) = &self.value.variadic { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::Variadic); + struct Print(syn::BareVariadic); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("variadic", Print::ref_cast(val)); } - formatter.field("output", Lite(&_val.output)); + formatter.field("output", Lite(&self.value.output)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeGroup"); - formatter.field("elem", Lite(&_val.elem)); + formatter.field("elem", Lite(&self.value.elem)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeImplTrait"); - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeInfer"); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeMacro"); - formatter.field("mac", Lite(&_val.mac)); + formatter.field("mac", Lite(&self.value.mac)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeNever"); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeParam"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("ident", Lite(&_val.ident)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("ident", Lite(&self.value.ident)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } - if let Some(val) = &_val.eq_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Eq); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("eq_token", Print::ref_cast(val)); + if self.value.eq_token.is_some() { + formatter.field("eq_token", &Present); } - if let Some(val) = &_val.default { + if let Some(val) = &self.value.default { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Type); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -5232,261 +4336,213 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::TypeParamBound::Trait(_val) => { - formatter.write_str("Trait")?; + formatter.write_str("TypeParamBound::Trait")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::TypeParamBound::Lifetime(_val) => { - formatter.write_str("Lifetime")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; + let mut formatter = formatter.debug_struct("TypeParamBound::Lifetime"); + formatter.field("ident", Lite(&_val.ident)); + formatter.finish() + } + syn::TypeParamBound::Verbatim(_val) => { + formatter.write_str("TypeParamBound::Verbatim")?; + formatter.write_str("(`")?; + Display::fmt(_val, formatter)?; + formatter.write_str("`)")?; Ok(()) } + _ => unreachable!(), } } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeParen"); - formatter.field("elem", Lite(&_val.elem)); + formatter.field("elem", Lite(&self.value.elem)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypePath"); - if let Some(val) = &_val.qself { + if let Some(val) = &self.value.qself { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("qself", Print::ref_cast(val)); } - formatter.field("path", Lite(&_val.path)); + formatter.field("path", Lite(&self.value.path)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypePtr"); - if let Some(val) = &_val.const_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Const); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("const_token", Print::ref_cast(val)); + if self.value.const_token.is_some() { + formatter.field("const_token", &Present); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } - formatter.field("elem", Lite(&_val.elem)); + formatter.field("elem", Lite(&self.value.elem)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeReference"); - if let Some(val) = &_val.lifetime { + if let Some(val) = &self.value.lifetime { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetime", Print::ref_cast(val)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } - formatter.field("elem", Lite(&_val.elem)); + formatter.field("elem", Lite(&self.value.elem)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeSlice"); - formatter.field("elem", Lite(&_val.elem)); + formatter.field("elem", Lite(&self.value.elem)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeTraitObject"); - if let Some(val) = &_val.dyn_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Dyn); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("dyn_token", Print::ref_cast(val)); + if self.value.dyn_token.is_some() { + formatter.field("dyn_token", &Present); } - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeTuple"); - if !_val.elems.is_empty() { - formatter.field("elems", Lite(&_val.elems)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::UnOp::Deref(_val) => { - formatter.write_str("Deref")?; + formatter.write_str("UnOp::Deref")?; Ok(()) } syn::UnOp::Not(_val) => { - formatter.write_str("Not")?; + formatter.write_str("UnOp::Not")?; Ok(()) } syn::UnOp::Neg(_val) => { - formatter.write_str("Neg")?; + formatter.write_str("UnOp::Neg")?; Ok(()) } + _ => unreachable!(), } } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("UseGlob"); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("UseGroup"); - if !_val.items.is_empty() { - formatter.field("items", Lite(&_val.items)); + if !self.value.items.is_empty() { + formatter.field("items", Lite(&self.value.items)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("UseName"); - formatter.field("ident", Lite(&_val.ident)); + formatter.field("ident", Lite(&self.value.ident)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("UsePath"); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("tree", Lite(&_val.tree)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("tree", Lite(&self.value.tree)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("UseRename"); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("rename", Lite(&_val.rename)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("rename", Lite(&self.value.rename)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::UseTree::Path(_val) => { - formatter.write_str("Path")?; + formatter.write_str("UseTree::Path")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::UseTree::Name(_val) => { - formatter.write_str("Name")?; + formatter.write_str("UseTree::Name")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::UseTree::Rename(_val) => { - formatter.write_str("Rename")?; + formatter.write_str("UseTree::Rename")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::UseTree::Glob(_val) => { - formatter.write_str("Glob")?; + formatter.write_str("UseTree::Glob")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::UseTree::Group(_val) => { - formatter.write_str("Group")?; + formatter.write_str("UseTree::Group")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; @@ -5497,33 +4553,46 @@ impl Debug for Lite { } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Variadic"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + if let Some(val) = &self.value.pat { + #[derive(RefCast)] + #[repr(transparent)] + struct Print((Box, syn::token::Colon)); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("pat", Print::ref_cast(val)); + } + if self.value.comma.is_some() { + formatter.field("comma", &Present); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Variant"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("fields", Lite(&_val.fields)); - if let Some(val) = &_val.discriminant { + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("fields", Lite(&self.value.fields)); + if let Some(val) = &self.value.discriminant { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::Eq, syn::Expr)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -5533,108 +4602,62 @@ impl Debug for Lite { formatter.finish() } } -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("VisCrate"); - formatter.finish() - } -} -impl Debug for Lite { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("VisPublic"); - formatter.finish() - } -} impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("VisRestricted"); - if let Some(val) = &_val.in_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::In); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("in_token", Print::ref_cast(val)); + if self.value.in_token.is_some() { + formatter.field("in_token", &Present); } - formatter.field("path", Lite(&_val.path)); + formatter.field("path", Lite(&self.value.path)); formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Visibility::Public(_val) => { - let mut formatter = formatter.debug_struct("Visibility::Public"); - formatter.finish() - } - syn::Visibility::Crate(_val) => { - let mut formatter = formatter.debug_struct("Visibility::Crate"); - formatter.finish() + formatter.write_str("Visibility::Public")?; + Ok(()) } syn::Visibility::Restricted(_val) => { let mut formatter = formatter.debug_struct("Visibility::Restricted"); - if let Some(val) = &_val.in_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::In); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("in_token", Print::ref_cast(val)); + if _val.in_token.is_some() { + formatter.field("in_token", &Present); } formatter.field("path", Lite(&_val.path)); formatter.finish() } - syn::Visibility::Inherited => formatter.write_str("Inherited"), + syn::Visibility::Inherited => formatter.write_str("Visibility::Inherited"), } } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("WhereClause"); - if !_val.predicates.is_empty() { - formatter.field("predicates", Lite(&_val.predicates)); + if !self.value.predicates.is_empty() { + formatter.field("predicates", Lite(&self.value.predicates)); } formatter.finish() } } impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::WherePredicate::Type(_val) => { - formatter.write_str("Type")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } + match &self.value { syn::WherePredicate::Lifetime(_val) => { - formatter.write_str("Lifetime")?; + formatter.write_str("WherePredicate::Lifetime")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::WherePredicate::Eq(_val) => { - formatter.write_str("Eq")?; + syn::WherePredicate::Type(_val) => { + formatter.write_str("WherePredicate::Type")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } + _ => unreachable!(), } } } diff --git a/vendor/syn/tests/debug/mod.rs b/vendor/syn/tests/debug/mod.rs index 0a0991a92..caf9eed80 100644 --- a/vendor/syn/tests/debug/mod.rs +++ b/vendor/syn/tests/debug/mod.rs @@ -123,3 +123,21 @@ where .finish() } } + +struct Present; + +impl Debug for Present { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some") + } +} + +struct Option { + present: bool, +} + +impl Debug for Option { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str(if self.present { "Some" } else { "None" }) + } +} diff --git a/vendor/syn/tests/regression.rs b/vendor/syn/tests/regression.rs index fb2b25c89..5c7fcddc8 100644 --- a/vendor/syn/tests/regression.rs +++ b/vendor/syn/tests/regression.rs @@ -1,3 +1,5 @@ +#![allow(clippy::let_underscore_untyped, clippy::uninlined_format_args)] + mod regression { automod::dir!("tests/regression"); } diff --git a/vendor/syn/tests/regression/issue1108.rs b/vendor/syn/tests/regression/issue1108.rs index 4fd30c0c7..11a82adaa 100644 --- a/vendor/syn/tests/regression/issue1108.rs +++ b/vendor/syn/tests/regression/issue1108.rs @@ -1,5 +1,5 @@ #[test] fn issue1108() { let data = "impl>::x for"; - _ = syn::parse_file(data); + let _ = syn::parse_file(data); } diff --git a/vendor/syn/tests/repo/mod.rs b/vendor/syn/tests/repo/mod.rs index 8418b8719..7be1cc323 100644 --- a/vendor/syn/tests/repo/mod.rs +++ b/vendor/syn/tests/repo/mod.rs @@ -10,33 +10,95 @@ use std::path::Path; use tar::Archive; use walkdir::DirEntry; -const REVISION: &str = "98ad6a5519651af36e246c0335c964dd52c554ba"; +const REVISION: &str = "22f247c6f3ed388cb702d01c2ff27da658a8b353"; #[rustfmt::skip] static EXCLUDE_FILES: &[&str] = &[ - // TODO: impl ~const T {} - // https://github.com/dtolnay/syn/issues/1051 - "src/test/ui/rfc-2632-const-trait-impl/syntax.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", + "tests/ui/const-generics/early/closing-args-token.rs", + "tests/ui/const-generics/early/const-expression-parameter.rs", + + // Compile-fail variadics in not the last position of a function parameter list + "tests/ui/parser/variadic-ffi-syntactic-pass.rs", // Need at least one trait in impl Trait, no such type as impl 'static - "src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs", + "tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs", + + // Lifetime bound inside for<>: `T: ~const ?for<'a: 'b> Trait<'a>` + "tests/ui/rfc-2632-const-trait-impl/tilde-const-syntax.rs", + + // Const impl that is not a trait impl: `impl ~const T {}` + "tests/ui/rfc-2632-const-trait-impl/syntax.rs", // Deprecated anonymous parameter syntax in traits - "src/test/ui/issues/issue-13105.rs", - "src/test/ui/issues/issue-13775.rs", - "src/test/ui/issues/issue-34074.rs", - "src/test/ui/proc-macro/trait-fn-args-2015.rs", "src/tools/rustfmt/tests/source/trait.rs", "src/tools/rustfmt/tests/target/trait.rs", + "tests/ui/issues/issue-13105.rs", + "tests/ui/issues/issue-13775.rs", + "tests/ui/issues/issue-34074.rs", + "tests/ui/proc-macro/trait-fn-args-2015.rs", + + // Deprecated where-clause location + "src/tools/rustfmt/tests/source/issue_4257.rs", + "src/tools/rustfmt/tests/source/issue_4911.rs", + "src/tools/rustfmt/tests/target/issue_4257.rs", + "src/tools/rustfmt/tests/target/issue_4911.rs", + "tests/pretty/gat-bounds.rs", + "tests/rustdoc/generic-associated-types/gats.rs", + + // Deprecated trait object syntax with parenthesized generic arguments and no dyn keyword + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0104_path_fn_trait_args.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0202_typepathfn_with_coloncolon.rs", + "src/tools/rustfmt/tests/source/attrib.rs", + "src/tools/rustfmt/tests/source/closure.rs", + "src/tools/rustfmt/tests/source/existential_type.rs", + "src/tools/rustfmt/tests/source/fn-simple.rs", + "src/tools/rustfmt/tests/source/fn_args_layout-vertical.rs", + "src/tools/rustfmt/tests/source/issue-4689/one.rs", + "src/tools/rustfmt/tests/source/issue-4689/two.rs", + "src/tools/rustfmt/tests/source/paths.rs", + "src/tools/rustfmt/tests/source/structs.rs", + "src/tools/rustfmt/tests/target/attrib.rs", + "src/tools/rustfmt/tests/target/closure.rs", + "src/tools/rustfmt/tests/target/existential_type.rs", + "src/tools/rustfmt/tests/target/fn-simple.rs", + "src/tools/rustfmt/tests/target/fn.rs", + "src/tools/rustfmt/tests/target/fn_args_layout-vertical.rs", + "src/tools/rustfmt/tests/target/issue-4689/one.rs", + "src/tools/rustfmt/tests/target/issue-4689/two.rs", + "src/tools/rustfmt/tests/target/paths.rs", + "src/tools/rustfmt/tests/target/structs.rs", + "tests/codegen-units/item-collection/non-generic-closures.rs", + "tests/debuginfo/recursive-enum.rs", + "tests/pretty/closure-reform-pretty.rs", + "tests/run-make-fulldeps/reproducible-build-2/reproducible-build.rs", + "tests/run-make-fulldeps/reproducible-build/reproducible-build.rs", + "tests/ui/auxiliary/typeid-intrinsic-aux1.rs", + "tests/ui/auxiliary/typeid-intrinsic-aux2.rs", + "tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs", + "tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs", + "tests/ui/lifetimes/bare-trait-object-borrowck.rs", + "tests/ui/lifetimes/bare-trait-object.rs", + "tests/ui/parser/bounds-obj-parens.rs", + + // Old type ascription expression syntax + "src/tools/rustfmt/tests/source/type-ascription.rs", + "src/tools/rustfmt/tests/target/type-ascription.rs", + + // Obsolete box syntax + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0132_box_expr.rs", + + // Invalid unparenthesized range pattern inside slice pattern: `[1..]` + "tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs", // Various extensions to Rust syntax made up by rust-analyzer "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0012_type_item_where_clause.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0040_crate_keyword_vis.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0058_range_pat.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0123_param_list_vararg.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0131_existential_type.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0156_fn_def_param.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0179_use_tree_abs_star.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0188_const_param_default_path.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0015_use_tree.rs", @@ -45,20 +107,44 @@ static EXCLUDE_FILES: &[&str] = &[ "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0055_dot_dot_dot.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0068_item_modifiers.rs", "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0031_block_inner_attrs.rs", + "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0038_endless_inclusive_range.rs", "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0045_ambiguous_trait_object.rs", "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0046_mutable_const_item.rs", // Placeholder syntax for "throw expressions" - "src/test/pretty/yeet-expr.rs", - "src/test/ui/try-trait/yeet-for-option.rs", - "src/test/ui/try-trait/yeet-for-result.rs", + "compiler/rustc_errors/src/translation.rs", + "src/tools/clippy/tests/ui/needless_return.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0204_yeet_expr.rs", + "tests/pretty/yeet-expr.rs", + "tests/ui/try-trait/yeet-for-option.rs", + "tests/ui/try-trait/yeet-for-result.rs", + + // Edition 2015 code using identifiers that are now keywords + // TODO: some of these we should probably parse + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0159_try_macro_fallback.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0160_try_macro_rules.rs", + "src/tools/rustfmt/tests/source/configs/indent_style/block_call.rs", + "src/tools/rustfmt/tests/source/configs/use_try_shorthand/false.rs", + "src/tools/rustfmt/tests/source/configs/use_try_shorthand/true.rs", + "src/tools/rustfmt/tests/source/issue_1306.rs", + "src/tools/rustfmt/tests/source/try-conversion.rs", + "src/tools/rustfmt/tests/target/configs/indent_style/block_call.rs", + "src/tools/rustfmt/tests/target/configs/use_try_shorthand/false.rs", + "src/tools/rustfmt/tests/target/issue-1681.rs", + "src/tools/rustfmt/tests/target/issue_1306.rs", + "tests/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs", + "tests/ui/editions/edition-keywords-2015-2015.rs", + "tests/ui/editions/edition-keywords-2015-2018.rs", + "tests/ui/lint/lint_pre_expansion_extern_module_aux.rs", + "tests/ui/macros/macro-comma-support-rpass.rs", + "tests/ui/macros/try-macro.rs", + "tests/ui/parser/extern-crate-async.rs", + "tests/ui/try-block/try-is-identifier-edition2015.rs", // Excessive nesting - "src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs", + "tests/ui/issues/issue-74564-if-expr-stack-overflow.rs", // Testing tools on invalid syntax - "src/test/run-make/translation/test.rs", - "src/test/ui/generics/issue-94432-garbage-ice.rs", "src/tools/rustfmt/tests/coverage/target/comments.rs", "src/tools/rustfmt/tests/parser/issue-4126/invalid.rs", "src/tools/rustfmt/tests/parser/issue_4418.rs", @@ -70,32 +156,22 @@ static EXCLUDE_FILES: &[&str] = &[ "src/tools/rustfmt/tests/target/configs/spaces_around_ranges/false.rs", "src/tools/rustfmt/tests/target/configs/spaces_around_ranges/true.rs", "src/tools/rustfmt/tests/target/type.rs", + "tests/run-make/translation/test.rs", + "tests/ui/generics/issue-94432-garbage-ice.rs", // Generated file containing a top-level expression, used with `include!` "compiler/rustc_codegen_gcc/src/intrinsic/archs.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/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/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", + "tests/ui/lint/expansion-time-include.rs", + "tests/ui/macros/auxiliary/macro-comma-support.rs", + "tests/ui/macros/auxiliary/macro-include-items-expr.rs", + "tests/ui/macros/include-single-expr-helper.rs", + "tests/ui/macros/include-single-expr-helper-1.rs", + "tests/ui/parser/issues/auxiliary/issue-21146-inc.rs", ]; #[rustfmt::skip] @@ -135,7 +211,7 @@ pub fn base_dir_filter(entry: &DirEntry) -> bool { return false; } - if path_string.starts_with("src/test/ui") || path_string.starts_with("src/test/rustdoc-ui") { + if path_string.starts_with("tests/ui") || path_string.starts_with("tests/rustdoc-ui") { let stderr_path = path.with_extension("stderr"); if stderr_path.exists() { // Expected to fail in some way diff --git a/vendor/syn/tests/test_asyncness.rs b/vendor/syn/tests/test_asyncness.rs index 0efef5976..6bc5a1637 100644 --- a/vendor/syn/tests/test_asyncness.rs +++ b/vendor/syn/tests/test_asyncness.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; @@ -9,12 +11,12 @@ fn test_async_fn() { snapshot!(input as Item, @r###" Item::Fn { - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { asyncness: Some, ident: "process", generics: Generics, - output: Default, + output: ReturnType::Default, }, block: Block, } @@ -28,7 +30,7 @@ fn test_async_closure() { snapshot!(input as Expr, @r###" Expr::Closure { asyncness: Some, - output: Default, + output: ReturnType::Default, body: Expr::Block { block: Block, }, diff --git a/vendor/syn/tests/test_attribute.rs b/vendor/syn/tests/test_attribute.rs index c26bd090e..597ae3adc 100644 --- a/vendor/syn/tests/test_attribute.rs +++ b/vendor/syn/tests/test_attribute.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; @@ -9,14 +11,13 @@ fn test_meta_item_word() { let meta = test("#[foo]"); snapshot!(meta, @r###" - Path(Path { + Meta::Path { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], - }) + } "###); } @@ -30,11 +31,12 @@ fn test_meta_item_name_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - lit: 5, + value: Expr::Lit { + lit: 5, + }, } "###); } @@ -49,12 +51,13 @@ fn test_meta_item_bool_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - lit: Lit::Bool { - value: true, + value: Expr::Lit { + lit: Lit::Bool { + value: true, + }, }, } "###); @@ -67,12 +70,13 @@ fn test_meta_item_bool_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - lit: Lit::Bool { - value: false, + value: Expr::Lit { + lit: Lit::Bool { + value: false, + }, }, } "###); @@ -88,13 +92,11 @@ fn test_meta_item_list_lit() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Lit(5), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`5`), } "###); } @@ -109,20 +111,11 @@ fn test_meta_item_list_word() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Path(Path { - segments: [ - PathSegment { - ident: "bar", - arguments: None, - }, - ], - })), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`bar`), } "###); } @@ -137,23 +130,11 @@ fn test_meta_item_list_name_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "bar", - arguments: None, - }, - ], - }, - lit: 5, - }), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`bar = 5`), } "###); } @@ -168,25 +149,11 @@ fn test_meta_item_list_bool_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "bar", - arguments: None, - }, - ], - }, - lit: Lit::Bool { - value: true, - }, - }), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`bar = true`), } "###); } @@ -201,62 +168,11 @@ fn test_meta_item_multiple() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word", - arguments: None, - }, - ], - })), - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name", - arguments: None, - }, - ], - }, - lit: 5, - }), - Meta(Meta::List { - path: Path { - segments: [ - PathSegment { - ident: "list", - arguments: None, - }, - ], - }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name2", - arguments: None, - }, - ], - }, - lit: 6, - }), - ], - }), - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word2", - arguments: None, - }, - ], - })), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`word , name = 5 , list (name2 = 6) , word2`), } "###); } @@ -271,15 +187,11 @@ fn test_bool_lit() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Lit(Lit::Bool { - value: true, - }), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`true`), } "###); } @@ -294,34 +206,11 @@ fn test_negative_lit() { segments: [ PathSegment { ident: "form", - arguments: None, }, ], }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "min", - arguments: None, - }, - ], - }, - lit: -1, - }), - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "max", - arguments: None, - }, - ], - }, - lit: 200, - }), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`min = - 1 , max = 200`), } "###); } @@ -332,5 +221,5 @@ fn test(input: &str) -> Meta { assert_eq!(attrs.len(), 1); let attr = attrs.into_iter().next().unwrap(); - attr.parse_meta().unwrap() + attr.meta } diff --git a/vendor/syn/tests/test_derive_input.rs b/vendor/syn/tests/test_derive_input.rs index 1eff01186..3ec6aecbc 100644 --- a/vendor/syn/tests/test_derive_input.rs +++ b/vendor/syn/tests/test_derive_input.rs @@ -1,4 +1,9 @@ -#![allow(clippy::assertions_on_result_states, clippy::too_many_lines)] +#![allow( + clippy::assertions_on_result_states, + clippy::manual_let_else, + clippy::too_many_lines, + clippy::uninlined_format_args +)] #[macro_use] mod macros; @@ -14,11 +19,11 @@ fn test_unit() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "Unit", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -39,16 +44,18 @@ fn test_struct() { DeriveInput { attrs: [ Attribute { - style: Outer, - path: Path { - segments: [ - PathSegment { - ident: "derive", - arguments: None, - }, - ], + style: AttrStyle::Outer, + meta: Meta::List { + path: Path { + segments: [ + PathSegment { + ident: "derive", + }, + ], + }, + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`Debug , Clone`), }, - tokens: TokenStream(`(Debug , Clone)`), }, ], vis: Visibility::Public, @@ -66,7 +73,6 @@ fn test_struct() { segments: [ PathSegment { ident: "Ident", - arguments: None, }, ], }, @@ -83,12 +89,11 @@ fn test_struct() { ident: "Vec", arguments: PathArguments::AngleBracketed { args: [ - Type(Type::Path { + GenericArgument::Type(Type::Path { path: Path { segments: [ PathSegment { ident: "Attribute", - arguments: None, }, ], }, @@ -106,34 +111,17 @@ fn test_struct() { } "###); - snapshot!(input.attrs[0].parse_meta().unwrap(), @r###" + snapshot!(&input.attrs[0].meta, @r###" Meta::List { path: Path { segments: [ PathSegment { ident: "derive", - arguments: None, }, ], }, - nested: [ - Meta(Path(Path { - segments: [ - PathSegment { - ident: "Debug", - arguments: None, - }, - ], - })), - Meta(Path(Path { - segments: [ - PathSegment { - ident: "Clone", - arguments: None, - }, - ], - })), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`Debug , Clone`), } "###); } @@ -149,12 +137,12 @@ fn test_union() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "MaybeUninit", generics: Generics { lt_token: Some, params: [ - Type(TypeParam { + GenericParam::Type(TypeParam { ident: "T", }), ], @@ -164,13 +152,13 @@ fn test_union() { fields: FieldsNamed { named: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ident: Some("uninit"), colon_token: Some, ty: Type::Tuple, }, Field { - vis: Inherited, + vis: Visibility::Inherited, ident: Some("value"), colon_token: Some, ty: Type::Path { @@ -178,7 +166,6 @@ fn test_union() { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -212,28 +199,29 @@ fn test_enum() { DeriveInput { attrs: [ Attribute { - style: Outer, - path: Path { - segments: [ - PathSegment { - ident: "doc", - arguments: None, - }, - ], + style: AttrStyle::Outer, + meta: Meta::NameValue { + path: Path { + segments: [ + PathSegment { + ident: "doc", + }, + ], + }, + value: Expr::Lit { + lit: " See the std::result module documentation for details.", + }, }, - tokens: TokenStream(`= r" See the std::result module documentation for details."`), }, Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "must_use", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], vis: Visibility::Public, @@ -241,10 +229,10 @@ fn test_enum() { generics: Generics { lt_token: Some, params: [ - Type(TypeParam { + GenericParam::Type(TypeParam { ident: "T", }), - Type(TypeParam { + GenericParam::Type(TypeParam { ident: "E", }), ], @@ -257,13 +245,12 @@ fn test_enum() { fields: Fields::Unnamed { unnamed: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ty: Type::Path { path: Path { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -277,13 +264,12 @@ fn test_enum() { fields: Fields::Unnamed { unnamed: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ty: Type::Path { path: Path { segments: [ PathSegment { ident: "E", - arguments: None, }, ], }, @@ -294,14 +280,14 @@ fn test_enum() { }, Variant { ident: "Surprise", - fields: Unit, + fields: Fields::Unit, discriminant: Some(Expr::Lit { lit: 0isize, }), }, Variant { ident: "ProcMacroHack", - fields: Unit, + fields: Fields::Unit, discriminant: Some(Expr::Field { base: Expr::Tuple { elems: [ @@ -313,7 +299,7 @@ fn test_enum() { }, ], }, - member: Unnamed(Index { + member: Member::Unnamed(Index { index: 0, }), }), @@ -323,11 +309,7 @@ fn test_enum() { } "###); - let meta_items: Vec<_> = input - .attrs - .into_iter() - .map(|attr| attr.parse_meta().unwrap()) - .collect(); + let meta_items: Vec<_> = input.attrs.into_iter().map(|attr| attr.meta).collect(); snapshot!(meta_items, @r###" [ @@ -336,64 +318,22 @@ fn test_enum() { segments: [ PathSegment { ident: "doc", - arguments: None, }, ], }, - lit: " See the std::result module documentation for details.", + value: Expr::Lit { + lit: " See the std::result module documentation for details.", + }, }, - Path(Path { + Meta::Path { segments: [ PathSegment { ident: "must_use", - arguments: None, }, ], - }), - ] - "###); -} - -#[test] -fn test_attr_with_path() { - let input = quote! { - #[::attr_args::identity - fn main() { assert_eq!(foo(), "Hello, world!"); }] - struct Dummy; - }; - - snapshot!(input as DeriveInput, @r###" - DeriveInput { - attrs: [ - Attribute { - style: Outer, - path: Path { - leading_colon: Some, - segments: [ - PathSegment { - ident: "attr_args", - arguments: None, - }, - PathSegment { - ident: "identity", - arguments: None, - }, - ], - }, - tokens: TokenStream(`fn main () { assert_eq ! (foo () , "Hello, world!") ; }`), - }, - ], - vis: Inherited, - ident: "Dummy", - generics: Generics, - data: Data::Struct { - fields: Unit, - semi_token: Some, }, - } + ] "###); - - assert!(input.attrs[0].parse_meta().is_err()); } #[test] @@ -403,33 +343,7 @@ fn test_attr_with_non_mod_style_path() { struct S; }; - snapshot!(input as DeriveInput, @r###" - DeriveInput { - attrs: [ - Attribute { - style: Outer, - path: Path { - segments: [ - PathSegment { - ident: "inert", - arguments: None, - }, - ], - }, - tokens: TokenStream(`< T >`), - }, - ], - vis: Inherited, - ident: "S", - generics: Generics, - data: Data::Struct { - fields: Unit, - semi_token: Some, - }, - } - "###); - - assert!(input.attrs[0].parse_meta().is_err()); + syn::parse2::(input).unwrap_err(); } #[test] @@ -443,45 +357,40 @@ fn test_attr_with_mod_style_path_with_self() { DeriveInput { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "foo", - arguments: None, }, PathSegment { ident: "self", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } "###); - snapshot!(input.attrs[0].parse_meta().unwrap(), @r###" - Path(Path { + snapshot!(&input.attrs[0].meta, @r###" + Meta::Path { segments: [ PathSegment { ident: "foo", - arguments: None, }, PathSegment { ident: "self", - arguments: None, }, ], - }) + } "###); } @@ -500,7 +409,6 @@ fn test_pub_restricted() { segments: [ PathSegment { ident: "m", - arguments: None, }, ], }, @@ -517,11 +425,9 @@ fn test_pub_restricted() { segments: [ PathSegment { ident: "m", - arguments: None, }, PathSegment { ident: "n", - arguments: None, }, ], }, @@ -531,7 +437,6 @@ fn test_pub_restricted() { segments: [ PathSegment { ident: "u8", - arguments: None, }, ], }, @@ -545,25 +450,6 @@ fn test_pub_restricted() { "###); } -#[test] -fn test_vis_crate() { - let input = quote! { - crate struct S; - }; - - snapshot!(input as DeriveInput, @r###" - DeriveInput { - vis: Visibility::Crate, - ident: "S", - generics: Generics, - data: Data::Struct { - fields: Unit, - semi_token: Some, - }, - } - "###); -} - #[test] fn test_pub_restricted_crate() { let input = quote! { @@ -577,7 +463,6 @@ fn test_pub_restricted_crate() { segments: [ PathSegment { ident: "crate", - arguments: None, }, ], }, @@ -585,7 +470,7 @@ fn test_pub_restricted_crate() { ident: "S", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -605,7 +490,6 @@ fn test_pub_restricted_super() { segments: [ PathSegment { ident: "super", - arguments: None, }, ], }, @@ -613,7 +497,7 @@ fn test_pub_restricted_super() { ident: "S", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -634,7 +518,6 @@ fn test_pub_restricted_in_super() { segments: [ PathSegment { ident: "super", - arguments: None, }, ], }, @@ -642,7 +525,7 @@ fn test_pub_restricted_in_super() { ident: "S", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -657,11 +540,11 @@ fn test_fields_on_unit_struct() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -686,14 +569,14 @@ fn test_fields_on_named_struct() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { fields: Fields::Named { named: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ident: Some("foo"), colon_token: Some, ty: Type::Path { @@ -701,7 +584,6 @@ fn test_fields_on_named_struct() { segments: [ PathSegment { ident: "i32", - arguments: None, }, ], }, @@ -716,7 +598,6 @@ fn test_fields_on_named_struct() { segments: [ PathSegment { ident: "String", - arguments: None, }, ], }, @@ -736,7 +617,7 @@ fn test_fields_on_named_struct() { snapshot!(data.fields.into_iter().collect::>(), @r###" [ Field { - vis: Inherited, + vis: Visibility::Inherited, ident: Some("foo"), colon_token: Some, ty: Type::Path { @@ -744,7 +625,6 @@ fn test_fields_on_named_struct() { segments: [ PathSegment { ident: "i32", - arguments: None, }, ], }, @@ -759,7 +639,6 @@ fn test_fields_on_named_struct() { segments: [ PathSegment { ident: "String", - arguments: None, }, ], }, @@ -777,20 +656,19 @@ fn test_fields_on_tuple_struct() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { fields: Fields::Unnamed { unnamed: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ty: Type::Path { path: Path { segments: [ PathSegment { ident: "i32", - arguments: None, }, ], }, @@ -803,7 +681,6 @@ fn test_fields_on_tuple_struct() { segments: [ PathSegment { ident: "String", - arguments: None, }, ], }, @@ -824,13 +701,12 @@ fn test_fields_on_tuple_struct() { snapshot!(data.fields.iter().collect::>(), @r###" [ Field { - vis: Inherited, + vis: Visibility::Inherited, ty: Type::Path { path: Path { segments: [ PathSegment { ident: "i32", - arguments: None, }, ], }, @@ -843,7 +719,6 @@ fn test_fields_on_tuple_struct() { segments: [ PathSegment { ident: "String", - arguments: None, }, ], }, @@ -862,24 +737,22 @@ fn test_ambiguous_crate() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { fields: Fields::Unnamed { unnamed: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ty: Type::Path { path: Path { segments: [ PathSegment { ident: "crate", - arguments: None, }, PathSegment { ident: "X", - arguments: None, }, ], }, diff --git a/vendor/syn/tests/test_expr.rs b/vendor/syn/tests/test_expr.rs index e5b151fd8..c7230c6dc 100644 --- a/vendor/syn/tests/test_expr.rs +++ b/vendor/syn/tests/test_expr.rs @@ -1,9 +1,10 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; use quote::quote; -use std::iter::FromIterator; use syn::{Expr, ExprRange}; #[test] @@ -11,8 +12,8 @@ fn test_expr_parse() { let tokens = quote!(..100u32); snapshot!(tokens as Expr, @r###" Expr::Range { - limits: HalfOpen, - to: Some(Expr::Lit { + limits: RangeLimits::HalfOpen, + end: Some(Expr::Lit { lit: 100u32, }), } @@ -21,8 +22,8 @@ fn test_expr_parse() { let tokens = quote!(..100u32); snapshot!(tokens as ExprRange, @r###" ExprRange { - limits: HalfOpen, - to: Some(Expr::Lit { + limits: RangeLimits::HalfOpen, + end: Some(Expr::Lit { lit: 100u32, }), } @@ -41,7 +42,6 @@ fn test_await() { segments: [ PathSegment { ident: "fut", - arguments: None, }, ], }, @@ -61,16 +61,15 @@ fn test_tuple_multi_index() { segments: [ PathSegment { ident: "tuple", - arguments: None, }, ], }, }, - member: Unnamed(Index { + member: Member::Unnamed(Index { index: 0, }), }, - member: Unnamed(Index { + member: Member::Unnamed(Index { index: 0, }), } @@ -114,7 +113,6 @@ fn test_macro_variable_func() { segments: [ PathSegment { ident: "f", - arguments: None, }, ], }, @@ -134,39 +132,34 @@ fn test_macro_variable_func() { Expr::Call { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "outside", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], func: Expr::Group { expr: Expr::Path { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "inside", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], path: Path { segments: [ PathSegment { ident: "f", - arguments: None, }, ], }, @@ -192,11 +185,10 @@ fn test_macro_variable_macro() { segments: [ PathSegment { ident: "m", - arguments: None, }, ], }, - delimiter: Paren, + delimiter: MacroDelimiter::Paren, tokens: TokenStream(``), }, } @@ -217,7 +209,6 @@ fn test_macro_variable_struct() { segments: [ PathSegment { ident: "S", - arguments: None, }, ], }, @@ -249,7 +240,6 @@ fn test_macro_variable_match_arm() { segments: [ PathSegment { ident: "v", - arguments: None, }, ], }, @@ -261,16 +251,14 @@ fn test_macro_variable_match_arm() { expr: Expr::Tuple { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "a", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], }, @@ -289,9 +277,9 @@ fn test_closure_vs_rangefull() { snapshot!(tokens as Expr, @r###" Expr::MethodCall { receiver: Expr::Closure { - output: Default, + output: ReturnType::Default, body: Expr::Range { - limits: HalfOpen, + limits: RangeLimits::HalfOpen, }, }, method: "method", @@ -304,3 +292,21 @@ fn test_postfix_operator_after_cast() { syn::parse_str::("|| &x as T[0]").unwrap_err(); syn::parse_str::("|| () as ()()").unwrap_err(); } + +#[test] +fn test_ranges() { + syn::parse_str::("..").unwrap(); + syn::parse_str::("..hi").unwrap(); + syn::parse_str::("lo..").unwrap(); + syn::parse_str::("lo..hi").unwrap(); + + syn::parse_str::("..=").unwrap_err(); + syn::parse_str::("..=hi").unwrap(); + syn::parse_str::("lo..=").unwrap_err(); + syn::parse_str::("lo..=hi").unwrap(); + + syn::parse_str::("...").unwrap_err(); + syn::parse_str::("...hi").unwrap_err(); + syn::parse_str::("lo...").unwrap_err(); + syn::parse_str::("lo...hi").unwrap_err(); +} diff --git a/vendor/syn/tests/test_generics.rs b/vendor/syn/tests/test_generics.rs index 330f02f4d..51119adc8 100644 --- a/vendor/syn/tests/test_generics.rs +++ b/vendor/syn/tests/test_generics.rs @@ -1,4 +1,8 @@ -#![allow(clippy::too_many_lines)] +#![allow( + clippy::manual_let_else, + clippy::too_many_lines, + clippy::uninlined_format_args +)] #[macro_use] mod macros; @@ -14,17 +18,17 @@ fn test_split_for_impl() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics { lt_token: Some, params: [ - Lifetime(LifetimeDef { + GenericParam::Lifetime(LifetimeParam { lifetime: Lifetime { ident: "a", }, }), - Lifetime(LifetimeDef { + GenericParam::Lifetime(LifetimeParam { lifetime: Lifetime { ident: "b", }, @@ -35,27 +39,25 @@ fn test_split_for_impl() { }, ], }), - Type(TypeParam { + GenericParam::Type(TypeParam { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "may_dangle", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], ident: "T", colon_token: Some, bounds: [ - Lifetime(Lifetime { + TypeParamBound::Lifetime { ident: "a", - }), + }, ], eq_token: Some, default: Some(Type::Tuple), @@ -64,25 +66,22 @@ fn test_split_for_impl() { gt_token: Some, where_clause: Some(WhereClause { predicates: [ - Type(PredicateType { + WherePredicate::Type(PredicateType { bounded_ty: Type::Path { path: Path { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, }, bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Debug", - arguments: None, }, ], }, @@ -93,7 +92,7 @@ fn test_split_for_impl() { }), }, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -128,27 +127,25 @@ fn test_split_for_impl() { fn test_ty_param_bound() { let tokens = quote!('a); snapshot!(tokens as TypeParamBound, @r###" - Lifetime(Lifetime { + TypeParamBound::Lifetime { ident: "a", - }) + } "###); let tokens = quote!('_); snapshot!(tokens as TypeParamBound, @r###" - Lifetime(Lifetime { + TypeParamBound::Lifetime { ident: "_", - }) + } "###); let tokens = quote!(Debug); snapshot!(tokens as TypeParamBound, @r###" - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Debug", - arguments: None, }, ], }, @@ -157,13 +154,12 @@ fn test_ty_param_bound() { let tokens = quote!(?Sized); snapshot!(tokens as TypeParamBound, @r###" - Trait(TraitBound { - modifier: Maybe, + TypeParamBound::Trait(TraitBound { + modifier: TraitBoundModifier::Maybe, path: Path { segments: [ PathSegment { ident: "Sized", - arguments: None, }, ], }, @@ -185,45 +181,42 @@ fn test_fn_precedence_in_where_clause() { snapshot!(input as ItemFn, @r###" ItemFn { - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { ident: "f", generics: Generics { lt_token: Some, params: [ - Type(TypeParam { + GenericParam::Type(TypeParam { ident: "G", }), ], gt_token: Some, where_clause: Some(WhereClause { predicates: [ - Type(PredicateType { + WherePredicate::Type(PredicateType { bounded_ty: Type::Path { path: Path { segments: [ PathSegment { ident: "G", - arguments: None, }, ], }, }, bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "FnOnce", arguments: PathArguments::Parenthesized { - output: Type( + output: ReturnType::Type( Type::Path { path: Path { segments: [ PathSegment { ident: "i32", - arguments: None, }, ], }, @@ -234,13 +227,11 @@ fn test_fn_precedence_in_where_clause() { ], }, }), - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Send", - arguments: None, }, ], }, @@ -250,7 +241,7 @@ fn test_fn_precedence_in_where_clause() { ], }), }, - output: Default, + output: ReturnType::Default, }, block: Block, } diff --git a/vendor/syn/tests/test_grouping.rs b/vendor/syn/tests/test_grouping.rs index 9eb7eee9b..6a73a9244 100644 --- a/vendor/syn/tests/test_grouping.rs +++ b/vendor/syn/tests/test_grouping.rs @@ -1,8 +1,9 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Literal, Punct, Spacing, TokenStream, TokenTree}; -use std::iter::FromIterator; use syn::Expr; #[test] @@ -29,20 +30,20 @@ fn test_grouping() { left: Expr::Lit { lit: 1i32, }, - op: Add, + op: BinOp::Add, right: Expr::Binary { left: Expr::Group { expr: Expr::Binary { left: Expr::Lit { lit: 2i32, }, - op: Add, + op: BinOp::Add, right: Expr::Lit { lit: 3i32, }, }, }, - op: Mul, + op: BinOp::Mul, right: Expr::Lit { lit: 4i32, }, diff --git a/vendor/syn/tests/test_item.rs b/vendor/syn/tests/test_item.rs index 96df4b1aa..9b0e1c9ff 100644 --- a/vendor/syn/tests/test_item.rs +++ b/vendor/syn/tests/test_item.rs @@ -1,9 +1,10 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; use quote::quote; -use std::iter::FromIterator; use syn::{Item, ItemTrait}; #[test] @@ -21,23 +22,21 @@ fn test_macro_variable_attr() { Item::Fn { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "test", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { ident: "f", generics: Generics, - output: Default, + output: ReturnType::Default, }, block: Block, } @@ -69,7 +68,7 @@ fn test_negative_impl() { snapshot!(tokens as Item, @r###" Item::Impl { generics: Generics, - self_ty: Verbatim(`! Trait`), + self_ty: Type::Verbatim(`! Trait`), } "###); @@ -87,7 +86,6 @@ fn test_negative_impl() { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, @@ -97,7 +95,6 @@ fn test_negative_impl() { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -114,7 +111,7 @@ fn test_negative_impl() { snapshot!(tokens as Item, @r###" Item::Impl { generics: Generics, - self_ty: Verbatim(`! !`), + self_ty: Type::Verbatim(`! !`), } "###); } @@ -139,7 +136,6 @@ fn test_macro_variable_impl() { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, @@ -150,7 +146,6 @@ fn test_macro_variable_impl() { segments: [ PathSegment { ident: "Type", - arguments: None, }, ], }, @@ -168,7 +163,7 @@ fn test_supertraits() { let tokens = quote!(trait Trait where {}); snapshot!(tokens as ItemTrait, @r###" ItemTrait { - vis: Inherited, + vis: Visibility::Inherited, ident: "Trait", generics: Generics { where_clause: Some(WhereClause), @@ -180,7 +175,7 @@ fn test_supertraits() { let tokens = quote!(trait Trait: where {}); snapshot!(tokens as ItemTrait, @r###" ItemTrait { - vis: Inherited, + vis: Visibility::Inherited, ident: "Trait", generics: Generics { where_clause: Some(WhereClause), @@ -193,20 +188,18 @@ fn test_supertraits() { let tokens = quote!(trait Trait: Sized where {}); snapshot!(tokens as ItemTrait, @r###" ItemTrait { - vis: Inherited, + vis: Visibility::Inherited, ident: "Trait", generics: Generics { where_clause: Some(WhereClause), }, colon_token: Some, supertraits: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Sized", - arguments: None, }, ], }, @@ -219,20 +212,18 @@ fn test_supertraits() { let tokens = quote!(trait Trait: Sized + where {}); snapshot!(tokens as ItemTrait, @r###" ItemTrait { - vis: Inherited, + vis: Visibility::Inherited, ident: "Trait", generics: Generics { where_clause: Some(WhereClause), }, colon_token: Some, supertraits: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Sized", - arguments: None, }, ], }, @@ -253,7 +244,7 @@ fn test_type_empty_bounds() { snapshot!(tokens as ItemTrait, @r###" ItemTrait { - vis: Inherited, + vis: Visibility::Inherited, ident: "Foo", generics: Generics, items: [ @@ -273,7 +264,7 @@ fn test_impl_visibility() { pub default unsafe impl union {} }; - snapshot!(tokens as Item, @"Verbatim(`pub default unsafe impl union { }`)"); + snapshot!(tokens as Item, @"Item::Verbatim(`pub default unsafe impl union { }`)"); } #[test] @@ -288,7 +279,7 @@ fn test_impl_type_parameter_defaults() { generics: Generics { lt_token: Some, params: [ - Type(TypeParam { + GenericParam::Type(TypeParam { ident: "T", eq_token: Some, default: Some(Type::Tuple), @@ -297,7 +288,8 @@ fn test_impl_type_parameter_defaults() { gt_token: Some, }, self_ty: Type::Tuple, - }"###); + } + "###); } #[test] @@ -308,20 +300,18 @@ fn test_impl_trait_trailing_plus() { snapshot!(tokens as Item, @r###" Item::Fn { - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { ident: "f", generics: Generics, - output: Type( + output: ReturnType::Type( Type::ImplTrait { bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Sized", - arguments: None, }, ], }, diff --git a/vendor/syn/tests/test_iterators.rs b/vendor/syn/tests/test_iterators.rs index 0ab0fb914..5f0eff59e 100644 --- a/vendor/syn/tests/test_iterators.rs +++ b/vendor/syn/tests/test_iterators.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + use syn::punctuated::{Pair, Punctuated}; use syn::Token; diff --git a/vendor/syn/tests/test_lit.rs b/vendor/syn/tests/test_lit.rs index ebe077c61..82d229001 100644 --- a/vendor/syn/tests/test_lit.rs +++ b/vendor/syn/tests/test_lit.rs @@ -1,11 +1,14 @@ -#![allow(clippy::float_cmp, clippy::non_ascii_literal)] +#![allow( + clippy::float_cmp, + clippy::non_ascii_literal, + clippy::uninlined_format_args +)] #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Literal, Span, TokenStream, TokenTree}; use quote::ToTokens; -use std::iter::FromIterator; use std::str::FromStr; use syn::{Lit, LitFloat, LitInt, LitStr}; @@ -50,6 +53,10 @@ fn strings() { "\"contains\nnewlines\\\nescaped newlines\"", "contains\nnewlinesescaped newlines", ); + test_string( + "\"escaped newline\\\n \x0C unsupported whitespace\"", + "escaped newline\x0C unsupported whitespace", + ); test_string("r\"raw\nstring\\\nhere\"", "raw\nstring\\\nhere"); test_string("\"...\"q", "..."); test_string("r\"...\"q", "..."); diff --git a/vendor/syn/tests/test_meta.rs b/vendor/syn/tests/test_meta.rs index 9b3f30dee..91a980700 100644 --- a/vendor/syn/tests/test_meta.rs +++ b/vendor/syn/tests/test_meta.rs @@ -1,23 +1,26 @@ -#![allow(clippy::shadow_unrelated, clippy::too_many_lines)] +#![allow( + clippy::shadow_unrelated, + clippy::too_many_lines, + clippy::uninlined_format_args +)] #[macro_use] mod macros; -use syn::{Meta, MetaList, MetaNameValue, NestedMeta}; +use syn::{Meta, MetaList, MetaNameValue}; #[test] fn test_parse_meta_item_word() { let input = "hello"; snapshot!(input as Meta, @r###" - Path(Path { + Meta::Path { segments: [ PathSegment { ident: "hello", - arguments: None, }, ], - }) + } "###); } @@ -32,47 +35,12 @@ fn test_parse_meta_name_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - lit: 5, - } - "###); - - snapshot!(meta as Meta, @r###" - Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "foo", - arguments: None, - }, - ], - }, - lit: 5, - } - "###); - - assert_eq!(meta, inner.into()); -} - -#[test] -fn test_parse_meta_name_value_with_keyword() { - let input = "static = 5"; - let (inner, meta) = (input, input); - - snapshot!(inner as MetaNameValue, @r###" - MetaNameValue { - path: Path { - segments: [ - PathSegment { - ident: "static", - arguments: None, - }, - ], + value: Expr::Lit { + lit: 5, }, - lit: 5, } "###); @@ -81,48 +49,13 @@ fn test_parse_meta_name_value_with_keyword() { path: Path { segments: [ PathSegment { - ident: "static", - arguments: None, - }, - ], - }, - lit: 5, - } - "###); - - assert_eq!(meta, inner.into()); -} - -#[test] -fn test_parse_meta_name_value_with_bool() { - let input = "true = 5"; - let (inner, meta) = (input, input); - - snapshot!(inner as MetaNameValue, @r###" - MetaNameValue { - path: Path { - segments: [ - PathSegment { - ident: "true", - arguments: None, + ident: "foo", }, ], }, - lit: 5, - } - "###); - - snapshot!(meta as Meta, @r###" - Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "true", - arguments: None, - }, - ], + value: Expr::Lit { + lit: 5, }, - lit: 5, } "###); @@ -140,13 +73,11 @@ fn test_parse_meta_item_list_lit() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Lit(5), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`5`), } "###); @@ -156,13 +87,11 @@ fn test_parse_meta_item_list_lit() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Lit(5), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`5`), } "###); @@ -180,62 +109,11 @@ fn test_parse_meta_item_multiple() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word", - arguments: None, - }, - ], - })), - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name", - arguments: None, - }, - ], - }, - lit: 5, - }), - Meta(Meta::List { - path: Path { - segments: [ - PathSegment { - ident: "list", - arguments: None, - }, - ], - }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name2", - arguments: None, - }, - ], - }, - lit: 6, - }), - ], - }), - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word2", - arguments: None, - }, - ], - })), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`word , name = 5 , list (name2 = 6) , word2`), } "###); @@ -245,134 +123,31 @@ fn test_parse_meta_item_multiple() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word", - arguments: None, - }, - ], - })), - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name", - arguments: None, - }, - ], - }, - lit: 5, - }), - Meta(Meta::List { - path: Path { - segments: [ - PathSegment { - ident: "list", - arguments: None, - }, - ], - }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name2", - arguments: None, - }, - ], - }, - lit: 6, - }), - ], - }), - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word2", - arguments: None, - }, - ], - })), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`word , name = 5 , list (name2 = 6) , word2`), } "###); assert_eq!(meta, inner.into()); } -#[test] -fn test_parse_nested_meta() { - let input = "5"; - snapshot!(input as NestedMeta, @"Lit(5)"); - - let input = "list(name2 = 6)"; - snapshot!(input as NestedMeta, @r###" - Meta(Meta::List { - path: Path { - segments: [ - PathSegment { - ident: "list", - arguments: None, - }, - ], - }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name2", - arguments: None, - }, - ], - }, - lit: 6, - }), - ], - }) - "###); -} - #[test] fn test_parse_path() { let input = "::serde::Serialize"; snapshot!(input as Meta, @r###" - Path(Path { - leading_colon: Some, - segments: [ - PathSegment { - ident: "serde", - arguments: None, - }, - PathSegment { - ident: "Serialize", - arguments: None, - }, - ], - }) - "###); - - let input = "::serde::Serialize"; - snapshot!(input as NestedMeta, @r###" - Meta(Path(Path { + Meta::Path { leading_colon: Some, segments: [ PathSegment { ident: "serde", - arguments: None, }, PathSegment { ident: "Serialize", - arguments: None, }, ], - })) + } "###); } diff --git a/vendor/syn/tests/test_parse_buffer.rs b/vendor/syn/tests/test_parse_buffer.rs index cc23e9ba6..f2ca59c75 100644 --- a/vendor/syn/tests/test_parse_buffer.rs +++ b/vendor/syn/tests/test_parse_buffer.rs @@ -1,7 +1,6 @@ #![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}; use syn::{parenthesized, Token}; diff --git a/vendor/syn/tests/test_parse_stream.rs b/vendor/syn/tests/test_parse_stream.rs index cc14fa032..2265dfe87 100644 --- a/vendor/syn/tests/test_parse_stream.rs +++ b/vendor/syn/tests/test_parse_stream.rs @@ -1,12 +1,14 @@ +#![allow(clippy::let_underscore_untyped)] + use syn::ext::IdentExt; use syn::parse::ParseStream; use syn::{Ident, Token}; #[test] fn test_peek() { - _ = |input: ParseStream| { - _ = input.peek(Ident); - _ = input.peek(Ident::peek_any); - _ = input.peek(Token![::]); + let _ = |input: ParseStream| { + let _ = input.peek(Ident); + let _ = input.peek(Ident::peek_any); + let _ = input.peek(Token![::]); }; } diff --git a/vendor/syn/tests/test_pat.rs b/vendor/syn/tests/test_pat.rs index 695e4736e..cab7aa7f6 100644 --- a/vendor/syn/tests/test_pat.rs +++ b/vendor/syn/tests/test_pat.rs @@ -1,14 +1,16 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, TokenStream, TokenTree}; use quote::quote; -use std::iter::FromIterator; +use syn::parse::Parser; use syn::{Item, Pat, Stmt}; #[test] fn test_pat_ident() { - match syn::parse2(quote!(self)).unwrap() { + match Pat::parse_single.parse2(quote!(self)).unwrap() { Pat::Ident(_) => (), value => panic!("expected PatIdent, got {:?}", value), } @@ -16,7 +18,7 @@ fn test_pat_ident() { #[test] fn test_pat_path() { - match syn::parse2(quote!(self::CONST)).unwrap() { + match Pat::parse_single.parse2(quote!(self::CONST)).unwrap() { Pat::Path(_) => (), value => panic!("expected PatPath, got {:?}", value), } @@ -30,7 +32,7 @@ fn test_leading_vert() { syn::parse_str::("fn fun1(| A: E) {}").unwrap_err(); syn::parse_str::("fn fun2(|| A: E) {}").unwrap_err(); - syn::parse_str::("let | () = ();").unwrap(); + syn::parse_str::("let | () = ();").unwrap_err(); syn::parse_str::("let (| A): E;").unwrap(); syn::parse_str::("let (|| A): (E);").unwrap_err(); syn::parse_str::("let (| A,): (E,);").unwrap(); @@ -46,22 +48,50 @@ fn test_leading_vert() { fn test_group() { let group = Group::new(Delimiter::None, quote!(Some(_))); let tokens = TokenStream::from_iter(vec![TokenTree::Group(group)]); + let pat = Pat::parse_single.parse2(tokens).unwrap(); - snapshot!(tokens as Pat, @r###" + snapshot!(pat, @r###" Pat::TupleStruct { path: Path { segments: [ PathSegment { ident: "Some", - arguments: None, }, ], }, - pat: PatTuple { - elems: [ - Pat::Wild, - ], - }, + elems: [ + Pat::Wild, + ], } "###); } + +#[test] +fn test_ranges() { + Pat::parse_single.parse_str("..").unwrap(); + Pat::parse_single.parse_str("..hi").unwrap(); + Pat::parse_single.parse_str("lo..").unwrap(); + Pat::parse_single.parse_str("lo..hi").unwrap(); + + Pat::parse_single.parse_str("..=").unwrap_err(); + Pat::parse_single.parse_str("..=hi").unwrap(); + Pat::parse_single.parse_str("lo..=").unwrap_err(); + Pat::parse_single.parse_str("lo..=hi").unwrap(); + + Pat::parse_single.parse_str("...").unwrap_err(); + Pat::parse_single.parse_str("...hi").unwrap_err(); + Pat::parse_single.parse_str("lo...").unwrap_err(); + Pat::parse_single.parse_str("lo...hi").unwrap(); + + Pat::parse_single.parse_str("[lo..]").unwrap_err(); + Pat::parse_single.parse_str("[..=hi]").unwrap_err(); + Pat::parse_single.parse_str("[(lo..)]").unwrap(); + Pat::parse_single.parse_str("[(..=hi)]").unwrap(); + Pat::parse_single.parse_str("[lo..=hi]").unwrap(); + + Pat::parse_single.parse_str("[_, lo.., _]").unwrap_err(); + Pat::parse_single.parse_str("[_, ..=hi, _]").unwrap_err(); + Pat::parse_single.parse_str("[_, (lo..), _]").unwrap(); + Pat::parse_single.parse_str("[_, (..=hi), _]").unwrap(); + Pat::parse_single.parse_str("[_, lo..=hi, _]").unwrap(); +} diff --git a/vendor/syn/tests/test_path.rs b/vendor/syn/tests/test_path.rs index c732eff70..6aded74e6 100644 --- a/vendor/syn/tests/test_path.rs +++ b/vendor/syn/tests/test_path.rs @@ -1,9 +1,10 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; use quote::{quote, ToTokens}; -use std::iter::FromIterator; use syn::{parse_quote, Expr, Type, TypePath}; #[test] @@ -22,11 +23,9 @@ fn parse_interpolated_leading_component() { segments: [ PathSegment { ident: "first", - arguments: None, }, PathSegment { ident: "rest", - arguments: None, }, ], }, @@ -39,11 +38,9 @@ fn parse_interpolated_leading_component() { segments: [ PathSegment { ident: "first", - arguments: None, }, PathSegment { ident: "rest", - arguments: None, }, ], }, @@ -106,21 +103,26 @@ fn print_incomplete_qpath() { #[test] fn parse_parenthesized_path_arguments_with_disambiguator() { #[rustfmt::skip] - let tokens = quote!(FnOnce::() -> !); + let tokens = quote!(dyn FnOnce::() -> !); snapshot!(tokens as Type, @r###" - Type::Path { - path: Path { - segments: [ - PathSegment { - ident: "FnOnce", - arguments: PathArguments::Parenthesized { - output: Type( - Type::Never, - ), - }, + Type::TraitObject { + dyn_token: Some, + bounds: [ + TypeParamBound::Trait(TraitBound { + path: Path { + segments: [ + PathSegment { + ident: "FnOnce", + arguments: PathArguments::Parenthesized { + output: ReturnType::Type( + Type::Never, + ), + }, + }, + ], }, - ], - }, + }), + ], } "###); } diff --git a/vendor/syn/tests/test_precedence.rs b/vendor/syn/tests/test_precedence.rs index dbcd74f16..e2931ff5a 100644 --- a/vendor/syn/tests/test_precedence.rs +++ b/vendor/syn/tests/test_precedence.rs @@ -4,9 +4,13 @@ #![feature(rustc_private)] #![allow( clippy::explicit_deref_methods, + clippy::let_underscore_untyped, clippy::manual_assert, + clippy::manual_let_else, + clippy::match_like_matches_macro, clippy::match_wildcard_for_single_variants, - clippy::too_many_lines + clippy::too_many_lines, + clippy::uninlined_format_args )] //! The tests in this module do the following: @@ -22,7 +26,9 @@ //! 5. Compare the expressions with one another, if they are not equal fail. extern crate rustc_ast; +extern crate rustc_ast_pretty; extern crate rustc_data_structures; +extern crate rustc_driver; extern crate rustc_span; extern crate thin_vec; @@ -33,8 +39,10 @@ use rayon::iter::{IntoParallelIterator, ParallelIterator}; use regex::Regex; use rustc_ast::ast; use rustc_ast::ptr::P; +use rustc_ast_pretty::pprust; use rustc_span::edition::Edition; use std::fs; +use std::path::Path; use std::process; use std::sync::atomic::{AtomicUsize, Ordering}; use walkdir::{DirEntry, WalkDir}; @@ -47,45 +55,6 @@ mod common; mod repo; -/// Test some pre-set expressions chosen by us. -#[test] -fn test_simple_precedence() { - const EXPRS: &[&str] = &[ - "1 + 2 * 3 + 4", - "1 + 2 * ( 3 + 4 )", - "{ for i in r { } *some_ptr += 1; }", - "{ loop { break 5; } }", - "{ if true { () }.mthd() }", - "{ for i in unsafe { 20 } { } }", - ]; - - let mut failed = 0; - - for input in EXPRS { - let expr = if let Some(expr) = parse::syn_expr(input) { - expr - } else { - failed += 1; - continue; - }; - - let pf = match test_expressions(Edition::Edition2018, vec![expr]) { - (1, 0) => "passed", - (0, 1) => { - failed += 1; - "failed" - } - _ => unreachable!(), - }; - errorf!("=== {}: {}\n", input, pf); - } - - if failed > 0 { - panic!("Failed {} tests", failed); - } -} - -/// Test expressions from rustc, like in `test_round_trip`. #[test] fn test_rustc_precedence() { common::rayon_init(); @@ -121,21 +90,21 @@ fn test_rustc_precedence() { Ok(file) => { let edition = repo::edition(path).parse().unwrap(); let exprs = collect_exprs(file); - test_expressions(edition, exprs) + let (l_passed, l_failed) = test_expressions(path, edition, exprs); + errorf!( + "=== {}: {} passed | {} failed\n", + path.display(), + l_passed, + l_failed, + ); + (l_passed, l_failed) } Err(msg) => { - errorf!("syn failed to parse\n{:?}\n", msg); + errorf!("\nFAIL {} - syn failed to parse: {}\n", path.display(), msg); (0, 1) } }; - errorf!( - "=== {}: {} passed | {} failed\n", - path.display(), - l_passed, - l_failed - ); - passed.fetch_add(l_passed, Ordering::Relaxed); let prev_failed = failed.fetch_add(l_failed, Ordering::Relaxed); @@ -155,7 +124,7 @@ fn test_rustc_precedence() { } } -fn test_expressions(edition: Edition, exprs: Vec) -> (usize, usize) { +fn test_expressions(path: &Path, edition: Edition, exprs: Vec) -> (usize, usize) { let mut passed = 0; let mut failed = 0; @@ -167,7 +136,7 @@ fn test_expressions(edition: Edition, exprs: Vec) -> (usize, usize) { e } else { failed += 1; - errorf!("\nFAIL - librustc failed to parse raw\n"); + errorf!("\nFAIL {} - librustc failed to parse raw\n", path.display()); continue; }; @@ -176,7 +145,10 @@ fn test_expressions(edition: Edition, exprs: Vec) -> (usize, usize) { e } else { failed += 1; - errorf!("\nFAIL - librustc failed to parse bracketed\n"); + errorf!( + "\nFAIL {} - librustc failed to parse bracketed\n", + path.display(), + ); continue; }; @@ -184,7 +156,14 @@ fn test_expressions(edition: Edition, exprs: Vec) -> (usize, usize) { passed += 1; } else { failed += 1; - errorf!("\nFAIL\n{:?}\n!=\n{:?}\n", syn_ast, librustc_ast); + let syn_program = pprust::expr_to_string(&syn_ast); + let librustc_program = pprust::expr_to_string(&librustc_ast); + errorf!( + "\nFAIL {}\n{}\nsyn != rustc\n{}\n", + path.display(), + syn_program, + librustc_program, + ); } } }); @@ -203,11 +182,14 @@ fn librustc_parse_and_rewrite(input: &str) -> Option> { /// This method operates on librustc objects. fn librustc_brackets(mut librustc_expr: P) -> Option> { use rustc_ast::ast::{ - Attribute, Block, BorrowKind, Expr, ExprField, ExprKind, GenericArg, Local, LocalKind, Pat, - Stmt, StmtKind, StructExpr, StructRest, Ty, + Attribute, BinOpKind, Block, BorrowKind, Expr, ExprField, ExprKind, GenericArg, + GenericBound, Local, LocalKind, Pat, Stmt, StmtKind, StructExpr, StructRest, + TraitBoundModifier, Ty, }; - use rustc_ast::mut_visit::{noop_visit_generic_arg, noop_visit_local, MutVisitor}; - use rustc_data_structures::map_in_place::MapInPlace; + use rustc_ast::mut_visit::{ + noop_visit_generic_arg, noop_visit_local, noop_visit_param_bound, MutVisitor, + }; + use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_span::DUMMY_SP; use std::mem; use std::ops::DerefMut; @@ -270,12 +252,15 @@ fn librustc_brackets(mut librustc_expr: P) -> Option> { impl MutVisitor for BracketsVisitor { fn visit_expr(&mut self, e: &mut P) { + noop_visit_expr(e, self); match e.kind { - ExprKind::ConstBlock(..) => {} - _ => noop_visit_expr(e, self), - } - match e.kind { - ExprKind::If(..) | ExprKind::Block(..) | ExprKind::Let(..) => {} + ExprKind::Block(..) | ExprKind::If(..) | ExprKind::Let(..) => {} + ExprKind::Binary(binop, ref left, ref right) + if match (&left.kind, binop.node, &right.kind) { + (ExprKind::Let(..), BinOpKind::And, _) + | (_, BinOpKind::And, ExprKind::Let(..)) => true, + _ => false, + } => {} _ => { let inner = mem::replace( e, @@ -304,6 +289,16 @@ fn librustc_brackets(mut librustc_expr: P) -> Option> { } } + fn visit_param_bound(&mut self, bound: &mut GenericBound) { + match bound { + GenericBound::Trait( + _, + TraitBoundModifier::MaybeConst | TraitBoundModifier::MaybeConstMaybe, + ) => {} + _ => noop_visit_param_bound(bound, self), + } + } + fn visit_block(&mut self, block: &mut P) { self.visit_id(&mut block.id); block @@ -323,15 +318,15 @@ fn librustc_brackets(mut librustc_expr: P) -> Option> { // types yet. We'll look into comparing those in the future. For now // focus on expressions appearing in other places. fn visit_pat(&mut self, pat: &mut P) { - _ = pat; + let _ = pat; } fn visit_ty(&mut self, ty: &mut P) { - _ = ty; + let _ = ty; } fn visit_attribute(&mut self, attr: &mut Attribute) { - _ = attr; + let _ = attr; } } @@ -348,22 +343,33 @@ fn librustc_brackets(mut librustc_expr: P) -> Option> { /// 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::{fold_expr, fold_generic_argument, fold_generic_method_argument, Fold}; - use syn::{token, Expr, ExprParen, GenericArgument, GenericMethodArgument, Pat, Stmt, Type}; + use syn::fold::{fold_expr, fold_generic_argument, Fold}; + use syn::{token, BinOp, Expr, ExprParen, GenericArgument, MetaNameValue, Pat, Stmt, Type}; struct ParenthesizeEveryExpr; + + fn needs_paren(expr: &Expr) -> bool { + match expr { + Expr::Group(_) => unreachable!(), + Expr::If(_) | Expr::Unsafe(_) | Expr::Block(_) | Expr::Let(_) => false, + Expr::Binary(bin) => match (&*bin.left, bin.op, &*bin.right) { + (Expr::Let(_), BinOp::And(_), _) | (_, BinOp::And(_), Expr::Let(_)) => false, + _ => true, + }, + _ => true, + } + } + impl Fold for ParenthesizeEveryExpr { fn fold_expr(&mut self, expr: Expr) -> Expr { - match expr { - Expr::Group(_) => unreachable!(), - Expr::If(..) | Expr::Unsafe(..) | Expr::Block(..) | Expr::Let(..) => { - fold_expr(self, expr) - } - _ => Expr::Paren(ExprParen { + if needs_paren(&expr) { + Expr::Paren(ExprParen { attrs: Vec::new(), expr: Box::new(fold_expr(self, expr)), paren_token: token::Paren::default(), - }), + }) + } else { + fold_expr(self, expr) } } @@ -378,35 +384,20 @@ fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr { } } - fn fold_generic_method_argument( - &mut self, - arg: GenericMethodArgument, - ) -> GenericMethodArgument { - match arg { - GenericMethodArgument::Const(arg) => GenericMethodArgument::Const(match arg { - Expr::Block(_) => fold_expr(self, arg), - // Don't wrap unbraced const generic arg as that's invalid syntax. - _ => arg, - }), - _ => fold_generic_method_argument(self, arg), - } - } - fn fold_stmt(&mut self, stmt: Stmt) -> Stmt { match stmt { // Don't wrap toplevel expressions in statements. - Stmt::Expr(e) => Stmt::Expr(fold_expr(self, e)), - Stmt::Semi(e, semi) => { - if let Expr::Verbatim(_) = e { - Stmt::Semi(e, semi) - } else { - Stmt::Semi(fold_expr(self, e), semi) - } - } + Stmt::Expr(Expr::Verbatim(_), Some(_)) => stmt, + Stmt::Expr(e, semi) => Stmt::Expr(fold_expr(self, e), semi), s => s, } } + fn fold_meta_name_value(&mut self, meta: MetaNameValue) -> MetaNameValue { + // Don't turn #[p = "..."] into #[p = ("...")]. + meta + } + // We don't want to look at expressions that might appear in patterns or // types yet. We'll look into comparing those in the future. For now // focus on expressions appearing in other places. @@ -427,7 +418,7 @@ fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr { fn collect_exprs(file: syn::File) -> Vec { use syn::fold::Fold; use syn::punctuated::Punctuated; - use syn::{token, ConstParam, Expr, ExprTuple, Path}; + use syn::{token, ConstParam, Expr, ExprTuple, Pat, Path}; struct CollectExprs(Vec); impl Fold for CollectExprs { @@ -444,6 +435,10 @@ fn collect_exprs(file: syn::File) -> Vec { }) } + fn fold_pat(&mut self, pat: Pat) -> Pat { + pat + } + fn fold_path(&mut self, path: Path) -> Path { // Skip traversing into const generic path arguments path diff --git a/vendor/syn/tests/test_receiver.rs b/vendor/syn/tests/test_receiver.rs index 923df96ba..8decb555c 100644 --- a/vendor/syn/tests/test_receiver.rs +++ b/vendor/syn/tests/test_receiver.rs @@ -1,127 +1,321 @@ -use syn::{parse_quote, FnArg, Receiver, TraitItemMethod}; +#![allow(clippy::uninlined_format_args)] + +#[macro_use] +mod macros; + +use syn::{parse_quote, TraitItemFn}; #[test] fn test_by_value() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn by_value(self: Self); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + colon_token: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }) + "###); } #[test] fn test_by_mut_value() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn by_mut(mut self: Self); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + mutability: Some, + colon_token: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }) + "###); } #[test] fn test_by_ref() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn by_ref(self: &Self); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + colon_token: Some, + ty: Type::Reference { + elem: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }, + }) + "###); } #[test] fn test_by_box() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn by_box(self: Box); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + colon_token: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Box", + arguments: PathArguments::AngleBracketed { + args: [ + GenericArgument::Type(Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }), + ], + }, + }, + ], + }, + }, + }) + "###); } #[test] fn test_by_pin() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn by_pin(self: Pin); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + colon_token: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Pin", + arguments: PathArguments::AngleBracketed { + args: [ + GenericArgument::Type(Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }), + ], + }, + }, + ], + }, + }, + }) + "###); } #[test] fn test_explicit_type() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn explicit_type(self: Pin); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + colon_token: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Pin", + arguments: PathArguments::AngleBracketed { + args: [ + GenericArgument::Type(Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "MyType", + }, + ], + }, + }), + ], + }, + }, + ], + }, + }, + }) + "###); } #[test] fn test_value_shorthand() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn value_shorthand(self); }; - match sig.receiver() { - Some(FnArg::Receiver(Receiver { - reference: None, - mutability: None, - .. - })) => (), - value => panic!("expected FnArg::Receiver without ref/mut, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }) + "###); } #[test] fn test_mut_value_shorthand() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn mut_value_shorthand(mut self); }; - match sig.receiver() { - Some(FnArg::Receiver(Receiver { - reference: None, - mutability: Some(_), - .. - })) => (), - value => panic!("expected FnArg::Receiver with mut, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + mutability: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }) + "###); } #[test] fn test_ref_shorthand() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn ref_shorthand(&self); }; - match sig.receiver() { - Some(FnArg::Receiver(Receiver { - reference: Some(_), - mutability: None, - .. - })) => (), - value => panic!("expected FnArg::Receiver with ref, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + reference: Some(None), + ty: Type::Reference { + elem: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }, + }) + "###); +} + +#[test] +fn test_ref_shorthand_with_lifetime() { + let TraitItemFn { sig, .. } = parse_quote! { + fn ref_shorthand(&'a self); + }; + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + reference: Some(Some(Lifetime { + ident: "a", + })), + ty: Type::Reference { + lifetime: Some(Lifetime { + ident: "a", + }), + elem: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }, + }) + "###); } #[test] fn test_ref_mut_shorthand() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn ref_mut_shorthand(&mut self); }; - match sig.receiver() { - Some(FnArg::Receiver(Receiver { - reference: Some(_), - mutability: Some(_), - .. - })) => (), - value => panic!("expected FnArg::Receiver with ref+mut, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + reference: Some(None), + mutability: Some, + ty: Type::Reference { + mutability: Some, + elem: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }, + }) + "###); +} + +#[test] +fn test_ref_mut_shorthand_with_lifetime() { + let TraitItemFn { sig, .. } = parse_quote! { + fn ref_mut_shorthand(&'a mut self); + }; + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + reference: Some(Some(Lifetime { + ident: "a", + })), + mutability: Some, + ty: Type::Reference { + lifetime: Some(Lifetime { + ident: "a", + }), + mutability: Some, + elem: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }, + }) + "###); } diff --git a/vendor/syn/tests/test_round_trip.rs b/vendor/syn/tests/test_round_trip.rs index 9a5801d44..853f45eae 100644 --- a/vendor/syn/tests/test_round_trip.rs +++ b/vendor/syn/tests/test_round_trip.rs @@ -2,10 +2,17 @@ #![cfg(not(miri))] #![recursion_limit = "1024"] #![feature(rustc_private)] -#![allow(clippy::manual_assert)] +#![allow( + clippy::manual_assert, + clippy::manual_let_else, + clippy::match_like_matches_macro, + clippy::uninlined_format_args +)] extern crate rustc_ast; +extern crate rustc_ast_pretty; extern crate rustc_data_structures; +extern crate rustc_driver; extern crate rustc_error_messages; extern crate rustc_errors; extern crate rustc_expand; @@ -21,6 +28,7 @@ use rustc_ast::ast::{ WhereClause, }; use rustc_ast::mut_visit::{self, MutVisitor}; +use rustc_ast_pretty::pprust; use rustc_error_messages::{DiagnosticMessage, LazyFallbackBundle}; use rustc_errors::{translation, Diagnostic, PResult}; use rustc_session::parse::ParseSess; @@ -93,7 +101,9 @@ fn test(path: &Path, failed: &AtomicUsize, abort_after: usize) { rustc_span::create_session_if_not_set_then(edition, |_| { let equal = match panic::catch_unwind(|| { - let sess = ParseSess::new(FilePathMapping::empty()); + let locale_resources = rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(); + let file_path_mapping = FilePathMapping::empty(); + let sess = ParseSess::new(locale_resources, file_path_mapping); let before = match librustc_parse(content, &sess) { Ok(before) => before, Err(diagnostic) => { @@ -133,10 +143,10 @@ fn test(path: &Path, failed: &AtomicUsize, abort_after: usize) { true } else { errorf!( - "=== {}: FAIL\nbefore: {:#?}\nafter: {:#?}\n", + "=== {}: FAIL\n{}\n!=\n{}\n", path.display(), - before, - after, + pprust::crate_to_string_for_macros(&before), + pprust::crate_to_string_for_macros(&after), ); false } @@ -161,9 +171,9 @@ fn librustc_parse(content: String, sess: &ParseSess) -> PResult { fn translate_message(diagnostic: &Diagnostic) -> String { thread_local! { static FLUENT_BUNDLE: LazyFallbackBundle = { - let resources = rustc_error_messages::DEFAULT_LOCALE_RESOURCES; + let locale_resources = rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(); let with_directionality_markers = false; - rustc_error_messages::fallback_fluent_bundle(resources, with_directionality_markers) + rustc_error_messages::fallback_fluent_bundle(locale_resources, with_directionality_markers) }; } diff --git a/vendor/syn/tests/test_shebang.rs b/vendor/syn/tests/test_shebang.rs index dc26b9aab..4c2a20457 100644 --- a/vendor/syn/tests/test_shebang.rs +++ b/vendor/syn/tests/test_shebang.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; @@ -10,11 +12,11 @@ fn test_basic() { shebang: Some("#!/usr/bin/env rustx"), items: [ Item::Fn { - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { ident: "main", generics: Generics, - output: Default, + output: ReturnType::Default, }, block: Block, }, @@ -31,25 +33,27 @@ fn test_comment() { File { attrs: [ Attribute { - style: Inner, - path: Path { - segments: [ - PathSegment { - ident: "allow", - arguments: None, - }, - ], + style: AttrStyle::Inner, + meta: Meta::List { + path: Path { + segments: [ + PathSegment { + ident: "allow", + }, + ], + }, + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`dead_code`), }, - tokens: TokenStream(`(dead_code)`), }, ], items: [ Item::Fn { - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { ident: "main", generics: Generics, - output: Default, + output: ReturnType::Default, }, block: Block, }, diff --git a/vendor/syn/tests/test_size.rs b/vendor/syn/tests/test_size.rs index 32c6edaed..864c0116a 100644 --- a/vendor/syn/tests/test_size.rs +++ b/vendor/syn/tests/test_size.rs @@ -1,28 +1,35 @@ +// Assumes proc-macro2's "span-locations" feature is off. + #![cfg(target_pointer_width = "64")] use std::mem; use syn::{Expr, Item, Lit, Pat, Type}; +#[rustversion::attr(before(2022-11-24), ignore)] #[test] fn test_expr_size() { - assert_eq!(mem::size_of::(), 272); + assert_eq!(mem::size_of::(), 176); } +#[rustversion::attr(before(2022-09-09), ignore)] #[test] fn test_item_size() { - assert_eq!(mem::size_of::(), 320); + assert_eq!(mem::size_of::(), 360); } +#[rustversion::attr(before(2022-11-24), ignore)] #[test] fn test_type_size() { - assert_eq!(mem::size_of::(), 288); + assert_eq!(mem::size_of::(), 240); } +#[rustversion::attr(before(2021-10-11), ignore)] #[test] fn test_pat_size() { - assert_eq!(mem::size_of::(), 144); + assert_eq!(mem::size_of::(), 192); } +#[rustversion::attr(before(2022-09-09), ignore)] #[test] fn test_lit_size() { assert_eq!(mem::size_of::(), 32); diff --git a/vendor/syn/tests/test_stmt.rs b/vendor/syn/tests/test_stmt.rs index f444e5b49..bc57685df 100644 --- a/vendor/syn/tests/test_stmt.rs +++ b/vendor/syn/tests/test_stmt.rs @@ -1,11 +1,14 @@ -#![allow(clippy::assertions_on_result_states, clippy::non_ascii_literal)] +#![allow( + clippy::assertions_on_result_states, + clippy::non_ascii_literal, + clippy::uninlined_format_args +)] #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; use quote::quote; -use std::iter::FromIterator; use syn::Stmt; #[test] @@ -13,10 +16,12 @@ fn test_raw_operator() { let stmt = syn::parse_str::("let _ = &raw const x;").unwrap(); snapshot!(stmt, @r###" - Local(Local { + Stmt::Local { pat: Pat::Wild, - init: Some(Verbatim(`& raw const x`)), - }) + init: Some(LocalInit { + expr: Expr::Verbatim(`& raw const x`), + }), + } "###); } @@ -25,21 +30,22 @@ fn test_raw_variable() { let stmt = syn::parse_str::("let _ = &raw;").unwrap(); snapshot!(stmt, @r###" - Local(Local { + Stmt::Local { pat: Pat::Wild, - init: Some(Expr::Reference { - expr: Expr::Path { - path: Path { - segments: [ - PathSegment { - ident: "raw", - arguments: None, - }, - ], + init: Some(LocalInit { + expr: Expr::Reference { + expr: Expr::Path { + path: Path { + segments: [ + PathSegment { + ident: "raw", + }, + ], + }, }, }, }), - }) + } "###); } @@ -63,13 +69,13 @@ fn test_none_group() { ))]); snapshot!(tokens as Stmt, @r###" - Item(Item::Fn { - vis: Inherited, + Stmt::Item(Item::Fn { + vis: Visibility::Inherited, sig: Signature { asyncness: Some, ident: "f", generics: Generics, - output: Default, + output: ReturnType::Default, }, block: Block, }) @@ -83,11 +89,148 @@ fn test_let_dot_dot() { }; snapshot!(tokens as Stmt, @r###" - Local(Local { + Stmt::Local { pat: Pat::Rest, - init: Some(Expr::Lit { - lit: 10, + init: Some(LocalInit { + expr: Expr::Lit { + lit: 10, + }, + }), + } + "###); +} + +#[test] +fn test_let_else() { + let tokens = quote! { + let Some(x) = None else { return 0; }; + }; + + snapshot!(tokens as Stmt, @r###" + Stmt::Local { + pat: Pat::TupleStruct { + path: Path { + segments: [ + PathSegment { + ident: "Some", + }, + ], + }, + elems: [ + Pat::Ident { + ident: "x", + }, + ], + }, + init: Some(LocalInit { + expr: Expr::Path { + path: Path { + segments: [ + PathSegment { + ident: "None", + }, + ], + }, + }, + diverge: Some(Expr::Block { + block: Block { + stmts: [ + Stmt::Expr( + Expr::Return { + expr: Some(Expr::Lit { + lit: 0, + }), + }, + Some, + ), + ], + }, + }), }), + } + "###); +} + +#[test] +fn test_macros() { + let tokens = quote! { + fn main() { + macro_rules! mac {} + thread_local! { static FOO } + println!(""); + vec![] + } + }; + + snapshot!(tokens as Stmt, @r###" + Stmt::Item(Item::Fn { + vis: Visibility::Inherited, + sig: Signature { + ident: "main", + generics: Generics, + output: ReturnType::Default, + }, + block: Block { + stmts: [ + Stmt::Item(Item::Macro { + ident: Some("mac"), + mac: Macro { + path: Path { + segments: [ + PathSegment { + ident: "macro_rules", + }, + ], + }, + delimiter: MacroDelimiter::Brace, + tokens: TokenStream(``), + }, + }), + Stmt::Macro { + mac: Macro { + path: Path { + segments: [ + PathSegment { + ident: "thread_local", + }, + ], + }, + delimiter: MacroDelimiter::Brace, + tokens: TokenStream(`static FOO`), + }, + }, + Stmt::Macro { + mac: Macro { + path: Path { + segments: [ + PathSegment { + ident: "println", + }, + ], + }, + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`""`), + }, + semi_token: Some, + }, + Stmt::Expr( + Expr::Macro { + mac: Macro { + path: Path { + segments: [ + PathSegment { + ident: "vec", + }, + ], + }, + delimiter: MacroDelimiter::Bracket, + tokens: TokenStream(``), + }, + }, + None, + ), + ], + }, }) "###); } diff --git a/vendor/syn/tests/test_token_trees.rs b/vendor/syn/tests/test_token_trees.rs index 5b00448af..f5a067fd2 100644 --- a/vendor/syn/tests/test_token_trees.rs +++ b/vendor/syn/tests/test_token_trees.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; diff --git a/vendor/syn/tests/test_ty.rs b/vendor/syn/tests/test_ty.rs index 335cafa2a..a400a7612 100644 --- a/vendor/syn/tests/test_ty.rs +++ b/vendor/syn/tests/test_ty.rs @@ -1,9 +1,10 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; use quote::quote; -use std::iter::FromIterator; use syn::Type; #[test] @@ -34,12 +35,11 @@ fn test_macro_variable_type() { ident: "ty", arguments: PathArguments::AngleBracketed { args: [ - Type(Type::Path { + GenericArgument::Type(Type::Path { path: Path { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -71,12 +71,11 @@ fn test_macro_variable_type() { arguments: PathArguments::AngleBracketed { colon2_token: Some, args: [ - Type(Type::Path { + GenericArgument::Type(Type::Path { path: Path { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -108,7 +107,7 @@ fn test_group_angle_brackets() { ident: "Option", arguments: PathArguments::AngleBracketed { args: [ - Type(Type::Group { + GenericArgument::Type(Type::Group { elem: Type::Path { path: Path { segments: [ @@ -116,12 +115,11 @@ fn test_group_angle_brackets() { ident: "Vec", arguments: PathArguments::AngleBracketed { args: [ - Type(Type::Path { + GenericArgument::Type(Type::Path { path: Path { segments: [ PathSegment { ident: "u8", - arguments: None, }, ], }, @@ -160,12 +158,11 @@ fn test_group_colons() { ident: "Vec", arguments: PathArguments::AngleBracketed { args: [ - Type(Type::Path { + GenericArgument::Type(Type::Path { path: Path { segments: [ PathSegment { ident: "u8", - arguments: None, }, ], }, @@ -175,7 +172,6 @@ fn test_group_colons() { }, PathSegment { ident: "Item", - arguments: None, }, ], }, @@ -198,7 +194,6 @@ fn test_group_colons() { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -211,7 +206,6 @@ fn test_group_colons() { segments: [ PathSegment { ident: "Element", - arguments: None, }, ], }, @@ -226,15 +220,14 @@ fn test_trait_object() { Type::TraitObject { dyn_token: Some, bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { lifetimes: Some(BoundLifetimes { lifetimes: [ - LifetimeDef { + GenericParam::Lifetime(LifetimeParam { lifetime: Lifetime { ident: "a", }, - }, + }), ], }), path: Path { @@ -243,7 +236,7 @@ fn test_trait_object() { ident: "Trait", arguments: PathArguments::AngleBracketed { args: [ - Lifetime(Lifetime { + GenericArgument::Lifetime(Lifetime { ident: "a", }), ], @@ -252,9 +245,9 @@ fn test_trait_object() { ], }, }), - Lifetime(Lifetime { + TypeParamBound::Lifetime { ident: "static", - }), + }, ], } "###); @@ -264,16 +257,14 @@ fn test_trait_object() { Type::TraitObject { dyn_token: Some, bounds: [ - Lifetime(Lifetime { + TypeParamBound::Lifetime { ident: "a", - }), - Trait(TraitBound { - modifier: None, + }, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, @@ -294,13 +285,11 @@ fn test_trailing_plus() { snapshot!(tokens as Type, @r###" Type::ImplTrait { bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, @@ -315,13 +304,11 @@ fn test_trailing_plus() { Type::TraitObject { dyn_token: Some, bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, @@ -335,13 +322,11 @@ fn test_trailing_plus() { snapshot!(tokens as Type, @r###" Type::TraitObject { bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, diff --git a/vendor/syn/tests/test_visibility.rs b/vendor/syn/tests/test_visibility.rs index 7b2c00ba3..496e0070b 100644 --- a/vendor/syn/tests/test_visibility.rs +++ b/vendor/syn/tests/test_visibility.rs @@ -1,8 +1,9 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; -use std::iter::FromIterator; use syn::parse::{Parse, ParseStream}; use syn::{DeriveInput, Result, Visibility}; @@ -50,11 +51,6 @@ fn test_pub() { assert_vis_parse!("pub", Ok(Visibility::Public(_))); } -#[test] -fn test_crate() { - assert_vis_parse!("crate", Ok(Visibility::Crate(_))); -} - #[test] fn test_inherited() { assert_vis_parse!("", Ok(Visibility::Inherited)); @@ -128,14 +124,14 @@ fn test_empty_group_vis() { snapshot!(tokens as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { fields: Fields::Named { named: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ident: Some("f"), colon_token: Some, ty: Type::Tuple, -- cgit v1.2.3