about summary refs log tree commit diff
path: root/compiler/rustc_macros
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_macros')
-rw-r--r--compiler/rustc_macros/src/newtype.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/rustc_macros/src/newtype.rs b/compiler/rustc_macros/src/newtype.rs
index 59cedef08ea..99f3f638d2f 100644
--- a/compiler/rustc_macros/src/newtype.rs
+++ b/compiler/rustc_macros/src/newtype.rs
@@ -59,6 +59,17 @@ impl Parse for Newtype {
                     ord = false;
                     false
                 }
+                "max" => {
+                    let Ok(Meta::NameValue(literal) )= attr.parse_meta() else {
+                        panic!("#[max = NUMBER] attribute requires max value");
+                    };
+
+                    if let Some(old) = max.replace(literal.lit) {
+                        panic!("Specified multiple MAX: {:?}", old);
+                    }
+
+                    false
+                }
                 _ => true,
             },
             _ => true,
@@ -84,16 +95,6 @@ impl Parse for Newtype {
                     }
                     continue;
                 }
-                if body.lookahead1().peek(kw::MAX) {
-                    body.parse::<kw::MAX>()?;
-                    body.parse::<Token![=]>()?;
-                    let val: Lit = body.parse()?;
-                    try_comma()?;
-                    if let Some(old) = max.replace(val) {
-                        panic!("Specified multiple MAX: {:?}", old);
-                    }
-                    continue;
-                }
 
                 // We've parsed everything that the user provided, so we're done
                 if body.is_empty() {