Replace FileSearch::for_each_lib_search_path with search_paths.

Returning an iterator leads to nicer code all around.
This commit is contained in:
Nicholas Nethercote 2018-11-23 13:36:41 +11:00
parent 2bfe32cc93
commit 95a6262df1
3 changed files with 22 additions and 32 deletions

View file

@ -212,12 +212,7 @@ fn link_binary_output(sess: &Session,
}
fn archive_search_paths(sess: &Session) -> Vec<PathBuf> {
let mut search = Vec::new();
sess.target_filesearch(PathKind::Native).for_each_lib_search_path(|search_path| {
search.push(search_path.dir.to_path_buf());
});
search
sess.target_filesearch(PathKind::Native).search_path_dirs()
}
fn archive_config<'a>(sess: &'a Session,
@ -1067,12 +1062,13 @@ fn link_args(cmd: &mut dyn Linker,
fn add_local_native_libraries(cmd: &mut dyn Linker,
sess: &Session,
codegen_results: &CodegenResults) {
sess.target_filesearch(PathKind::All).for_each_lib_search_path(|search_path| {
let filesearch = sess.target_filesearch(PathKind::All);
for search_path in filesearch.search_paths() {
match search_path.kind {
PathKind::Framework => { cmd.framework_path(&search_path.dir); }
_ => { cmd.include_path(&fix_windows_verbatim_for_gcc(&search_path.dir)); }
}
});
}
let relevant_libs = codegen_results.crate_info.used_libraries.iter().filter(|l| {
relevant_lib(sess, l)