diff --git a/src/expr.rs b/src/expr.rs index d5c631ed37..db8d5b9211 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -647,7 +647,7 @@ ast_struct! { ast_struct! { /// A tuple expression: `(a, b, c, d)`. #[cfg_attr(docsrs, doc(cfg(feature = "full")))] - pub struct ExprTuple #full { + pub struct ExprTuple { pub attrs: Vec, pub paren_token: token::Paren, pub elems: Punctuated, @@ -1111,13 +1111,13 @@ pub(crate) mod parsing { use crate::expr::{ Arm, ExprArray, ExprAssign, ExprAsync, ExprAwait, ExprBlock, ExprBreak, ExprClosure, ExprConst, ExprContinue, ExprForLoop, ExprIf, ExprInfer, ExprLet, ExprLoop, ExprMatch, - ExprRange, ExprRepeat, ExprReturn, ExprTry, ExprTryBlock, ExprTuple, ExprUnsafe, ExprWhile, - ExprYield, Label, RangeLimits, + ExprRange, ExprRepeat, ExprReturn, ExprTry, ExprTryBlock, ExprUnsafe, ExprWhile, ExprYield, + Label, RangeLimits, }; use crate::expr::{ Expr, ExprBinary, ExprCall, ExprCast, ExprField, ExprGroup, ExprIndex, ExprLit, ExprMacro, - ExprMethodCall, ExprParen, ExprPath, ExprReference, ExprStruct, ExprUnary, FieldValue, - Index, Member, + ExprMethodCall, ExprParen, ExprPath, ExprReference, ExprStruct, ExprTuple, ExprUnary, + FieldValue, Index, Member, }; #[cfg(feature = "full")] use crate::ext::IdentExt as _; @@ -1807,7 +1807,7 @@ pub(crate) mod parsing { } else if input.peek(Lit) { input.parse().map(Expr::Lit) } else if input.peek(token::Paren) { - input.call(expr_paren).map(Expr::Paren) + paren_or_tuple(input) } else if input.peek(Ident) || input.peek(Token![::]) || input.peek(Token![<]) @@ -1911,7 +1911,6 @@ pub(crate) mod parsing { } } - #[cfg(feature = "full")] fn paren_or_tuple(input: ParseStream) -> Result { let content; let paren_token = parenthesized!(content in input); @@ -2103,19 +2102,15 @@ pub(crate) mod parsing { #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))] impl Parse for ExprParen { fn parse(input: ParseStream) -> Result { - expr_paren(input) + let content; + Ok(ExprParen { + attrs: Vec::new(), + paren_token: parenthesized!(content in input), + expr: content.parse()?, + }) } } - fn expr_paren(input: ParseStream) -> Result { - let content; - Ok(ExprParen { - attrs: Vec::new(), - paren_token: parenthesized!(content in input), - expr: content.parse()?, - }) - } - #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))] impl Parse for ExprLet { @@ -3000,13 +2995,13 @@ pub(crate) mod printing { use crate::expr::{ Arm, ExprArray, ExprAssign, ExprAsync, ExprAwait, ExprBlock, ExprBreak, ExprClosure, ExprConst, ExprContinue, ExprForLoop, ExprIf, ExprInfer, ExprLet, ExprLoop, ExprMatch, - ExprRange, ExprRepeat, ExprReturn, ExprTry, ExprTryBlock, ExprTuple, ExprUnsafe, ExprWhile, - ExprYield, Label, RangeLimits, + ExprRange, ExprRepeat, ExprReturn, ExprTry, ExprTryBlock, ExprUnsafe, ExprWhile, ExprYield, + Label, RangeLimits, }; use crate::expr::{ Expr, ExprBinary, ExprCall, ExprCast, ExprField, ExprGroup, ExprIndex, ExprLit, ExprMacro, - ExprMethodCall, ExprParen, ExprPath, ExprReference, ExprStruct, ExprUnary, FieldValue, - Index, Member, + ExprMethodCall, ExprParen, ExprPath, ExprReference, ExprStruct, ExprTuple, ExprUnary, + FieldValue, Index, Member, }; use crate::fixup::FixupContext; use crate::op::BinOp; @@ -3781,7 +3776,6 @@ pub(crate) mod printing { } } - #[cfg(feature = "full")] #[cfg_attr(docsrs, doc(cfg(feature = "printing")))] impl ToTokens for ExprTuple { fn to_tokens(&self, tokens: &mut TokenStream) { diff --git a/src/gen/clone.rs b/src/gen/clone.rs index de8d574516..9757561395 100644 --- a/src/gen/clone.rs +++ b/src/gen/clone.rs @@ -280,7 +280,6 @@ impl Clone for crate::Expr { crate::Expr::Try(v0) => crate::Expr::Try(v0.clone()), #[cfg(feature = "full")] crate::Expr::TryBlock(v0) => crate::Expr::TryBlock(v0.clone()), - #[cfg(feature = "full")] crate::Expr::Tuple(v0) => crate::Expr::Tuple(v0.clone()), crate::Expr::Unary(v0) => crate::Expr::Unary(v0.clone()), #[cfg(feature = "full")] @@ -695,7 +694,7 @@ impl Clone for crate::ExprTryBlock { } } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "clone-impls")))] impl Clone for crate::ExprTuple { fn clone(&self) -> Self { diff --git a/src/gen/debug.rs b/src/gen/debug.rs index 9232ece8ac..fe1179c9ff 100644 --- a/src/gen/debug.rs +++ b/src/gen/debug.rs @@ -451,7 +451,6 @@ impl Debug for crate::Expr { crate::Expr::Try(v0) => v0.debug(formatter, "Try"), #[cfg(feature = "full")] crate::Expr::TryBlock(v0) => v0.debug(formatter, "TryBlock"), - #[cfg(feature = "full")] crate::Expr::Tuple(v0) => v0.debug(formatter, "Tuple"), crate::Expr::Unary(v0) => v0.debug(formatter, "Unary"), #[cfg(feature = "full")] @@ -1068,14 +1067,14 @@ impl crate::ExprTryBlock { formatter.finish() } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] impl Debug for crate::ExprTuple { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { self.debug(formatter, "ExprTuple") } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] impl crate::ExprTuple { fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { let mut formatter = formatter.debug_struct(name); diff --git a/src/gen/eq.rs b/src/gen/eq.rs index bbcca47281..936293c39a 100644 --- a/src/gen/eq.rs +++ b/src/gen/eq.rs @@ -311,7 +311,6 @@ impl PartialEq for crate::Expr { (crate::Expr::TryBlock(self0), crate::Expr::TryBlock(other0)) => { self0 == other0 } - #[cfg(feature = "full")] (crate::Expr::Tuple(self0), crate::Expr::Tuple(other0)) => self0 == other0, (crate::Expr::Unary(self0), crate::Expr::Unary(other0)) => self0 == other0, #[cfg(feature = "full")] @@ -674,10 +673,10 @@ impl PartialEq for crate::ExprTryBlock { self.attrs == other.attrs && self.block == other.block } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] impl Eq for crate::ExprTuple {} -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] impl PartialEq for crate::ExprTuple { fn eq(&self, other: &Self) -> bool { diff --git a/src/gen/fold.rs b/src/gen/fold.rs index e5662f5834..c3de096682 100644 --- a/src/gen/fold.rs +++ b/src/gen/fold.rs @@ -299,8 +299,8 @@ pub trait Fold { fn fold_expr_try_block(&mut self, i: crate::ExprTryBlock) -> crate::ExprTryBlock { fold_expr_try_block(self, i) } - #[cfg(feature = "full")] - #[cfg_attr(docsrs, doc(cfg(feature = "full")))] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_tuple(&mut self, i: crate::ExprTuple) -> crate::ExprTuple { fold_expr_tuple(self, i) } @@ -1358,7 +1358,7 @@ where crate::Expr::TryBlock(full!(f.fold_expr_try_block(_binding_0))) } crate::Expr::Tuple(_binding_0) => { - crate::Expr::Tuple(full!(f.fold_expr_tuple(_binding_0))) + crate::Expr::Tuple(f.fold_expr_tuple(_binding_0)) } crate::Expr::Unary(_binding_0) => { crate::Expr::Unary(f.fold_expr_unary(_binding_0)) @@ -1819,8 +1819,8 @@ where block: f.fold_block(node.block), } } -#[cfg(feature = "full")] -#[cfg_attr(docsrs, doc(cfg(feature = "full")))] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_tuple(f: &mut F, node: crate::ExprTuple) -> crate::ExprTuple where F: Fold + ?Sized, diff --git a/src/gen/hash.rs b/src/gen/hash.rs index 02097b9d6e..4dedba4a1f 100644 --- a/src/gen/hash.rs +++ b/src/gen/hash.rs @@ -484,7 +484,6 @@ impl Hash for crate::Expr { state.write_u8(32u8); v0.hash(state); } - #[cfg(feature = "full")] crate::Expr::Tuple(v0) => { state.write_u8(33u8); v0.hash(state); @@ -916,7 +915,7 @@ impl Hash for crate::ExprTryBlock { self.block.hash(state); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(feature = "extra-traits")))] impl Hash for crate::ExprTuple { fn hash(&self, state: &mut H) diff --git a/src/gen/visit.rs b/src/gen/visit.rs index b61997f177..6c96a3f31d 100644 --- a/src/gen/visit.rs +++ b/src/gen/visit.rs @@ -294,8 +294,8 @@ pub trait Visit<'ast> { fn visit_expr_try_block(&mut self, i: &'ast crate::ExprTryBlock) { visit_expr_try_block(self, i); } - #[cfg(feature = "full")] - #[cfg_attr(docsrs, doc(cfg(feature = "full")))] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_tuple(&mut self, i: &'ast crate::ExprTuple) { visit_expr_tuple(self, i); } @@ -1374,7 +1374,7 @@ where full!(v.visit_expr_try_block(_binding_0)); } crate::Expr::Tuple(_binding_0) => { - full!(v.visit_expr_tuple(_binding_0)); + v.visit_expr_tuple(_binding_0); } crate::Expr::Unary(_binding_0) => { v.visit_expr_unary(_binding_0); @@ -1874,8 +1874,8 @@ where skip!(node.try_token); v.visit_block(&node.block); } -#[cfg(feature = "full")] -#[cfg_attr(docsrs, doc(cfg(feature = "full")))] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_tuple<'ast, V>(v: &mut V, node: &'ast crate::ExprTuple) where V: Visit<'ast> + ?Sized, diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs index 9d457f1640..b70a4227ec 100644 --- a/src/gen/visit_mut.rs +++ b/src/gen/visit_mut.rs @@ -295,8 +295,8 @@ pub trait VisitMut { fn visit_expr_try_block_mut(&mut self, i: &mut crate::ExprTryBlock) { visit_expr_try_block_mut(self, i); } - #[cfg(feature = "full")] - #[cfg_attr(docsrs, doc(cfg(feature = "full")))] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_tuple_mut(&mut self, i: &mut crate::ExprTuple) { visit_expr_tuple_mut(self, i); } @@ -1375,7 +1375,7 @@ where full!(v.visit_expr_try_block_mut(_binding_0)); } crate::Expr::Tuple(_binding_0) => { - full!(v.visit_expr_tuple_mut(_binding_0)); + v.visit_expr_tuple_mut(_binding_0); } crate::Expr::Unary(_binding_0) => { v.visit_expr_unary_mut(_binding_0); @@ -1875,8 +1875,8 @@ where skip!(node.try_token); v.visit_block_mut(&mut node.block); } -#[cfg(feature = "full")] -#[cfg_attr(docsrs, doc(cfg(feature = "full")))] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_tuple_mut(v: &mut V, node: &mut crate::ExprTuple) where V: VisitMut + ?Sized, diff --git a/syn.json b/syn.json index d382430180..f1ac6a5fac 100644 --- a/syn.json +++ b/syn.json @@ -1799,6 +1799,7 @@ "ident": "ExprTuple", "features": { "any": [ + "derive", "full" ] },