[breaking-change] don't glob export ast::Expr_ variants
This commit is contained in:
@@ -303,7 +303,7 @@ impl MacResult for MacEager {
|
||||
return Some(p);
|
||||
}
|
||||
if let Some(e) = self.expr {
|
||||
if let ast::ExprLit(_) = e.node {
|
||||
if let ast::ExprKind::Lit(_) = e.node {
|
||||
return Some(P(ast::Pat {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: e.span,
|
||||
@@ -349,7 +349,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::LitBool(false)))),
|
||||
node: ast::ExprKind::Lit(P(codemap::respan(sp, ast::LitBool(false)))),
|
||||
span: sp,
|
||||
attrs: None,
|
||||
})
|
||||
@@ -773,7 +773,7 @@ pub fn expr_to_string(cx: &mut ExtCtxt, expr: P<ast::Expr>, err_msg: &str)
|
||||
// we want to be able to handle e.g. concat("foo", "bar")
|
||||
let expr = cx.expander().fold_expr(expr);
|
||||
match expr.node {
|
||||
ast::ExprLit(ref l) => match l.node {
|
||||
ast::ExprKind::Lit(ref l) => match l.node {
|
||||
ast::LitStr(ref s, style) => return Some(((*s).clone(), style)),
|
||||
_ => cx.span_err(l.span, err_msg)
|
||||
},
|
||||
|
||||
@@ -108,7 +108,7 @@ pub trait AstBuilder {
|
||||
expr: Option<P<ast::Expr>>) -> P<ast::Block>;
|
||||
|
||||
// expressions
|
||||
fn expr(&self, span: Span, node: ast::Expr_) -> P<ast::Expr>;
|
||||
fn expr(&self, span: Span, node: ast::ExprKind) -> P<ast::Expr>;
|
||||
fn expr_path(&self, path: ast::Path) -> P<ast::Expr>;
|
||||
fn expr_qpath(&self, span: Span, qself: ast::QSelf, path: ast::Path) -> P<ast::Expr>;
|
||||
fn expr_ident(&self, span: Span, id: ast::Ident) -> P<ast::Expr>;
|
||||
@@ -578,7 +578,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
})
|
||||
}
|
||||
|
||||
fn expr(&self, span: Span, node: ast::Expr_) -> P<ast::Expr> {
|
||||
fn expr(&self, span: Span, node: ast::ExprKind) -> P<ast::Expr> {
|
||||
P(ast::Expr {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: node,
|
||||
@@ -588,12 +588,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
}
|
||||
|
||||
fn expr_path(&self, path: ast::Path) -> P<ast::Expr> {
|
||||
self.expr(path.span, ast::ExprPath(None, path))
|
||||
self.expr(path.span, ast::ExprKind::Path(None, path))
|
||||
}
|
||||
|
||||
/// Constructs a QPath expression.
|
||||
fn expr_qpath(&self, span: Span, qself: ast::QSelf, path: ast::Path) -> P<ast::Expr> {
|
||||
self.expr(span, ast::ExprPath(Some(qself), path))
|
||||
self.expr(span, ast::ExprKind::Path(Some(qself), path))
|
||||
}
|
||||
|
||||
fn expr_ident(&self, span: Span, id: ast::Ident) -> P<ast::Expr> {
|
||||
@@ -605,14 +605,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
|
||||
fn expr_binary(&self, sp: Span, op: ast::BinOpKind,
|
||||
lhs: P<ast::Expr>, rhs: P<ast::Expr>) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprBinary(Spanned { node: op, span: sp }, lhs, rhs))
|
||||
self.expr(sp, ast::ExprKind::Binary(Spanned { node: op, span: sp }, lhs, rhs))
|
||||
}
|
||||
|
||||
fn expr_deref(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
|
||||
self.expr_unary(sp, UnOp::Deref, e)
|
||||
}
|
||||
fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P<ast::Expr>) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprUnary(op, e))
|
||||
self.expr(sp, ast::ExprKind::Unary(op, e))
|
||||
}
|
||||
|
||||
fn expr_field_access(&self, sp: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> {
|
||||
@@ -623,7 +623,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
};
|
||||
|
||||
let id = Spanned { node: ident, span: field_span };
|
||||
self.expr(sp, ast::ExprField(expr, id))
|
||||
self.expr(sp, ast::ExprKind::Field(expr, id))
|
||||
}
|
||||
fn expr_tup_field_access(&self, sp: Span, expr: P<ast::Expr>, idx: usize) -> P<ast::Expr> {
|
||||
let field_span = Span {
|
||||
@@ -633,21 +633,21 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
};
|
||||
|
||||
let id = Spanned { node: idx, span: field_span };
|
||||
self.expr(sp, ast::ExprTupField(expr, id))
|
||||
self.expr(sp, ast::ExprKind::TupField(expr, id))
|
||||
}
|
||||
fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprAddrOf(ast::MutImmutable, e))
|
||||
self.expr(sp, ast::ExprKind::AddrOf(ast::MutImmutable, e))
|
||||
}
|
||||
fn expr_mut_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprAddrOf(ast::MutMutable, e))
|
||||
self.expr(sp, ast::ExprKind::AddrOf(ast::MutMutable, e))
|
||||
}
|
||||
|
||||
fn expr_call(&self, span: Span, expr: P<ast::Expr>, args: Vec<P<ast::Expr>>) -> P<ast::Expr> {
|
||||
self.expr(span, ast::ExprCall(expr, args))
|
||||
self.expr(span, ast::ExprKind::Call(expr, args))
|
||||
}
|
||||
fn expr_call_ident(&self, span: Span, id: ast::Ident,
|
||||
args: Vec<P<ast::Expr>>) -> P<ast::Expr> {
|
||||
self.expr(span, ast::ExprCall(self.expr_ident(span, id), args))
|
||||
self.expr(span, ast::ExprKind::Call(self.expr_ident(span, id), args))
|
||||
}
|
||||
fn expr_call_global(&self, sp: Span, fn_path: Vec<ast::Ident> ,
|
||||
args: Vec<P<ast::Expr>> ) -> P<ast::Expr> {
|
||||
@@ -660,16 +660,16 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
mut args: Vec<P<ast::Expr>> ) -> P<ast::Expr> {
|
||||
let id = Spanned { node: ident, span: span };
|
||||
args.insert(0, expr);
|
||||
self.expr(span, ast::ExprMethodCall(id, Vec::new(), args))
|
||||
self.expr(span, ast::ExprKind::MethodCall(id, Vec::new(), args))
|
||||
}
|
||||
fn expr_block(&self, b: P<ast::Block>) -> P<ast::Expr> {
|
||||
self.expr(b.span, ast::ExprBlock(b))
|
||||
self.expr(b.span, ast::ExprKind::Block(b))
|
||||
}
|
||||
fn field_imm(&self, span: Span, name: Ident, e: P<ast::Expr>) -> ast::Field {
|
||||
ast::Field { ident: respan(span, name), expr: e, span: span }
|
||||
}
|
||||
fn expr_struct(&self, span: Span, path: ast::Path, fields: Vec<ast::Field>) -> P<ast::Expr> {
|
||||
self.expr(span, ast::ExprStruct(path, fields, None))
|
||||
self.expr(span, ast::ExprKind::Struct(path, fields, None))
|
||||
}
|
||||
fn expr_struct_ident(&self, span: Span,
|
||||
id: ast::Ident, fields: Vec<ast::Field>) -> P<ast::Expr> {
|
||||
@@ -677,7 +677,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
}
|
||||
|
||||
fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprLit(P(respan(sp, lit))))
|
||||
self.expr(sp, ast::ExprKind::Lit(P(respan(sp, lit))))
|
||||
}
|
||||
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> {
|
||||
self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs)))
|
||||
@@ -697,7 +697,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
}
|
||||
|
||||
fn expr_vec(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprVec(exprs))
|
||||
self.expr(sp, ast::ExprKind::Vec(exprs))
|
||||
}
|
||||
fn expr_vec_ng(&self, sp: Span) -> P<ast::Expr> {
|
||||
self.expr_call_global(sp, self.std_path(&["vec", "Vec", "new"]),
|
||||
@@ -711,7 +711,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
}
|
||||
|
||||
fn expr_cast(&self, sp: Span, expr: P<ast::Expr>, ty: P<ast::Ty>) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprCast(expr, ty))
|
||||
self.expr(sp, ast::ExprKind::Cast(expr, ty))
|
||||
}
|
||||
|
||||
|
||||
@@ -728,12 +728,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
|
||||
|
||||
fn expr_break(&self, sp: Span) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprBreak(None))
|
||||
self.expr(sp, ast::ExprKind::Break(None))
|
||||
}
|
||||
|
||||
|
||||
fn expr_tuple(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprTup(exprs))
|
||||
self.expr(sp, ast::ExprKind::Tup(exprs))
|
||||
}
|
||||
|
||||
fn expr_fail(&self, span: Span, msg: InternedString) -> P<ast::Expr> {
|
||||
@@ -785,7 +785,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
let err_inner_expr = self.expr_call(sp, self.expr_path(err_path),
|
||||
vec!(binding_expr.clone()));
|
||||
// return Err(__try_var)
|
||||
let err_expr = self.expr(sp, ast::ExprRet(Some(err_inner_expr)));
|
||||
let err_expr = self.expr(sp, ast::ExprKind::Ret(Some(err_inner_expr)));
|
||||
|
||||
// Ok(__try_var) => __try_var
|
||||
let ok_arm = self.arm(sp, vec!(ok_pat), binding_expr);
|
||||
@@ -868,29 +868,29 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
}
|
||||
|
||||
fn expr_match(&self, span: Span, arg: P<ast::Expr>, arms: Vec<ast::Arm>) -> P<Expr> {
|
||||
self.expr(span, ast::ExprMatch(arg, arms))
|
||||
self.expr(span, ast::ExprKind::Match(arg, arms))
|
||||
}
|
||||
|
||||
fn expr_if(&self, span: Span, cond: P<ast::Expr>,
|
||||
then: P<ast::Expr>, els: Option<P<ast::Expr>>) -> P<ast::Expr> {
|
||||
let els = els.map(|x| self.expr_block(self.block_expr(x)));
|
||||
self.expr(span, ast::ExprIf(cond, self.block_expr(then), els))
|
||||
self.expr(span, ast::ExprKind::If(cond, self.block_expr(then), els))
|
||||
}
|
||||
|
||||
fn expr_loop(&self, span: Span, block: P<ast::Block>) -> P<ast::Expr> {
|
||||
self.expr(span, ast::ExprLoop(block, None))
|
||||
self.expr(span, ast::ExprKind::Loop(block, None))
|
||||
}
|
||||
|
||||
fn lambda_fn_decl(&self, span: Span,
|
||||
fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> P<ast::Expr> {
|
||||
self.expr(span, ast::ExprClosure(ast::CaptureBy::Ref, fn_decl, blk))
|
||||
self.expr(span, ast::ExprKind::Closure(ast::CaptureBy::Ref, fn_decl, blk))
|
||||
}
|
||||
fn lambda(&self, span: Span, ids: Vec<ast::Ident>, blk: P<ast::Block>) -> P<ast::Expr> {
|
||||
let fn_decl = self.fn_decl(
|
||||
ids.iter().map(|id| self.arg(span, *id, self.ty_infer(span))).collect(),
|
||||
self.ty_infer(span));
|
||||
|
||||
self.expr(span, ast::ExprClosure(ast::CaptureBy::Ref, fn_decl, blk))
|
||||
self.expr(span, ast::ExprKind::Closure(ast::CaptureBy::Ref, fn_decl, blk))
|
||||
}
|
||||
fn lambda0(&self, span: Span, blk: P<ast::Block>) -> P<ast::Expr> {
|
||||
self.lambda(span, Vec::new(), blk)
|
||||
|
||||
@@ -42,7 +42,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
|
||||
|
||||
// expr_mac should really be expr_ext or something; it's the
|
||||
// entry-point for all syntax extensions.
|
||||
ast::ExprMac(mac) => {
|
||||
ast::ExprKind::Mac(mac) => {
|
||||
|
||||
// Assert that we drop any macro attributes on the floor here
|
||||
drop(attrs);
|
||||
@@ -69,7 +69,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
|
||||
})
|
||||
}
|
||||
|
||||
ast::ExprInPlace(placer, value_expr) => {
|
||||
ast::ExprKind::InPlace(placer, value_expr) => {
|
||||
// Ensure feature-gate is enabled
|
||||
feature_gate::check_for_placement_in(
|
||||
fld.cx.ecfg.features,
|
||||
@@ -78,18 +78,18 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
|
||||
|
||||
let placer = fld.fold_expr(placer);
|
||||
let value_expr = fld.fold_expr(value_expr);
|
||||
fld.cx.expr(span, ast::ExprInPlace(placer, value_expr))
|
||||
fld.cx.expr(span, ast::ExprKind::InPlace(placer, value_expr))
|
||||
.with_attrs(fold_thin_attrs(attrs, fld))
|
||||
}
|
||||
|
||||
ast::ExprWhile(cond, body, opt_ident) => {
|
||||
ast::ExprKind::While(cond, body, opt_ident) => {
|
||||
let cond = fld.fold_expr(cond);
|
||||
let (body, opt_ident) = expand_loop_block(body, opt_ident, fld);
|
||||
fld.cx.expr(span, ast::ExprWhile(cond, body, opt_ident))
|
||||
fld.cx.expr(span, ast::ExprKind::While(cond, body, opt_ident))
|
||||
.with_attrs(fold_thin_attrs(attrs, fld))
|
||||
}
|
||||
|
||||
ast::ExprWhileLet(pat, expr, body, opt_ident) => {
|
||||
ast::ExprKind::WhileLet(pat, expr, body, opt_ident) => {
|
||||
let pat = fld.fold_pat(pat);
|
||||
let expr = fld.fold_expr(expr);
|
||||
|
||||
@@ -103,17 +103,17 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
|
||||
});
|
||||
assert!(rewritten_pats.len() == 1);
|
||||
|
||||
fld.cx.expr(span, ast::ExprWhileLet(rewritten_pats.remove(0), expr, body, opt_ident))
|
||||
.with_attrs(fold_thin_attrs(attrs, fld))
|
||||
let wl = ast::ExprKind::WhileLet(rewritten_pats.remove(0), expr, body, opt_ident);
|
||||
fld.cx.expr(span, wl).with_attrs(fold_thin_attrs(attrs, fld))
|
||||
}
|
||||
|
||||
ast::ExprLoop(loop_block, opt_ident) => {
|
||||
ast::ExprKind::Loop(loop_block, opt_ident) => {
|
||||
let (loop_block, opt_ident) = expand_loop_block(loop_block, opt_ident, fld);
|
||||
fld.cx.expr(span, ast::ExprLoop(loop_block, opt_ident))
|
||||
fld.cx.expr(span, ast::ExprKind::Loop(loop_block, opt_ident))
|
||||
.with_attrs(fold_thin_attrs(attrs, fld))
|
||||
}
|
||||
|
||||
ast::ExprForLoop(pat, head, body, opt_ident) => {
|
||||
ast::ExprKind::ForLoop(pat, head, body, opt_ident) => {
|
||||
let pat = fld.fold_pat(pat);
|
||||
|
||||
// Hygienic renaming of the for loop body (for loop binds its pattern).
|
||||
@@ -127,11 +127,11 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
|
||||
assert!(rewritten_pats.len() == 1);
|
||||
|
||||
let head = fld.fold_expr(head);
|
||||
fld.cx.expr(span, ast::ExprForLoop(rewritten_pats.remove(0), head, body, opt_ident))
|
||||
.with_attrs(fold_thin_attrs(attrs, fld))
|
||||
let fl = ast::ExprKind::ForLoop(rewritten_pats.remove(0), head, body, opt_ident);
|
||||
fld.cx.expr(span, fl).with_attrs(fold_thin_attrs(attrs, fld))
|
||||
}
|
||||
|
||||
ast::ExprIfLet(pat, sub_expr, body, else_opt) => {
|
||||
ast::ExprKind::IfLet(pat, sub_expr, body, else_opt) => {
|
||||
let pat = fld.fold_pat(pat);
|
||||
|
||||
// Hygienic renaming of the body.
|
||||
@@ -146,14 +146,14 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
|
||||
|
||||
let else_opt = else_opt.map(|else_opt| fld.fold_expr(else_opt));
|
||||
let sub_expr = fld.fold_expr(sub_expr);
|
||||
fld.cx.expr(span, ast::ExprIfLet(rewritten_pats.remove(0), sub_expr, body, else_opt))
|
||||
.with_attrs(fold_thin_attrs(attrs, fld))
|
||||
let il = ast::ExprKind::IfLet(rewritten_pats.remove(0), sub_expr, body, else_opt);
|
||||
fld.cx.expr(span, il).with_attrs(fold_thin_attrs(attrs, fld))
|
||||
}
|
||||
|
||||
ast::ExprClosure(capture_clause, fn_decl, block) => {
|
||||
ast::ExprKind::Closure(capture_clause, fn_decl, block) => {
|
||||
let (rewritten_fn_decl, rewritten_block)
|
||||
= expand_and_rename_fn_decl_and_block(fn_decl, block, fld);
|
||||
let new_node = ast::ExprClosure(capture_clause,
|
||||
let new_node = ast::ExprKind::Closure(capture_clause,
|
||||
rewritten_fn_decl,
|
||||
rewritten_block);
|
||||
P(ast::Expr{id:id, node: new_node, span: fld.new_span(span),
|
||||
@@ -1427,7 +1427,7 @@ mod tests {
|
||||
|
||||
impl<'v> Visitor<'v> for PathExprFinderContext {
|
||||
fn visit_expr(&mut self, expr: &ast::Expr) {
|
||||
if let ast::ExprPath(None, ref p) = expr.node {
|
||||
if let ast::ExprKind::Path(None, ref p) = expr.node {
|
||||
self.path_accumulator.push(p.clone());
|
||||
}
|
||||
visit::walk_expr(self, expr);
|
||||
@@ -1694,7 +1694,7 @@ mod tests {
|
||||
0)
|
||||
}
|
||||
|
||||
// closure arg hygiene (ExprClosure)
|
||||
// closure arg hygiene (ExprKind::Closure)
|
||||
// expands to fn f(){(|x_1 : i32| {(x_2 + x_1)})(3);}
|
||||
#[test]
|
||||
fn closure_arg_hygiene(){
|
||||
|
||||
@@ -240,7 +240,7 @@ pub mod rt {
|
||||
// FIXME: This is wrong
|
||||
P(ast::Expr {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::ExprLit(P(self.clone())),
|
||||
node: ast::ExprKind::Lit(P(self.clone())),
|
||||
span: DUMMY_SP,
|
||||
attrs: None,
|
||||
}).to_tokens(cx)
|
||||
|
||||
Reference in New Issue
Block a user