}
pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> {
+ use syntax::ast::TyKind::*;
P(hir::Ty {
id: t.id,
node: match t.node {
- TyInfer => hir::TyInfer,
- TyVec(ref ty) => hir::TyVec(lower_ty(lctx, ty)),
- TyPtr(ref mt) => hir::TyPtr(lower_mt(lctx, mt)),
- TyRptr(ref region, ref mt) => {
+ Infer => hir::TyInfer,
+ Vec(ref ty) => hir::TyVec(lower_ty(lctx, ty)),
+ Ptr(ref mt) => hir::TyPtr(lower_mt(lctx, mt)),
+ Rptr(ref region, ref mt) => {
hir::TyRptr(lower_opt_lifetime(lctx, region), lower_mt(lctx, mt))
}
- TyBareFn(ref f) => {
+ BareFn(ref f) => {
hir::TyBareFn(P(hir::BareFnTy {
lifetimes: lower_lifetime_defs(lctx, &f.lifetimes),
unsafety: lower_unsafety(lctx, f.unsafety),
decl: lower_fn_decl(lctx, &f.decl),
}))
}
- TyTup(ref tys) => hir::TyTup(tys.iter().map(|ty| lower_ty(lctx, ty)).collect()),
- TyParen(ref ty) => {
+ Tup(ref tys) => hir::TyTup(tys.iter().map(|ty| lower_ty(lctx, ty)).collect()),
+ Paren(ref ty) => {
return lower_ty(lctx, ty);
}
- TyPath(ref qself, ref path) => {
+ Path(ref qself, ref path) => {
let qself = qself.as_ref().map(|&QSelf { ref ty, position }| {
hir::QSelf {
ty: lower_ty(lctx, ty),
});
hir::TyPath(qself, lower_path(lctx, path))
}
- TyObjectSum(ref ty, ref bounds) => {
+ ObjectSum(ref ty, ref bounds) => {
hir::TyObjectSum(lower_ty(lctx, ty), lower_bounds(lctx, bounds))
}
- TyFixedLengthVec(ref ty, ref e) => {
+ FixedLengthVec(ref ty, ref e) => {
hir::TyFixedLengthVec(lower_ty(lctx, ty), lower_expr(lctx, e))
}
- TyTypeof(ref expr) => {
+ Typeof(ref expr) => {
hir::TyTypeof(lower_expr(lctx, expr))
}
- TyPolyTraitRef(ref bounds) => {
+ PolyTraitRef(ref bounds) => {
hir::TyPolyTraitRef(bounds.iter().map(|b| lower_ty_param_bound(lctx, b)).collect())
}
- TyMac(_) => panic!("TyMac should have been expanded by now."),
+ Mac(_) => panic!("TyMac should have been expanded by now."),
},
span: t.span,
})
})
}
-pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ {
+pub fn lower_item_kind(lctx: &LoweringContext, i: &ItemKind) -> hir::Item_ {
match *i {
- ItemExternCrate(string) => hir::ItemExternCrate(string),
- ItemUse(ref view_path) => {
+ ItemKind::ExternCrate(string) => hir::ItemExternCrate(string),
+ ItemKind::Use(ref view_path) => {
hir::ItemUse(lower_view_path(lctx, view_path))
}
- ItemStatic(ref t, m, ref e) => {
+ ItemKind::Static(ref t, m, ref e) => {
hir::ItemStatic(lower_ty(lctx, t),
lower_mutability(lctx, m),
lower_expr(lctx, e))
}
- ItemConst(ref t, ref e) => {
+ ItemKind::Const(ref t, ref e) => {
hir::ItemConst(lower_ty(lctx, t), lower_expr(lctx, e))
}
- ItemFn(ref decl, unsafety, constness, abi, ref generics, ref body) => {
+ ItemKind::Fn(ref decl, unsafety, constness, abi, ref generics, ref body) => {
hir::ItemFn(lower_fn_decl(lctx, decl),
lower_unsafety(lctx, unsafety),
lower_constness(lctx, constness),
lower_generics(lctx, generics),
lower_block(lctx, body))
}
- ItemMod(ref m) => hir::ItemMod(lower_mod(lctx, m)),
- ItemForeignMod(ref nm) => hir::ItemForeignMod(lower_foreign_mod(lctx, nm)),
- ItemTy(ref t, ref generics) => {
+ ItemKind::Mod(ref m) => hir::ItemMod(lower_mod(lctx, m)),
+ ItemKind::ForeignMod(ref nm) => hir::ItemForeignMod(lower_foreign_mod(lctx, nm)),
+ ItemKind::Ty(ref t, ref generics) => {
hir::ItemTy(lower_ty(lctx, t), lower_generics(lctx, generics))
}
- ItemEnum(ref enum_definition, ref generics) => {
+ ItemKind::Enum(ref enum_definition, ref generics) => {
hir::ItemEnum(hir::EnumDef {
variants: enum_definition.variants
.iter()
},
lower_generics(lctx, generics))
}
- ItemStruct(ref struct_def, ref generics) => {
+ ItemKind::Struct(ref struct_def, ref generics) => {
let struct_def = lower_variant_data(lctx, struct_def);
hir::ItemStruct(struct_def, lower_generics(lctx, generics))
}
- ItemDefaultImpl(unsafety, ref trait_ref) => {
+ ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
hir::ItemDefaultImpl(lower_unsafety(lctx, unsafety),
lower_trait_ref(lctx, trait_ref))
}
- ItemImpl(unsafety, polarity, ref generics, ref ifce, ref ty, ref impl_items) => {
+ ItemKind::Impl(unsafety, polarity, ref generics, ref ifce, ref ty, ref impl_items) => {
let new_impl_items = impl_items.iter()
.map(|item| lower_impl_item(lctx, item))
.collect();
lower_ty(lctx, ty),
new_impl_items)
}
- ItemTrait(unsafety, ref generics, ref bounds, ref items) => {
+ ItemKind::Trait(unsafety, ref generics, ref bounds, ref items) => {
let bounds = lower_bounds(lctx, bounds);
let items = items.iter().map(|item| lower_trait_item(lctx, item)).collect();
hir::ItemTrait(lower_unsafety(lctx, unsafety),
bounds,
items)
}
- ItemMac(_) => panic!("Shouldn't still be around"),
+ ItemKind::Mac(_) => panic!("Shouldn't still be around"),
}
}
}
pub fn lower_item(lctx: &LoweringContext, i: &Item) -> hir::Item {
- let node = lower_item_underscore(lctx, &i.node);
+ let node = lower_item_kind(lctx, &i.node);
hir::Item {
id: i.id,
name: i.ident.name,
attrs: lower_attrs(lctx, &i.attrs),
node: match i.node {
- ForeignItemFn(ref fdec, ref generics) => {
+ ForeignItemKind::Fn(ref fdec, ref generics) => {
hir::ForeignItemFn(lower_fn_decl(lctx, fdec), lower_generics(lctx, generics))
}
- ForeignItemStatic(ref t, m) => {
+ ForeignItemKind::Static(ref t, m) => {
hir::ForeignItemStatic(lower_ty(lctx, t), m)
}
},
pub fn lower_stmt(lctx: &LoweringContext, s: &Stmt) -> hir::Stmt {
match s.node {
- StmtDecl(ref d, id) => {
+ StmtKind::Decl(ref d, id) => {
Spanned {
node: hir::StmtDecl(lower_decl(lctx, d), id),
span: s.span,
}
}
- StmtExpr(ref e, id) => {
+ StmtKind::Expr(ref e, id) => {
Spanned {
node: hir::StmtExpr(lower_expr(lctx, e), id),
span: s.span,
}
}
- StmtSemi(ref e, id) => {
+ StmtKind::Semi(ref e, id) => {
Spanned {
node: hir::StmtSemi(lower_expr(lctx, e), id),
span: s.span,
}
}
- StmtMac(..) => panic!("Shouldn't exist here"),
+ StmtKind::Mac(..) => panic!("Shouldn't exist here"),
}
}