Skip to content

Commit 265452b

Browse files
committed
---
yaml --- r: 12955 b: refs/heads/master c: c0a36b7 h: refs/heads/master i: 12953: 5ac1699 12951: 9d2f966 v: v3
1 parent 60a4f0d commit 265452b

File tree

6 files changed

+65
-50
lines changed

6 files changed

+65
-50
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 98b93b6c86d6dc3db7e057866bb8a29a38cc7a3a
2+
refs/heads/master: c0a36b71be60e4dcb6fd5ef186a3fe9e694e4550
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/driver/driver.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
162162
time(time_passes, "ast indexing",
163163
bind syntax::ast_map::map_crate(sess.diagnostic(), *crate));
164164
time(time_passes, "external crate/lib resolution",
165-
bind creader::read_crates(sess, *crate));
165+
bind creader::read_crates(
166+
sess.diagnostic(), *crate, sess.cstore,
167+
sess.filesearch,
168+
session::sess_os_to_meta_os(sess.targ_cfg.os),
169+
sess.opts.static));
166170
let {def_map, exp_map, impl_map} =
167171
time(time_passes, "resolution",
168172
bind resolve::resolve_crate(sess, ast_map, crate));

trunk/src/rustc/metadata.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ mod back {
1414
}
1515

1616
mod driver {
17-
import session = driver_::session;
18-
export session;
1917
}
2018

2119
mod util {

trunk/src/rustc/metadata/creader.rs

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,28 @@ Validates all used crates and native libraries and loads their metadata
44
55
"];
66

7-
import driver::session;
8-
import session::session;
7+
import syntax::diagnostic::span_handler;
98
import syntax::{ast, ast_util};
109
import syntax::attr;
1110
import syntax::visit;
1211
import syntax::codemap::span;
1312
import std::map::{hashmap, int_hash};
1413
import syntax::print::pprust;
14+
import util::filesearch::filesearch;
1515
import common::*;
1616

1717
export read_crates;
1818

1919
// Traverses an AST, reading all the information about use'd crates and native
2020
// libraries necessary for later resolving, typechecking, linking, etc.
21-
fn read_crates(sess: session::session, crate: ast::crate) {
22-
let e = @{sess: sess,
21+
fn read_crates(diag: span_handler, crate: ast::crate,
22+
cstore: cstore::cstore, filesearch: filesearch,
23+
os: loader::os, static: bool) {
24+
let e = @{diag: diag,
25+
filesearch: filesearch,
26+
cstore: cstore,
27+
os: os,
28+
static: static,
2329
mut crate_cache: [],
2430
mut next_crate_num: 1};
2531
let v =
@@ -29,7 +35,7 @@ fn read_crates(sess: session::session, crate: ast::crate) {
2935
with *visit::default_simple_visitor()});
3036
visit::visit_crate(crate, (), v);
3137
dump_crates(e.crate_cache);
32-
warn_if_multiple_versions(sess, copy e.crate_cache);
38+
warn_if_multiple_versions(diag, copy e.crate_cache);
3339
}
3440

3541
type cache_entry = {
@@ -54,7 +60,7 @@ fn dump_crates(crate_cache: [cache_entry]) {
5460
}
5561
}
5662

57-
fn warn_if_multiple_versions(sess: session::session,
63+
fn warn_if_multiple_versions(diag: span_handler,
5864
crate_cache: [cache_entry]) {
5965
import either::*;
6066

@@ -73,21 +79,26 @@ fn warn_if_multiple_versions(sess: session::session,
7379
assert matches.is_not_empty();
7480

7581
if matches.len() != 1u {
76-
sess.warn(#fmt("using multiple versions of crate `%s`", name));
82+
diag.handler().warn(
83+
#fmt("using multiple versions of crate `%s`", name));
7784
for matches.each {|match|
78-
sess.span_note(match.span, "used here");
85+
diag.span_note(match.span, "used here");
7986
let attrs = [
8087
attr::mk_attr(attr::mk_list_item("link", *match.metas))
8188
];
82-
loader::note_linkage_attrs(sess, attrs);
89+
loader::note_linkage_attrs(diag, attrs);
8390
}
8491
}
8592

86-
warn_if_multiple_versions(sess, non_matches);
93+
warn_if_multiple_versions(diag, non_matches);
8794
}
8895
}
8996

90-
type env = @{sess: session::session,
97+
type env = @{diag: span_handler,
98+
filesearch: filesearch,
99+
cstore: cstore::cstore,
100+
os: loader::os,
101+
static: bool,
91102
mut crate_cache: [cache_entry],
92103
mut next_crate_num: ast::crate_num};
93104

@@ -96,7 +107,7 @@ fn visit_view_item(e: env, i: @ast::view_item) {
96107
ast::view_item_use(ident, meta_items, id) {
97108
#debug("resolving use stmt. ident: %?, meta: %?", ident, meta_items);
98109
let cnum = resolve_crate(e, ident, meta_items, "", i.span);
99-
cstore::add_use_stmt_cnum(e.sess.cstore, id, cnum);
110+
cstore::add_use_stmt_cnum(e.cstore, id, cnum);
100111
}
101112
_ { }
102113
}
@@ -110,15 +121,15 @@ fn visit_item(e: env, i: @ast::item) {
110121
if abi != ast::native_abi_cdecl &&
111122
abi != ast::native_abi_stdcall { ret; }
112123
}
113-
either::left(msg) { e.sess.span_fatal(i.span, msg); }
124+
either::left(msg) { e.diag.span_fatal(i.span, msg); }
114125
}
115126

116-
let cstore = e.sess.cstore;
127+
let cstore = e.cstore;
117128
let native_name =
118129
alt attr::first_attr_value_str_by_name(i.attrs, "link_name") {
119130
some(nn) {
120131
if nn == "" {
121-
e.sess.span_fatal(
132+
e.diag.span_fatal(
122133
i.span,
123134
"empty #[link_name] not allowed; use #[nolink].");
124135
}
@@ -132,7 +143,7 @@ fn visit_item(e: env, i: @ast::item) {
132143
}
133144
let link_args = attr::find_attrs_by_name(i.attrs, "link_args");
134145
if vec::len(link_args) > 0u && already_added {
135-
e.sess.span_fatal(i.span, "library '" + native_name +
146+
e.diag.span_fatal(i.span, "library '" + native_name +
136147
"' already added: can't specify link_args.");
137148
}
138149
for link_args.each {|a|
@@ -180,13 +191,14 @@ fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item],
180191
alt existing_match(e, metas, hash) {
181192
none {
182193
let load_ctxt: loader::ctxt = {
183-
sess: e.sess,
194+
diag: e.diag,
195+
filesearch: e.filesearch,
184196
span: span,
185197
ident: ident,
186198
metas: metas,
187199
hash: hash,
188-
os: session::sess_os_to_meta_os(e.sess.targ_cfg.os),
189-
static: e.sess.opts.static
200+
os: e.os,
201+
static: e.static
190202
};
191203
let cinfo = loader::load_library_crate(load_ctxt);
192204

@@ -214,7 +226,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item],
214226
let cmeta = @{name: cname, data: cdata,
215227
cnum_map: cnum_map, cnum: cnum};
216228

217-
let cstore = e.sess.cstore;
229+
let cstore = e.cstore;
218230
cstore::set_crate_data(cstore, cnum, cmeta);
219231
cstore::add_used_crate_file(cstore, cfilename);
220232
ret cnum;

trunk/src/rustc/metadata/csearch.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import syntax::ast_util;
66
import syntax::ast_map;
77
import middle::ty;
88
import option::{some, none};
9-
import driver::session;
10-
import driver::session::expect;
9+
import syntax::diagnostic::span_handler;
10+
import syntax::diagnostic::expect;
1111
import common::*;
1212
import std::map::hashmap;
1313

@@ -82,7 +82,7 @@ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num,
8282
}
8383

8484
fn get_item_path(tcx: ty::ctxt, def: ast::def_id) -> ast_map::path {
85-
let cstore = tcx.sess.cstore;
85+
let cstore = tcx.cstore;
8686
let cdata = cstore::get_crate_data(cstore, def.crate);
8787
let path = decoder::get_item_path(cdata, def.node);
8888

@@ -103,14 +103,14 @@ enum found_ast {
103103
fn maybe_get_item_ast(tcx: ty::ctxt, def: ast::def_id,
104104
decode_inlined_item: decoder::decode_inlined_item)
105105
-> found_ast {
106-
let cstore = tcx.sess.cstore;
106+
let cstore = tcx.cstore;
107107
let cdata = cstore::get_crate_data(cstore, def.crate);
108108
decoder::maybe_get_item_ast(cdata, tcx, def.node,
109109
decode_inlined_item)
110110
}
111111

112112
fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id) -> [ty::variant_info] {
113-
let cstore = tcx.sess.cstore;
113+
let cstore = tcx.cstore;
114114
let cdata = cstore::get_crate_data(cstore, def.crate);
115115
ret decoder::get_enum_variants(cdata, def.node, tcx)
116116
}
@@ -125,35 +125,35 @@ fn get_impls_for_mod(cstore: cstore::cstore, def: ast::def_id,
125125
}
126126

127127
fn get_iface_methods(tcx: ty::ctxt, def: ast::def_id) -> @[ty::method] {
128-
let cstore = tcx.sess.cstore;
128+
let cstore = tcx.cstore;
129129
let cdata = cstore::get_crate_data(cstore, def.crate);
130130
decoder::get_iface_methods(cdata, def.node, tcx)
131131
}
132132

133133
fn get_class_fields(tcx: ty::ctxt, def: ast::def_id) -> [ty::field_ty] {
134-
let cstore = tcx.sess.cstore;
134+
let cstore = tcx.cstore;
135135
let cdata = cstore::get_crate_data(cstore, def.crate);
136136
decoder::get_class_fields(cdata, def.node)
137137
}
138138

139139
fn get_type(tcx: ty::ctxt, def: ast::def_id) -> ty::ty_param_bounds_and_ty {
140-
let cstore = tcx.sess.cstore;
140+
let cstore = tcx.cstore;
141141
let cdata = cstore::get_crate_data(cstore, def.crate);
142142
decoder::get_type(cdata, def.node, tcx)
143143
}
144144

145145
fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id,
146146
def: ast::def_id) -> ty::ty_param_bounds_and_ty {
147-
let cstore = tcx.sess.cstore;
147+
let cstore = tcx.cstore;
148148
let cdata = cstore::get_crate_data(cstore, class_id.crate);
149149
let all_items = ebml::get_doc(ebml::doc(cdata.data), tag_items);
150150
#debug("Looking up %?", class_id);
151-
let class_doc = expect(tcx.sess,
151+
let class_doc = expect(tcx.diag,
152152
decoder::maybe_find_item(class_id.node, all_items),
153153
{|| #fmt("get_field_type: class ID %? not found",
154154
class_id)});
155155
#debug("looking up %? : %?", def, class_doc);
156-
let the_field = expect(tcx.sess,
156+
let the_field = expect(tcx.diag,
157157
decoder::maybe_find_item(def.node, class_doc),
158158
{|| #fmt("get_field_type: in class %?, field ID %? not found",
159159
class_id, def)});
@@ -165,7 +165,7 @@ fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id,
165165
// Given a def_id for an impl or class, return the iface it implements,
166166
// or none if it's not for an impl or for a class that implements ifaces
167167
fn get_impl_iface(tcx: ty::ctxt, def: ast::def_id) -> option<ty::t> {
168-
let cstore = tcx.sess.cstore;
168+
let cstore = tcx.cstore;
169169
let cdata = cstore::get_crate_data(cstore, def.crate);
170170
decoder::get_impl_iface(cdata, def.node, tcx)
171171
}

trunk/src/rustc/metadata/loader.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Finds crate binaries and loads their metadata
44
55
"];
66

7-
import driver::session;
8-
import session::session;
7+
import syntax::diagnostic::span_handler;
98
import syntax::{ast, attr};
109
import syntax::print::pprust;
1110
import syntax::codemap::span;
1211
import lib::llvm::{False, llvm, mk_object_file, mk_section_iter};
13-
import util::{filesearch};
12+
import util::filesearch;
13+
import filesearch::filesearch;
1414
import io::writer_util;
1515

1616
export os;
@@ -30,7 +30,8 @@ enum os {
3030
}
3131

3232
type ctxt = {
33-
sess: session,
33+
diag: span_handler,
34+
filesearch: filesearch,
3435
span: span,
3536
ident: ast::ident,
3637
metas: [@ast::meta_item],
@@ -43,15 +44,15 @@ fn load_library_crate(cx: ctxt) -> {ident: str, data: @[u8]} {
4344
alt find_library_crate(cx) {
4445
some(t) { ret t; }
4546
none {
46-
cx.sess.span_fatal(
47+
cx.diag.span_fatal(
4748
cx.span, #fmt["can't find crate for '%s'", cx.ident]);
4849
}
4950
}
5051
}
5152

5253
fn find_library_crate(cx: ctxt) -> option<{ident: str, data: @[u8]}> {
53-
attr::require_unique_names(cx.sess.diagnostic(), cx.metas);
54-
find_library_crate_aux(cx, libname(cx), cx.sess.filesearch)
54+
attr::require_unique_names(cx.diag, cx.metas);
55+
find_library_crate_aux(cx, libname(cx), cx.filesearch)
5556
}
5657

5758
fn libname(cx: ctxt) -> {prefix: str, suffix: str} {
@@ -106,15 +107,15 @@ fn find_library_crate_aux(cx: ctxt,
106107
} else if matches.len() == 1u {
107108
some(matches[0])
108109
} else {
109-
cx.sess.span_err(
110+
cx.diag.span_err(
110111
cx.span, #fmt("multiple matching crates for `%s`", crate_name));
111-
cx.sess.note("candidates:");
112+
cx.diag.handler().note("candidates:");
112113
for matches.each {|match|
113-
cx.sess.note(#fmt("path: %s", match.ident));
114+
cx.diag.handler().note(#fmt("path: %s", match.ident));
114115
let attrs = decoder::get_crate_attributes(match.data);
115-
note_linkage_attrs(cx.sess, attrs);
116+
note_linkage_attrs(cx.diag, attrs);
116117
}
117-
cx.sess.abort_if_errors();
118+
cx.diag.handler().abort_if_errors();
118119
none
119120
}
120121
}
@@ -134,9 +135,9 @@ fn crate_name_from_metas(metas: [@ast::meta_item]) -> str {
134135
}
135136
}
136137

137-
fn note_linkage_attrs(sess: session::session, attrs: [ast::attribute]) {
138+
fn note_linkage_attrs(diag: span_handler, attrs: [ast::attribute]) {
138139
for attr::find_linkage_attrs(attrs).each {|attr|
139-
sess.note(#fmt("meta: %s", pprust::attr_to_str(attr)));
140+
diag.handler().note(#fmt("meta: %s", pprust::attr_to_str(attr)));
140141
}
141142
}
142143

0 commit comments

Comments
 (0)