Skip to content

Commit 33ee731

Browse files
committed
Remove some redundancy in metadata::creader
1 parent d91b7b6 commit 33ee731

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/comp/driver/rustc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ mod test {
536536
alt getopts::getopts(["--test"], opts()) {
537537
getopts::success(m) { m }
538538
};
539-
let sessopts = build_session_options("whatever", match);
540-
let sess = build_session(sessopts);
539+
let sessopts = build_session_options(match);
540+
let sess = build_session("whatever", sessopts);
541541
let cfg = build_configuration(sess, "whatever", "whatever");
542542
assert (attr::contains_name(cfg, "test"));
543543
}
@@ -550,8 +550,8 @@ mod test {
550550
alt getopts::getopts(["--test", "--cfg=test"], opts()) {
551551
getopts::success(m) { m }
552552
};
553-
let sessopts = build_session_options("whatever", match);
554-
let sess = build_session(sessopts);
553+
let sessopts = build_session_options(match);
554+
let sess = build_session("whatever", sessopts);
555555
let cfg = build_configuration(sess, "whatever", "whatever");
556556
let test_items = attr::find_meta_items_by_name(cfg, "test");
557557
assert (vec::len(test_items) == 1u);

src/comp/metadata/creader.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ fn read_crates(sess: session::session, crate: ast::crate) {
2424
let e =
2525
@{sess: sess,
2626
crate_cache: @std::map::new_str_hash::<int>(),
27-
library_search_paths: sess.filesearch().lib_search_paths(),
2827
mutable next_crate_num: 1};
2928
let v =
3029
visit::mk_simple_visitor(@{visit_view_item:
@@ -37,7 +36,6 @@ fn read_crates(sess: session::session, crate: ast::crate) {
3736
type env =
3837
@{sess: session::session,
3938
crate_cache: @hashmap<str, int>,
40-
library_search_paths: [fs::path],
4139
mutable next_crate_num: ast::crate_num};
4240

4341
fn visit_view_item(e: env, i: @ast::view_item) {
@@ -109,7 +107,7 @@ fn default_native_lib_naming(sess: session::session, static: bool) ->
109107
}
110108

111109
fn find_library_crate(sess: session::session, ident: ast::ident,
112-
metas: [@ast::meta_item], library_search_paths: [str])
110+
metas: [@ast::meta_item])
113111
-> option::t<{ident: str, data: @[u8]}> {
114112

115113
attr::require_unique_names(sess, metas);
@@ -132,10 +130,12 @@ fn find_library_crate(sess: session::session, ident: ast::ident,
132130

133131
let nn = default_native_lib_naming(sess, sess.get_opts().static);
134132
let x =
135-
find_library_crate_aux(nn, crate_name, metas, library_search_paths);
133+
find_library_crate_aux(nn, crate_name, metas,
134+
sess.filesearch().lib_search_paths());
136135
if x != none || sess.get_opts().static { ret x; }
137136
let nn2 = default_native_lib_naming(sess, true);
138-
ret find_library_crate_aux(nn2, crate_name, metas, library_search_paths);
137+
ret find_library_crate_aux(nn2, crate_name, metas,
138+
sess.filesearch().lib_search_paths());
139139
}
140140

141141
fn find_library_crate_aux(nn: {prefix: str, suffix: str}, crate_name: str,
@@ -198,11 +198,11 @@ fn get_metadata_section(filename: str) -> option::t<@[u8]> {
198198
}
199199

200200
fn load_library_crate(sess: session::session, span: span, ident: ast::ident,
201-
metas: [@ast::meta_item], library_search_paths: [str])
201+
metas: [@ast::meta_item])
202202
-> {ident: str, data: @[u8]} {
203203

204204

205-
alt find_library_crate(sess, ident, metas, library_search_paths) {
205+
alt find_library_crate(sess, ident, metas) {
206206
some(t) { ret t; }
207207
none. {
208208
sess.span_fatal(span, #fmt["can't find crate for '%s'", ident]);
@@ -214,8 +214,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item],
214214
span: span) -> ast::crate_num {
215215
if !e.crate_cache.contains_key(ident) {
216216
let cinfo =
217-
load_library_crate(e.sess, span, ident, metas,
218-
e.library_search_paths);
217+
load_library_crate(e.sess, span, ident, metas);
219218

220219
let cfilename = cinfo.ident;
221220
let cdata = cinfo.data;

0 commit comments

Comments
 (0)