X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibsyntax%2Fast.rs;h=b677941291bc92fbd7d2d2a33492a1578833359b;hb=8290c950a8b4cdc70038736abcf29f41dede6e0c;hp=e327adfaf892ce5a6e42d5c0ae9194d6a5b3c1dd;hpb=badc23b6ad47c6b6d401a3ea1dc5163bdcd86cd7;p=rust.git diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index e327adfaf89..b677941291b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,35 +10,18 @@ // The Rust abstract syntax tree. -pub use self::BinOp_::*; -pub use self::BlockCheckMode::*; -pub use self::CaptureClause::*; -pub use self::Decl_::*; -pub use self::ExplicitSelf_::*; -pub use self::Expr_::*; -pub use self::FloatTy::*; -pub use self::FunctionRetTy::*; pub use self::ForeignItem_::*; -pub use self::IntTy::*; pub use self::Item_::*; pub use self::KleeneOp::*; -pub use self::Lit_::*; -pub use self::LitIntType::*; pub use self::MacStmtStyle::*; pub use self::MetaItem_::*; pub use self::Mutability::*; pub use self::Pat_::*; pub use self::PathListItem_::*; -pub use self::PrimTy::*; -pub use self::Sign::*; -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::UintTy::*; -pub use self::UnOp::*; pub use self::UnsafeSource::*; pub use self::ViewPath_::*; pub use self::Visibility::*; @@ -70,9 +53,9 @@ /// A SyntaxContext represents a chain of macro-expandings /// and renamings. Each macro expansion corresponds to /// a fresh u32. This u32 is a reference to a table stored -// in thread-local storage. -// The special value EMPTY_CTXT is used to indicate an empty -// syntax context. +/// in thread-local storage. +/// The special value EMPTY_CTXT is used to indicate an empty +/// syntax context. #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)] pub struct SyntaxContext(pub u32); @@ -628,128 +611,130 @@ pub enum Mutability { } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] -pub enum BinOp_ { +pub enum BinOpKind { /// The `+` operator (addition) - BiAdd, + Add, /// The `-` operator (subtraction) - BiSub, + Sub, /// The `*` operator (multiplication) - BiMul, + Mul, /// The `/` operator (division) - BiDiv, + Div, /// The `%` operator (modulus) - BiRem, + Rem, /// The `&&` operator (logical and) - BiAnd, + And, /// The `||` operator (logical or) - BiOr, + Or, /// The `^` operator (bitwise xor) - BiBitXor, + BitXor, /// The `&` operator (bitwise and) - BiBitAnd, + BitAnd, /// The `|` operator (bitwise or) - BiBitOr, + BitOr, /// The `<<` operator (shift left) - BiShl, + Shl, /// The `>>` operator (shift right) - BiShr, + Shr, /// The `==` operator (equality) - BiEq, + Eq, /// The `<` operator (less than) - BiLt, + Lt, /// The `<=` operator (less than or equal to) - BiLe, + Le, /// The `!=` operator (not equal to) - BiNe, + Ne, /// The `>=` operator (greater than or equal to) - BiGe, + Ge, /// The `>` operator (greater than) - BiGt, + Gt, } -impl BinOp_ { +impl BinOpKind { pub fn to_string(&self) -> &'static str { + use self::BinOpKind::*; match *self { - BiAdd => "+", - BiSub => "-", - BiMul => "*", - BiDiv => "/", - BiRem => "%", - BiAnd => "&&", - BiOr => "||", - BiBitXor => "^", - BiBitAnd => "&", - BiBitOr => "|", - BiShl => "<<", - BiShr => ">>", - BiEq => "==", - BiLt => "<", - BiLe => "<=", - BiNe => "!=", - BiGe => ">=", - BiGt => ">" + Add => "+", + Sub => "-", + Mul => "*", + Div => "/", + Rem => "%", + And => "&&", + Or => "||", + BitXor => "^", + BitAnd => "&", + BitOr => "|", + Shl => "<<", + Shr => ">>", + Eq => "==", + Lt => "<", + Le => "<=", + Ne => "!=", + Ge => ">=", + Gt => ">", } } pub fn lazy(&self) -> bool { match *self { - BiAnd | BiOr => true, + BinOpKind::And | BinOpKind::Or => true, _ => false } } pub fn is_shift(&self) -> bool { match *self { - BiShl | BiShr => true, + BinOpKind::Shl | BinOpKind::Shr => true, _ => false } } pub fn is_comparison(&self) -> bool { + use self::BinOpKind::*; match *self { - BiEq | BiLt | BiLe | BiNe | BiGt | BiGe => + Eq | Lt | Le | Ne | Gt | Ge => true, - BiAnd | BiOr | BiAdd | BiSub | BiMul | BiDiv | BiRem | - BiBitXor | BiBitAnd | BiBitOr | BiShl | BiShr => + And | Or | Add | Sub | Mul | Div | Rem | + BitXor | BitAnd | BitOr | Shl | Shr => false, } } /// Returns `true` if the binary operator takes its arguments by value pub fn is_by_value(&self) -> bool { - !BinOp_::is_comparison(self) + !self.is_comparison() } } -pub type BinOp = Spanned; +pub type BinOp = Spanned; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum UnOp { /// The `*` operator for dereferencing - UnDeref, + Deref, /// The `!` operator for logical inversion - UnNot, + Not, /// The `-` operator for negation - UnNeg + Neg, } impl UnOp { /// Returns `true` if the unary operator takes its argument by value pub fn is_by_value(u: UnOp) -> bool { match u { - UnNeg | UnNot => true, + UnOp::Neg | UnOp::Not => true, _ => false, } } pub fn to_string(op: UnOp) -> &'static str { match op { - UnDeref => "*", - UnNot => "!", - UnNeg => "-", + UnOp::Deref => "*", + UnOp::Not => "!", + UnOp::Neg => "-", } } } /// A statement -pub type Stmt = Spanned; +pub type Stmt = Spanned; impl fmt::Debug for Stmt { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -762,36 +747,36 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] -pub enum Stmt_ { +pub enum StmtKind { /// Could be an item or a local (let) binding: - StmtDecl(P, NodeId), + Decl(P, NodeId), /// Expr without trailing semi-colon (must have unit type): - StmtExpr(P, NodeId), + Expr(P, NodeId), /// Expr with trailing semi-colon (may have any type): - StmtSemi(P, NodeId), + Semi(P, NodeId), - StmtMac(P, MacStmtStyle, ThinAttributes), + Mac(P, MacStmtStyle, ThinAttributes), } -impl Stmt_ { +impl StmtKind { pub fn id(&self) -> Option { match *self { - StmtDecl(_, id) => Some(id), - StmtExpr(_, id) => Some(id), - StmtSemi(_, id) => Some(id), - StmtMac(..) => None, + StmtKind::Decl(_, id) => Some(id), + StmtKind::Expr(_, id) => Some(id), + StmtKind::Semi(_, id) => Some(id), + StmtKind::Mac(..) => None, } } pub fn attrs(&self) -> &[Attribute] { match *self { - StmtDecl(ref d, _) => d.attrs(), - StmtExpr(ref e, _) | - StmtSemi(ref e, _) => e.attrs(), - StmtMac(_, _, Some(ref b)) => b, - StmtMac(_, _, None) => &[], + StmtKind::Decl(ref d, _) => d.attrs(), + StmtKind::Expr(ref e, _) | + StmtKind::Semi(ref e, _) => e.attrs(), + StmtKind::Mac(_, _, Some(ref b)) => b, + StmtKind::Mac(_, _, None) => &[], } } } @@ -832,21 +817,21 @@ pub fn attrs(&self) -> &[Attribute] { } } -pub type Decl = Spanned; +pub type Decl = Spanned; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum Decl_ { +pub enum DeclKind { /// A local (let) binding: - DeclLocal(P), + Local(P), /// An item binding: - DeclItem(P), + Item(P), } impl Decl { pub fn attrs(&self) -> &[Attribute] { match self.node { - DeclLocal(ref l) => l.attrs(), - DeclItem(ref i) => i.attrs(), + DeclKind::Local(ref l) => l.attrs(), + DeclKind::Item(ref i) => i.attrs(), } } } @@ -871,8 +856,8 @@ pub struct Field { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum BlockCheckMode { - DefaultBlock, - UnsafeBlock(UnsafeSource), + Default, + Unsafe(UnsafeSource), } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] @@ -885,7 +870,7 @@ pub enum UnsafeSource { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash,)] pub struct Expr { pub id: NodeId, - pub node: Expr_, + pub node: ExprKind, pub span: Span, pub attrs: ThinAttributes } @@ -906,18 +891,18 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum Expr_ { +pub enum ExprKind { /// A `box x` expression. - ExprBox(P), + Box(P), /// First expr is the place; second expr is the value. - ExprInPlace(P, P), + InPlace(P, P), /// An array (`[a, b, c, d]`) - ExprVec(Vec>), + Vec(Vec>), /// A function call /// /// The first field resolves to the function itself, /// and the second field is the list of arguments - ExprCall(P, Vec>), + Call(P, Vec>), /// A method call (`x.foo::(a, b, c, d)`) /// /// The `SpannedIdent` is the identifier for the method name. @@ -929,109 +914,109 @@ pub enum Expr_ { /// and the remaining elements are the rest of the arguments. /// /// Thus, `x.foo::(a, b, c, d)` is represented as - /// `ExprMethodCall(foo, [Bar, Baz], [x, a, b, c, d])`. - ExprMethodCall(SpannedIdent, Vec>, Vec>), + /// `ExprKind::MethodCall(foo, [Bar, Baz], [x, a, b, c, d])`. + MethodCall(SpannedIdent, Vec>, Vec>), /// A tuple (`(a, b, c ,d)`) - ExprTup(Vec>), + Tup(Vec>), /// A binary operation (For example: `a + b`, `a * b`) - ExprBinary(BinOp, P, P), + Binary(BinOp, P, P), /// A unary operation (For example: `!x`, `*x`) - ExprUnary(UnOp, P), + Unary(UnOp, P), /// A literal (For example: `1u8`, `"foo"`) - ExprLit(P), + Lit(P), /// A cast (`foo as f64`) - ExprCast(P, P), - ExprType(P, P), + Cast(P, P), + Type(P, P), /// An `if` block, with an optional else block /// /// `if expr { block } else { expr }` - ExprIf(P, P, Option>), + If(P, P, Option>), /// An `if let` expression with an optional else block /// /// `if let pat = expr { block } else { expr }` /// /// This is desugared to a `match` expression. - ExprIfLet(P, P, P, Option>), + IfLet(P, P, P, Option>), /// A while loop, with an optional label /// /// `'label: while expr { block }` - ExprWhile(P, P, Option), + While(P, P, Option), /// A while-let loop, with an optional label /// /// `'label: while let pat = expr { block }` /// /// This is desugared to a combination of `loop` and `match` expressions. - ExprWhileLet(P, P, P, Option), + WhileLet(P, P, P, Option), /// A for loop, with an optional label /// /// `'label: for pat in expr { block }` /// /// This is desugared to a combination of `loop` and `match` expressions. - ExprForLoop(P, P, P, Option), + ForLoop(P, P, P, Option), /// Conditionless loop (can be exited with break, continue, or return) /// /// `'label: loop { block }` - ExprLoop(P, Option), + Loop(P, Option), /// A `match` block. - ExprMatch(P, Vec), + Match(P, Vec), /// A closure (for example, `move |a, b, c| {a + b + c}`) - ExprClosure(CaptureClause, P, P), + Closure(CaptureBy, P, P), /// A block (`{ ... }`) - ExprBlock(P), + Block(P), /// An assignment (`a = foo()`) - ExprAssign(P, P), + Assign(P, P), /// An assignment with an operator /// /// For example, `a += 1`. - ExprAssignOp(BinOp, P, P), + AssignOp(BinOp, P, P), /// Access of a named struct field (`obj.foo`) - ExprField(P, SpannedIdent), + Field(P, SpannedIdent), /// Access of an unnamed field of a struct or tuple-struct /// /// For example, `foo.0`. - ExprTupField(P, Spanned), + TupField(P, Spanned), /// An indexing operation (`foo[2]`) - ExprIndex(P, P), + Index(P, P), /// A range (`1..2`, `1..`, or `..2`) - ExprRange(Option>, Option>), + Range(Option>, Option>), /// Variable reference, possibly containing `::` and/or type /// parameters, e.g. foo::bar::. /// /// Optionally "qualified", /// e.g. ` as SomeTrait>::SomeType`. - ExprPath(Option, Path), + Path(Option, Path), /// A referencing operation (`&a` or `&mut a`) - ExprAddrOf(Mutability, P), + AddrOf(Mutability, P), /// A `break`, with an optional label to break - ExprBreak(Option), + Break(Option), /// A `continue`, with an optional label - ExprAgain(Option), + Again(Option), /// A `return`, with an optional value to be returned - ExprRet(Option>), + Ret(Option>), /// Output of the `asm!()` macro - ExprInlineAsm(InlineAsm), + InlineAsm(InlineAsm), /// A macro invocation; pre-expansion - ExprMac(Mac), + Mac(Mac), /// A struct literal expression. /// /// For example, `Foo {x: 1, y: 2}`, or /// `Foo {x: 1, .. base}`, where `base` is the `Option`. - ExprStruct(Path, Vec, Option>), + Struct(Path, Vec, Option>), /// An array literal constructed from one repeated element. /// /// For example, `[1u8; 5]`. The first expression is the element /// to be repeated; the second is the number of times to repeat it. - ExprRepeat(P, P), + Repeat(P, P), /// No-op: used solely so we can pretty-print faithfully - ExprParen(P) + Paren(P), } /// The explicit Self type in a "qualified path". The actual @@ -1054,10 +1039,11 @@ pub struct QSelf { pub position: usize } +/// A capture clause #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] -pub enum CaptureClause { - CaptureByValue, - CaptureByRef, +pub enum CaptureBy { + Value, + Ref, } /// A delimited sequence of token trees @@ -1174,6 +1160,20 @@ pub fn get_tt(&self, index: usize) -> TokenTree { } (&TokenTree::Token(sp, token::DocComment(name)), _) => { let stripped = strip_doc_comment_decoration(&name.as_str()); + + // Searches for the occurrences of `"#*` and returns the minimum number of `#`s + // required to wrap the text. + let num_of_hashes = stripped.chars().scan(0, |cnt, x| { + *cnt = if x == '"' { + 1 + } else if *cnt != 0 && x == '#' { + *cnt + 1 + } else { + 0 + }; + Some(*cnt) + }).max().unwrap_or(0); + TokenTree::Delimited(sp, Rc::new(Delimited { delim: token::Bracket, open_span: sp, @@ -1181,7 +1181,7 @@ pub fn get_tt(&self, index: usize) -> TokenTree { token::Plain)), TokenTree::Token(sp, token::Eq), TokenTree::Token(sp, token::Literal( - token::StrRaw(token::intern(&stripped), 0), None))], + token::StrRaw(token::intern(&stripped), num_of_hashes), None))], close_span: sp, })) } @@ -1261,65 +1261,40 @@ pub enum StrStyle { } /// A literal -pub type Lit = Spanned; - -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] -pub enum Sign { - Minus, - Plus -} - -impl Sign { - pub fn new(n: T) -> Sign { - n.sign() - } -} - -pub trait IntSign { - fn sign(&self) -> Sign; -} -macro_rules! doit { - ($($t:ident)*) => ($(impl IntSign for $t { - #[allow(unused_comparisons)] - fn sign(&self) -> Sign { - if *self < 0 {Minus} else {Plus} - } - })*) -} -doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } +pub type Lit = Spanned; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum LitIntType { - SignedIntLit(IntTy, Sign), - UnsignedIntLit(UintTy), - UnsuffixedIntLit(Sign) + Signed(IntTy), + Unsigned(UintTy), + Unsuffixed, } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum Lit_ { +pub enum LitKind { /// A string literal (`"foo"`) - LitStr(InternedString, StrStyle), + Str(InternedString, StrStyle), /// A byte string (`b"foo"`) - LitByteStr(Rc>), + ByteStr(Rc>), /// A byte char (`b'f'`) - LitByte(u8), + Byte(u8), /// A character literal (`'a'`) - LitChar(char), + Char(char), /// An integer literal (`1u8`) - LitInt(u64, LitIntType), + Int(u64, LitIntType), /// A float literal (`1f64` or `1E10f64`) - LitFloat(InternedString, FloatTy), + Float(InternedString, FloatTy), /// A float literal without a suffix (`1.0 or 1.0E10`) - LitFloatUnsuffixed(InternedString), + FloatUnsuffixed(InternedString), /// A boolean literal - LitBool(bool), + Bool(bool), } -impl Lit_ { +impl LitKind { /// Returns true if this literal is a string and false otherwise. pub fn is_str(&self) -> bool { match *self { - LitStr(..) => true, + LitKind::Str(..) => true, _ => false, } } @@ -1385,11 +1360,11 @@ pub enum ImplItemKind { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum IntTy { - TyIs, - TyI8, - TyI16, - TyI32, - TyI64, + Is, + I8, + I16, + I32, + I64, } impl fmt::Debug for IntTy { @@ -1407,11 +1382,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { impl IntTy { pub fn ty_to_string(&self) -> &'static str { match *self { - TyIs => "isize", - TyI8 => "i8", - TyI16 => "i16", - TyI32 => "i32", - TyI64 => "i64" + IntTy::Is => "isize", + IntTy::I8 => "i8", + IntTy::I16 => "i16", + IntTy::I32 => "i32", + IntTy::I64 => "i64" } } @@ -1424,41 +1399,41 @@ pub fn val_to_string(&self, val: i64) -> String { pub fn ty_max(&self) -> u64 { match *self { - TyI8 => 0x80, - TyI16 => 0x8000, - TyIs | TyI32 => 0x80000000, // actually ni about TyIs - TyI64 => 0x8000000000000000 + IntTy::I8 => 0x80, + IntTy::I16 => 0x8000, + IntTy::Is | IntTy::I32 => 0x80000000, // FIXME: actually ni about Is + IntTy::I64 => 0x8000000000000000 } } pub fn bit_width(&self) -> Option { Some(match *self { - TyIs => return None, - TyI8 => 8, - TyI16 => 16, - TyI32 => 32, - TyI64 => 64, + IntTy::Is => return None, + IntTy::I8 => 8, + IntTy::I16 => 16, + IntTy::I32 => 32, + IntTy::I64 => 64, }) } } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum UintTy { - TyUs, - TyU8, - TyU16, - TyU32, - TyU64, + Us, + U8, + U16, + U32, + U64, } impl UintTy { pub fn ty_to_string(&self) -> &'static str { match *self { - TyUs => "usize", - TyU8 => "u8", - TyU16 => "u16", - TyU32 => "u32", - TyU64 => "u64" + UintTy::Us => "usize", + UintTy::U8 => "u8", + UintTy::U16 => "u16", + UintTy::U32 => "u32", + UintTy::U64 => "u64" } } @@ -1468,20 +1443,20 @@ pub fn val_to_string(&self, val: u64) -> String { pub fn ty_max(&self) -> u64 { match *self { - TyU8 => 0xff, - TyU16 => 0xffff, - TyUs | TyU32 => 0xffffffff, // actually ni about TyUs - TyU64 => 0xffffffffffffffff + UintTy::U8 => 0xff, + UintTy::U16 => 0xffff, + UintTy::Us | UintTy::U32 => 0xffffffff, // FIXME: actually ni about Us + UintTy::U64 => 0xffffffffffffffff } } pub fn bit_width(&self) -> Option { Some(match *self { - TyUs => return None, - TyU8 => 8, - TyU16 => 16, - TyU32 => 32, - TyU64 => 64, + UintTy::Us => return None, + UintTy::U8 => 8, + UintTy::U16 => 16, + UintTy::U32 => 32, + UintTy::U64 => 64, }) } } @@ -1500,8 +1475,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum FloatTy { - TyF32, - TyF64, + F32, + F64, } impl fmt::Debug for FloatTy { @@ -1519,15 +1494,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { impl FloatTy { pub fn ty_to_string(&self) -> &'static str { match *self { - TyF32 => "f32", - TyF64 => "f64", + FloatTy::F32 => "f32", + FloatTy::F64 => "f64", } } pub fn bit_width(&self) -> usize { match *self { - TyF32 => 32, - TyF64 => 64, + FloatTy::F32 => 32, + FloatTy::F64 => 64, } } } @@ -1544,7 +1519,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, } @@ -1554,17 +1529,6 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { } } -/// Not represented directly in the AST, referred to by name through a ty_path. -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] -pub enum PrimTy { - TyInt(IntTy), - TyUint(UintTy), - TyFloat(FloatTy), - TyStr, - TyBool, - TyChar -} - #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct BareFnTy { pub unsafety: Unsafety, @@ -1575,36 +1539,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)] @@ -1649,7 +1613,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 { @@ -1713,41 +1677,41 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { pub enum FunctionRetTy { /// Functions with return type `!`that always /// raise an error or exit (i.e. never return to the caller) - NoReturn(Span), + None(Span), /// Return type is not specified. /// /// Functions default to `()` and /// closures default to inference. Span points to where return /// type would be inserted. - DefaultReturn(Span), + Default(Span), /// Everything else - Return(P), + Ty(P), } impl FunctionRetTy { pub fn span(&self) -> Span { match *self { - NoReturn(span) => span, - DefaultReturn(span) => span, - Return(ref ty) => ty.span + FunctionRetTy::None(span) => span, + FunctionRetTy::Default(span) => span, + FunctionRetTy::Ty(ref ty) => ty.span, } } } /// Represents the kind of 'self' associated with a method #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum ExplicitSelf_ { +pub enum SelfKind { /// No self - SelfStatic, + Static, /// `self` - SelfValue(Ident), + Value(Ident), /// `&'lt self`, `&'lt mut self` - SelfRegion(Option, Mutability, Ident), + Region(Option, Mutability, Ident), /// `self: TYPE` - SelfExplicit(P, Ident), + Explicit(P, Ident), } -pub type ExplicitSelf = Spanned; +pub type ExplicitSelf = Spanned; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct Mod {