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.
This commit is contained in:
parent
08d6774f39
commit
eb01b17b06
34 changed files with 348 additions and 405 deletions
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue