Skip to content

Commit

Permalink
syntax: Move ast_map into it's own crate
Browse files Browse the repository at this point in the history
This lets us remove the arena dependency from libsyntax, which
is unstable.
  • Loading branch information
erickt committed May 1, 2015
1 parent 1320c29 commit 19f1a15
Show file tree
Hide file tree
Showing 49 changed files with 133 additions and 91 deletions.
27 changes: 15 additions & 12 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ TARGET_CRATES := libc std flate arena term \
rustc_unicode rustc_bitflags
RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_resolve rustc_driver \
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
rustc_data_structures
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
rustc_data_structures rustc_ast_map
SYNTAX_CRATES := syntax
HOST_CRATES := $(SYNTAX_CRATES) $(RUSTC_CRATES) rustdoc fmt_macros
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
TOOLS := compiletest rustdoc rustc rustbook

Expand All @@ -68,24 +69,26 @@ DEPS_std := core libc rand alloc collections rustc_unicode \
native:rust_builtin native:backtrace native:rustrt_native \
rustc_bitflags
DEPS_graphviz := std
DEPS_syntax := std term serialize log fmt_macros arena libc
DEPS_syntax := std term serialize log fmt_macros libc
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
rustc_typeck rustc_resolve log syntax serialize rustc_llvm \
rustc_trans rustc_privacy rustc_lint
rustc_trans rustc_privacy rustc_lint rustc_ast_map

DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
log syntax serialize rustc_llvm
DEPS_rustc_typeck := rustc syntax
DEPS_rustc_borrowck := rustc log graphviz syntax
DEPS_rustc_resolve := rustc log syntax
DEPS_rustc_privacy := rustc log syntax
DEPS_rustc_lint := rustc log syntax
log syntax rustc_ast_map serialize rustc_llvm
DEPS_rustc_typeck := rustc syntax rustc_ast_map
DEPS_rustc_borrowck := rustc log graphviz syntax rustc_ast_map
DEPS_rustc_resolve := rustc log syntax rustc_ast_map
DEPS_rustc_privacy := rustc log syntax rustc_ast_map
DEPS_rustc_lint := rustc log syntax rustc_ast_map
DEPS_rustc := syntax flate arena serialize getopts rbml \
log graphviz rustc_llvm rustc_back rustc_data_structures
log graphviz rustc_llvm rustc_back rustc_data_structures \
rustc_ast_map
DEPS_rustc_llvm := native:rustllvm libc std
DEPS_rustc_back := std syntax rustc_llvm flate log libc
DEPS_rustc_data_structures := std log serialize
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
DEPS_rustc_ast_map := std arena syntax
DEPS_rustdoc := rustc rustc_driver native:hoedown syntax rustc_ast_map serialize getopts \
test rustc_lint
DEPS_rustc_bitflags := core
DEPS_flate := std native:miniz
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ extern crate fmt_macros;
extern crate getopts;
extern crate graphviz;
extern crate libc;
extern crate rustc_llvm;
extern crate rustc_ast_map;
extern crate rustc_back;
extern crate rustc_data_structures;
extern crate rustc_llvm;
extern crate serialize;
extern crate rbml;
extern crate collections;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use middle::ty;

use rbml;
use rbml::reader;
use rustc_ast_map as ast_map;
use std::rc::Rc;
use syntax::ast;
use syntax::ast_map;
use syntax::attr;
use syntax::attr::AttrMetaMethods;
use syntax::diagnostic::expect;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ use std::str;

use rbml::reader;
use rbml;
use rustc_ast_map as ast_map;
use serialize::Decodable;
use syntax::ast_map;
use syntax::attr;
use syntax::parse::token::{IdentInterner, special_idents};
use syntax::parse::token;
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ use std::cell::RefCell;
use std::hash::{Hash, Hasher, SipHasher};
use std::io::prelude::*;
use std::io::{Cursor, SeekFrom};
use rbml::writer::Encoder;
use rustc_ast_map as ast_map;
use rustc_ast_map::{LinkedPath, PathElem, PathElems};
use syntax::abi;
use syntax::ast::{self, DefId, NodeId};
use syntax::ast_map::{self, LinkedPath, PathElem, PathElems};
use syntax::ast_util::*;
use syntax::ast_util;
use syntax::attr;
Expand All @@ -47,7 +49,6 @@ use syntax::ptr::P;
use syntax::visit::Visitor;
use syntax::visit;
use syntax;
use rbml::writer::Encoder;

/// A borrowed version of `ast::InlinedItem`.
pub enum InlinedItemRef<'a> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ use middle::subst::VecPerParamSpace;
use middle::ty::{self, Ty, MethodCall, MethodCallee, MethodOrigin};
use util::ppaux::ty_to_string;

use syntax::{ast, ast_map, ast_util, codemap, fold};
use syntax::{self, ast, ast_util, codemap, fold};
use syntax::codemap::Span;
use syntax::fold::Folder;
use syntax::parse::token;
use syntax::ptr::P;
use syntax;

use std::cell::Cell;
use std::io::SeekFrom;
Expand All @@ -46,6 +45,7 @@ use std::fmt::Debug;
use rbml::reader;
use rbml::writer::Encoder;
use rbml;
use rustc_ast_map as ast_map;
use serialize;
use serialize::{Decodable, Decoder, DecoderHelpers, Encodable};
use serialize::EncoderHelpers;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/cfg/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use std::borrow::IntoCow;
// For clarity, rename the graphviz crate locally to dot.
use graphviz as dot;

use rustc_ast_map as ast_map;
use syntax::ast;
use syntax::ast_map;

use middle::cfg;

Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/check_static_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
use session::Session;
use middle::def::{DefStatic, DefConst, DefAssociatedConst, DefMap};

use rustc_ast_map as ast_map;
use syntax::ast;
use syntax::{ast_util, ast_map};
use syntax::ast_util;
use syntax::codemap::Span;
use syntax::visit::Visitor;
use syntax::visit;
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ use middle::astconv_util::ast_ty_to_prim_ty;
use util::num::ToPrimitive;
use util::ppaux::Repr;

use rustc_ast_map as ast_map;
use syntax::ast::{self, Expr};
use syntax::codemap::Span;
use syntax::feature_gate;
use syntax::parse::token::InternedString;
use syntax::ptr::P;
use syntax::{ast_map, ast_util, codemap};
use syntax::{ast_util, codemap};

use std::borrow::{Cow, IntoCow};
use std::num::wrapping::OverflowingOps;
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use lint;
use util::nodemap::NodeSet;

use std::collections::HashSet;
use syntax::{ast, ast_map, codemap};
use rustc_ast_map as ast_map;
use syntax::{ast, codemap};
use syntax::ast_util::{local_def, is_local};
use syntax::attr::{self, AttrMetaMethods};
use syntax::visit::{self, Visitor};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
// except according to those terms.


use rustc_ast_map as ast_map;
use session::{config, Session};
use syntax::ast::{Name, NodeId, Item, ItemFn};
use syntax::ast_map;
use syntax::attr;
use syntax::codemap::Span;
use syntax::parse::token;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ use middle::infer;
use middle::subst;
use middle::ty::{self, Ty};
use middle::ty::{Region, ReFree};
use rustc_ast_map as ast_map;
use std::cell::{Cell, RefCell};
use std::char::from_u32;
use std::string::String;
use syntax::ast;
use syntax::ast_map;
use syntax::ast_util::name_to_dummy_lifetime;
use syntax::owned_slice::OwnedSlice;
use syntax::codemap;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/intrinsicck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use middle::ty::{TransmuteRestriction, ctxt, ty_bare_fn};
use middle::ty::{self, Ty};
use util::ppaux::Repr;

use rustc_ast_map::NodeForeignItem;
use syntax::abi::RustIntrinsic;
use syntax::ast::DefId;
use syntax::ast;
use syntax::ast_map::NodeForeignItem;
use syntax::codemap::Span;
use syntax::parse::token;
use syntax::visit::Visitor;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ use middle::ty::{self, Ty};
use util::nodemap::NodeMap;
use util::ppaux::{Repr, UserString};

use rustc_ast_map as ast_map;
use syntax::ast::{MutImmutable, MutMutable};
use syntax::ast;
use syntax::ast_map;
use syntax::codemap::Span;
use syntax::print::pprust;
use syntax::parse::token;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ use middle::privacy;
use session::config;
use util::nodemap::NodeSet;

use rustc_ast_map as ast_map;
use std::collections::HashSet;
use syntax::abi;
use syntax::ast;
use syntax::ast_map;
use syntax::ast_util::is_local;
use syntax::attr;
use syntax::visit::Visitor;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ use session::Session;
use middle::ty::{self, Ty};
use util::nodemap::{FnvHashMap, FnvHashSet, NodeMap};

use rustc_ast_map as ast_map;
use std::cell::RefCell;
use syntax::codemap::{self, Span};
use syntax::{ast, visit};
use syntax::ast::{Block, Item, FnDecl, NodeId, Arm, Pat, Stmt, Expr, Local};
use syntax::ast_util::stmt_id;
use syntax::ast_map;
use syntax::ptr::P;
use syntax::visit::{Visitor, FnKind};

Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ use std::ops;
use std::rc::Rc;
use std::vec::IntoIter;
use collections::enum_set::{EnumSet, CLike};
use rustc_ast_map as ast_map;
use rustc_ast_map::LinkedPath;
use std::collections::{HashMap, HashSet};
use syntax::abi;
use syntax::ast::{CrateNum, DefId, ItemImpl, ItemTrait, LOCAL_CRATE};
Expand All @@ -91,7 +93,6 @@ use syntax::parse::token::{self, InternedString, special_idents};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::ast;
use syntax::ast_map::{self, LinkedPath};

pub type Disr = u64;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_infer};
use middle::ty;
use middle::ty_fold::TypeFoldable;

use rustc_ast_map as ast_map;
use std::collections::HashMap;
use std::collections::hash_state::HashState;
use std::hash::Hash;
use std::rc::Rc;
use syntax::abi;
use syntax::ast_map;
use syntax::codemap::{Span, Pos};
use syntax::parse::token;
use syntax::print::pprust;
Expand Down
34 changes: 17 additions & 17 deletions src/libsyntax/ast_map/blocks.rs → src/librustc_ast_map/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

pub use self::Code::*;

use abi;
use ast::{Block, FnDecl, NodeId};
use ast;
use ast_map::Node;
use ast_map;
use codemap::Span;
use visit;
use syntax::abi;
use syntax::ast::{Block, FnDecl, NodeId};
use syntax::ast;
use syntax::codemap::Span;
use syntax::visit;

use super::Node;

/// An FnLikeNode is a Node that is like a fn, in that it has a decl
/// and a body (as well as a NodeId, a span, etc).
Expand All @@ -41,7 +41,7 @@ use visit;
///
/// To construct one, use the `Code::from_node` function.
#[derive(Copy, Clone)]
pub struct FnLikeNode<'a> { node: ast_map::Node<'a> }
pub struct FnLikeNode<'a> { node: Node<'a> }

/// MaybeFnLike wraps a method that indicates if an object
/// corresponds to some FnLikeNode.
Expand Down Expand Up @@ -98,15 +98,15 @@ impl<'a> Code<'a> {
pub fn from_node(node: Node) -> Option<Code> {
fn new(node: Node) -> FnLikeNode { FnLikeNode { node: node } }
match node {
ast_map::NodeItem(item) if item.is_fn_like() =>
Node::NodeItem(item) if item.is_fn_like() =>
Some(FnLikeCode(new(node))),
ast_map::NodeTraitItem(tm) if tm.is_fn_like() =>
Node::NodeTraitItem(tm) if tm.is_fn_like() =>
Some(FnLikeCode(new(node))),
ast_map::NodeImplItem(_) =>
Node::NodeImplItem(_) =>
Some(FnLikeCode(new(node))),
ast_map::NodeExpr(e) if e.is_fn_like() =>
Node::NodeExpr(e) if e.is_fn_like() =>
Some(FnLikeCode(new(node))),
ast_map::NodeBlock(block) =>
Node::NodeBlock(block) =>
Some(BlockCode(block)),
_ =>
None,
Expand Down Expand Up @@ -203,21 +203,21 @@ impl<'a> FnLikeNode<'a> {
C: FnOnce(ClosureParts<'a>) -> A,
{
match self.node {
ast_map::NodeItem(i) => match i.node {
Node::NodeItem(i) => match i.node {
ast::ItemFn(ref decl, unsafety, abi, ref generics, ref block) =>
item_fn(ItemFnParts{
ident: i.ident, decl: &**decl, unsafety: unsafety, body: &**block,
generics: generics, abi: abi, vis: i.vis, id: i.id, span: i.span
}),
_ => panic!("item FnLikeNode that is not fn-like"),
},
ast_map::NodeTraitItem(ti) => match ti.node {
Node::NodeTraitItem(ti) => match ti.node {
ast::MethodTraitItem(ref sig, Some(ref body)) => {
method(ti.id, ti.ident, sig, None, body, ti.span)
}
_ => panic!("trait method FnLikeNode that is not fn-like"),
},
ast_map::NodeImplItem(ii) => {
Node::NodeImplItem(ii) => {
match ii.node {
ast::MethodImplItem(ref sig, ref body) => {
method(ii.id, ii.ident, sig, Some(ii.vis), body, ii.span)
Expand All @@ -227,7 +227,7 @@ impl<'a> FnLikeNode<'a> {
}
}
}
ast_map::NodeExpr(e) => match e.node {
Node::NodeExpr(e) => match e.node {
ast::ExprClosure(_, ref decl, ref block) =>
closure(ClosureParts::new(&**decl, &**block, e.id, e.span)),
_ => panic!("expr FnLikeNode that is not fn-like"),
Expand Down
Loading

0 comments on commit 19f1a15

Please sign in to comment.