From 05d4cefd630cd9ae104555e69ceb3b1566298a6a Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 8 Feb 2016 16:53:21 +0100 Subject: [PATCH] [breaking-change] don't pub export ast::Ty_ variants --- src/librustc_front/lowering.rs | 27 ++++++------ src/librustc_trans/save/dump_csv.rs | 2 +- src/librustc_trans/save/mod.rs | 2 +- src/libsyntax/ast.rs | 35 ++++++++-------- src/libsyntax/diagnostics/plugin.rs | 4 +- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/build.rs | 14 +++---- src/libsyntax/ext/expand.rs | 4 +- src/libsyntax/fold.rs | 42 +++++++++---------- src/libsyntax/parse/mod.rs | 2 +- src/libsyntax/parse/parser.rs | 50 +++++++++++------------ src/libsyntax/print/pprust.rs | 30 +++++++------- src/libsyntax/test.rs | 8 ++-- src/libsyntax/visit.rs | 24 +++++------ src/libsyntax_ext/deriving/generic/mod.rs | 4 +- src/libsyntax_ext/deriving/generic/ty.rs | 2 +- src/libsyntax_ext/format.rs | 2 +- 17 files changed, 126 insertions(+), 128 deletions(-) diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index fe44ba7a646..813a7f71fe9 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -268,16 +268,17 @@ pub fn lower_ty_binding(lctx: &LoweringContext, b: &TypeBinding) -> hir::TypeBin } pub fn lower_ty(lctx: &LoweringContext, t: &Ty) -> P { + 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 { 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::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, }) diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index e8a0e4a8d42..10840933c01 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -1063,7 +1063,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { 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); diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 116051f6fe5..53fa1bfff38 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -316,7 +316,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { 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| { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index d06ed4be978..5752cbda9b9 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -24,7 +24,6 @@ pub use self::Stmt_::*; 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), +pub enum TyKind { + Vec(P), /// A fixed length array (`[T; n]`) - TyFixedLengthVec(P, P), + FixedLengthVec(P, P), /// A raw pointer (`*const T` or `*mut T`) - TyPtr(MutTy), + Ptr(MutTy), /// A reference (`&'a T` or `&'a mut T`) - TyRptr(Option, MutTy), + Rptr(Option, MutTy), /// A bare function (e.g. `fn(usize) -> bool`) - TyBareFn(P), + BareFn(P), /// A tuple (`(A, B, C, D,...)`) - TyTup(Vec> ), + Tup(Vec> ), /// A path (`module::module::...::Type`), optionally /// "qualified", e.g. ` as SomeTrait>::SomeType`. /// /// Type parameters are stored in the Path itself - TyPath(Option, Path), + Path(Option, Path), /// Something like `A+B`. Note that `B` must always be a path. - TyObjectSum(P, TyParamBounds), + ObjectSum(P, 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), + Paren(P), /// Unused for now - TyTypeof(P), - /// TyInfer means the type should be inferred instead of it having been + Typeof(P), + /// 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 @@ impl 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 { diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 6e389e83591..4e6fde10ade 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -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), ), diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 33414a697a7..b58f8007e0a 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -367,7 +367,7 @@ impl DummyResult { pub fn raw_ty(sp: Span) -> P { P(ast::Ty { id: ast::DUMMY_NODE_ID, - node: ast::TyInfer, + node: ast::TyKind::Infer, span: sp }) } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 1c2d1cebf3d..241ea976eee 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -52,7 +52,7 @@ pub trait AstBuilder { // types fn ty_mt(&self, ty: P, mutbl: ast::Mutability) -> ast::MutTy; - fn ty(&self, span: Span, ty: ast::Ty_) -> P; + fn ty(&self, span: Span, ty: ast::TyKind) -> P; fn ty_path(&self, ast::Path) -> P; fn ty_sum(&self, ast::Path, ast::TyParamBounds) -> P; fn ty_ident(&self, span: Span, idents: ast::Ident) -> P; @@ -385,7 +385,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } } - fn ty(&self, span: Span, ty: ast::Ty_) -> P { + fn ty(&self, span: Span, ty: ast::TyKind) -> P { P(ast::Ty { id: ast::DUMMY_NODE_ID, span: span, @@ -394,12 +394,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn ty_path(&self, path: ast::Path) -> P { - 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 { self.ty(path.span, - ast::TyObjectSum(self.ty_path(path), + ast::TyKind::ObjectSum(self.ty_path(path), bounds)) } @@ -417,7 +417,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { mutbl: ast::Mutability) -> P { 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 @@ impl<'a> AstBuilder for ExtCtxt<'a> { mutbl: ast::Mutability) -> P { self.ty(span, - ast::TyPtr(self.ty_mt(ty, mutbl))) + ast::TyKind::Ptr(self.ty_mt(ty, mutbl))) } fn ty_option(&self, ty: P) -> P { @@ -440,7 +440,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn ty_infer(&self, span: Span) -> P { - self.ty(span, ast::TyInfer) + self.ty(span, ast::TyKind::Infer) } fn typaram(&self, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 69b932aa72b..9b31465b547 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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, pub fn expand_type(t: P, fld: &mut MacroExpander) -> P { 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(), diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 8cd2d24102f..1a6171e1981 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -380,46 +380,46 @@ pub fn noop_fold_ty(t: P, fld: &mut T) -> P { 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) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index d800b6925c0..d467405e089 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -916,7 +916,7 @@ mod tests { 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!( diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 99db01a915e..1a8b1cbc374 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -42,10 +42,7 @@ use ast::{StmtExpr, StmtSemi, StmtMac, VariantData, StructField}; 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 @@ impl<'a> Parser<'a> { } } - 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 @@ impl<'a> Parser<'a> { 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) -> PResult<'a, Ty_> { + /// parse a TyKind::BareFn type: + pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec) + -> PResult<'a, TyKind> { /* [unsafe] [extern "ABI"] fn <'lt> (S) -> T @@ -1134,7 +1132,7 @@ impl<'a> Parser<'a> { 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 @@ impl<'a> Parser<'a> { } 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 @@ impl<'a> Parser<'a> { 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 @@ impl<'a> Parser<'a> { // 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 @@ impl<'a> Parser<'a> { 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 @@ impl<'a> Parser<'a> { 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 @@ impl<'a> Parser<'a> { 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 @@ impl<'a> Parser<'a> { } 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 @@ impl<'a> Parser<'a> { 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, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 1df73014b85..1e57d347f5a 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -957,12 +957,12 @@ impl<'a> State<'a> { 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 @@ impl<'a> State<'a> { } 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 @@ impl<'a> State<'a> { } 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 @@ impl<'a> State<'a> { &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 @@ impl<'a> State<'a> { 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 diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index dbdc1bfcbaa..24890d2cbed 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -358,7 +358,7 @@ fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool { 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 is_bench_fn(cx: &TestCtxt, 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 { 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 { 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 = &[...]; diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 90cc403961e..44b3e581849 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -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) } } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 950c2f48bac..e54ff637f25 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -354,7 +354,7 @@ fn find_type_parameters(ty: &ast::Ty, ty_param_names: &[ast::Name]) -> Vec 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 @@ impl<'a> TraitDef<'a> { 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) { diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index 543beeb5da0..e5b82fa1afc 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -153,7 +153,7 @@ impl<'a> Ty<'a> { 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) diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 986cdef49b2..21b32153ed9 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -448,7 +448,7 @@ impl<'a, 'b> Context<'a, 'b> { -> P { 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);