diff options
| author | Jakub Bukaj <jakub@jakub.cc> | 2014-11-09 16:14:15 +0100 |
|---|---|---|
| committer | Jakub Bukaj <jakub@jakub.cc> | 2014-11-16 14:23:15 +0100 |
| commit | eb01b17b06eb35542bb80ff7456043b0ed5572ba (patch) | |
| tree | 75ee1c7184f8f3ea00966c91186c844ca268b3c7 /src/libsyntax/ext | |
| parent | 08d6774f39743b69c199d79a5c64dbcef58c03d3 (diff) | |
| download | rust-eb01b17b06eb35542bb80ff7456043b0ed5572ba.tar.gz rust-eb01b17b06eb35542bb80ff7456043b0ed5572ba.zip | |
Complete the removal of ty_nil, ast::LitNil, ast::TyBot and ast::TyUniq
[breaking-change] This will break any uses of macros that assumed () being a valid literal.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 21 | ||||
| -rw-r--r-- | src/libsyntax/ext/concat.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/encodable.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/ty.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/format.rs | 2 |
8 files changed, 13 insertions, 34 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 1e2d935af00..0c7a3cf4a6c 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -248,7 +248,7 @@ impl DummyResult { pub fn raw_expr(sp: Span) -> P<ast::Expr> { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprLit(P(codemap::respan(sp, ast::LitNil))), + node: ast::ExprLit(P(codemap::respan(sp, ast::LitBool(false)))), span: sp, }) } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 862cbf3d7ca..ffc42b67033 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -54,11 +54,9 @@ pub trait AstBuilder { fn ty_ptr(&self, span: Span, ty: P<ast::Ty>, mutbl: ast::Mutability) -> P<ast::Ty>; - fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty>; fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty>; fn ty_infer(&self, sp: Span) -> P<ast::Ty>; - fn ty_nil(&self) -> P<ast::Ty>; fn ty_vars(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> ; fn ty_vars_global(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> ; @@ -377,9 +375,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.ty(span, ast::TyPtr(self.ty_mt(ty, mutbl))) } - fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> { - self.ty(span, ast::TyUniq(ty)) - } fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> { self.ty_path( @@ -406,14 +401,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.ty(span, ast::TyInfer) } - fn ty_nil(&self) -> P<ast::Ty> { - P(ast::Ty { - id: ast::DUMMY_NODE_ID, - node: ast::TyNil, - span: DUMMY_SP, - }) - } - fn typaram(&self, span: Span, id: ast::Ident, @@ -809,8 +796,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.pat(span, pat) } fn pat_tuple(&self, span: Span, pats: Vec<P<ast::Pat>>) -> P<ast::Pat> { - let pat = ast::PatTup(pats); - self.pat(span, pat) + self.pat(span, ast::PatTup(pats)) } fn pat_some(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> { @@ -931,11 +917,10 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } // FIXME unused self - fn fn_decl(&self, inputs: Vec<ast::Arg> , output: P<ast::Ty>) -> P<ast::FnDecl> { + fn fn_decl(&self, inputs: Vec<ast::Arg>, output: P<ast::Ty>) -> P<ast::FnDecl> { P(ast::FnDecl { inputs: inputs, - output: output, - cf: ast::Return, + output: ast::Return(output), variadic: false }) } diff --git a/src/libsyntax/ext/concat.rs b/src/libsyntax/ext/concat.rs index af7cd4157ec..e2867c2fbab 100644 --- a/src/libsyntax/ext/concat.rs +++ b/src/libsyntax/ext/concat.rs @@ -46,7 +46,6 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, ast::LitInt(i, ast::UnsuffixedIntLit(ast::Minus)) => { accumulator.push_str(format!("-{}", i).as_slice()); } - ast::LitNil => {} ast::LitBool(b) => { accumulator.push_str(format!("{}", b).as_slice()); } diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 69eb260b8c4..62f3b5d01b4 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -88,7 +88,7 @@ //! } //! ``` -use ast::{MetaItem, Item, Expr, ExprRet, MutMutable, LitNil}; +use ast::{MetaItem, Item, Expr, ExprRet, MutMutable}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; @@ -186,7 +186,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span, if stmts.is_empty() { let ret_ok = cx.expr(trait_span, ExprRet(Some(cx.expr_ok(trait_span, - cx.expr_lit(trait_span, LitNil))))); + cx.expr_tuple(trait_span, vec![]))))); stmts.push(cx.stmt_expr(ret_ok)); } @@ -231,7 +231,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span, if stmts.len() == 0 { let ret_ok = cx.expr(trait_span, ExprRet(Some(cx.expr_ok(trait_span, - cx.expr_lit(trait_span, LitNil))))); + cx.expr_tuple(trait_span, vec![]))))); stmts.push(cx.stmt_expr(ret_ok)); } diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 7c32b845508..4be299994fd 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -922,7 +922,7 @@ impl<'a> MethodDef<'a> { } // Here is the pat = `(&VariantK, &VariantK, ...)` - let single_pat = cx.pat(sp, ast::PatTup(subpats)); + let single_pat = cx.pat_tuple(sp, subpats); // For the BodyK, we need to delegate to our caller, // passing it an EnumMatching to indicate which case diff --git a/src/libsyntax/ext/deriving/generic/ty.rs b/src/libsyntax/ext/deriving/generic/ty.rs index 1ec1e3b1224..8b46769d633 100644 --- a/src/libsyntax/ext/deriving/generic/ty.rs +++ b/src/libsyntax/ext/deriving/generic/ty.rs @@ -152,14 +152,9 @@ impl<'a> Ty<'a> { cx.ty_path(self.to_path(cx, span, self_ty, self_generics), None) } Tuple(ref fields) => { - let ty = if fields.is_empty() { - ast::TyNil - } else { - ast::TyTup(fields.iter() - .map(|f| f.to_ty(cx, span, self_ty, self_generics)) - .collect()) - }; - + let ty = ast::TyTup(fields.iter() + .map(|f| f.to_ty(cx, span, self_ty, self_generics)) + .collect()); cx.ty(span, ty) } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 87406081aae..fa69495fa42 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -159,7 +159,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> { // `_ => [<elseopt> | ()]` let else_arm = { let pat_under = fld.cx.pat_wild(span); - let else_expr = elseopt.unwrap_or_else(|| fld.cx.expr_lit(span, ast::LitNil)); + let else_expr = elseopt.unwrap_or_else(|| fld.cx.expr_tuple(span, vec![])); fld.cx.arm(span, vec![pat_under], else_expr) }; diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index a28f24e7663..a816b479630 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -654,7 +654,7 @@ impl<'a, 'b> Context<'a, 'b> { // // But the nested match expression is proved to perform not as well // as series of let's; the first approach does. - let pat = self.ecx.pat(self.fmtsp, ast::PatTup(pats)); + let pat = self.ecx.pat_tuple(self.fmtsp, pats); let arm = self.ecx.arm(self.fmtsp, vec!(pat), body); let head = self.ecx.expr(self.fmtsp, ast::ExprTup(heads)); self.ecx.expr_match(self.fmtsp, head, vec!(arm)) |
