提交 05d4cefd 编写于 作者: O Oliver Schneider

[breaking-change] don't pub export ast::Ty_ variants

上级 ec61e632
...@@ -268,16 +268,17 @@ pub fn lower_ty_binding(lctx: &LoweringContext, b: &TypeBinding) -> hir::TypeBin ...@@ -268,16 +268,17 @@ pub fn lower_ty_binding(lctx: &LoweringContext, b: &TypeBinding) -> hir::TypeBin
} }
pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> { pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> {
use syntax::ast::TyKind::*;
P(hir::Ty { P(hir::Ty {
id: t.id, id: t.id,
node: match t.node { node: match t.node {
TyInfer => hir::TyInfer, Infer => hir::TyInfer,
TyVec(ref ty) => hir::TyVec(lower_ty(lctx, ty)), Vec(ref ty) => hir::TyVec(lower_ty(lctx, ty)),
TyPtr(ref mt) => hir::TyPtr(lower_mt(lctx, mt)), Ptr(ref mt) => hir::TyPtr(lower_mt(lctx, mt)),
TyRptr(ref region, ref mt) => { Rptr(ref region, ref mt) => {
hir::TyRptr(lower_opt_lifetime(lctx, region), lower_mt(lctx, mt)) hir::TyRptr(lower_opt_lifetime(lctx, region), lower_mt(lctx, mt))
} }
TyBareFn(ref f) => { BareFn(ref f) => {
hir::TyBareFn(P(hir::BareFnTy { hir::TyBareFn(P(hir::BareFnTy {
lifetimes: lower_lifetime_defs(lctx, &f.lifetimes), lifetimes: lower_lifetime_defs(lctx, &f.lifetimes),
unsafety: lower_unsafety(lctx, f.unsafety), unsafety: lower_unsafety(lctx, f.unsafety),
...@@ -285,11 +286,11 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> { ...@@ -285,11 +286,11 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> {
decl: lower_fn_decl(lctx, &f.decl), decl: lower_fn_decl(lctx, &f.decl),
})) }))
} }
TyTup(ref tys) => hir::TyTup(tys.iter().map(|ty| lower_ty(lctx, ty)).collect()), Tup(ref tys) => hir::TyTup(tys.iter().map(|ty| lower_ty(lctx, ty)).collect()),
TyParen(ref ty) => { Paren(ref ty) => {
return lower_ty(lctx, 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 }| { let qself = qself.as_ref().map(|&QSelf { ref ty, position }| {
hir::QSelf { hir::QSelf {
ty: lower_ty(lctx, ty), ty: lower_ty(lctx, ty),
...@@ -298,19 +299,19 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> { ...@@ -298,19 +299,19 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> {
}); });
hir::TyPath(qself, lower_path(lctx, path)) 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)) 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)) hir::TyFixedLengthVec(lower_ty(lctx, ty), lower_expr(lctx, e))
} }
TyTypeof(ref expr) => { Typeof(ref expr) => {
hir::TyTypeof(lower_expr(lctx, 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()) 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, span: t.span,
}) })
......
...@@ -1063,7 +1063,7 @@ fn visit_impl_item(&mut self, impl_item: &ast::ImplItem) { ...@@ -1063,7 +1063,7 @@ fn visit_impl_item(&mut self, impl_item: &ast::ImplItem) {
fn visit_ty(&mut self, t: &ast::Ty) { fn visit_ty(&mut self, t: &ast::Ty) {
self.process_macro_use(t.span, t.id); self.process_macro_use(t.span, t.id);
match t.node { match t.node {
ast::TyPath(_, ref path) => { ast::TyKind::Path(_, ref path) => {
match self.lookup_type_ref(t.id) { match self.lookup_type_ref(t.id) {
Some(id) => { Some(id) => {
let sub_span = self.span.sub_span_for_type_name(t.span); let sub_span = self.span.sub_span_for_type_name(t.span);
......
...@@ -316,7 +316,7 @@ pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> { ...@@ -316,7 +316,7 @@ pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
match typ.node { match typ.node {
// Common case impl for a struct or something basic. // Common case impl for a struct or something basic.
ast::TyPath(None, ref path) => { ast::TyKind::Path(None, ref path) => {
sub_span = self.span_utils.sub_span_for_type_name(path.span); sub_span = self.span_utils.sub_span_for_type_name(path.span);
filter!(self.span_utils, sub_span, path.span, None); filter!(self.span_utils, sub_span, path.span, None);
type_data = self.lookup_ref_id(typ.id).map(|id| { type_data = self.lookup_ref_id(typ.id).map(|id| {
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
pub use self::StrStyle::*; pub use self::StrStyle::*;
pub use self::StructFieldKind::*; pub use self::StructFieldKind::*;
pub use self::TraitItem_::*; pub use self::TraitItem_::*;
pub use self::Ty_::*;
pub use self::TyParamBound::*; pub use self::TyParamBound::*;
pub use self::UnsafeSource::*; pub use self::UnsafeSource::*;
pub use self::ViewPath_::*; pub use self::ViewPath_::*;
...@@ -1523,7 +1522,7 @@ pub struct TypeBinding { ...@@ -1523,7 +1522,7 @@ pub struct TypeBinding {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
pub struct Ty { pub struct Ty {
pub id: NodeId, pub id: NodeId,
pub node: Ty_, pub node: TyKind,
pub span: Span, pub span: Span,
} }
...@@ -1543,36 +1542,36 @@ pub struct BareFnTy { ...@@ -1543,36 +1542,36 @@ pub struct BareFnTy {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
/// The different kinds of types recognized by the compiler /// The different kinds of types recognized by the compiler
pub enum Ty_ { pub enum TyKind {
TyVec(P<Ty>), Vec(P<Ty>),
/// A fixed length array (`[T; n]`) /// A fixed length array (`[T; n]`)
TyFixedLengthVec(P<Ty>, P<Expr>), FixedLengthVec(P<Ty>, P<Expr>),
/// A raw pointer (`*const T` or `*mut T`) /// A raw pointer (`*const T` or `*mut T`)
TyPtr(MutTy), Ptr(MutTy),
/// A reference (`&'a T` or `&'a mut T`) /// A reference (`&'a T` or `&'a mut T`)
TyRptr(Option<Lifetime>, MutTy), Rptr(Option<Lifetime>, MutTy),
/// A bare function (e.g. `fn(usize) -> bool`) /// A bare function (e.g. `fn(usize) -> bool`)
TyBareFn(P<BareFnTy>), BareFn(P<BareFnTy>),
/// A tuple (`(A, B, C, D,...)`) /// A tuple (`(A, B, C, D,...)`)
TyTup(Vec<P<Ty>> ), Tup(Vec<P<Ty>> ),
/// A path (`module::module::...::Type`), optionally /// A path (`module::module::...::Type`), optionally
/// "qualified", e.g. `<Vec<T> as SomeTrait>::SomeType`. /// "qualified", e.g. `<Vec<T> as SomeTrait>::SomeType`.
/// ///
/// Type parameters are stored in the Path itself /// Type parameters are stored in the Path itself
TyPath(Option<QSelf>, Path), Path(Option<QSelf>, Path),
/// Something like `A+B`. Note that `B` must always be a path. /// Something like `A+B`. Note that `B` must always be a path.
TyObjectSum(P<Ty>, TyParamBounds), ObjectSum(P<Ty>, TyParamBounds),
/// A type like `for<'a> Foo<&'a Bar>` /// A type like `for<'a> Foo<&'a Bar>`
TyPolyTraitRef(TyParamBounds), PolyTraitRef(TyParamBounds),
/// No-op; kept solely so that we can pretty-print faithfully /// No-op; kept solely so that we can pretty-print faithfully
TyParen(P<Ty>), Paren(P<Ty>),
/// Unused for now /// Unused for now
TyTypeof(P<Expr>), Typeof(P<Expr>),
/// TyInfer means the type should be inferred instead of it having been /// TyKind::Infer means the type should be inferred instead of it having been
/// specified. This can appear anywhere in a type. /// specified. This can appear anywhere in a type.
TyInfer, Infer,
// A macro in the type position. // A macro in the type position.
TyMac(Mac) Mac(Mac),
} }
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
...@@ -1617,7 +1616,7 @@ pub fn new_self(span: Span, mutability: Mutability, self_ident: Ident) -> Arg { ...@@ -1617,7 +1616,7 @@ pub fn new_self(span: Span, mutability: Mutability, self_ident: Ident) -> Arg {
// HACK(eddyb) fake type for the self argument. // HACK(eddyb) fake type for the self argument.
ty: P(Ty { ty: P(Ty {
id: DUMMY_NODE_ID, id: DUMMY_NODE_ID,
node: TyInfer, node: TyKind::Infer,
span: DUMMY_SP, span: DUMMY_SP,
}), }),
pat: P(Pat { pat: P(Pat {
......
...@@ -212,10 +212,10 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, ...@@ -212,10 +212,10 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
let ty = ecx.ty( let ty = ecx.ty(
span, span,
ast::TyFixedLengthVec( ast::TyKind::FixedLengthVec(
ecx.ty( ecx.ty(
span, span,
ast::TyTup(vec![ty_str.clone(), ty_str]) ast::TyKind::Tup(vec![ty_str.clone(), ty_str])
), ),
ecx.expr_usize(span, count), ecx.expr_usize(span, count),
), ),
......
...@@ -367,7 +367,7 @@ pub fn raw_pat(sp: Span) -> ast::Pat { ...@@ -367,7 +367,7 @@ pub fn raw_pat(sp: Span) -> ast::Pat {
pub fn raw_ty(sp: Span) -> P<ast::Ty> { pub fn raw_ty(sp: Span) -> P<ast::Ty> {
P(ast::Ty { P(ast::Ty {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: ast::TyInfer, node: ast::TyKind::Infer,
span: sp span: sp
}) })
} }
......
...@@ -52,7 +52,7 @@ fn qpath_all(&self, self_type: P<ast::Ty>, ...@@ -52,7 +52,7 @@ fn qpath_all(&self, self_type: P<ast::Ty>,
// types // types
fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy; fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy;
fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty>; fn ty(&self, span: Span, ty: ast::TyKind) -> P<ast::Ty>;
fn ty_path(&self, ast::Path) -> P<ast::Ty>; fn ty_path(&self, ast::Path) -> P<ast::Ty>;
fn ty_sum(&self, ast::Path, ast::TyParamBounds) -> P<ast::Ty>; fn ty_sum(&self, ast::Path, ast::TyParamBounds) -> P<ast::Ty>;
fn ty_ident(&self, span: Span, idents: ast::Ident) -> P<ast::Ty>; fn ty_ident(&self, span: Span, idents: ast::Ident) -> P<ast::Ty>;
...@@ -385,7 +385,7 @@ fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy { ...@@ -385,7 +385,7 @@ fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy {
} }
} }
fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty> { fn ty(&self, span: Span, ty: ast::TyKind) -> P<ast::Ty> {
P(ast::Ty { P(ast::Ty {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
span: span, span: span,
...@@ -394,12 +394,12 @@ fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty> { ...@@ -394,12 +394,12 @@ fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty> {
} }
fn ty_path(&self, path: ast::Path) -> P<ast::Ty> { fn ty_path(&self, path: ast::Path) -> P<ast::Ty> {
self.ty(path.span, ast::TyPath(None, path)) self.ty(path.span, ast::TyKind::Path(None, path))
} }
fn ty_sum(&self, path: ast::Path, bounds: ast::TyParamBounds) -> P<ast::Ty> { fn ty_sum(&self, path: ast::Path, bounds: ast::TyParamBounds) -> P<ast::Ty> {
self.ty(path.span, self.ty(path.span,
ast::TyObjectSum(self.ty_path(path), ast::TyKind::ObjectSum(self.ty_path(path),
bounds)) bounds))
} }
...@@ -417,7 +417,7 @@ fn ty_rptr(&self, ...@@ -417,7 +417,7 @@ fn ty_rptr(&self,
mutbl: ast::Mutability) mutbl: ast::Mutability)
-> P<ast::Ty> { -> P<ast::Ty> {
self.ty(span, self.ty(span,
ast::TyRptr(lifetime, self.ty_mt(ty, mutbl))) ast::TyKind::Rptr(lifetime, self.ty_mt(ty, mutbl)))
} }
fn ty_ptr(&self, fn ty_ptr(&self,
...@@ -426,7 +426,7 @@ fn ty_ptr(&self, ...@@ -426,7 +426,7 @@ fn ty_ptr(&self,
mutbl: ast::Mutability) mutbl: ast::Mutability)
-> P<ast::Ty> { -> P<ast::Ty> {
self.ty(span, self.ty(span,
ast::TyPtr(self.ty_mt(ty, mutbl))) ast::TyKind::Ptr(self.ty_mt(ty, mutbl)))
} }
fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> { fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> {
...@@ -440,7 +440,7 @@ fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> { ...@@ -440,7 +440,7 @@ fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> {
} }
fn ty_infer(&self, span: Span) -> P<ast::Ty> { fn ty_infer(&self, span: Span) -> P<ast::Ty> {
self.ty(span, ast::TyInfer) self.ty(span, ast::TyKind::Infer)
} }
fn typaram(&self, fn typaram(&self,
......
...@@ -562,7 +562,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE ...@@ -562,7 +562,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE
DeclKind::Local(local) => { DeclKind::Local(local) => {
// take it apart: // take it apart:
let rewritten_local = local.map(|Local {id, pat, ty, init, span, attrs}| { let rewritten_local = local.map(|Local {id, pat, ty, init, span, attrs}| {
// expand the ty since TyFixedLengthVec contains an Expr // expand the ty since TyKind::FixedLengthVec contains an Expr
// and thus may have a macro use // and thus may have a macro use
let expanded_ty = ty.map(|t| fld.fold_ty(t)); let expanded_ty = ty.map(|t| fld.fold_ty(t));
// expand the pat (it might contain macro uses): // expand the pat (it might contain macro uses):
...@@ -1133,7 +1133,7 @@ fn expand_and_rename_method(sig: ast::MethodSig, body: P<ast::Block>, ...@@ -1133,7 +1133,7 @@ fn expand_and_rename_method(sig: ast::MethodSig, body: P<ast::Block>,
pub fn expand_type(t: P<ast::Ty>, fld: &mut MacroExpander) -> P<ast::Ty> { pub fn expand_type(t: P<ast::Ty>, fld: &mut MacroExpander) -> P<ast::Ty> {
let t = match t.node.clone() { let t = match t.node.clone() {
ast::Ty_::TyMac(mac) => { ast::TyKind::Mac(mac) => {
if fld.cx.ecfg.features.unwrap().type_macros { if fld.cx.ecfg.features.unwrap().type_macros {
let expanded_ty = match expand_mac_invoc(mac, t.span, let expanded_ty = match expand_mac_invoc(mac, t.span,
|r| r.make_ty(), |r| r.make_ty(),
......
...@@ -380,46 +380,46 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> { ...@@ -380,46 +380,46 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
t.map(|Ty {id, node, span}| Ty { t.map(|Ty {id, node, span}| Ty {
id: fld.new_id(id), id: fld.new_id(id),
node: match node { node: match node {
TyInfer => node, TyKind::Infer => node,
TyVec(ty) => TyVec(fld.fold_ty(ty)), TyKind::Vec(ty) => TyKind::Vec(fld.fold_ty(ty)),
TyPtr(mt) => TyPtr(fld.fold_mt(mt)), TyKind::Ptr(mt) => TyKind::Ptr(fld.fold_mt(mt)),
TyRptr(region, mt) => { TyKind::Rptr(region, mt) => {
TyRptr(fld.fold_opt_lifetime(region), fld.fold_mt(mt)) TyKind::Rptr(fld.fold_opt_lifetime(region), fld.fold_mt(mt))
} }
TyBareFn(f) => { TyKind::BareFn(f) => {
TyBareFn(f.map(|BareFnTy {lifetimes, unsafety, abi, decl}| BareFnTy { TyKind::BareFn(f.map(|BareFnTy {lifetimes, unsafety, abi, decl}| BareFnTy {
lifetimes: fld.fold_lifetime_defs(lifetimes), lifetimes: fld.fold_lifetime_defs(lifetimes),
unsafety: unsafety, unsafety: unsafety,
abi: abi, abi: abi,
decl: fld.fold_fn_decl(decl) decl: fld.fold_fn_decl(decl)
})) }))
} }
TyTup(tys) => TyTup(tys.move_map(|ty| fld.fold_ty(ty))), TyKind::Tup(tys) => TyKind::Tup(tys.move_map(|ty| fld.fold_ty(ty))),
TyParen(ty) => TyParen(fld.fold_ty(ty)), TyKind::Paren(ty) => TyKind::Paren(fld.fold_ty(ty)),
TyPath(qself, path) => { TyKind::Path(qself, path) => {
let qself = qself.map(|QSelf { ty, position }| { let qself = qself.map(|QSelf { ty, position }| {
QSelf { QSelf {
ty: fld.fold_ty(ty), ty: fld.fold_ty(ty),
position: position position: position
} }
}); });
TyPath(qself, fld.fold_path(path)) TyKind::Path(qself, fld.fold_path(path))
} }
TyObjectSum(ty, bounds) => { TyKind::ObjectSum(ty, bounds) => {
TyObjectSum(fld.fold_ty(ty), TyKind::ObjectSum(fld.fold_ty(ty),
fld.fold_bounds(bounds)) fld.fold_bounds(bounds))
} }
TyFixedLengthVec(ty, e) => { TyKind::FixedLengthVec(ty, e) => {
TyFixedLengthVec(fld.fold_ty(ty), fld.fold_expr(e)) TyKind::FixedLengthVec(fld.fold_ty(ty), fld.fold_expr(e))
} }
TyTypeof(expr) => { TyKind::Typeof(expr) => {
TyTypeof(fld.fold_expr(expr)) TyKind::Typeof(fld.fold_expr(expr))
} }
TyPolyTraitRef(bounds) => { TyKind::PolyTraitRef(bounds) => {
TyPolyTraitRef(bounds.move_map(|b| fld.fold_ty_param_bound(b))) TyKind::PolyTraitRef(bounds.move_map(|b| fld.fold_ty_param_bound(b)))
} }
TyMac(mac) => { TyKind::Mac(mac) => {
TyMac(fld.fold_mac(mac)) TyKind::Mac(fld.fold_mac(mac))
} }
}, },
span: fld.new_span(span) span: fld.new_span(span)
......
...@@ -916,7 +916,7 @@ fn parser_done(p: Parser){ ...@@ -916,7 +916,7 @@ fn parser_done(p: Parser){
node: ast::ItemFn(P(ast::FnDecl { node: ast::ItemFn(P(ast::FnDecl {
inputs: vec!(ast::Arg{ inputs: vec!(ast::Arg{
ty: P(ast::Ty{id: ast::DUMMY_NODE_ID, ty: P(ast::Ty{id: ast::DUMMY_NODE_ID,
node: ast::TyPath(None, ast::Path{ node: ast::TyKind::Path(None, ast::Path{
span:sp(10,13), span:sp(10,13),
global:false, global:false,
segments: vec!( segments: vec!(
......
...@@ -42,10 +42,7 @@ ...@@ -42,10 +42,7 @@
use ast::StrStyle; use ast::StrStyle;
use ast::SelfKind; use ast::SelfKind;
use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef}; use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
use ast::{Ty, Ty_, TypeBinding, TyMac}; use ast::{Ty, TyKind, TypeBinding, TyParam, TyParamBounds};
use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer};
use ast::{TyParam, TyParamBounds, TyParen, TyPath, TyPtr};
use ast::{TyRptr, TyTup, TyVec};
use ast::TypeTraitItem; use ast::TypeTraitItem;
use ast::UnnamedField; use ast::UnnamedField;
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
...@@ -1058,7 +1055,7 @@ pub fn get_lifetime(&mut self) -> ast::Ident { ...@@ -1058,7 +1055,7 @@ pub fn get_lifetime(&mut self) -> ast::Ident {
} }
} }
pub fn parse_for_in_type(&mut self) -> PResult<'a, Ty_> { pub fn parse_for_in_type(&mut self) -> PResult<'a, TyKind> {
/* /*
Parses whatever can come after a `for` keyword in a type. Parses whatever can come after a `for` keyword in a type.
The `for` has already been consumed. The `for` has already been consumed.
...@@ -1097,16 +1094,17 @@ pub fn parse_for_in_type(&mut self) -> PResult<'a, Ty_> { ...@@ -1097,16 +1094,17 @@ pub fn parse_for_in_type(&mut self) -> PResult<'a, Ty_> {
Some(TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)).into_iter() Some(TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)).into_iter()
.chain(other_bounds.into_vec()) .chain(other_bounds.into_vec())
.collect(); .collect();
Ok(ast::TyPolyTraitRef(all_bounds)) Ok(ast::TyKind::PolyTraitRef(all_bounds))
} }
} }
pub fn parse_ty_path(&mut self) -> PResult<'a, Ty_> { pub fn parse_ty_path(&mut self) -> PResult<'a, TyKind> {
Ok(TyPath(None, try!(self.parse_path(LifetimeAndTypesWithoutColons)))) Ok(TyKind::Path(None, try!(self.parse_path(LifetimeAndTypesWithoutColons))))
} }
/// parse a TyBareFn type: /// parse a TyKind::BareFn type:
pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec<ast::LifetimeDef>) -> PResult<'a, Ty_> { pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec<ast::LifetimeDef>)
-> PResult<'a, TyKind> {
/* /*
[unsafe] [extern "ABI"] fn <'lt> (S) -> T [unsafe] [extern "ABI"] fn <'lt> (S) -> T
...@@ -1134,7 +1132,7 @@ pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec<ast::LifetimeDef>) -> PRes ...@@ -1134,7 +1132,7 @@ pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec<ast::LifetimeDef>) -> PRes
output: ret_ty, output: ret_ty,
variadic: variadic variadic: variadic
}); });
Ok(TyBareFn(P(BareFnTy { Ok(TyKind::BareFn(P(BareFnTy {
abi: abi, abi: abi,
unsafety: unsafety, unsafety: unsafety,
lifetimes: lifetime_defs, lifetimes: lifetime_defs,
...@@ -1308,7 +1306,7 @@ pub fn parse_ty_sum(&mut self) -> PResult<'a, P<Ty>> { ...@@ -1308,7 +1306,7 @@ pub fn parse_ty_sum(&mut self) -> PResult<'a, P<Ty>> {
} }
let sp = mk_sp(lo, self.last_span.hi); let sp = mk_sp(lo, self.last_span.hi);
let sum = ast::TyObjectSum(lhs, bounds); let sum = ast::TyKind::ObjectSum(lhs, bounds);
Ok(P(Ty {id: ast::DUMMY_NODE_ID, node: sum, span: sp})) Ok(P(Ty {id: ast::DUMMY_NODE_ID, node: sum, span: sp}))
} }
...@@ -1339,14 +1337,14 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> { ...@@ -1339,14 +1337,14 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
try!(self.expect(&token::CloseDelim(token::Paren))); try!(self.expect(&token::CloseDelim(token::Paren)));
if ts.len() == 1 && !last_comma { if ts.len() == 1 && !last_comma {
TyParen(ts.into_iter().nth(0).unwrap()) TyKind::Paren(ts.into_iter().nth(0).unwrap())
} else { } else {
TyTup(ts) TyKind::Tup(ts)
} }
} else if self.check(&token::BinOp(token::Star)) { } else if self.check(&token::BinOp(token::Star)) {
// STAR POINTER (bare pointer?) // STAR POINTER (bare pointer?)
self.bump(); self.bump();
TyPtr(try!(self.parse_ptr())) TyKind::Ptr(try!(self.parse_ptr()))
} else if self.check(&token::OpenDelim(token::Bracket)) { } else if self.check(&token::OpenDelim(token::Bracket)) {
// VECTOR // VECTOR
try!(self.expect(&token::OpenDelim(token::Bracket))); try!(self.expect(&token::OpenDelim(token::Bracket)));
...@@ -1355,8 +1353,8 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> { ...@@ -1355,8 +1353,8 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
// Parse the `; e` in `[ i32; e ]` // Parse the `; e` in `[ i32; e ]`
// where `e` is a const expression // where `e` is a const expression
let t = match try!(self.maybe_parse_fixed_length_of_vec()) { let t = match try!(self.maybe_parse_fixed_length_of_vec()) {
None => TyVec(t), None => TyKind::Vec(t),
Some(suffix) => TyFixedLengthVec(t, suffix) Some(suffix) => TyKind::FixedLengthVec(t, suffix)
}; };
try!(self.expect(&token::CloseDelim(token::Bracket))); try!(self.expect(&token::CloseDelim(token::Bracket)));
t t
...@@ -1376,13 +1374,13 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> { ...@@ -1376,13 +1374,13 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
try!(self.expect(&token::OpenDelim(token::Paren))); try!(self.expect(&token::OpenDelim(token::Paren)));
let e = try!(self.parse_expr()); let e = try!(self.parse_expr());
try!(self.expect(&token::CloseDelim(token::Paren))); try!(self.expect(&token::CloseDelim(token::Paren)));
TyTypeof(e) TyKind::Typeof(e)
} else if self.eat_lt() { } else if self.eat_lt() {
let (qself, path) = let (qself, path) =
try!(self.parse_qualified_path(NoTypesAllowed)); try!(self.parse_qualified_path(NoTypesAllowed));
TyPath(Some(qself), path) TyKind::Path(Some(qself), path)
} else if self.check(&token::ModSep) || } else if self.check(&token::ModSep) ||
self.token.is_ident() || self.token.is_ident() ||
self.token.is_path() { self.token.is_path() {
...@@ -1395,14 +1393,14 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> { ...@@ -1395,14 +1393,14 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
seq_sep_none(), seq_sep_none(),
|p| p.parse_token_tree())); |p| p.parse_token_tree()));
let hi = self.span.hi; let hi = self.span.hi;
TyMac(spanned(lo, hi, Mac_ { path: path, tts: tts, ctxt: EMPTY_CTXT })) TyKind::Mac(spanned(lo, hi, Mac_ { path: path, tts: tts, ctxt: EMPTY_CTXT }))
} else { } else {
// NAMED TYPE // NAMED TYPE
TyPath(None, path) TyKind::Path(None, path)
} }
} else if self.eat(&token::Underscore) { } else if self.eat(&token::Underscore) {
// TYPE TO BE INFERRED // TYPE TO BE INFERRED
TyInfer TyKind::Infer
} else { } else {
let this_token_str = self.this_token_to_string(); let this_token_str = self.this_token_to_string();
let msg = format!("expected type, found `{}`", this_token_str); let msg = format!("expected type, found `{}`", this_token_str);
...@@ -1413,12 +1411,12 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> { ...@@ -1413,12 +1411,12 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
Ok(P(Ty {id: ast::DUMMY_NODE_ID, node: t, span: sp})) Ok(P(Ty {id: ast::DUMMY_NODE_ID, node: t, span: sp}))
} }
pub fn parse_borrowed_pointee(&mut self) -> PResult<'a, Ty_> { pub fn parse_borrowed_pointee(&mut self) -> PResult<'a, TyKind> {
// look for `&'lt` or `&'foo ` and interpret `foo` as the region name: // look for `&'lt` or `&'foo ` and interpret `foo` as the region name:
let opt_lifetime = try!(self.parse_opt_lifetime()); let opt_lifetime = try!(self.parse_opt_lifetime());
let mt = try!(self.parse_mt()); let mt = try!(self.parse_mt());
return Ok(TyRptr(opt_lifetime, mt)); return Ok(TyKind::Rptr(opt_lifetime, mt));
} }
pub fn parse_ptr(&mut self) -> PResult<'a, MutTy> { pub fn parse_ptr(&mut self) -> PResult<'a, MutTy> {
...@@ -1498,7 +1496,7 @@ pub fn parse_fn_block_arg(&mut self) -> PResult<'a, Arg> { ...@@ -1498,7 +1496,7 @@ pub fn parse_fn_block_arg(&mut self) -> PResult<'a, Arg> {
} else { } else {
P(Ty { P(Ty {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: TyInfer, node: TyKind::Infer,
span: mk_sp(self.span.lo, self.span.hi), span: mk_sp(self.span.lo, self.span.hi),
}) })
}; };
...@@ -4809,7 +4807,7 @@ fn parse_item_impl(&mut self, unsafety: ast::Unsafety) -> PResult<'a, ItemInfo> ...@@ -4809,7 +4807,7 @@ fn parse_item_impl(&mut self, unsafety: ast::Unsafety) -> PResult<'a, ItemInfo>
let opt_trait = if could_be_trait && self.eat_keyword(keywords::For) { let opt_trait = if could_be_trait && self.eat_keyword(keywords::For) {
// New-style trait. Reinterpret the type as a trait. // New-style trait. Reinterpret the type as a trait.
match ty.node { match ty.node {
TyPath(None, ref path) => { TyKind::Path(None, ref path) => {
Some(TraitRef { Some(TraitRef {
path: (*path).clone(), path: (*path).clone(),
ref_id: ty.id, ref_id: ty.id,
......
...@@ -957,12 +957,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> { ...@@ -957,12 +957,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
try!(self.maybe_print_comment(ty.span.lo)); try!(self.maybe_print_comment(ty.span.lo));
try!(self.ibox(0)); try!(self.ibox(0));
match ty.node { match ty.node {
ast::TyVec(ref ty) => { ast::TyKind::Vec(ref ty) => {
try!(word(&mut self.s, "[")); try!(word(&mut self.s, "["));
try!(self.print_type(&**ty)); try!(self.print_type(&**ty));
try!(word(&mut self.s, "]")); try!(word(&mut self.s, "]"));
} }
ast::TyPtr(ref mt) => { ast::TyKind::Ptr(ref mt) => {
try!(word(&mut self.s, "*")); try!(word(&mut self.s, "*"));
match mt.mutbl { match mt.mutbl {
ast::MutMutable => try!(self.word_nbsp("mut")), ast::MutMutable => try!(self.word_nbsp("mut")),
...@@ -970,12 +970,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> { ...@@ -970,12 +970,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
} }
try!(self.print_type(&*mt.ty)); try!(self.print_type(&*mt.ty));
} }
ast::TyRptr(ref lifetime, ref mt) => { ast::TyKind::Rptr(ref lifetime, ref mt) => {
try!(word(&mut self.s, "&")); try!(word(&mut self.s, "&"));
try!(self.print_opt_lifetime(lifetime)); try!(self.print_opt_lifetime(lifetime));
try!(self.print_mt(mt)); try!(self.print_mt(mt));
} }
ast::TyTup(ref elts) => { ast::TyKind::Tup(ref elts) => {
try!(self.popen()); try!(self.popen());
try!(self.commasep(Inconsistent, &elts[..], try!(self.commasep(Inconsistent, &elts[..],
|s, ty| s.print_type(&**ty))); |s, ty| s.print_type(&**ty)));
...@@ -984,12 +984,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> { ...@@ -984,12 +984,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
} }
try!(self.pclose()); try!(self.pclose());
} }
ast::TyParen(ref typ) => { ast::TyKind::Paren(ref typ) => {
try!(self.popen()); try!(self.popen());
try!(self.print_type(&**typ)); try!(self.print_type(&**typ));
try!(self.pclose()); try!(self.pclose());
} }
ast::TyBareFn(ref f) => { ast::TyKind::BareFn(ref f) => {
let generics = ast::Generics { let generics = ast::Generics {
lifetimes: f.lifetimes.clone(), lifetimes: f.lifetimes.clone(),
ty_params: P::empty(), ty_params: P::empty(),
...@@ -1005,35 +1005,35 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> { ...@@ -1005,35 +1005,35 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
&generics, &generics,
None)); None));
} }
ast::TyPath(None, ref path) => { ast::TyKind::Path(None, ref path) => {
try!(self.print_path(path, false, 0)); try!(self.print_path(path, false, 0));
} }
ast::TyPath(Some(ref qself), ref path) => { ast::TyKind::Path(Some(ref qself), ref path) => {
try!(self.print_qpath(path, qself, false)) try!(self.print_qpath(path, qself, false))
} }
ast::TyObjectSum(ref ty, ref bounds) => { ast::TyKind::ObjectSum(ref ty, ref bounds) => {
try!(self.print_type(&**ty)); try!(self.print_type(&**ty));
try!(self.print_bounds("+", &bounds[..])); try!(self.print_bounds("+", &bounds[..]));
} }
ast::TyPolyTraitRef(ref bounds) => { ast::TyKind::PolyTraitRef(ref bounds) => {
try!(self.print_bounds("", &bounds[..])); try!(self.print_bounds("", &bounds[..]));
} }
ast::TyFixedLengthVec(ref ty, ref v) => { ast::TyKind::FixedLengthVec(ref ty, ref v) => {
try!(word(&mut self.s, "[")); try!(word(&mut self.s, "["));
try!(self.print_type(&**ty)); try!(self.print_type(&**ty));
try!(word(&mut self.s, "; ")); try!(word(&mut self.s, "; "));
try!(self.print_expr(&**v)); try!(self.print_expr(&**v));
try!(word(&mut self.s, "]")); try!(word(&mut self.s, "]"));
} }
ast::TyTypeof(ref e) => { ast::TyKind::Typeof(ref e) => {
try!(word(&mut self.s, "typeof(")); try!(word(&mut self.s, "typeof("));
try!(self.print_expr(&**e)); try!(self.print_expr(&**e));
try!(word(&mut self.s, ")")); try!(word(&mut self.s, ")"));
} }
ast::TyInfer => { ast::TyKind::Infer => {
try!(word(&mut self.s, "_")); try!(word(&mut self.s, "_"));
} }
ast::TyMac(ref m) => { ast::TyKind::Mac(ref m) => {
try!(self.print_mac(m, token::Paren)); try!(self.print_mac(m, token::Paren));
} }
} }
...@@ -2959,7 +2959,7 @@ pub fn print_mt(&mut self, mt: &ast::MutTy) -> io::Result<()> { ...@@ -2959,7 +2959,7 @@ pub fn print_mt(&mut self, mt: &ast::MutTy) -> io::Result<()> {
pub fn print_arg(&mut self, input: &ast::Arg, is_closure: bool) -> io::Result<()> { pub fn print_arg(&mut self, input: &ast::Arg, is_closure: bool) -> io::Result<()> {
try!(self.ibox(INDENT_UNIT)); try!(self.ibox(INDENT_UNIT));
match input.ty.node { match input.ty.node {
ast::TyInfer if is_closure => try!(self.print_pat(&*input.pat)), ast::TyKind::Infer if is_closure => try!(self.print_pat(&*input.pat)),
_ => { _ => {
match input.pat.node { match input.pat.node {
ast::PatIdent(_, ref path1, _) if ast::PatIdent(_, ref path1, _) if
......
...@@ -358,7 +358,7 @@ fn has_test_signature(i: &ast::Item) -> HasTestSignature { ...@@ -358,7 +358,7 @@ fn has_test_signature(i: &ast::Item) -> HasTestSignature {
ast::ItemFn(ref decl, _, _, _, ref generics, _) => { ast::ItemFn(ref decl, _, _, _, ref generics, _) => {
let no_output = match decl.output { let no_output = match decl.output {
ast::FunctionRetTy::Default(..) => true, ast::FunctionRetTy::Default(..) => true,
ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyTup(vec![]) => true, ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyKind::Tup(vec![]) => true,
_ => false _ => false
}; };
if decl.inputs.is_empty() if decl.inputs.is_empty()
...@@ -395,7 +395,7 @@ fn has_test_signature(i: &ast::Item) -> bool { ...@@ -395,7 +395,7 @@ fn has_test_signature(i: &ast::Item) -> bool {
let input_cnt = decl.inputs.len(); let input_cnt = decl.inputs.len();
let no_output = match decl.output { let no_output = match decl.output {
ast::FunctionRetTy::Default(..) => true, ast::FunctionRetTy::Default(..) => true,
ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyTup(vec![]) => true, ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyKind::Tup(vec![]) => true,
_ => false _ => false
}; };
let tparm_cnt = generics.ty_params.len(); let tparm_cnt = generics.ty_params.len();
...@@ -494,7 +494,7 @@ fn mk_main(cx: &mut TestCtxt) -> P<ast::Item> { ...@@ -494,7 +494,7 @@ fn mk_main(cx: &mut TestCtxt) -> P<ast::Item> {
let main_meta = ecx.meta_word(sp, token::intern_and_get_ident("main")); let main_meta = ecx.meta_word(sp, token::intern_and_get_ident("main"));
let main_attr = ecx.attribute(sp, main_meta); let main_attr = ecx.attribute(sp, main_meta);
// pub fn main() { ... } // pub fn main() { ... }
let main_ret_ty = ecx.ty(sp, ast::TyTup(vec![])); let main_ret_ty = ecx.ty(sp, ast::TyKind::Tup(vec![]));
let main_body = ecx.block_all(sp, vec![call_test_main], None); let main_body = ecx.block_all(sp, vec![call_test_main], None);
let main = ast::ItemFn(ecx.fn_decl(vec![], main_ret_ty), let main = ast::ItemFn(ecx.fn_decl(vec![], main_ret_ty),
ast::Unsafety::Normal, ast::Unsafety::Normal,
...@@ -591,7 +591,7 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> { ...@@ -591,7 +591,7 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
let static_lt = ecx.lifetime(sp, token::special_idents::static_lifetime.name); let static_lt = ecx.lifetime(sp, token::special_idents::static_lifetime.name);
// &'static [self::test::TestDescAndFn] // &'static [self::test::TestDescAndFn]
let static_type = ecx.ty_rptr(sp, let static_type = ecx.ty_rptr(sp,
ecx.ty(sp, ast::TyVec(struct_type)), ecx.ty(sp, ast::TyKind::Vec(struct_type)),
Some(static_lt), Some(static_lt),
ast::MutImmutable); ast::MutImmutable);
// static TESTS: $static_type = &[...]; // static TESTS: $static_type = &[...];
......
...@@ -328,45 +328,45 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V, ...@@ -328,45 +328,45 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
match typ.node { match typ.node {
TyVec(ref ty) | TyParen(ref ty) => { TyKind::Vec(ref ty) | TyKind::Paren(ref ty) => {
visitor.visit_ty(ty) visitor.visit_ty(ty)
} }
TyPtr(ref mutable_type) => { TyKind::Ptr(ref mutable_type) => {
visitor.visit_ty(&mutable_type.ty) visitor.visit_ty(&mutable_type.ty)
} }
TyRptr(ref opt_lifetime, ref mutable_type) => { TyKind::Rptr(ref opt_lifetime, ref mutable_type) => {
walk_list!(visitor, visit_lifetime, opt_lifetime); walk_list!(visitor, visit_lifetime, opt_lifetime);
visitor.visit_ty(&mutable_type.ty) visitor.visit_ty(&mutable_type.ty)
} }
TyTup(ref tuple_element_types) => { TyKind::Tup(ref tuple_element_types) => {
walk_list!(visitor, visit_ty, tuple_element_types); walk_list!(visitor, visit_ty, tuple_element_types);
} }
TyBareFn(ref function_declaration) => { TyKind::BareFn(ref function_declaration) => {
walk_fn_decl(visitor, &function_declaration.decl); walk_fn_decl(visitor, &function_declaration.decl);
walk_list!(visitor, visit_lifetime_def, &function_declaration.lifetimes); walk_list!(visitor, visit_lifetime_def, &function_declaration.lifetimes);
} }
TyPath(ref maybe_qself, ref path) => { TyKind::Path(ref maybe_qself, ref path) => {
if let Some(ref qself) = *maybe_qself { if let Some(ref qself) = *maybe_qself {
visitor.visit_ty(&qself.ty); visitor.visit_ty(&qself.ty);
} }
visitor.visit_path(path, typ.id); visitor.visit_path(path, typ.id);
} }
TyObjectSum(ref ty, ref bounds) => { TyKind::ObjectSum(ref ty, ref bounds) => {
visitor.visit_ty(ty); visitor.visit_ty(ty);
walk_list!(visitor, visit_ty_param_bound, bounds); walk_list!(visitor, visit_ty_param_bound, bounds);
} }
TyFixedLengthVec(ref ty, ref expression) => { TyKind::FixedLengthVec(ref ty, ref expression) => {
visitor.visit_ty(ty); visitor.visit_ty(ty);
visitor.visit_expr(expression) visitor.visit_expr(expression)
} }
TyPolyTraitRef(ref bounds) => { TyKind::PolyTraitRef(ref bounds) => {
walk_list!(visitor, visit_ty_param_bound, bounds); walk_list!(visitor, visit_ty_param_bound, bounds);
} }
TyTypeof(ref expression) => { TyKind::Typeof(ref expression) => {
visitor.visit_expr(expression) visitor.visit_expr(expression)
} }
TyInfer => {} TyKind::Infer => {}
TyMac(ref mac) => { TyKind::Mac(ref mac) => {
visitor.visit_mac(mac) visitor.visit_mac(mac)
} }
} }
......
...@@ -354,7 +354,7 @@ struct Visitor<'a> { ...@@ -354,7 +354,7 @@ struct Visitor<'a> {
impl<'a> visit::Visitor<'a> for Visitor<'a> { impl<'a> visit::Visitor<'a> for Visitor<'a> {
fn visit_ty(&mut self, ty: &'a ast::Ty) { fn visit_ty(&mut self, ty: &'a ast::Ty) {
match ty.node { match ty.node {
ast::TyPath(_, ref path) if !path.global => { ast::TyKind::Path(_, ref path) if !path.global => {
match path.segments.first() { match path.segments.first() {
Some(segment) => { Some(segment) => {
if self.ty_param_names.contains(&segment.identifier.name) { if self.ty_param_names.contains(&segment.identifier.name) {
...@@ -557,7 +557,7 @@ fn create_derived_impl(&self, ...@@ -557,7 +557,7 @@ fn create_derived_impl(&self,
for ty in tys { for ty in tys {
// if we have already handled this type, skip it // if we have already handled this type, skip it
if let ast::TyPath(_, ref p) = ty.node { if let ast::TyKind::Path(_, ref p) = ty.node {
if p.segments.len() == 1 if p.segments.len() == 1
&& ty_param_names.contains(&p.segments[0].identifier.name) && ty_param_names.contains(&p.segments[0].identifier.name)
|| processed_field_types.contains(&p.segments) { || processed_field_types.contains(&p.segments) {
......
...@@ -153,7 +153,7 @@ pub fn to_ty(&self, ...@@ -153,7 +153,7 @@ pub fn to_ty(&self,
cx.ty_path(self.to_path(cx, span, self_ty, self_generics)) cx.ty_path(self.to_path(cx, span, self_ty, self_generics))
} }
Tuple(ref fields) => { Tuple(ref fields) => {
let ty = ast::TyTup(fields.iter() let ty = ast::TyKind::Tup(fields.iter()
.map(|f| f.to_ty(cx, span, self_ty, self_generics)) .map(|f| f.to_ty(cx, span, self_ty, self_generics))
.collect()); .collect());
cx.ty(span, ty) cx.ty(span, ty)
......
...@@ -448,7 +448,7 @@ fn static_array(ecx: &mut ExtCtxt, ...@@ -448,7 +448,7 @@ fn static_array(ecx: &mut ExtCtxt,
-> P<ast::Expr> { -> P<ast::Expr> {
let sp = piece_ty.span; let sp = piece_ty.span;
let ty = ecx.ty_rptr(sp, let ty = ecx.ty_rptr(sp,
ecx.ty(sp, ast::TyVec(piece_ty)), ecx.ty(sp, ast::TyKind::Vec(piece_ty)),
Some(ecx.lifetime(sp, special_idents::static_lifetime.name)), Some(ecx.lifetime(sp, special_idents::static_lifetime.name)),
ast::MutImmutable); ast::MutImmutable);
let slice = ecx.expr_vec_slice(sp, pieces); let slice = ecx.expr_vec_slice(sp, pieces);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册