Repository: dtolnay/syn
Pull request #1355 (2023-02-05 01:58:04)

Rename punctuation tokens to match naming used in Reference
https://doc.rust-lang.org/nightly/reference/tokens.html#punctuation


Patch:
diff --git a/src/token.rs b/src/token.rs
index 3effc4f4..033ce8b3 100644
--- a/src/token.rs
+++ b/src/token.rs
@@ -707,24 +707,18 @@ define_keywords! {
 }
 
 define_punctuation! {
-    "+"           pub struct Add/1        /// `+`
-    "+="          pub struct AddEq/2      /// `+=`
     "&"           pub struct And/1        /// `&`
     "&&"          pub struct AndAnd/2     /// `&&`
     "&="          pub struct AndEq/2      /// `&=`
     "@"           pub struct At/1         /// `@`
-    "!"           pub struct Bang/1       /// `!`
     "^"           pub struct Caret/1      /// `^`
     "^="          pub struct CaretEq/2    /// `^=`
     ":"           pub struct Colon/1      /// `:`
-    "::"          pub struct Colon2/2     /// `::`
     ","           pub struct Comma/1      /// `,`
-    "/"           pub struct Div/1        /// `/`
-    "/="          pub struct DivEq/2      /// `/=`
     "$"           pub struct Dollar/1     /// `$`
     "."           pub struct Dot/1        /// `.`
-    ".."          pub struct Dot2/2       /// `..`
-    "..."         pub struct Dot3/3       /// `...`
+    ".."          pub struct DotDot/2     /// `..`
+    "..."         pub struct DotDotDot/3  /// `...`
     "..="         pub struct DotDotEq/3   /// `..=`
     "="           pub struct Eq/1         /// `=`
     "=="          pub struct EqEq/2       /// `==`
@@ -734,24 +728,30 @@ define_punctuation! {
     "<-"          pub struct LArrow/2     /// `<-`
     "<="          pub struct Le/2         /// `<=`
     "<"           pub struct Lt/1         /// `<`
-    "*="          pub struct MulEq/2      /// `*=`
+    "-"           pub struct Minus/1      /// `-`
+    "-="          pub struct MinusEq/2    /// `-=`
     "!="          pub struct Ne/2         /// `!=`
+    "!"           pub struct Not/1        /// `!`
     "|"           pub struct Or/1         /// `|`
     "|="          pub struct OrEq/2       /// `|=`
     "||"          pub struct OrOr/2       /// `||`
+    "::"          pub struct PathSep/2    /// `::`
+    "%"           pub struct Percent/1    /// `%`
+    "%="          pub struct PercentEq/2  /// `%=`
+    "+"           pub struct Plus/1       /// `+`
+    "+="          pub struct PlusEq/2     /// `+=`
     "#"           pub struct Pound/1      /// `#`
     "?"           pub struct Question/1   /// `?`
     "->"          pub struct RArrow/2     /// `->`
-    "%"           pub struct Rem/1        /// `%`
-    "%="          pub struct RemEq/2      /// `%=`
     ";"           pub struct Semi/1       /// `;`
     "<<"          pub struct Shl/2        /// `<<`
     "<<="         pub struct ShlEq/3      /// `<<=`
     ">>"          pub struct Shr/2        /// `>>`
     ">>="         pub struct ShrEq/3      /// `>>=`
+    "/"           pub struct Slash/1      /// `/`
+    "/="          pub struct SlashEq/2    /// `/=`
     "*"           pub struct Star/1       /// `*`
-    "-"           pub struct Sub/1        /// `-`
-    "-="          pub struct SubEq/2      /// `-=`
+    "*="          pub struct StarEq/2     /// `*=`
     "~"           pub struct Tilde/1      /// `~`
 }
 
@@ -824,24 +824,18 @@ macro_rules! Token {
     [where]       => { $crate::token::Where };
     [while]       => { $crate::token::While };
     [yield]       => { $crate::token::Yield };
-    [+]           => { $crate::token::Add };
-    [+=]          => { $crate::token::AddEq };
     [&]           => { $crate::token::And };
     [&&]          => { $crate::token::AndAnd };
     [&=]          => { $crate::token::AndEq };
     [@]           => { $crate::token::At };
-    [!]           => { $crate::token::Bang };
     [^]           => { $crate::token::Caret };
     [^=]          => { $crate::token::CaretEq };
     [:]           => { $crate::token::Colon };
-    [::]          => { $crate::token::Colon2 };
     [,]           => { $crate::token::Comma };
-    [/]           => { $crate::token::Div };
-    [/=]          => { $crate::token::DivEq };
     [$]           => { $crate::token::Dollar };
     [.]           => { $crate::token::Dot };
-    [..]          => { $crate::token::Dot2 };
-    [...]         => { $crate::token::Dot3 };
+    [..]          => { $crate::token::DotDot };
+    [...]         => { $crate::token::DotDotDot };
     [..=]         => { $crate::token::DotDotEq };
     [=]           => { $crate::token::Eq };
     [==]          => { $crate::token::EqEq };
@@ -851,24 +845,30 @@ macro_rules! Token {
     [<-]          => { $crate::token::LArrow };
     [<=]          => { $crate::token::Le };
     [<]           => { $crate::token::Lt };
-    [*=]          => { $crate::token::MulEq };
+    [-]           => { $crate::token::Minus };
+    [-=]          => { $crate::token::MinusEq };
     [!=]          => { $crate::token::Ne };
+    [!]           => { $crate::token::Not };
     [|]           => { $crate::token::Or };
     [|=]          => { $crate::token::OrEq };
     [||]          => { $crate::token::OrOr };
+    [::]          => { $crate::token::PathSep };
+    [%]           => { $crate::token::Percent };
+    [%=]          => { $crate::token::PercentEq };
+    [+]           => { $crate::token::Plus };
+    [+=]          => { $crate::token::PlusEq };
     [#]           => { $crate::token::Pound };
     [?]           => { $crate::token::Question };
     [->]          => { $crate::token::RArrow };
-    [%]           => { $crate::token::Rem };
-    [%=]          => { $crate::token::RemEq };
     [;]           => { $crate::token::Semi };
     [<<]          => { $crate::token::Shl };
     [<<=]         => { $crate::token::ShlEq };
     [>>]          => { $crate::token::Shr };
     [>>=]         => { $crate::token::ShrEq };
+    [/]           => { $crate::token::Slash };
+    [/=]          => { $crate::token::SlashEq };
     [*]           => { $crate::token::Star };
-    [-]           => { $crate::token::Sub };
-    [-=]          => { $crate::token::SubEq };
+    [*=]          => { $crate::token::StarEq };
     [~]           => { $crate::token::Tilde };
     [_]           => { $crate::token::Underscore };
 }
diff --git a/syn.json b/syn.json
index b366505a..4ea5b0d1 100644
--- a/syn.json
+++ b/syn.json
@@ -31,7 +31,7 @@
       "fields": {
         "colon2_token": {
           "option": {
-            "token": "Colon2"
+            "token": "PathSep"
           }
         },
         "lt_token": {
@@ -157,7 +157,7 @@
         "Outer": [],
         "Inner": [
           {
-            "token": "Bang"
+            "token": "Not"
           }
         ]
       }
@@ -243,7 +243,7 @@
           }
         },
         "dots": {
-          "token": "Dot3"
+          "token": "DotDotDot"
         },
         "comma": {
           "option": {
@@ -263,12 +263,12 @@
       "variants": {
         "Add": [
           {
-            "token": "Add"
+            "token": "Plus"
           }
         ],
         "Sub": [
           {
-            "token": "Sub"
+            "token": "Minus"
           }
         ],
         "Mul": [
@@ -278,12 +278,12 @@
         ],
         "Div": [
           {
-            "token": "Div"
+            "token": "Slash"
           }
         ],
         "Rem": [
           {
-            "token": "Rem"
+            "token": "Percent"
           }
         ],
         "And": [
@@ -353,27 +353,27 @@
         ],
         "AddEq": [
           {
-            "token": "AddEq"
+            "token": "PlusEq"
           }
         ],
         "SubEq": [
           {
-            "token": "SubEq"
+            "token": "MinusEq"
           }
         ],
         "MulEq": [
           {
-            "token": "MulEq"
+            "token": "StarEq"
           }
         ],
         "DivEq": [
           {
-            "token": "DivEq"
+            "token": "SlashEq"
           }
         ],
         "RemEq": [
           {
-            "token": "RemEq"
+            "token": "PercentEq"
           }
         ],
         "BitXorEq": [
@@ -512,7 +512,7 @@
             "element": {
               "syn": "TypeParamBound"
             },
-            "punct": "Add"
+            "punct": "Plus"
           }
         }
       }
@@ -1766,7 +1766,7 @@
         },
         "dot2_token": {
           "option": {
-            "token": "Dot2"
+            "token": "DotDot"
           }
         },
         "rest": {
@@ -2917,7 +2917,7 @@
             "tuple": [
               {
                 "option": {
-                  "token": "Bang"
+                  "token": "Not"
                 }
               },
               {
@@ -3146,7 +3146,7 @@
             "element": {
               "syn": "TypeParamBound"
             },
-            "punct": "Add"
+            "punct": "Plus"
           }
         },
         "brace_token": {
@@ -3192,7 +3192,7 @@
             "element": {
               "syn": "TypeParamBound"
             },
-            "punct": "Add"
+            "punct": "Plus"
           }
         },
         "semi_token": {
@@ -3289,7 +3289,7 @@
         },
         "leading_colon": {
           "option": {
-            "token": "Colon2"
+            "token": "PathSep"
           }
         },
         "tree": {
@@ -3357,7 +3357,7 @@
             "element": {
               "syn": "Lifetime"
             },
-            "punct": "Add"
+            "punct": "Plus"
           }
         }
       }
@@ -3535,7 +3535,7 @@
           "syn": "Path"
         },
         "bang_token": {
-          "token": "Bang"
+          "token": "Not"
         },
         "delimiter": {
           "syn": "MacroDelimiter"
@@ -3886,7 +3886,7 @@
           }
         },
         "dot2_token": {
-          "token": "Dot2"
+          "token": "DotDot"
         }
       }
     },
@@ -4064,7 +4064,7 @@
       "fields": {
         "leading_colon": {
           "option": {
-            "token": "Colon2"
+            "token": "PathSep"
           }
         },
         "segments": {
@@ -4072,7 +4072,7 @@
             "element": {
               "syn": "PathSegment"
             },
-            "punct": "Colon2"
+            "punct": "PathSep"
           }
         }
       }
@@ -4136,7 +4136,7 @@
             "element": {
               "syn": "Lifetime"
             },
-            "punct": "Add"
+            "punct": "Plus"
           }
         }
       }
@@ -4166,7 +4166,7 @@
             "element": {
               "syn": "TypeParamBound"
             },
-            "punct": "Add"
+            "punct": "Plus"
           }
         }
       }
@@ -4211,7 +4211,7 @@
       "variants": {
         "HalfOpen": [
           {
-            "token": "Dot2"
+            "token": "DotDot"
           }
         ],
         "Closed": [
@@ -4621,7 +4621,7 @@
             "element": {
               "syn": "TypeParamBound"
             },
-            "punct": "Add"
+            "punct": "Plus"
           }
         },
         "default": {
@@ -4837,7 +4837,7 @@
             "element": {
               "syn": "TypeParamBound"
             },
-            "punct": "Add"
+            "punct": "Plus"
           }
         }
       }
@@ -4880,7 +4880,7 @@
       },
       "fields": {
         "bang_token": {
-          "token": "Bang"
+          "token": "Not"
         }
       }
     },
@@ -4911,7 +4911,7 @@
             "element": {
               "syn": "TypeParamBound"
             },
-            "punct": "Add"
+            "punct": "Plus"
           }
         },
         "eq_token": {
@@ -5087,7 +5087,7 @@
             "element": {
               "syn": "TypeParamBound"
             },
-            "punct": "Add"
+            "punct": "Plus"
           }
         }
       }
@@ -5130,12 +5130,12 @@
         ],
         "Not": [
           {
-            "token": "Bang"
+            "token": "Not"
           }
         ],
         "Neg": [
           {
-            "token": "Sub"
+            "token": "Minus"
           }
         ]
       }
@@ -5199,7 +5199,7 @@
           "proc_macro2": "Ident"
         },
         "colon2_token": {
-          "token": "Colon2"
+          "token": "PathSep"
         },
         "tree": {
           "box": {
@@ -5290,7 +5290,7 @@
           }
         },
         "dots": {
-          "token": "Dot3"
+          "token": "DotDotDot"
         },
         "comma": {
           "option": {
@@ -5429,8 +5429,6 @@
   ],
   "tokens": {
     "Abstract": "abstract",
-    "Add": "+",
-    "AddEq": "+=",
     "And": "&",
     "AndAnd": "&&",
     "AndEq": "&=",
@@ -5439,26 +5437,22 @@
     "At": "@",
     "Auto": "auto",
     "Await": "await",
-    "Bang": "!",
     "Become": "become",
     "Box": "box",
     "Break": "break",
     "Caret": "^",
     "CaretEq": "^=",
     "Colon": ":",
-    "Colon2": "::",
     "Comma": ",",
     "Const": "const",
     "Continue": "continue",
     "Crate": "crate",
     "Default": "default",
-    "Div": "/",
-    "DivEq": "/=",
     "Do": "do",
     "Dollar": "$",
     "Dot": ".",
-    "Dot2": "..",
-    "Dot3": "...",
+    "DotDot": "..",
+    "DotDotDot": "...",
     "DotDotEq": "..=",
     "Dyn": "dyn",
     "Else": "else",
@@ -5482,23 +5476,28 @@
     "Lt": "<",
     "Macro": "macro",
     "Match": "match",
+    "Minus": "-",
+    "MinusEq": "-=",
     "Mod": "mod",
     "Move": "move",
-    "MulEq": "*=",
     "Mut": "mut",
     "Ne": "!=",
+    "Not": "!",
     "Or": "|",
     "OrEq": "|=",
     "OrOr": "||",
     "Override": "override",
+    "PathSep": "::",
+    "Percent": "%",
+    "PercentEq": "%=",
+    "Plus": "+",
+    "PlusEq": "+=",
     "Pound": "#",
     "Priv": "priv",
     "Pub": "pub",
     "Question": "?",
     "RArrow": "->",
     "Ref": "ref",
-    "Rem": "%",
-    "RemEq": "%=",
     "Return": "return",
     "SelfType": "Self",
     "SelfValue": "self",
@@ -5507,11 +5506,12 @@
     "ShlEq": "<<=",
     "Shr": ">>",
     "ShrEq": ">>=",
+    "Slash": "/",
+    "SlashEq": "/=",
     "Star": "*",
+    "StarEq": "*=",
     "Static": "static",
     "Struct": "struct",
-    "Sub": "-",
-    "SubEq": "-=",
     "Super": "super",
     "Tilde": "~",
     "Trait": "trait",


Test patch:
diff --git a/tests/debug/gen.rs b/tests/debug/gen.rs
index 01ab7549..57bc30e4 100644
--- a/tests/debug/gen.rs
+++ b/tests/debug/gen.rs
@@ -34,7 +34,7 @@ impl Debug for Lite<syn::AngleBracketedGenericArguments> {
         if let Some(val) = &_val.colon2_token {
             #[derive(RefCast)]
             #[repr(transparent)]
-            struct Print(syn::token::Colon2);
+            struct Print(syn::token::PathSep);
             impl Debug for Print {
                 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                     formatter.write_str("Some")?;
@@ -1104,7 +1104,7 @@ impl Debug for Lite<syn::Expr> {
                 if let Some(val) = &_val.dot2_token {
                     #[derive(RefCast)]
                     #[repr(transparent)]
-                    struct Print(syn::token::Dot2);
+                    struct Print(syn::token::DotDot);
                     impl Debug for Print {
                         fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                             formatter.write_str("Some")?;
@@ -1909,7 +1909,7 @@ impl Debug for Lite<syn::ExprStruct> {
         if let Some(val) = &_val.dot2_token {
             #[derive(RefCast)]
             #[repr(transparent)]
-            struct Print(syn::token::Dot2);
+            struct Print(syn::token::DotDot);
             impl Debug for Print {
                 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                     formatter.write_str("Some")?;
@@ -2833,7 +2833,7 @@ impl Debug for Lite<syn::Item> {
                 if let Some(val) = &_val.trait_ {
                     #[derive(RefCast)]
                     #[repr(transparent)]
-                    struct Print((Option<syn::token::Bang>, syn::Path, syn::token::For));
+                    struct Print((Option<syn::token::Not>, syn::Path, syn::token::For));
                     impl Debug for Print {
                         fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                             formatter.write_str("Some")?;
@@ -2844,7 +2844,7 @@ impl Debug for Lite<syn::Item> {
                                     {
                                         #[derive(RefCast)]
                                         #[repr(transparent)]
-                                        struct Print(Option<syn::token::Bang>);
+                                        struct Print(Option<syn::token::Not>);
                                         impl Debug for Print {
                                             fn fmt(
                                                 &self,
@@ -3102,7 +3102,7 @@ impl Debug for Lite<syn::Item> {
                 if let Some(val) = &_val.leading_colon {
                     #[derive(RefCast)]
                     #[repr(transparent)]
-                    struct Print(syn::token::Colon2);
+                    struct Print(syn::token::PathSep);
                     impl Debug for Print {
                         fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                             formatter.write_str("Some")?;
@@ -3246,7 +3246,7 @@ impl Debug for Lite<syn::ItemImpl> {
         if let Some(val) = &_val.trait_ {
             #[derive(RefCast)]
             #[repr(transparent)]
-            struct Print((Option<syn::token::Bang>, syn::Path, syn::token::For));
+            struct Print((Option<syn::token::Not>, syn::Path, syn::token::For));
             impl Debug for Print {
                 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                     formatter.write_str("Some")?;
@@ -3257,7 +3257,7 @@ impl Debug for Lite<syn::ItemImpl> {
                             {
                                 #[derive(RefCast)]
                                 #[repr(transparent)]
-                                struct Print(Option<syn::token::Bang>);
+                                struct Print(Option<syn::token::Not>);
                                 impl Debug for Print {
                                     fn fmt(
                                         &self,
@@ -3542,7 +3542,7 @@ impl Debug for Lite<syn::ItemUse> {
         if let Some(val) = &_val.leading_colon {
             #[derive(RefCast)]
             #[repr(transparent)]
-            struct Print(syn::token::Colon2);
+            struct Print(syn::token::PathSep);
             impl Debug for Print {
                 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                     formatter.write_str("Some")?;
@@ -3777,7 +3777,7 @@ impl Debug for Lite<syn::Meta> {
                 if let Some(val) = &_val.leading_colon {
                     #[derive(RefCast)]
                     #[repr(transparent)]
-                    struct Print(syn::token::Colon2);
+                    struct Print(syn::token::PathSep);
                     impl Debug for Print {
                         fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                             formatter.write_str("Some")?;
@@ -4326,7 +4326,7 @@ impl Debug for Lite<syn::Path> {
         if let Some(val) = &_val.leading_colon {
             #[derive(RefCast)]
             #[repr(transparent)]
-            struct Print(syn::token::Colon2);
+            struct Print(syn::token::PathSep);
             impl Debug for Print {
                 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                     formatter.write_str("Some")?;
@@ -4352,7 +4352,7 @@ impl Debug for Lite<syn::PathArguments> {
                 if let Some(val) = &_val.colon2_token {
                     #[derive(RefCast)]
                     #[repr(transparent)]
-                    struct Print(syn::token::Colon2);
+                    struct Print(syn::token::PathSep);
                     impl Debug for Print {
                         fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                             formatter.write_str("Some")?;