pub use self::PathListItem_::*;
pub use self::PrimTy::*;
pub use self::Stmt_::*;
-pub use self::StructFieldKind::*;
pub use self::TraitItem_::*;
pub use self::Ty_::*;
pub use self::TyParamBound::*;
ExprBinary(BinOp, P<Expr>, P<Expr>),
/// A unary operation (For example: `!x`, `*x`)
ExprUnary(UnOp, P<Expr>),
- /// A literal (For example: `1u8`, `"foo"`)
+ /// A literal (For example: `1`, `"foo"`)
ExprLit(P<Lit>),
/// A cast (`foo as f64`)
ExprCast(P<Expr>, P<Ty>),
/// A `return`, with an optional value to be returned
ExprRet(Option<P<Expr>>),
- /// Output of the `asm!()` macro
- ExprInlineAsm(InlineAsm),
+ /// Inline assembly (from `asm!`), with its outputs and inputs.
+ ExprInlineAsm(InlineAsm, Vec<P<Expr>>, Vec<P<Expr>>),
/// A struct literal expression.
///
/// A vector literal constructed from one repeated element.
///
- /// For example, `[1u8; 5]`. The first expression is the element
+ /// For example, `[1; 5]`. The first expression is the element
/// to be repeated; the second is the number of times to repeat it.
ExprRepeat(P<Expr>, P<Expr>),
}
},
WhileLetDesugar,
ForLoopDesugar,
+ TryDesugar,
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub explicit_self: ExplicitSelf,
}
-/// Represents a method declaration in a trait declaration, possibly including
-/// a default implementation A trait method is either required (meaning it
-/// doesn't have an implementation, just a signature) or provided (meaning it
-/// has a default implementation).
+/// Represents an item declaration within a trait declaration,
+/// possibly including a default implementation. A trait item is
+/// either required (meaning it doesn't have an implementation, just a
+/// signature) or provided (meaning it has a default implementation).
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct TraitItem {
pub id: NodeId,
pub id: NodeId,
pub name: Name,
pub vis: Visibility,
+ pub defaultness: Defaultness,
pub attrs: HirVec<Attribute>,
pub node: ImplItemKind,
pub span: Span,
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct InlineAsmOutput {
pub constraint: InternedString,
- pub expr: P<Expr>,
pub is_rw: bool,
pub is_indirect: bool,
}
pub asm: InternedString,
pub asm_str_style: StrStyle,
pub outputs: HirVec<InlineAsmOutput>,
- pub inputs: HirVec<(InternedString, P<Expr>)>,
+ pub inputs: HirVec<InternedString>,
pub clobbers: HirVec<InternedString>,
pub volatile: bool,
pub alignstack: bool,
NotConst,
}
+#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+pub enum Defaultness {
+ Default,
+ Final,
+}
+
+impl Defaultness {
+ pub fn is_final(&self) -> bool {
+ *self == Defaultness::Final
+ }
+
+ pub fn is_default(&self) -> bool {
+ *self == Defaultness::Default
+ }
+}
+
impl fmt::Display for Unsafety {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(match *self {
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
-pub struct StructField_ {
- pub kind: StructFieldKind,
+pub struct StructField {
+ pub span: Span,
+ pub name: Name,
+ pub vis: Visibility,
pub id: NodeId,
pub ty: P<Ty>,
pub attrs: HirVec<Attribute>,
}
-impl StructField_ {
- pub fn name(&self) -> Option<Name> {
- match self.kind {
- NamedField(name, _) => Some(name),
- UnnamedField(_) => None,
- }
- }
-}
-
-pub type StructField = Spanned<StructField_>;
-
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
-pub enum StructFieldKind {
- NamedField(Name, Visibility),
- /// Element of a tuple-like struct
- UnnamedField(Visibility),
-}
-
-impl StructFieldKind {
- pub fn is_unnamed(&self) -> bool {
- match *self {
- UnnamedField(..) => true,
- NamedField(..) => false,
- }
- }
-
- pub fn visibility(&self) -> Visibility {
- match *self {
- NamedField(_, vis) | UnnamedField(vis) => vis,
- }
+impl StructField {
+ // Still necessary in couple of places
+ pub fn is_positional(&self) -> bool {
+ let first = self.name.as_str().as_bytes()[0];
+ first >= b'0' && first <= b'9'
}
}