From 33ee73102df243e4b794b81c2e53ba6f222b2f60 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 3 Oct 2011 13:13:21 -0700 Subject: [PATCH] Remove some redundancy in metadata::creader --- src/comp/driver/rustc.rs | 8 ++++---- src/comp/metadata/creader.rs | 17 ++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 70007240b63..b6e72175e15 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -536,8 +536,8 @@ mod test { alt getopts::getopts(["--test"], opts()) { getopts::success(m) { m } }; - let sessopts = build_session_options("whatever", match); - let sess = build_session(sessopts); + let sessopts = build_session_options(match); + let sess = build_session("whatever", sessopts); let cfg = build_configuration(sess, "whatever", "whatever"); assert (attr::contains_name(cfg, "test")); } @@ -550,8 +550,8 @@ mod test { alt getopts::getopts(["--test", "--cfg=test"], opts()) { getopts::success(m) { m } }; - let sessopts = build_session_options("whatever", match); - let sess = build_session(sessopts); + let sessopts = build_session_options(match); + let sess = build_session("whatever", sessopts); let cfg = build_configuration(sess, "whatever", "whatever"); let test_items = attr::find_meta_items_by_name(cfg, "test"); assert (vec::len(test_items) == 1u); diff --git a/src/comp/metadata/creader.rs b/src/comp/metadata/creader.rs index 9589a504c47..ccded566cfd 100644 --- a/src/comp/metadata/creader.rs +++ b/src/comp/metadata/creader.rs @@ -24,7 +24,6 @@ fn read_crates(sess: session::session, crate: ast::crate) { let e = @{sess: sess, crate_cache: @std::map::new_str_hash::(), - library_search_paths: sess.filesearch().lib_search_paths(), mutable next_crate_num: 1}; let v = visit::mk_simple_visitor(@{visit_view_item: @@ -37,7 +36,6 @@ fn read_crates(sess: session::session, crate: ast::crate) { type env = @{sess: session::session, crate_cache: @hashmap, - library_search_paths: [fs::path], mutable next_crate_num: ast::crate_num}; fn visit_view_item(e: env, i: @ast::view_item) { @@ -109,7 +107,7 @@ fn default_native_lib_naming(sess: session::session, static: bool) -> } fn find_library_crate(sess: session::session, ident: ast::ident, - metas: [@ast::meta_item], library_search_paths: [str]) + metas: [@ast::meta_item]) -> option::t<{ident: str, data: @[u8]}> { attr::require_unique_names(sess, metas); @@ -132,10 +130,12 @@ fn find_library_crate(sess: session::session, ident: ast::ident, let nn = default_native_lib_naming(sess, sess.get_opts().static); let x = - find_library_crate_aux(nn, crate_name, metas, library_search_paths); + find_library_crate_aux(nn, crate_name, metas, + sess.filesearch().lib_search_paths()); if x != none || sess.get_opts().static { ret x; } let nn2 = default_native_lib_naming(sess, true); - ret find_library_crate_aux(nn2, crate_name, metas, library_search_paths); + ret find_library_crate_aux(nn2, crate_name, metas, + sess.filesearch().lib_search_paths()); } 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]> { } fn load_library_crate(sess: session::session, span: span, ident: ast::ident, - metas: [@ast::meta_item], library_search_paths: [str]) + metas: [@ast::meta_item]) -> {ident: str, data: @[u8]} { - alt find_library_crate(sess, ident, metas, library_search_paths) { + alt find_library_crate(sess, ident, metas) { some(t) { ret t; } none. { 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], span: span) -> ast::crate_num { if !e.crate_cache.contains_key(ident) { let cinfo = - load_library_crate(e.sess, span, ident, metas, - e.library_search_paths); + load_library_crate(e.sess, span, ident, metas); let cfilename = cinfo.ident; let cdata = cinfo.data;