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 Apr 24, 2015
1 parent 6b29a7d commit 7ea8f33
Show file tree
Hide file tree
Showing 44 changed files with 115 additions and 77 deletions.
26 changes: 14 additions & 12 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ TARGET_CRATES := libc std flate arena term \
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
SYNTAX_CRATES := syntax syntax_ast_map
HOST_CRATES := $(SYNTAX_CRATES) $(RUSTC_CRATES) rustdoc fmt_macros
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
TOOLS := compiletest rustdoc rustc rustbook

Expand All @@ -68,24 +69,25 @@ 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_syntax_ast_map := std arena syntax
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_typeck rustc_resolve log syntax syntax_ast_map serialize \
rustc_llvm rustc_trans rustc_privacy rustc_lint

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
DEPS_rustc := syntax flate arena serialize getopts rbml \
log syntax syntax_ast_map serialize rustc_llvm
DEPS_rustc_typeck := rustc syntax syntax_ast_map
DEPS_rustc_borrowck := rustc log graphviz syntax syntax_ast_map
DEPS_rustc_resolve := rustc log syntax syntax_ast_map
DEPS_rustc_privacy := rustc log syntax syntax_ast_map
DEPS_rustc_lint := rustc log syntax syntax_ast_map
DEPS_rustc := syntax syntax_ast_map flate arena serialize getopts rbml \
log graphviz rustc_llvm rustc_back rustc_data_structures
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_rustdoc := rustc rustc_driver native:hoedown syntax syntax_ast_map serialize getopts \
test rustc_lint
DEPS_rustc_bitflags := core
DEPS_flate := std native:miniz
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ extern crate rbml;
extern crate collections;
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate syntax_ast_map;
#[macro_use] #[no_link] extern crate rustc_bitflags;

extern crate serialize as rustc_serialize; // used by deriving
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 @@ -21,11 +21,11 @@ use rbml;
use rbml::reader;
use std::rc::Rc;
use syntax::ast;
use syntax::ast_map;
use syntax::attr;
use syntax::attr::AttrMetaMethods;
use syntax::diagnostic::expect;
use syntax::parse::token;
use syntax_ast_map as ast_map;

use std::collections::hash_map::HashMap;

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 @@ -42,14 +42,14 @@ use std::str;
use rbml::reader;
use rbml;
use serialize::Decodable;
use syntax::ast_map;
use syntax::attr;
use syntax::parse::token::{IdentInterner, special_idents};
use syntax::parse::token;
use syntax::print::pprust;
use syntax::ast;
use syntax::codemap;
use syntax::ptr::P;
use syntax_ast_map as ast_map;

pub type Cmd<'a> = &'a crate_metadata;

Expand Down
3 changes: 2 additions & 1 deletion src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use std::io::prelude::*;
use std::io::{Cursor, SeekFrom};
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,6 +46,8 @@ use syntax::ptr::P;
use syntax::visit::Visitor;
use syntax::visit;
use syntax;
use syntax_ast_map as ast_map;
use syntax_ast_map::{LinkedPath, PathElem, PathElems};
use rbml::writer::Encoder;

/// A borrowed version of `ast::InlinedItem`.
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ 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::{ast, ast_util, codemap, fold};
use syntax::codemap::Span;
use syntax::fold::Folder;
use syntax::parse::token;
use syntax::ptr::P;
use syntax;
use syntax_ast_map as ast_map;

use std::cell::Cell;
use std::io::SeekFrom;
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 @@ -17,7 +17,7 @@ use std::borrow::IntoCow;
use graphviz as dot;

use syntax::ast;
use syntax::ast_map;
use syntax_ast_map as 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 @@ -15,9 +15,10 @@ use session::Session;
use middle::def::{DefStatic, DefConst, DefMap};

use syntax::ast;
use syntax::{ast_util, ast_map};
use syntax::ast_util;
use syntax::visit::Visitor;
use syntax::visit;
use syntax_ast_map as ast_map;

struct CheckCrateVisitor<'a, 'ast: 'a> {
sess: &'a Session,
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 @@ -27,7 +27,8 @@ 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 syntax_ast_map as ast_map;

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,10 +17,11 @@ use lint;
use util::nodemap::NodeSet;

use std::collections::HashSet;
use syntax::{ast, ast_map, codemap};
use syntax::{ast, codemap};
use syntax::ast_util::{local_def, is_local};
use syntax::attr::{self, AttrMetaMethods};
use syntax::visit::{self, Visitor};
use syntax_ast_map as ast_map;

// Any local node that may call something in its body block should be
// explored. For example, if it's a live NodeItem that is a
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 @@ -11,12 +11,12 @@

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;
use syntax::visit;
use syntax::visit::Visitor;
use syntax_ast_map as ast_map;

struct EntryContext<'a, 'ast: 'a> {
session: &'a Session,
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 @@ -82,13 +82,13 @@ use std::char::from_u32;
use std::rc::Rc;
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;
use syntax::parse::token;
use syntax::print::pprust;
use syntax::ptr::P;
use syntax_ast_map as ast_map;
use util::ppaux::bound_region_to_string;
use util::ppaux::note_and_explain_region;

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 @@ -18,11 +18,11 @@ use util::ppaux::Repr;
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;
use syntax::visit;
use syntax_ast_map::NodeForeignItem;

pub fn check_crate(tcx: &ctxt) {
let mut visitor = IntrinsicCheckingVisitor {
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 @@ -82,10 +82,10 @@ use util::ppaux::{Repr, UserString};

use syntax::ast::{MutImmutable, MutMutable};
use syntax::ast;
use syntax::ast_map;
use syntax::codemap::Span;
use syntax::print::pprust;
use syntax::parse::token;
use syntax_ast_map as ast_map;

use std::cell::RefCell;
use std::rc::Rc;
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 @@ -24,11 +24,11 @@ use util::nodemap::NodeSet;
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;
use syntax::visit;
use syntax_ast_map as ast_map;

// Returns true if the given set of generics implies that the item it's
// associated with must be inlined.
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 @@ -26,9 +26,9 @@ 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};
use syntax_ast_map as ast_map;

/// CodeExtent represents a statically-describable extent that can be
/// used to bound the lifetime/region for values.
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 @@ -88,7 +88,8 @@ 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};
use syntax_ast_map as ast_map;
use syntax_ast_map::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 @@ -31,13 +31,13 @@ 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;
use syntax::ptr::P;
use syntax::{ast, ast_util};
use syntax::owned_slice::OwnedSlice;
use syntax_ast_map as ast_map;

/// Produces a string suitable for debugging output.
pub trait Repr<'tcx> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ use rustc::util::ppaux::{note_and_explain_region, Repr, UserString};
use std::rc::Rc;
use std::string::String;
use syntax::ast;
use syntax::ast_map;
use syntax::ast_map::blocks::{FnLikeNode, FnParts};
use syntax::ast_util;
use syntax::codemap::Span;
use syntax::parse::token;
use syntax::visit;
use syntax::visit::{Visitor, FnKind};
use syntax::ast::{FnDecl, Block, NodeId};
use syntax_ast_map as ast_map;
use syntax_ast_map::blocks::{FnLikeNode, FnParts};

pub mod check_loans;

Expand Down
1 change: 1 addition & 0 deletions src/librustc_borrowck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate syntax_ast_map;

// for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
// refers to the borrowck-specific graphviz adapter traits.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ use std::fs;
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use syntax::ast;
use syntax::ast_map;
use syntax::attr;
use syntax::attr::AttrMetaMethods;
use syntax::diagnostics;
use syntax::parse;
use syntax::parse::token;
use syntax;
use syntax_ast_map as ast_map;

pub fn compile_input(sess: Session,
cfg: ast::CrateConfig,
Expand Down
1 change: 1 addition & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern crate serialize;
extern crate rustc_llvm as llvm;
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate syntax_ast_map;

pub use syntax::diagnostic;

Expand Down
3 changes: 2 additions & 1 deletion src/librustc_driver/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ use rustc_borrowck::graphviz as borrowck_dot;
use rustc_resolve as resolve;

use syntax::ast;
use syntax::ast_map::{self, blocks, NodePrinter};
use syntax::codemap;
use syntax::fold::{self, Folder};
use syntax::print::{pp, pprust};
use syntax::ptr::P;
use syntax_ast_map as ast_map;
use syntax_ast_map::{blocks, NodePrinter};

use graphviz as dot;

Expand Down
3 changes: 2 additions & 1 deletion src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::{cmp, slice};
use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};

use syntax::{abi, ast, ast_map};
use syntax::{abi, ast};
use syntax::ast_util::{self, is_shift_binop, local_def};
use syntax::attr::{self, AttrMetaMethods};
use syntax::codemap::{self, Span};
Expand All @@ -53,6 +53,7 @@ use syntax::parse::token;
use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
use syntax::ptr::P;
use syntax::visit::{self, Visitor};
use syntax_ast_map as ast_map;

// hardwired lints from librustc
pub use lint::builtin::*;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#![cfg_attr(test, feature(test))]

extern crate syntax;
extern crate syntax_ast_map;
#[macro_use]
extern crate rustc;
#[macro_use]
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate syntax_ast_map;

extern crate rustc;

Expand All @@ -46,11 +47,12 @@ use rustc::middle::ty::MethodTraitObject;
use rustc::middle::ty::{self, Ty};
use rustc::util::nodemap::{NodeMap, NodeSet};

use syntax::{ast, ast_map};
use syntax::ast;
use syntax::ast_util::{is_local, local_def};
use syntax::codemap::Span;
use syntax::parse::token;
use syntax::visit::{self, Visitor};
use syntax_ast_map as ast_map;

type Context<'a, 'tcx> = (&'a MethodMap<'tcx>, &'a def::ExportMap);

Expand Down
3 changes: 2 additions & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate syntax_ast_map;
#[macro_use] #[no_link] extern crate rustc_bitflags;

extern crate rustc;
Expand Down Expand Up @@ -77,14 +78,14 @@ use syntax::ast::{TyPath, TyPtr};
use syntax::ast::{TyRptr, TyStr, TyUs, TyU8, TyU16, TyU32, TyU64, TyUint};
use syntax::ast::TypeImplItem;
use syntax::ast;
use syntax::ast_map;
use syntax::ast_util::{local_def, walk_pat};
use syntax::attr::AttrMetaMethods;
use syntax::ext::mtwt;
use syntax::parse::token::{self, special_names, special_idents};
use syntax::ptr::P;
use syntax::codemap::{self, Span, Pos};
use syntax::visit::{self, Visitor};
use syntax_ast_map as ast_map;

use std::collections::{HashMap, HashSet};
use std::collections::hash_map::Entry::{Occupied, Vacant};
Expand Down
Loading

0 comments on commit 7ea8f33

Please sign in to comment.