提交 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
}
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),
......@@ -285,11 +286,11 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> {
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),
......@@ -298,19 +299,19 @@ pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P<hir::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,
})
......
......@@ -1063,7 +1063,7 @@ fn visit_impl_item(&mut self, impl_item: &ast::ImplItem) {
fn visit_ty(&mut self, t: &ast::Ty) {
self.process_macro_use(t.span, t.id);
match t.node {
ast::TyPath(_, ref path) => {
ast::TyKind::Path(_, ref path) => {
match self.lookup_type_ref(t.id) {
Some(id) => {
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> {
match typ.node {
// 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);
filter!(self.span_utils, sub_span, path.span, None);
type_data = self.lookup_ref_id(typ.id).map(|id| {
......
......@@ -24,7 +24,6 @@
pub use self::StrStyle::*;
pub use self::StructFieldKind::*;
pub use self::TraitItem_::*;
pub use self::Ty_::*;
pub use self::TyParamBound::*;
pub use self::UnsafeSource::*;
pub use self::ViewPath_::*;
......@@ -1523,7 +1522,7 @@ pub struct TypeBinding {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
pub struct Ty {
pub id: NodeId,
pub node: Ty_,
pub node: TyKind,
pub span: Span,
}
......@@ -1543,36 +1542,36 @@ pub struct BareFnTy {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
/// The different kinds of types recognized by the compiler
pub enum Ty_ {
TyVec(P<Ty>),
pub enum TyKind {
Vec(P<Ty>),
/// A fixed length array (`[T; n]`)
TyFixedLengthVec(P<Ty>, P<Expr>),
FixedLengthVec(P<Ty>, P<Expr>),
/// A raw pointer (`*const T` or `*mut T`)
TyPtr(MutTy),
Ptr(MutTy),
/// A reference (`&'a T` or `&'a mut T`)
TyRptr(Option<Lifetime>, MutTy),
Rptr(Option<Lifetime>, MutTy),
/// A bare function (e.g. `fn(usize) -> bool`)
TyBareFn(P<BareFnTy>),
BareFn(P<BareFnTy>),
/// A tuple (`(A, B, C, D,...)`)
TyTup(Vec<P<Ty>> ),
Tup(Vec<P<Ty>> ),
/// A path (`module::module::...::Type`), optionally
/// "qualified", e.g. `<Vec<T> as SomeTrait>::SomeType`.
///
/// 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.
TyObjectSum(P<Ty>, TyParamBounds),
ObjectSum(P<Ty>, TyParamBounds),
/// A type like `for<'a> Foo<&'a Bar>`
TyPolyTraitRef(TyParamBounds),
PolyTraitRef(TyParamBounds),
/// No-op; kept solely so that we can pretty-print faithfully
TyParen(P<Ty>),
Paren(P<Ty>),
/// Unused for now
TyTypeof(P<Expr>),
/// TyInfer means the type should be inferred instead of it having been
Typeof(P<Expr>),
/// TyKind::Infer means the type should be inferred instead of it having been
/// specified. This can appear anywhere in a type.
TyInfer,
Infer,
// A macro in the type position.
TyMac(Mac)
Mac(Mac),
}
#[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 {
// HACK(eddyb) fake type for the self argument.
ty: P(Ty {
id: DUMMY_NODE_ID,
node: TyInfer,
node: TyKind::Infer,
span: DUMMY_SP,
}),
pat: P(Pat {
......
......@@ -212,10 +212,10 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
let ty = ecx.ty(
span,
ast::TyFixedLengthVec(
ast::TyKind::FixedLengthVec(
ecx.ty(
span,
ast::TyTup(vec![ty_str.clone(), ty_str])
ast::TyKind::Tup(vec![ty_str.clone(), ty_str])
),
ecx.expr_usize(span, count),
),
......
......@@ -367,7 +367,7 @@ pub fn raw_pat(sp: Span) -> ast::Pat {
pub fn raw_ty(sp: Span) -> P<ast::Ty> {
P(ast::Ty {
id: ast::DUMMY_NODE_ID,
node: ast::TyInfer,
node: ast::TyKind::Infer,
span: sp
})
}
......
......@@ -52,7 +52,7 @@ fn qpath_all(&self, self_type: P<ast::Ty>,
// types
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_sum(&self, ast::Path, ast::TyParamBounds) -> 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 {
}
}
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 {
id: ast::DUMMY_NODE_ID,
span: span,
......@@ -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> {
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> {
self.ty(path.span,
ast::TyObjectSum(self.ty_path(path),
ast::TyKind::ObjectSum(self.ty_path(path),
bounds))
}
......@@ -417,7 +417,7 @@ fn ty_rptr(&self,
mutbl: ast::Mutability)
-> P<ast::Ty> {
self.ty(span,
ast::TyRptr(lifetime, self.ty_mt(ty, mutbl)))
ast::TyKind::Rptr(lifetime, self.ty_mt(ty, mutbl)))
}
fn ty_ptr(&self,
......@@ -426,7 +426,7 @@ fn ty_ptr(&self,
mutbl: ast::Mutability)
-> P<ast::Ty> {
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> {
......@@ -440,7 +440,7 @@ fn ty_option(&self, ty: P<ast::Ty>) -> 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,
......
......@@ -562,7 +562,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE
DeclKind::Local(local) => {
// take it apart:
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
let expanded_ty = ty.map(|t| fld.fold_ty(t));
// expand the pat (it might contain macro uses):
......@@ -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> {
let t = match t.node.clone() {
ast::Ty_::TyMac(mac) => {
ast::TyKind::Mac(mac) => {
if fld.cx.ecfg.features.unwrap().type_macros {
let expanded_ty = match expand_mac_invoc(mac, t.span,
|r| r.make_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 {
id: fld.new_id(id),
node: match node {
TyInfer => node,
TyVec(ty) => TyVec(fld.fold_ty(ty)),
TyPtr(mt) => TyPtr(fld.fold_mt(mt)),
TyRptr(region, mt) => {
TyRptr(fld.fold_opt_lifetime(region), fld.fold_mt(mt))
TyKind::Infer => node,
TyKind::Vec(ty) => TyKind::Vec(fld.fold_ty(ty)),
TyKind::Ptr(mt) => TyKind::Ptr(fld.fold_mt(mt)),
TyKind::Rptr(region, mt) => {
TyKind::Rptr(fld.fold_opt_lifetime(region), fld.fold_mt(mt))
}
TyBareFn(f) => {
TyBareFn(f.map(|BareFnTy {lifetimes, unsafety, abi, decl}| BareFnTy {
TyKind::BareFn(f) => {
TyKind::BareFn(f.map(|BareFnTy {lifetimes, unsafety, abi, decl}| BareFnTy {
lifetimes: fld.fold_lifetime_defs(lifetimes),
unsafety: unsafety,
abi: abi,
decl: fld.fold_fn_decl(decl)
}))
}
TyTup(tys) => TyTup(tys.move_map(|ty| fld.fold_ty(ty))),
TyParen(ty) => TyParen(fld.fold_ty(ty)),
TyPath(qself, path) => {
TyKind::Tup(tys) => TyKind::Tup(tys.move_map(|ty| fld.fold_ty(ty))),
TyKind::Paren(ty) => TyKind::Paren(fld.fold_ty(ty)),
TyKind::Path(qself, path) => {
let qself = qself.map(|QSelf { ty, position }| {
QSelf {
ty: fld.fold_ty(ty),
position: position
}
});
TyPath(qself, fld.fold_path(path))
TyKind::Path(qself, fld.fold_path(path))
}
TyObjectSum(ty, bounds) => {
TyObjectSum(fld.fold_ty(ty),
TyKind::ObjectSum(ty, bounds) => {
TyKind::ObjectSum(fld.fold_ty(ty),
fld.fold_bounds(bounds))
}
TyFixedLengthVec(ty, e) => {
TyFixedLengthVec(fld.fold_ty(ty), fld.fold_expr(e))
TyKind::FixedLengthVec(ty, e) => {
TyKind::FixedLengthVec(fld.fold_ty(ty), fld.fold_expr(e))
}
TyTypeof(expr) => {
TyTypeof(fld.fold_expr(expr))
TyKind::Typeof(expr) => {
TyKind::Typeof(fld.fold_expr(expr))
}
TyPolyTraitRef(bounds) => {
TyPolyTraitRef(bounds.move_map(|b| fld.fold_ty_param_bound(b)))
TyKind::PolyTraitRef(bounds) => {
TyKind::PolyTraitRef(bounds.move_map(|b| fld.fold_ty_param_bound(b)))
}
TyMac(mac) => {
TyMac(fld.fold_mac(mac))
TyKind::Mac(mac) => {
TyKind::Mac(fld.fold_mac(mac))
}
},
span: fld.new_span(span)
......
......@@ -916,7 +916,7 @@ fn parser_done(p: Parser){
node: ast::ItemFn(P(ast::FnDecl {
inputs: vec!(ast::Arg{
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),
global:false,
segments: vec!(
......
......@@ -42,10 +42,7 @@
use ast::StrStyle;
use ast::SelfKind;
use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
use ast::{Ty, Ty_, TypeBinding, TyMac};
use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer};
use ast::{TyParam, TyParamBounds, TyParen, TyPath, TyPtr};
use ast::{TyRptr, TyTup, TyVec};
use ast::{Ty, TyKind, TypeBinding, TyParam, TyParamBounds};
use ast::TypeTraitItem;
use ast::UnnamedField;
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
......@@ -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.
The `for` has already been consumed.
......@@ -1097,16 +1094,17 @@ pub fn parse_for_in_type(&mut self) -> PResult<'a, Ty_> {
Some(TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)).into_iter()
.chain(other_bounds.into_vec())
.collect();
Ok(ast::TyPolyTraitRef(all_bounds))
Ok(ast::TyKind::PolyTraitRef(all_bounds))
}
}
pub fn parse_ty_path(&mut self) -> PResult<'a, Ty_> {
Ok(TyPath(None, try!(self.parse_path(LifetimeAndTypesWithoutColons))))
pub fn parse_ty_path(&mut self) -> PResult<'a, TyKind> {
Ok(TyKind::Path(None, try!(self.parse_path(LifetimeAndTypesWithoutColons))))
}
/// parse a TyBareFn type:
pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec<ast::LifetimeDef>) -> PResult<'a, Ty_> {
/// parse a TyKind::BareFn type:
pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec<ast::LifetimeDef>)
-> PResult<'a, TyKind> {
/*
[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
output: ret_ty,
variadic: variadic
});
Ok(TyBareFn(P(BareFnTy {
Ok(TyKind::BareFn(P(BareFnTy {
abi: abi,
unsafety: unsafety,
lifetimes: lifetime_defs,
......@@ -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 sum = ast::TyObjectSum(lhs, bounds);
let sum = ast::TyKind::ObjectSum(lhs, bounds);
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>> {
try!(self.expect(&token::CloseDelim(token::Paren)));
if ts.len() == 1 && !last_comma {
TyParen(ts.into_iter().nth(0).unwrap())
TyKind::Paren(ts.into_iter().nth(0).unwrap())
} else {
TyTup(ts)
TyKind::Tup(ts)
}
} else if self.check(&token::BinOp(token::Star)) {
// STAR POINTER (bare pointer?)
self.bump();
TyPtr(try!(self.parse_ptr()))
TyKind::Ptr(try!(self.parse_ptr()))
} else if self.check(&token::OpenDelim(token::Bracket)) {
// VECTOR
try!(self.expect(&token::OpenDelim(token::Bracket)));
......@@ -1355,8 +1353,8 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
// Parse the `; e` in `[ i32; e ]`
// where `e` is a const expression
let t = match try!(self.maybe_parse_fixed_length_of_vec()) {
None => TyVec(t),
Some(suffix) => TyFixedLengthVec(t, suffix)
None => TyKind::Vec(t),
Some(suffix) => TyKind::FixedLengthVec(t, suffix)
};
try!(self.expect(&token::CloseDelim(token::Bracket)));
t
......@@ -1376,13 +1374,13 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
try!(self.expect(&token::OpenDelim(token::Paren)));
let e = try!(self.parse_expr());
try!(self.expect(&token::CloseDelim(token::Paren)));
TyTypeof(e)
TyKind::Typeof(e)
} else if self.eat_lt() {
let (qself, path) =
try!(self.parse_qualified_path(NoTypesAllowed));
TyPath(Some(qself), path)
TyKind::Path(Some(qself), path)
} else if self.check(&token::ModSep) ||
self.token.is_ident() ||
self.token.is_path() {
......@@ -1395,14 +1393,14 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
seq_sep_none(),
|p| p.parse_token_tree()));
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 {
// NAMED TYPE
TyPath(None, path)
TyKind::Path(None, path)
}
} else if self.eat(&token::Underscore) {
// TYPE TO BE INFERRED
TyInfer
TyKind::Infer
} else {
let this_token_str = self.this_token_to_string();
let msg = format!("expected type, found `{}`", this_token_str);
......@@ -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}))
}
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:
let opt_lifetime = try!(self.parse_opt_lifetime());
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> {
......@@ -1498,7 +1496,7 @@ pub fn parse_fn_block_arg(&mut self) -> PResult<'a, Arg> {
} else {
P(Ty {
id: ast::DUMMY_NODE_ID,
node: TyInfer,
node: TyKind::Infer,
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>
let opt_trait = if could_be_trait && self.eat_keyword(keywords::For) {
// New-style trait. Reinterpret the type as a trait.
match ty.node {
TyPath(None, ref path) => {
TyKind::Path(None, ref path) => {
Some(TraitRef {
path: (*path).clone(),
ref_id: ty.id,
......
......@@ -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.ibox(0));
match ty.node {
ast::TyVec(ref ty) => {
ast::TyKind::Vec(ref ty) => {
try!(word(&mut self.s, "["));
try!(self.print_type(&**ty));
try!(word(&mut self.s, "]"));
}
ast::TyPtr(ref mt) => {
ast::TyKind::Ptr(ref mt) => {
try!(word(&mut self.s, "*"));
match mt.mutbl {
ast::MutMutable => try!(self.word_nbsp("mut")),
......@@ -970,12 +970,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
}
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!(self.print_opt_lifetime(lifetime));
try!(self.print_mt(mt));
}
ast::TyTup(ref elts) => {
ast::TyKind::Tup(ref elts) => {
try!(self.popen());
try!(self.commasep(Inconsistent, &elts[..],
|s, ty| s.print_type(&**ty)));
......@@ -984,12 +984,12 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
}
try!(self.pclose());
}
ast::TyParen(ref typ) => {
ast::TyKind::Paren(ref typ) => {
try!(self.popen());
try!(self.print_type(&**typ));
try!(self.pclose());
}
ast::TyBareFn(ref f) => {
ast::TyKind::BareFn(ref f) => {
let generics = ast::Generics {
lifetimes: f.lifetimes.clone(),
ty_params: P::empty(),
......@@ -1005,35 +1005,35 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
&generics,
None));
}
ast::TyPath(None, ref path) => {
ast::TyKind::Path(None, ref path) => {
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))
}
ast::TyObjectSum(ref ty, ref bounds) => {
ast::TyKind::ObjectSum(ref ty, ref bounds) => {
try!(self.print_type(&**ty));
try!(self.print_bounds("+", &bounds[..]));
}
ast::TyPolyTraitRef(ref bounds) => {
ast::TyKind::PolyTraitRef(ref 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!(self.print_type(&**ty));
try!(word(&mut self.s, "; "));
try!(self.print_expr(&**v));
try!(word(&mut self.s, "]"));
}
ast::TyTypeof(ref e) => {
ast::TyKind::Typeof(ref e) => {
try!(word(&mut self.s, "typeof("));
try!(self.print_expr(&**e));
try!(word(&mut self.s, ")"));
}
ast::TyInfer => {
ast::TyKind::Infer => {
try!(word(&mut self.s, "_"));
}
ast::TyMac(ref m) => {
ast::TyKind::Mac(ref m) => {
try!(self.print_mac(m, token::Paren));
}
}
......@@ -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<()> {
try!(self.ibox(INDENT_UNIT));
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 {
ast::PatIdent(_, ref path1, _) if
......
......@@ -358,7 +358,7 @@ fn has_test_signature(i: &ast::Item) -> HasTestSignature {
ast::ItemFn(ref decl, _, _, _, ref generics, _) => {
let no_output = match decl.output {
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
};
if decl.inputs.is_empty()
......@@ -395,7 +395,7 @@ fn has_test_signature(i: &ast::Item) -> bool {
let input_cnt = decl.inputs.len();
let no_output = match decl.output {
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
};
let tparm_cnt = generics.ty_params.len();
......@@ -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_attr = ecx.attribute(sp, main_meta);
// 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 = ast::ItemFn(ecx.fn_decl(vec![], main_ret_ty),
ast::Unsafety::Normal,
......@@ -591,7 +591,7 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
let static_lt = ecx.lifetime(sp, token::special_idents::static_lifetime.name);
// &'static [self::test::TestDescAndFn]
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),
ast::MutImmutable);
// static TESTS: $static_type = &[...];
......
......@@ -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) {
match typ.node {
TyVec(ref ty) | TyParen(ref ty) => {
TyKind::Vec(ref ty) | TyKind::Paren(ref ty) => {
visitor.visit_ty(ty)
}
TyPtr(ref mutable_type) => {
TyKind::Ptr(ref mutable_type) => {
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);
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);
}
TyBareFn(ref function_declaration) => {
TyKind::BareFn(ref function_declaration) => {
walk_fn_decl(visitor, &function_declaration.decl);
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 {
visitor.visit_ty(&qself.ty);
}
visitor.visit_path(path, typ.id);
}
TyObjectSum(ref ty, ref bounds) => {
TyKind::ObjectSum(ref ty, ref bounds) => {
visitor.visit_ty(ty);
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_expr(expression)
}
TyPolyTraitRef(ref bounds) => {
TyKind::PolyTraitRef(ref bounds) => {
walk_list!(visitor, visit_ty_param_bound, bounds);
}
TyTypeof(ref expression) => {
TyKind::Typeof(ref expression) => {
visitor.visit_expr(expression)
}
TyInfer => {}
TyMac(ref mac) => {
TyKind::Infer => {}
TyKind::Mac(ref mac) => {
visitor.visit_mac(mac)
}
}
......
......@@ -354,7 +354,7 @@ struct Visitor<'a> {
impl<'a> visit::Visitor<'a> for Visitor<'a> {
fn visit_ty(&mut self, ty: &'a ast::Ty) {
match ty.node {
ast::TyPath(_, ref path) if !path.global => {
ast::TyKind::Path(_, ref path) if !path.global => {
match path.segments.first() {
Some(segment) => {
if self.ty_param_names.contains(&segment.identifier.name) {
......@@ -557,7 +557,7 @@ fn create_derived_impl(&self,
for ty in tys {
// 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
&& ty_param_names.contains(&p.segments[0].identifier.name)
|| processed_field_types.contains(&p.segments) {
......
......@@ -153,7 +153,7 @@ pub fn to_ty(&self,
cx.ty_path(self.to_path(cx, span, self_ty, self_generics))
}
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))
.collect());
cx.ty(span, ty)
......
......@@ -448,7 +448,7 @@ fn static_array(ecx: &mut ExtCtxt,
-> P<ast::Expr> {
let sp = piece_ty.span;
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)),
ast::MutImmutable);
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.
先完成此消息的编辑!
想要评论请 注册