Add support for parsing const expressions in type argument position
diff --git a/src/ty.rs b/src/ty.rs
index 413fe5b..085bf9c 100644
--- a/src/ty.rs
+++ b/src/ty.rs
@@ -201,6 +201,11 @@
///
/// E.g., `Foo<A=Bar>`.
TypeBinding(TypeBinding),
+ /// Const expression. Must be inside of a block.
+ ///
+ /// NOTE: Identity expressions are represented as Type arguments, as
+ /// they are indistinguishable syntactically.
+ Const(ExprBlock),
}
}
@@ -691,6 +696,7 @@
}
}
+ #[cfg(not(feature = "full"))]
impl Synom for GenericArgument {
named!(parse -> Self, alt!(
call!(ty_no_eq_after) => { GenericArgument::Type }
@@ -701,6 +707,19 @@
));
}
+ #[cfg(feature = "full")]
+ impl Synom for GenericArgument {
+ named!(parse -> Self, alt!(
+ call!(ty_no_eq_after) => { GenericArgument::Type }
+ |
+ syn!(Lifetime) => { GenericArgument::Lifetime }
+ |
+ syn!(TypeBinding) => { GenericArgument::TypeBinding }
+ |
+ syn!(ExprBlock) => { GenericArgument::Const }
+ ));
+ }
+
impl Synom for AngleBracketedGenericArguments {
named!(parse -> Self, do_parse!(
turbofish: option!(punct!(::)) >>
@@ -1029,6 +1048,10 @@
GenericArgument::Lifetime(ref lt) => lt.to_tokens(tokens),
GenericArgument::Type(ref ty) => ty.to_tokens(tokens),
GenericArgument::TypeBinding(ref tb) => tb.to_tokens(tokens),
+ #[cfg(not(feature = "full"))]
+ GenericArgument::Const(_) => unreachable!(),
+ #[cfg(feature = "full")]
+ GenericArgument::Const(ref eb) => eb.to_tokens(tokens),
}
}
}