Skip to content

Commit fdfaabb

Browse files
committed
syntax: merge ast::ViewItem into ast::Item.
1 parent b016fee commit fdfaabb

File tree

2 files changed

+131
-356
lines changed

2 files changed

+131
-356
lines changed

src/libsyntax/ast.rs

Lines changed: 11 additions & 38 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::*;
@@ -511,7 +510,6 @@ impl PartialEq for MetaItem_ {
511510

512511
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
513512
pub struct Block {
514-
pub view_items: Vec<ViewItem>,
515513
pub stmts: Vec<P<Stmt>>,
516514
pub expr: Option<P<Expr>>,
517515
pub id: NodeId,
@@ -1445,14 +1443,12 @@ pub struct Mod {
14451443
/// For `mod foo;`, the inner span ranges from the first token
14461444
/// to the last token in the external file.
14471445
pub inner: Span,
1448-
pub view_items: Vec<ViewItem>,
14491446
pub items: Vec<P<Item>>,
14501447
}
14511448

14521449
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
14531450
pub struct ForeignMod {
14541451
pub abi: Abi,
1455-
pub view_items: Vec<ViewItem>,
14561452
pub items: Vec<P<ForeignItem>>,
14571453
}
14581454

@@ -1511,44 +1507,13 @@ pub enum ViewPath_ {
15111507
/// or just
15121508
///
15131509
/// `foo::bar::baz` (with `as baz` implicitly on the right)
1514-
ViewPathSimple(Ident, Path, NodeId),
1510+
ViewPathSimple(Ident, Path),
15151511

15161512
/// `foo::bar::*`
1517-
ViewPathGlob(Path, NodeId),
1513+
ViewPathGlob(Path),
15181514

15191515
/// `foo::bar::{a,b,c}`
1520-
ViewPathList(Path, Vec<PathListItem> , NodeId)
1521-
}
1522-
1523-
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
1524-
pub struct ViewItem {
1525-
pub node: ViewItem_,
1526-
pub attrs: Vec<Attribute>,
1527-
pub vis: Visibility,
1528-
pub span: Span,
1529-
}
1530-
1531-
impl ViewItem {
1532-
pub fn id(&self) -> NodeId {
1533-
match self.node {
1534-
ViewItemExternCrate(_, _, id) => id,
1535-
ViewItemUse(ref vp) => match vp.node {
1536-
ViewPathSimple(_, _, id) => id,
1537-
ViewPathGlob(_, id) => id,
1538-
ViewPathList(_, _, id) => id,
1539-
}
1540-
}
1541-
}
1542-
}
1543-
1544-
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
1545-
pub enum ViewItem_ {
1546-
/// Ident: name used to refer to this crate in the code
1547-
/// optional (InternedString,StrStyle): if present, this is a location
1548-
/// (containing arbitrary characters) from which to fetch the crate sources
1549-
/// For example, extern crate whatever = "github.com/rust-lang/rust"
1550-
ViewItemExternCrate(Ident, Option<(InternedString,StrStyle)>, NodeId),
1551-
ViewItemUse(P<ViewPath>),
1516+
ViewPathList(Path, Vec<PathListItem>)
15521517
}
15531518

15541519
/// Meta-data associated with an item
@@ -1670,6 +1635,12 @@ pub struct Item {
16701635

16711636
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
16721637
pub enum Item_ {
1638+
// Optional location (containing arbitrary characters) from which
1639+
// to fetch the crate sources.
1640+
// For example, extern crate whatever = "github.com/rust-lang/rust".
1641+
ItemExternCrate(Option<(InternedString, StrStyle)>),
1642+
ItemUse(P<ViewPath>),
1643+
16731644
ItemStatic(P<Ty>, Mutability, P<Expr>),
16741645
ItemConst(P<Ty>, P<Expr>),
16751646
ItemFn(P<FnDecl>, Unsafety, Abi, Generics, P<Block>),
@@ -1696,6 +1667,8 @@ pub enum Item_ {
16961667
impl Item_ {
16971668
pub fn descriptive_variant(&self) -> &str {
16981669
match *self {
1670+
ItemExternCrate(..) => "extern crate",
1671+
ItemUse(..) => "use",
16991672
ItemStatic(..) => "static item",
17001673
ItemConst(..) => "constant item",
17011674
ItemFn(..) => "function",

0 commit comments

Comments
 (0)