Skip to content

Commit b5dbe01

Browse files
committed
Refactor away ast::Decl and refactor ast::Stmt
1 parent 114be1e commit b5dbe01

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/libsyntax/ast.rs

+14-16
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,12 @@ impl UnOp {
786786
}
787787

788788
/// A statement
789-
pub type Stmt = Spanned<StmtKind>;
789+
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
790+
pub struct Stmt {
791+
pub id: NodeId,
792+
pub node: StmtKind,
793+
pub span: Span,
794+
}
790795

791796
impl fmt::Debug for Stmt {
792797
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -800,16 +805,19 @@ impl fmt::Debug for Stmt {
800805

801806
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
802807
pub enum StmtKind {
803-
/// Could be an item or a local (let) binding:
804-
Decl(P<Decl>, NodeId),
808+
/// A local (let) binding:
809+
Local(P<Local>),
810+
811+
/// An item binding
812+
Item(P<Item>),
805813

806814
/// Expr without trailing semi-colon (must have unit type):
807-
Expr(P<Expr>, NodeId),
815+
Expr(P<Expr>),
808816

809817
/// Expr with trailing semi-colon (may have any type):
810-
Semi(P<Expr>, NodeId),
818+
Semi(P<Expr>),
811819

812-
Mac(P<Mac>, MacStmtStyle, ThinAttributes),
820+
Mac(P<(Mac, MacStmtStyle, ThinAttributes)>),
813821
}
814822

815823
impl StmtKind {
@@ -860,16 +868,6 @@ impl Local {
860868
}
861869
}
862870

863-
pub type Decl = Spanned<DeclKind>;
864-
865-
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
866-
pub enum DeclKind {
867-
/// A local (let) binding:
868-
Local(P<Local>),
869-
/// An item binding:
870-
Item(P<Item>),
871-
}
872-
873871
impl Decl {
874872
pub fn attrs(&self) -> &[Attribute] {
875873
HasAttrs::attrs(self)

0 commit comments

Comments
 (0)