Skip to content

Commit

Permalink
ast: colocate AssocItem with ForeignItem
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Feb 15, 2020
1 parent 2fd1544 commit f06df16
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions src/libsyntax/ast.rs
Expand Up @@ -1605,45 +1605,6 @@ pub struct FnSig {
pub decl: P<FnDecl>,
}

/// Represents associated items.
/// These include items in `impl` and `trait` definitions.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct AssocItem {
pub attrs: Vec<Attribute>,
pub id: NodeId,
pub span: Span,
pub vis: Visibility,
pub ident: Ident,

pub defaultness: Defaultness,
pub kind: AssocItemKind,
/// See `Item::tokens` for what this is.
pub tokens: Option<TokenStream>,
}

/// Represents various kinds of content within an `impl`.
///
/// The term "provided" in the variants below refers to the item having a default
/// definition / body. Meanwhile, a "required" item lacks a definition / body.
/// In an implementation, all items must be provided.
/// The `Option`s below denote the bodies, where `Some(_)`
/// means "provided" and conversely `None` means "required".
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum AssocItemKind {
/// An associated constant, `const $ident: $ty $def?;` where `def ::= "=" $expr? ;`.
/// If `def` is parsed, then the associated constant is provided, and otherwise required.
Const(P<Ty>, Option<P<Expr>>),

/// An associated function.
Fn(FnSig, Generics, Option<P<Block>>),

/// An associated type.
TyAlias(Generics, GenericBounds, Option<P<Ty>>),

/// A macro expanding to an associated item.
Macro(Mac),
}

#[derive(
Clone,
Copy,
Expand Down Expand Up @@ -2664,3 +2625,42 @@ impl ForeignItemKind {
}
}
}

/// Represents associated items.
/// These include items in `impl` and `trait` definitions.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct AssocItem {
pub attrs: Vec<Attribute>,
pub id: NodeId,
pub span: Span,
pub vis: Visibility,
pub ident: Ident,

pub defaultness: Defaultness,
pub kind: AssocItemKind,
/// See `Item::tokens` for what this is.
pub tokens: Option<TokenStream>,
}

/// Represents various kinds of content within an `impl`.
///
/// The term "provided" in the variants below refers to the item having a default
/// definition / body. Meanwhile, a "required" item lacks a definition / body.
/// In an implementation, all items must be provided.
/// The `Option`s below denote the bodies, where `Some(_)`
/// means "provided" and conversely `None` means "required".
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum AssocItemKind {
/// An associated constant, `const $ident: $ty $def?;` where `def ::= "=" $expr? ;`.
/// If `def` is parsed, then the associated constant is provided, and otherwise required.
Const(P<Ty>, Option<P<Expr>>),

/// An associated function.
Fn(FnSig, Generics, Option<P<Block>>),

/// An associated type.
TyAlias(Generics, GenericBounds, Option<P<Ty>>),

/// A macro expanding to an associated item.
Macro(Mac),
}

0 comments on commit f06df16

Please sign in to comment.