Skip to content

Commit df532e7

Browse files
committed
rustc: Remove ast_map's session dependency
1 parent 6118900 commit df532e7

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/rustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
160160

161161
let ast_map =
162162
time(time_passes, "ast indexing",
163-
bind middle::ast_map::map_crate(sess, *crate));
163+
bind middle::ast_map::map_crate(sess.diagnostic(), *crate));
164164
time(time_passes, "external crate/lib resolution",
165165
bind creader::read_crates(sess, *crate));
166166
let {def_map, exp_map, impl_map} =

src/rustc/middle/ast_map.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import syntax::ast_util;
66
import syntax::ast_util::path_to_ident;
77
import syntax::ast_util::inlined_item_methods;
88
import syntax::{visit, codemap};
9-
import driver::session::session;
109
import syntax::attr;
10+
import syntax::diagnostic::span_handler;
1111

1212
enum path_elt { path_mod(str), path_name(str) }
1313
type path = [path_elt];
@@ -59,7 +59,7 @@ enum a_ctor {
5959

6060
type map = std::map::hashmap<node_id, ast_node>;
6161
type ctx = {map: map, mut path: path,
62-
mut local_id: uint, sess: session};
62+
mut local_id: uint, diag: span_handler};
6363
type vt = visit::vt<ctx>;
6464

6565
fn extend(cx: ctx, elt: str) -> @path {
@@ -79,19 +79,20 @@ fn mk_ast_map_visitor() -> vt {
7979
});
8080
}
8181

82-
fn map_crate(sess: session, c: crate) -> map {
82+
fn map_crate(diag: span_handler, c: crate) -> map {
8383
let cx = {map: std::map::int_hash(),
8484
mut path: [],
8585
mut local_id: 0u,
86-
sess: sess};
86+
diag: diag};
8787
visit::visit_crate(c, cx, mk_ast_map_visitor());
8888
ret cx.map;
8989
}
9090

9191
// Used for items loaded from external crate that are being inlined into this
9292
// crate. The `path` should be the path to the item but should not include
9393
// the item itself.
94-
fn map_decoded_item(sess: session, map: map, path: path, ii: inlined_item) {
94+
fn map_decoded_item(diag: span_handler,
95+
map: map, path: path, ii: inlined_item) {
9596
// I believe it is ok for the local IDs of inlined items from other crates
9697
// to overlap with the local ids from this crate, so just generate the ids
9798
// 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) {
101102
let cx = {map: map,
102103
mut path: path,
103104
mut local_id: 0u,
104-
sess: sess};
105+
diag: diag};
105106
let v = mk_ast_map_visitor();
106107

107108
// 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) {
205206
}
206207
item_native_mod(nm) {
207208
let abi = alt attr::native_abi(i.attrs) {
208-
either::left(msg) { cx.sess.span_fatal(i.span, msg); }
209+
either::left(msg) { cx.diag.span_fatal(i.span, msg); }
209210
either::right(abi) { abi }
210211
};
211212
for nm.items.each {|nitem|

src/rustc/middle/astencode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ fn decode_inlined_item(cdata: cstore::crate_metadata,
115115
to_id_range: to_id_range};
116116
let raw_ii = decode_ast(ast_doc);
117117
let ii = renumber_ast(xcx, raw_ii);
118-
ast_map::map_decoded_item(tcx.sess, dcx.tcx.items, path, ii);
118+
ast_map::map_decoded_item(tcx.sess.diagnostic(),
119+
dcx.tcx.items, path, ii);
119120
#debug["Fn named: %s", ii.ident()];
120121
decode_side_tables(xcx, ast_doc);
121122
#debug["< Decoded inlined fn: %s::%s",

src/rustdoc/astsrv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import std::map::hashmap;
1111
import rustc::driver::session;
12+
import session::session;
1213
import rustc::driver::driver;
1314
import syntax::diagnostic;
1415
import syntax::diagnostic::handler;
@@ -110,7 +111,7 @@ fn build_ctxt(sess: session::session, ast: @ast::crate,
110111

111112
let ast = config::strip_unconfigured_items(ast);
112113
let ast = front::test::modify_for_testing(sess, ast);
113-
let ast_map = ast_map::map_crate(sess, *ast);
114+
let ast_map = ast_map::map_crate(sess.diagnostic(), *ast);
114115
*ignore_errors = true;
115116
let {exp_map, impl_map, _} = resolve::resolve_crate(sess, ast_map, ast);
116117
*ignore_errors = false;

0 commit comments

Comments
 (0)