#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Pat {
pub id: NodeId,
- pub node: PatKind,
+ pub kind: PatKind,
pub span: Span,
}
/// Attempt reparsing the pattern as a type.
/// This is intended for use by diagnostics.
pub(super) fn to_ty(&self) -> Option<P<Ty>> {
- let node = match &self.node {
+ let kind = match &self.kind {
// In a type expression `_` is an inference variable.
PatKind::Wild => TyKind::Infer,
// An IDENT pattern with no binding mode would be valid as path to a type. E.g. `u32`.
};
Some(P(Ty {
- node,
+ kind,
id: self.id,
span: self.span,
}))
return;
}
- match &self.node {
+ match &self.kind {
PatKind::Ident(_, _, Some(p)) => p.walk(it),
PatKind::Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk(it)),
PatKind::TupleStruct(_, s)
/// Is this a `..` pattern?
pub fn is_rest(&self) -> bool {
- match self.node {
+ match self.kind {
PatKind::Rest => true,
_ => false,
}
#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Expr {
pub id: NodeId,
- pub node: ExprKind,
+ pub kind: ExprKind,
pub span: Span,
pub attrs: ThinVec<Attribute>,
}
/// Returns `true` if this expression would be valid somewhere that expects a value;
/// for example, an `if` condition.
pub fn returns(&self) -> bool {
- if let ExprKind::Block(ref block, _) = self.node {
+ if let ExprKind::Block(ref block, _) = self.kind {
match block.stmts.last().map(|last_stmt| &last_stmt.node) {
// Implicit return
Some(&StmtKind::Expr(_)) => true,
Some(&StmtKind::Semi(ref expr)) => {
- if let ExprKind::Ret(_) = expr.node {
+ if let ExprKind::Ret(_) = expr.kind {
// Last statement is explicit return.
true
} else {
}
fn to_bound(&self) -> Option<GenericBound> {
- match &self.node {
+ match &self.kind {
ExprKind::Path(None, path) => Some(GenericBound::Trait(
PolyTraitRef::new(Vec::new(), path.clone(), self.span),
TraitBoundModifier::None,
}
pub(super) fn to_ty(&self) -> Option<P<Ty>> {
- let node = match &self.node {
+ let kind = match &self.kind {
ExprKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
ExprKind::Mac(mac) => TyKind::Mac(mac.clone()),
ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?,
};
Some(P(Ty {
- node,
+ kind,
id: self.id,
span: self.span,
}))
}
pub fn precedence(&self) -> ExprPrecedence {
- match self.node {
+ match self.kind {
ExprKind::Box(_) => ExprPrecedence::Box,
ExprKind::Array(_) => ExprPrecedence::Array,
ExprKind::Call(..) => ExprPrecedence::Call,
/// The "semantic" representation of the literal lowered from the original tokens.
/// Strings are unescaped, hexadecimal forms are eliminated, etc.
/// FIXME: Remove this and only create the semantic representation during lowering to HIR.
- pub node: LitKind,
+ pub kind: LitKind,
pub span: Span,
}
pub ident: Ident,
pub attrs: Vec<Attribute>,
pub generics: Generics,
- pub node: TraitItemKind,
+ pub kind: TraitItemKind,
pub span: Span,
/// See `Item::tokens` for what this is.
pub tokens: Option<TokenStream>,
pub defaultness: Defaultness,
pub attrs: Vec<Attribute>,
pub generics: Generics,
- pub node: ImplItemKind,
+ pub kind: ImplItemKind,
pub span: Span,
/// See `Item::tokens` for what this is.
pub tokens: Option<TokenStream>,
#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Ty {
pub id: NodeId,
- pub node: TyKind,
+ pub kind: TyKind,
pub span: Span,
}
impl Param {
pub fn to_self(&self) -> Option<ExplicitSelf> {
- if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.node {
+ if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.kind {
if ident.name == kw::SelfLower {
- return match self.ty.node {
+ return match self.ty.kind {
TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))),
- TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.node.is_implicit_self() => {
+ TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.kind.is_implicit_self() => {
Some(respan(self.pat.span, SelfKind::Region(lt, mutbl)))
}
_ => Some(respan(
}
pub fn is_self(&self) -> bool {
- if let PatKind::Ident(_, ident, _) = self.pat.node {
+ if let PatKind::Ident(_, ident, _) = self.pat.kind {
ident.name == kw::SelfLower
} else {
false
let span = eself.span.to(eself_ident.span);
let infer_ty = P(Ty {
id: DUMMY_NODE_ID,
- node: TyKind::ImplicitSelf,
+ kind: TyKind::ImplicitSelf,
span,
});
let param = |mutbl, ty| Param {
attrs,
pat: P(Pat {
id: DUMMY_NODE_ID,
- node: PatKind::Ident(BindingMode::ByValue(mutbl), eself_ident, None),
+ kind: PatKind::Ident(BindingMode::ByValue(mutbl), eself_ident, None),
span,
}),
span,
Mutability::Immutable,
P(Ty {
id: DUMMY_NODE_ID,
- node: TyKind::Rptr(
+ kind: TyKind::Rptr(
lt,
MutTy {
ty: infer_ty,