]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_macros/src/newtype.rs
Rollup merge of #107053 - devnexen:sigstringrepr_haiku, r=thomcc
[rust.git] / compiler / rustc_macros / src / newtype.rs
index 7b7e475da5b5f7144de6a1fcbce161a226fef7f2..89ea89cf502e5e4c2723be0c371b2794c2ff84db 100644 (file)
@@ -25,14 +25,6 @@ fn parse(input: ParseStream<'_>) -> Result<Self> {
         let mut encodable = true;
         let mut ord = true;
 
-        // Parse an optional trailing comma
-        let try_comma = || -> Result<()> {
-            if body.lookahead1().peek(Token![,]) {
-                body.parse::<Token![,]>()?;
-            }
-            Ok(())
-        };
-
         attrs.retain(|attr| match attr.path.get_ident() {
             Some(ident) => match &*ident.to_string() {
                 "custom_encodable" => {
@@ -49,7 +41,7 @@ fn parse(input: ParseStream<'_>) -> Result<Self> {
                     };
 
                     if let Some(old) = max.replace(literal.lit) {
-                        panic!("Specified multiple max: {:?}", old);
+                        panic!("Specified multiple max: {old:?}");
                     }
 
                     false
@@ -60,7 +52,7 @@ fn parse(input: ParseStream<'_>) -> Result<Self> {
                     };
 
                     if let Some(old) = debug_format.replace(literal.lit) {
-                        panic!("Specified multiple debug format options: {:?}", old);
+                        panic!("Specified multiple debug format options: {old:?}");
                     }
 
                     false
@@ -70,24 +62,20 @@ fn parse(input: ParseStream<'_>) -> Result<Self> {
             _ => true,
         });
 
-        if body.lookahead1().peek(Token![..]) {
-            body.parse::<Token![..]>()?;
-        } else {
-            loop {
-                // We've parsed everything that the user provided, so we're done
-                if body.is_empty() {
-                    break;
-                }
-
-                // Otherwise, we are parsing a user-defined constant
-                let const_attrs = body.call(Attribute::parse_outer)?;
-                body.parse::<Token![const]>()?;
-                let const_name: Ident = body.parse()?;
-                body.parse::<Token![=]>()?;
-                let const_val: Expr = body.parse()?;
-                try_comma()?;
-                consts.push(quote! { #(#const_attrs)* #vis const #const_name: #name = #name::from_u32(#const_val); });
+        loop {
+            // We've parsed everything that the user provided, so we're done
+            if body.is_empty() {
+                break;
             }
+
+            // Otherwise, we are parsing a user-defined constant
+            let const_attrs = body.call(Attribute::parse_outer)?;
+            body.parse::<Token![const]>()?;
+            let const_name: Ident = body.parse()?;
+            body.parse::<Token![=]>()?;
+            let const_val: Expr = body.parse()?;
+            body.parse::<Token![;]>()?;
+            consts.push(quote! { #(#const_attrs)* #vis const #const_name: #name = #name::from_u32(#const_val); });
         }
 
         let debug_format =