use syntax_pos::{Pos, Span};
-// Left so that Cargo tests don't break, this can be removed once those no longer use it
-pub trait AstBuilder {}
-
impl<'a> ExtCtxt<'a> {
pub fn path(&self, span: Span, strs: Vec<ast::Ident> ) -> ast::Path {
self.path_all(span, false, strs, vec![])
}
}
- pub fn ty(&self, span: Span, ty: ast::TyKind) -> P<ast::Ty> {
+ pub fn ty(&self, span: Span, kind: ast::TyKind) -> P<ast::Ty> {
P(ast::Ty {
id: ast::DUMMY_NODE_ID,
span,
- node: ty
+ kind,
})
}
self.ty_path(self.path_ident(span, ident))
}
- pub fn anon_const(&self, span: Span, expr: ast::ExprKind) -> ast::AnonConst {
+ pub fn anon_const(&self, span: Span, kind: ast::ExprKind) -> ast::AnonConst {
ast::AnonConst {
id: ast::DUMMY_NODE_ID,
value: P(ast::Expr {
id: ast::DUMMY_NODE_ID,
- node: expr,
+ kind,
span,
attrs: ThinVec::new(),
})
ast::TyKind::Ptr(self.ty_mt(ty, mutbl)))
}
- pub fn ty_infer(&self, span: Span) -> P<ast::Ty> {
- self.ty(span, ast::TyKind::Infer)
- }
-
pub fn typaram(&self,
span: Span,
ident: ast::Ident,
ast::Stmt {
id: ast::DUMMY_NODE_ID,
span: expr.span,
- node: ast::StmtKind::Expr(expr),
+ kind: ast::StmtKind::Expr(expr),
}
}
});
ast::Stmt {
id: ast::DUMMY_NODE_ID,
- node: ast::StmtKind::Local(local),
+ kind: ast::StmtKind::Local(local),
span: sp,
}
}
});
ast::Stmt {
id: ast::DUMMY_NODE_ID,
- node: ast::StmtKind::Local(local),
+ kind: ast::StmtKind::Local(local),
span,
}
}
pub fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> ast::Stmt {
ast::Stmt {
id: ast::DUMMY_NODE_ID,
- node: ast::StmtKind::Item(item),
+ kind: ast::StmtKind::Item(item),
span: sp,
}
}
self.block(expr.span, vec![ast::Stmt {
id: ast::DUMMY_NODE_ID,
span: expr.span,
- node: ast::StmtKind::Expr(expr),
+ kind: ast::StmtKind::Expr(expr),
}])
}
pub fn block(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Block> {
})
}
- pub fn expr(&self, span: Span, node: ast::ExprKind) -> P<ast::Expr> {
+ pub fn expr(&self, span: Span, kind: ast::ExprKind) -> P<ast::Expr> {
P(ast::Expr {
id: ast::DUMMY_NODE_ID,
- node,
+ kind,
span,
attrs: ThinVec::new(),
})
}
- pub fn pat(&self, span: Span, pat: PatKind) -> P<ast::Pat> {
- P(ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span })
+ pub fn pat(&self, span: Span, kind: PatKind) -> P<ast::Pat> {
+ P(ast::Pat { id: ast::DUMMY_NODE_ID, kind, span })
}
pub fn pat_wild(&self, span: Span) -> P<ast::Pat> {
self.pat(span, PatKind::Wild)
body: P<ast::Expr>)
-> P<ast::Expr> {
let fn_decl = self.fn_decl(
- ids.iter().map(|id| self.param(span, *id, self.ty_infer(span))).collect(),
+ ids.iter().map(|id| self.param(span, *id, self.ty(span, ast::TyKind::Infer))).collect(),
ast::FunctionRetTy::Default(span));
// FIXME -- We are using `span` as the span of the `|...|`
}
pub fn item(&self, span: Span, name: Ident,
- attrs: Vec<ast::Attribute>, node: ast::ItemKind) -> P<ast::Item> {
+ attrs: Vec<ast::Attribute>, kind: ast::ItemKind) -> P<ast::Item> {
// FIXME: Would be nice if our generated code didn't violate
// Rust coding conventions
P(ast::Item {
ident: name,
attrs,
id: ast::DUMMY_NODE_ID,
- node,
+ kind,
vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited),
span,
tokens: None,
pub fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem {
attr::mk_word_item(Ident::new(w, sp))
}
-
- pub fn meta_list_item_word(&self, sp: Span, w: ast::Name) -> ast::NestedMetaItem {
- attr::mk_nested_word_item(Ident::new(w, sp))
- }
-
- pub fn meta_list(&self, sp: Span, name: ast::Name, mis: Vec<ast::NestedMetaItem>)
- -> ast::MetaItem {
- attr::mk_list_item(Ident::new(name, sp), mis)
- }
-
- pub fn meta_name_value(&self, span: Span, name: ast::Name, lit_kind: ast::LitKind)
- -> ast::MetaItem {
- attr::mk_name_value_item(Ident::new(name, span), lit_kind, span)
- }
}