Skip to content

Commit 4489d26

Browse files
committed
syntax: merge ast::ViewItem into ast::Item.
1 parent ea0c621 commit 4489d26

File tree

2 files changed

+131
-344
lines changed

2 files changed

+131
-344
lines changed

src/libsyntax/ast.rs

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub use self::UnboxedClosureKind::*;
5353
pub use self::UnOp::*;
5454
pub use self::UnsafeSource::*;
5555
pub use self::VariantKind::*;
56-
pub use self::ViewItem_::*;
5756
pub use self::ViewPath_::*;
5857
pub use self::Visibility::*;
5958
pub use self::PathParameters::*;
@@ -499,7 +498,6 @@ impl PartialEq for MetaItem_ {
499498

500499
#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
501500
pub struct Block {
502-
pub view_items: Vec<ViewItem>,
503501
pub stmts: Vec<P<Stmt>>,
504502
pub expr: Option<P<Expr>>,
505503
pub id: NodeId,
@@ -1361,14 +1359,12 @@ pub struct Mod {
13611359
/// For `mod foo;`, the inner span ranges from the first token
13621360
/// to the last token in the external file.
13631361
pub inner: Span,
1364-
pub view_items: Vec<ViewItem>,
13651362
pub items: Vec<P<Item>>,
13661363
}
13671364

13681365
#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
13691366
pub struct ForeignMod {
13701367
pub abi: Abi,
1371-
pub view_items: Vec<ViewItem>,
13721368
pub items: Vec<P<ForeignItem>>,
13731369
}
13741370

@@ -1427,31 +1423,13 @@ pub enum ViewPath_ {
14271423
/// or just
14281424
///
14291425
/// `foo::bar::baz` (with `as baz` implicitly on the right)
1430-
ViewPathSimple(Ident, Path, NodeId),
1426+
ViewPathSimple(Ident, Path),
14311427

14321428
/// `foo::bar::*`
1433-
ViewPathGlob(Path, NodeId),
1429+
ViewPathGlob(Path),
14341430

14351431
/// `foo::bar::{a,b,c}`
1436-
ViewPathList(Path, Vec<PathListItem> , NodeId)
1437-
}
1438-
1439-
#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
1440-
pub struct ViewItem {
1441-
pub node: ViewItem_,
1442-
pub attrs: Vec<Attribute>,
1443-
pub vis: Visibility,
1444-
pub span: Span,
1445-
}
1446-
1447-
#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
1448-
pub enum ViewItem_ {
1449-
/// Ident: name used to refer to this crate in the code
1450-
/// optional (InternedString,StrStyle): if present, this is a location
1451-
/// (containing arbitrary characters) from which to fetch the crate sources
1452-
/// For example, extern crate whatever = "github.com/rust-lang/rust"
1453-
ViewItemExternCrate(Ident, Option<(InternedString,StrStyle)>, NodeId),
1454-
ViewItemUse(P<ViewPath>),
1432+
ViewPathList(Path, Vec<PathListItem>)
14551433
}
14561434

14571435
/// Meta-data associated with an item
@@ -1573,6 +1551,12 @@ pub struct Item {
15731551

15741552
#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
15751553
pub enum Item_ {
1554+
// Optional location (containing arbitrary characters) from which
1555+
// to fetch the crate sources.
1556+
// For example, extern crate whatever = "github.com/rust-lang/rust".
1557+
ItemExternCrate(Option<(InternedString, StrStyle)>),
1558+
ItemUse(P<ViewPath>),
1559+
15761560
ItemStatic(P<Ty>, Mutability, P<Expr>),
15771561
ItemConst(P<Ty>, P<Expr>),
15781562
ItemFn(P<FnDecl>, Unsafety, Abi, Generics, P<Block>),
@@ -1598,6 +1582,8 @@ pub enum Item_ {
15981582
impl Item_ {
15991583
pub fn descriptive_variant(&self) -> &str {
16001584
match *self {
1585+
ItemExternCrate(..) => "extern crate",
1586+
ItemUse(..) => "use",
16011587
ItemStatic(..) => "static item",
16021588
ItemConst(..) => "constant item",
16031589
ItemFn(..) => "function",
@@ -1674,7 +1660,6 @@ mod test {
16741660
hi: BytePos(19),
16751661
expn_id: NO_EXPANSION,
16761662
},
1677-
view_items: Vec::new(),
16781663
items: Vec::new(),
16791664
},
16801665
attrs: Vec::new(),

0 commit comments

Comments
 (0)