rustc: Remove ast_map's session dependency
This commit is contained in:
parent
611890013f
commit
df532e7f1b
@ -160,7 +160,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
|
||||
|
||||
let ast_map =
|
||||
time(time_passes, "ast indexing",
|
||||
bind middle::ast_map::map_crate(sess, *crate));
|
||||
bind middle::ast_map::map_crate(sess.diagnostic(), *crate));
|
||||
time(time_passes, "external crate/lib resolution",
|
||||
bind creader::read_crates(sess, *crate));
|
||||
let {def_map, exp_map, impl_map} =
|
||||
|
@ -6,8 +6,8 @@ import syntax::ast_util;
|
||||
import syntax::ast_util::path_to_ident;
|
||||
import syntax::ast_util::inlined_item_methods;
|
||||
import syntax::{visit, codemap};
|
||||
import driver::session::session;
|
||||
import syntax::attr;
|
||||
import syntax::diagnostic::span_handler;
|
||||
|
||||
enum path_elt { path_mod(str), path_name(str) }
|
||||
type path = [path_elt];
|
||||
@ -59,7 +59,7 @@ enum a_ctor {
|
||||
|
||||
type map = std::map::hashmap<node_id, ast_node>;
|
||||
type ctx = {map: map, mut path: path,
|
||||
mut local_id: uint, sess: session};
|
||||
mut local_id: uint, diag: span_handler};
|
||||
type vt = visit::vt<ctx>;
|
||||
|
||||
fn extend(cx: ctx, elt: str) -> @path {
|
||||
@ -79,11 +79,11 @@ fn mk_ast_map_visitor() -> vt {
|
||||
});
|
||||
}
|
||||
|
||||
fn map_crate(sess: session, c: crate) -> map {
|
||||
fn map_crate(diag: span_handler, c: crate) -> map {
|
||||
let cx = {map: std::map::int_hash(),
|
||||
mut path: [],
|
||||
mut local_id: 0u,
|
||||
sess: sess};
|
||||
diag: diag};
|
||||
visit::visit_crate(c, cx, mk_ast_map_visitor());
|
||||
ret cx.map;
|
||||
}
|
||||
@ -91,7 +91,8 @@ fn map_crate(sess: session, c: crate) -> map {
|
||||
// Used for items loaded from external crate that are being inlined into this
|
||||
// crate. The `path` should be the path to the item but should not include
|
||||
// the item itself.
|
||||
fn map_decoded_item(sess: session, map: map, path: path, ii: inlined_item) {
|
||||
fn map_decoded_item(diag: span_handler,
|
||||
map: map, path: path, ii: inlined_item) {
|
||||
// I believe it is ok for the local IDs of inlined items from other crates
|
||||
// to overlap with the local ids from this crate, so just generate the ids
|
||||
// starting from 0. (In particular, I think these ids are only used in
|
||||
@ -101,7 +102,7 @@ fn map_decoded_item(sess: session, map: map, path: path, ii: inlined_item) {
|
||||
let cx = {map: map,
|
||||
mut path: path,
|
||||
mut local_id: 0u,
|
||||
sess: sess};
|
||||
diag: diag};
|
||||
let v = mk_ast_map_visitor();
|
||||
|
||||
// methods get added to the AST map when their impl is visited. Since we
|
||||
@ -205,7 +206,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
|
||||
}
|
||||
item_native_mod(nm) {
|
||||
let abi = alt attr::native_abi(i.attrs) {
|
||||
either::left(msg) { cx.sess.span_fatal(i.span, msg); }
|
||||
either::left(msg) { cx.diag.span_fatal(i.span, msg); }
|
||||
either::right(abi) { abi }
|
||||
};
|
||||
for nm.items.each {|nitem|
|
||||
|
@ -115,7 +115,8 @@ fn decode_inlined_item(cdata: cstore::crate_metadata,
|
||||
to_id_range: to_id_range};
|
||||
let raw_ii = decode_ast(ast_doc);
|
||||
let ii = renumber_ast(xcx, raw_ii);
|
||||
ast_map::map_decoded_item(tcx.sess, dcx.tcx.items, path, ii);
|
||||
ast_map::map_decoded_item(tcx.sess.diagnostic(),
|
||||
dcx.tcx.items, path, ii);
|
||||
#debug["Fn named: %s", ii.ident()];
|
||||
decode_side_tables(xcx, ast_doc);
|
||||
#debug["< Decoded inlined fn: %s::%s",
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
import std::map::hashmap;
|
||||
import rustc::driver::session;
|
||||
import session::session;
|
||||
import rustc::driver::driver;
|
||||
import syntax::diagnostic;
|
||||
import syntax::diagnostic::handler;
|
||||
@ -110,7 +111,7 @@ fn build_ctxt(sess: session::session, ast: @ast::crate,
|
||||
|
||||
let ast = config::strip_unconfigured_items(ast);
|
||||
let ast = front::test::modify_for_testing(sess, ast);
|
||||
let ast_map = ast_map::map_crate(sess, *ast);
|
||||
let ast_map = ast_map::map_crate(sess.diagnostic(), *ast);
|
||||
*ignore_errors = true;
|
||||
let {exp_map, impl_map, _} = resolve::resolve_crate(sess, ast_map, ast);
|
||||
*ignore_errors = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user