From 751dcdf606d4ff3b27b1c820535304bfb022170c Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 5 Feb 2019 16:48:45 +0100 Subject: [PATCH] Add Const kind to AST Co-Authored-By: Gabriel Smith --- src/libsyntax/ast.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 2cfe2cc896cb..57a3bf86b0e5 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -167,6 +167,17 @@ impl GenericArgs { pub enum GenericArg { Lifetime(Lifetime), Type(P), + Const(AnonConst), +} + +impl GenericArg { + pub fn span(&self) -> Span { + match self { + GenericArg::Lifetime(lt) => lt.ident.span, + GenericArg::Type(ty) => ty.span, + GenericArg::Const(ct) => ct.value.span, + } + } } /// A path like `Foo<'a, T>` @@ -300,9 +311,8 @@ pub type GenericBounds = Vec; pub enum GenericParamKind { /// A lifetime definition (e.g., `'a: 'b + 'c + 'd`). Lifetime, - Type { - default: Option>, - }, + Type { default: Option> }, + Const { ty: P }, } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]