-pub trait AstBuilder {
- // Paths
- fn path(&self, span: Span, strs: Vec<ast::Ident> ) -> ast::Path;
- fn path_ident(&self, span: Span, id: ast::Ident) -> ast::Path;
- fn path_global(&self, span: Span, strs: Vec<ast::Ident> ) -> ast::Path;
- fn path_all(&self, sp: Span,
- global: bool,
- idents: Vec<ast::Ident>,
- args: Vec<ast::GenericArg>,
- constraints: Vec<ast::AssocTyConstraint>)
- -> ast::Path;
-
- fn qpath(&self, self_type: P<ast::Ty>,
- trait_path: ast::Path,
- ident: ast::Ident)
- -> (ast::QSelf, ast::Path);
- fn qpath_all(&self, self_type: P<ast::Ty>,
- trait_path: ast::Path,
- ident: ast::Ident,
- args: Vec<ast::GenericArg>,
- constraints: Vec<ast::AssocTyConstraint>)
- -> (ast::QSelf, ast::Path);
-
- // types and consts
- fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy;
-
- fn ty(&self, span: Span, ty: ast::TyKind) -> P<ast::Ty>;
- fn ty_path(&self, path: ast::Path) -> P<ast::Ty>;
- fn ty_ident(&self, span: Span, idents: ast::Ident) -> P<ast::Ty>;
- fn anon_const(&self, span: Span, expr: ast::ExprKind) -> ast::AnonConst;
- fn const_ident(&self, span: Span, idents: ast::Ident) -> ast::AnonConst;
-
- fn ty_rptr(&self, span: Span,
- ty: P<ast::Ty>,
- lifetime: Option<ast::Lifetime>,
- mutbl: ast::Mutability) -> P<ast::Ty>;
- fn ty_ptr(&self, span: Span,
- ty: P<ast::Ty>,
- mutbl: ast::Mutability) -> P<ast::Ty>;
-
- fn ty_infer(&self, sp: Span) -> P<ast::Ty>;
-
- fn typaram(&self,
- span: Span,
- id: ast::Ident,
- attrs: Vec<ast::Attribute>,
- bounds: ast::GenericBounds,
- default: Option<P<ast::Ty>>) -> ast::GenericParam;
-
- fn trait_ref(&self, path: ast::Path) -> ast::TraitRef;
- fn poly_trait_ref(&self, span: Span, path: ast::Path) -> ast::PolyTraitRef;
- fn trait_bound(&self, path: ast::Path) -> ast::GenericBound;
- fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime;
- fn lifetime_def(&self,
- span: Span,
- ident: ast::Ident,
- attrs: Vec<ast::Attribute>,
- bounds: ast::GenericBounds)
- -> ast::GenericParam;
-
- // Statements
- fn stmt_expr(&self, expr: P<ast::Expr>) -> ast::Stmt;
- fn stmt_semi(&self, expr: P<ast::Expr>) -> ast::Stmt;
- fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: P<ast::Expr>) -> ast::Stmt;
- fn stmt_let_typed(&self,
- sp: Span,
- mutbl: bool,
- ident: ast::Ident,
- typ: P<ast::Ty>,
- ex: P<ast::Expr>)
- -> 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
- fn block(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Block>;
- fn block_expr(&self, expr: P<ast::Expr>) -> P<ast::Block>;
-
- // Expressions
- 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>;
-
- fn expr_self(&self, span: Span) -> P<ast::Expr>;
- fn expr_binary(&self, sp: Span, op: ast::BinOpKind,
- lhs: P<ast::Expr>, rhs: P<ast::Expr>) -> P<ast::Expr>;
- fn expr_deref(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
- fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P<ast::Expr>) -> P<ast::Expr>;
-
- fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
- fn expr_mut_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
- fn expr_field_access(&self, span: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr>;
- fn expr_tup_field_access(&self, sp: Span, expr: P<ast::Expr>,
- idx: usize) -> P<ast::Expr>;
- fn expr_call(&self, span: Span, expr: P<ast::Expr>, args: Vec<P<ast::Expr>>) -> P<ast::Expr>;
- fn expr_call_ident(&self, span: Span, id: ast::Ident, args: Vec<P<ast::Expr>>) -> P<ast::Expr>;
- fn expr_call_global(&self, sp: Span, fn_path: Vec<ast::Ident>,
- args: Vec<P<ast::Expr>> ) -> P<ast::Expr>;
- fn expr_method_call(&self, span: Span,
- expr: P<ast::Expr>, ident: ast::Ident,
- args: Vec<P<ast::Expr>> ) -> P<ast::Expr>;
- fn expr_block(&self, b: P<ast::Block>) -> P<ast::Expr>;
- fn expr_cast(&self, sp: Span, expr: P<ast::Expr>, ty: P<ast::Ty>) -> P<ast::Expr>;
-
- fn field_imm(&self, span: Span, name: Ident, e: P<ast::Expr>) -> ast::Field;
- fn expr_struct(&self, span: Span, path: ast::Path, fields: Vec<ast::Field>) -> P<ast::Expr>;
- fn expr_struct_ident(&self, span: Span, id: ast::Ident,
- fields: Vec<ast::Field>) -> P<ast::Expr>;
-
- fn expr_lit(&self, sp: Span, lit: ast::LitKind) -> P<ast::Expr>;
-
- fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr>;
- fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr>;
- fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr>;
- fn expr_u16(&self, sp: Span, u: u16) -> P<ast::Expr>;
- fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr>;
- fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr>;
-
- fn expr_vec(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr>;
- fn expr_vec_ng(&self, sp: Span) -> P<ast::Expr>;
- fn expr_vec_slice(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr>;
- fn expr_str(&self, sp: Span, s: Symbol) -> P<ast::Expr>;
-
- fn expr_some(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
- fn expr_none(&self, sp: Span) -> P<ast::Expr>;
-
- fn expr_break(&self, sp: Span) -> P<ast::Expr>;
-
- fn expr_tuple(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr>;
-
- fn expr_fail(&self, span: Span, msg: Symbol) -> P<ast::Expr>;
- fn expr_unreachable(&self, span: Span) -> P<ast::Expr>;
-
- fn expr_ok(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
- fn expr_err(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
- fn expr_try(&self, span: Span, head: P<ast::Expr>) -> P<ast::Expr>;
-
- fn pat(&self, span: Span, pat: PatKind) -> P<ast::Pat>;
- fn pat_wild(&self, span: Span) -> P<ast::Pat>;
- fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat>;
- fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat>;
-
- fn pat_ident_binding_mode(&self,
- span: Span,
- ident: ast::Ident,
- bm: ast::BindingMode) -> P<ast::Pat>;
- fn pat_path(&self, span: Span, path: ast::Path) -> P<ast::Pat>;
- fn pat_tuple_struct(&self, span: Span, path: ast::Path,
- subpats: Vec<P<ast::Pat>>) -> P<ast::Pat>;
- fn pat_struct(&self, span: Span, path: ast::Path,
- field_pats: Vec<Spanned<ast::FieldPat>>) -> P<ast::Pat>;
- fn pat_tuple(&self, span: Span, pats: Vec<P<ast::Pat>>) -> P<ast::Pat>;
-
- fn pat_some(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat>;
- fn pat_none(&self, span: Span) -> P<ast::Pat>;
-
- fn pat_ok(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat>;
- fn pat_err(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat>;
-
- fn arm(&self, span: Span, pats: Vec<P<ast::Pat>>, expr: P<ast::Expr>) -> ast::Arm;
- fn arm_unreachable(&self, span: Span) -> ast::Arm;
-
- fn expr_match(&self, span: Span, arg: P<ast::Expr>, arms: Vec<ast::Arm> ) -> P<ast::Expr>;
- fn expr_if(&self, span: Span,
- cond: P<ast::Expr>, then: P<ast::Expr>, els: Option<P<ast::Expr>>) -> P<ast::Expr>;
- fn expr_loop(&self, span: Span, block: P<ast::Block>) -> P<ast::Expr>;
-
- fn lambda_fn_decl(&self,
- span: Span,
- fn_decl: P<ast::FnDecl>,
- body: P<ast::Expr>,
- fn_decl_span: Span)
- -> P<ast::Expr>;
-
- fn lambda(&self, span: Span, ids: Vec<ast::Ident>, body: P<ast::Expr>) -> P<ast::Expr>;
- fn lambda0(&self, span: Span, body: P<ast::Expr>) -> P<ast::Expr>;
- fn lambda1(&self, span: Span, body: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr>;
-
- fn lambda_stmts(&self, span: Span, ids: Vec<ast::Ident>,
- blk: Vec<ast::Stmt>) -> P<ast::Expr>;
- fn lambda_stmts_0(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Expr>;
- fn lambda_stmts_1(&self, span: Span, stmts: Vec<ast::Stmt>,
- ident: ast::Ident) -> P<ast::Expr>;
-
- // Items
- fn item(&self, span: Span,
- name: Ident, attrs: Vec<ast::Attribute> , node: ast::ItemKind) -> P<ast::Item>;
-
- fn arg(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::Arg;
- // FIXME: unused `self`
- fn fn_decl(&self, inputs: Vec<ast::Arg> , output: ast::FunctionRetTy) -> P<ast::FnDecl>;
-
- fn item_fn_poly(&self,
- span: Span,
- name: Ident,
- inputs: Vec<ast::Arg> ,
- output: P<ast::Ty>,
- generics: Generics,
- body: P<ast::Block>) -> P<ast::Item>;
- fn item_fn(&self,
- span: Span,
- name: Ident,
- inputs: Vec<ast::Arg> ,
- output: P<ast::Ty>,
- body: P<ast::Block>) -> P<ast::Item>;
-
- fn variant(&self, span: Span, name: Ident, tys: Vec<P<ast::Ty>> ) -> ast::Variant;
- fn item_enum_poly(&self,
- span: Span,
- name: Ident,
- enum_definition: ast::EnumDef,
- generics: Generics) -> P<ast::Item>;
- fn item_enum(&self, span: Span, name: Ident, enum_def: ast::EnumDef) -> P<ast::Item>;
-
- fn item_struct_poly(&self,
- span: Span,
- name: Ident,
- struct_def: ast::VariantData,
- generics: Generics) -> P<ast::Item>;
- fn item_struct(&self, span: Span, name: Ident, struct_def: ast::VariantData) -> P<ast::Item>;
-
- fn item_mod(&self, span: Span, inner_span: Span,
- name: Ident, attrs: Vec<ast::Attribute>,
- items: Vec<P<ast::Item>>) -> P<ast::Item>;
-
- fn item_extern_crate(&self, span: Span, name: Ident) -> P<ast::Item>;
-
- fn item_static(&self,
- span: Span,
- name: Ident,
- ty: P<ast::Ty>,
- mutbl: ast::Mutability,
- expr: P<ast::Expr>)
- -> P<ast::Item>;
-
- fn item_const(&self,
- span: Span,
- name: Ident,
- ty: P<ast::Ty>,
- expr: P<ast::Expr>)
- -> P<ast::Item>;
-
- fn item_ty_poly(&self,
- span: Span,
- name: Ident,
- ty: P<ast::Ty>,
- generics: Generics) -> P<ast::Item>;
- fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> P<ast::Item>;
-
- fn attribute(&self, mi: ast::MetaItem) -> ast::Attribute;
-
- fn meta_word(&self, sp: Span, w: ast::Name) -> ast::MetaItem;
-
- fn meta_list_item_word(&self, sp: Span, w: ast::Name) -> ast::NestedMetaItem;
-
- fn meta_list(&self,
- sp: Span,
- name: ast::Name,
- mis: Vec<ast::NestedMetaItem> )
- -> ast::MetaItem;
- fn meta_name_value(&self,
- sp: Span,
- name: ast::Name,
- value: ast::LitKind)
- -> ast::MetaItem;
-
- fn item_use(&self, sp: Span,
- vis: ast::Visibility, vp: P<ast::UseTree>) -> P<ast::Item>;
- fn item_use_simple(&self, sp: Span, vis: ast::Visibility, path: ast::Path) -> P<ast::Item>;
- fn item_use_simple_(&self, sp: Span, vis: ast::Visibility,
- ident: Option<ast::Ident>, path: ast::Path) -> P<ast::Item>;
- fn item_use_list(&self, sp: Span, vis: ast::Visibility,
- path: Vec<ast::Ident>, imports: &[ast::Ident]) -> P<ast::Item>;
- fn item_use_glob(&self, sp: Span,
- vis: ast::Visibility, path: Vec<ast::Ident>) -> P<ast::Item>;
-}