Skip to content

Commit 19b80aa

Browse files
committed
syntax: merge ast::ViewItem into ast::Item.
1 parent 20e3604 commit 19b80aa

File tree

2 files changed

+130
-353
lines changed

2 files changed

+130
-353
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,
@@ -1452,14 +1450,12 @@ pub struct Mod {
14521450
/// For `mod foo;`, the inner span ranges from the first token
14531451
/// to the last token in the external file.
14541452
pub inner: Span,
1455-
pub view_items: Vec<ViewItem>,
14561453
pub items: Vec<P<Item>>,
14571454
}
14581455

14591456
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
14601457
pub struct ForeignMod {
14611458
pub abi: Abi,
1462-
pub view_items: Vec<ViewItem>,
14631459
pub items: Vec<P<ForeignItem>>,
14641460
}
14651461

@@ -1518,44 +1514,13 @@ pub enum ViewPath_ {
15181514
/// or just
15191515
///
15201516
/// `foo::bar::baz` (with `as baz` implicitly on the right)
1521-
ViewPathSimple(Ident, Path, NodeId),
1517+
ViewPathSimple(Ident, Path),
15221518

15231519
/// `foo::bar::*`
1524-
ViewPathGlob(Path, NodeId),
1520+
ViewPathGlob(Path),
15251521

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

15611526
/// Meta-data associated with an item
@@ -1677,6 +1642,12 @@ pub struct Item {
16771642

16781643
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
16791644
pub enum Item_ {
1645+
// Optional location (containing arbitrary characters) from which
1646+
// to fetch the crate sources.
1647+
// For example, extern crate whatever = "github.com/rust-lang/rust".
1648+
ItemExternCrate(Option<(InternedString, StrStyle)>),
1649+
ItemUse(P<ViewPath>),
1650+
16801651
ItemStatic(P<Ty>, Mutability, P<Expr>),
16811652
ItemConst(P<Ty>, P<Expr>),
16821653
ItemFn(P<FnDecl>, Unsafety, Abi, Generics, P<Block>),
@@ -1703,6 +1674,8 @@ pub enum Item_ {
17031674
impl Item_ {
17041675
pub fn descriptive_variant(&self) -> &str {
17051676
match *self {
1677+
ItemExternCrate(..) => "extern crate",
1678+
ItemUse(..) => "use",
17061679
ItemStatic(..) => "static item",
17071680
ItemConst(..) => "constant item",
17081681
ItemFn(..) => "function",

0 commit comments

Comments
 (0)