diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-08-26 19:23:42 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-09-10 22:37:06 +0300 |
| commit | 62cb7510ac6285c93ec691198a92f910582d31a2 (patch) | |
| tree | c5eac82e2a7293c3b75dec9b4e9feb3ddd333846 /src/libsyntax/ext | |
| parent | 2a2c9d38c78ece0a6c5de80e382a136173e64b14 (diff) | |
| download | rust-62cb7510ac6285c93ec691198a92f910582d31a2.tar.gz rust-62cb7510ac6285c93ec691198a92f910582d31a2.zip | |
Improve `Eq` deriving
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 3dcdbc89096..b81d95a6998 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -97,6 +97,7 @@ pub trait AstBuilder { typ: P<ast::Ty>, ex: P<ast::Expr>) -> P<ast::Stmt>; + fn stmt_let_type_only(&self, span: Span, ty: P<ast::Ty>) -> ast::Stmt; fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> ast::Stmt; // blocks @@ -577,6 +578,23 @@ impl<'a> AstBuilder for ExtCtxt<'a> { }) } + // Generate `let _: Type;`, usually used for type assertions. + fn stmt_let_type_only(&self, span: Span, ty: P<ast::Ty>) -> ast::Stmt { + let local = P(ast::Local { + pat: self.pat_wild(span), + ty: Some(ty), + init: None, + id: ast::DUMMY_NODE_ID, + span: span, + attrs: ast::ThinVec::new(), + }); + ast::Stmt { + id: ast::DUMMY_NODE_ID, + node: ast::StmtKind::Local(local), + span: span, + } + } + fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> ast::Stmt { ast::Stmt { id: ast::DUMMY_NODE_ID, |
