diff options
| author | varkor <github@varkor.com> | 2019-02-05 16:50:00 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2019-02-07 15:02:16 +0100 |
| commit | d7695abb7667d2e8b7a010282ad5f44abbc58a58 (patch) | |
| tree | 77bb6c0c52f6bfba98b5cbb609666370c644803c /src/libsyntax | |
| parent | 0a8d98a270da057975d3cc552a4bb5f0bda5a3af (diff) | |
| download | rust-d7695abb7667d2e8b7a010282ad5f44abbc58a58.tar.gz rust-d7695abb7667d2e8b7a010282ad5f44abbc58a58.zip | |
Support const generics in derive
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 1e83f6c03ec..6708e3c12a0 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -38,12 +38,14 @@ pub trait AstBuilder { bindings: Vec<ast::TypeBinding>) -> (ast::QSelf, ast::Path); - // types + // types and consts fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy; fn ty(&self, span: Span, ty: ast::TyKind) -> P<ast::Ty>; fn ty_path(&self, path: ast::Path) -> P<ast::Ty>; fn ty_ident(&self, span: Span, idents: ast::Ident) -> P<ast::Ty>; + fn anon_const(&self, span: Span, expr: ast::ExprKind) -> ast::AnonConst; + fn const_ident(&self, span: Span, idents: ast::Ident) -> ast::AnonConst; fn ty_rptr(&self, span: Span, ty: P<ast::Ty>, @@ -394,6 +396,22 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.ty_path(self.path_ident(span, ident)) } + fn anon_const(&self, span: Span, expr: ast::ExprKind) -> ast::AnonConst { + ast::AnonConst { + id: ast::DUMMY_NODE_ID, + value: P(ast::Expr { + id: ast::DUMMY_NODE_ID, + node: expr, + span, + attrs: ThinVec::new(), + }) + } + } + + fn const_ident(&self, span: Span, ident: ast::Ident) -> ast::AnonConst { + self.anon_const(span, ast::ExprKind::Path(None, self.path_ident(span, ident))) + } + fn ty_rptr(&self, span: Span, ty: P<ast::Ty>, |
