]> git.proxmox.com Git - cargo.git/blobdiff - vendor/syn/src/generics.rs
New upstream version 0.37.0
[cargo.git] / vendor / syn / src / generics.rs
index 59c7c4523b4e6a7d7508282510e775fc8aed82f2..10fdb48a9f5eaceba98c1f50642b6bbb5465f636 100644 (file)
@@ -484,7 +484,8 @@ pub mod parsing {
             let lt_token: Token![<] = input.parse()?;
 
             let mut params = Punctuated::new();
-            let mut has_type_param = false;
+            let mut allow_lifetime_param = true;
+            let mut allow_type_param = true;
             loop {
                 if input.peek(Token![>]) {
                     break;
@@ -492,17 +493,24 @@ pub mod parsing {
 
                 let attrs = input.call(Attribute::parse_outer)?;
                 let lookahead = input.lookahead1();
-                if !has_type_param && lookahead.peek(Lifetime) {
+                if allow_lifetime_param && lookahead.peek(Lifetime) {
                     params.push_value(GenericParam::Lifetime(LifetimeDef {
                         attrs: attrs,
                         ..input.parse()?
                     }));
-                } else if lookahead.peek(Ident) {
-                    has_type_param = true;
+                } else if allow_type_param && lookahead.peek(Ident) {
+                    allow_lifetime_param = false;
                     params.push_value(GenericParam::Type(TypeParam {
                         attrs: attrs,
                         ..input.parse()?
                     }));
+                } else if lookahead.peek(Token![const]) {
+                    allow_lifetime_param = false;
+                    allow_type_param = false;
+                    params.push_value(GenericParam::Const(ConstParam {
+                        attrs: attrs,
+                        ..input.parse()?
+                    }));
                 } else {
                     return Err(lookahead.error());
                 }