about summary refs log tree commit diff
path: root/compiler/rustc_macros
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2022-12-18 21:22:14 +0100
committerNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2022-12-18 21:22:14 +0100
commit91c3c2040ce109d6e9ea00ffb8e8f69f3fd6d9bb (patch)
tree626f4cb52fe019aa00ad7a52c1f7501351474dd4 /compiler/rustc_macros
parent93429948cf0e6fe8aac3802a8fbc73a121463994 (diff)
downloadrust-91c3c2040ce109d6e9ea00ffb8e8f69f3fd6d9bb.tar.gz
rust-91c3c2040ce109d6e9ea00ffb8e8f69f3fd6d9bb.zip
Make `#[max]` an attribute in `newtype_index`
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() {