diff --git a/src/expr.rs b/src/expr.rs index 7b7c50769f..7c6a546f6f 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -840,6 +840,14 @@ ast_enum_of_structs! { pub pat: Box, }), + /// The dots in a tuple or slice pattern: `[0, 1, ..]` + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Rest(PatRest { + pub attrs: Vec, + pub dot2_token: Token![..], + }), + /// A dynamically sized slice pattern: `[a, b, i.., y, z]`. /// /// *This type is available if Syn is built with the `"full"` feature.* @@ -2123,6 +2131,7 @@ pub mod parsing { Pat::Path(pat) => pat.attrs = attrs, Pat::Range(pat) => pat.attrs = attrs, Pat::Reference(pat) => pat.attrs = attrs, + Pat::Rest(pat) => pat.attrs = attrs, Pat::Slice(pat) => pat.attrs = attrs, Pat::Struct(pat) => pat.attrs = attrs, Pat::Tuple(pat) => pat.attrs = attrs, @@ -3812,6 +3821,13 @@ mod printing { } } + #[cfg(feature = "full")] + impl ToTokens for PatRest { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.dot2_token.to_tokens(tokens); + } + } + #[cfg(feature = "full")] impl ToTokens for PatLit { fn to_tokens(&self, tokens: &mut TokenStream) { diff --git a/src/lib.rs b/src/lib.rs index 13b3200871..0fc5ccaa4c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -331,7 +331,7 @@ pub use crate::expr::{ #[cfg(feature = "full")] pub use crate::expr::{ Arm, Block, FieldPat, FieldValue, GenericMethodArgument, Label, Local, MethodTurbofish, Pat, - PatBox, PatIdent, PatLit, PatMacro, PatPath, PatRange, PatReference, PatSlice, PatStruct, PatTuple, + PatBox, PatIdent, PatLit, PatMacro, PatPath, PatRange, PatReference, PatRest, PatSlice, PatStruct, PatTuple, PatTupleStruct, PatType, PatVerbatim, PatWild, RangeLimits, Stmt, };