diff options
| author | bors <bors@rust-lang.org> | 2019-02-08 05:50:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-02-08 05:50:16 +0000 |
| commit | 43e04fb5522642b6b5230592934e9ee100f2fd56 (patch) | |
| tree | 2c850f35dba2f93a76e2c624bd0a99fd6e2f4e25 /src/libsyntax_ext | |
| parent | d1731801163df1d3a8d4ddfa68adac2ec833ef7f (diff) | |
| parent | f2fe71c02ac7ecb29106b1a826d657ff5705ad6c (diff) | |
| download | rust-43e04fb5522642b6b5230592934e9ee100f2fd56.tar.gz rust-43e04fb5522642b6b5230592934e9ee100f2fd56.zip | |
Auto merge of #58191 - varkor:const-generics-ast, r=petrochenkov
Add const generics to the AST This is mostly split out from https://github.com/rust-lang/rust/pull/53645 in an effort to make progress merging const generics piecewise instead of in one go. cc @yodaldevoid, @petrochenkov r? @eddyb
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/ty.rs | 12 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index e6fe125da9f..4678c752045 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -560,6 +560,7 @@ impl<'a> TraitDef<'a> { cx.typaram(self.span, param.ident, vec![], bounds, None) } + GenericParamKind::Const { .. } => param.clone(), })); // and similarly for where clauses @@ -657,6 +658,9 @@ impl<'a> TraitDef<'a> { GenericParamKind::Type { .. } => { GenericArg::Type(cx.ty_ident(self.span, param.ident)) } + GenericParamKind::Const { .. } => { + GenericArg::Const(cx.const_ident(self.span, param.ident)) + } }).collect(); // Create the type of `self`. diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index ea6e07922b2..100ec0057ee 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -94,7 +94,7 @@ impl<'a> Path<'a> { } } -/// A type. Supports pointers, Self, and literals +/// A type. Supports pointers, Self, and literals. #[derive(Clone)] pub enum Ty<'a> { Self_, @@ -107,6 +107,13 @@ pub enum Ty<'a> { Tuple(Vec<Ty<'a>>), } +/// A const expression. Supports literals and blocks. +#[derive(Clone, Eq, PartialEq)] +pub enum Const { + Literal, + Block, +} + pub fn borrowed_ptrty<'r>() -> PtrTy<'r> { Borrowed(None, ast::Mutability::Immutable) } @@ -180,6 +187,9 @@ impl<'a> Ty<'a> { GenericParamKind::Type { .. } => { GenericArg::Type(cx.ty_ident(span, param.ident)) } + GenericParamKind::Const { .. } => { + GenericArg::Const(cx.const_ident(span, param.ident)) + } }).collect(); cx.path_all(span, false, vec![self_ty], params, vec![]) |
