auto merge of #4979 : z0w0/rust/issue-1301, r=catamorphism

This commit is contained in:
bors 2013-02-18 13:50:36 -08:00
commit 1171a214a6
2 changed files with 17 additions and 2 deletions

View File

@ -55,6 +55,7 @@ pub fn read_crates(diag: span_handler,
visit_view_item: |a| visit_view_item(e, a), visit_view_item: |a| visit_view_item(e, a),
visit_item: |a| visit_item(e, a), visit_item: |a| visit_item(e, a),
.. *visit::default_simple_visitor()}); .. *visit::default_simple_visitor()});
visit_crate(e, crate);
visit::visit_crate(crate, (), v); visit::visit_crate(crate, (), v);
dump_crates(e.crate_cache); dump_crates(e.crate_cache);
warn_if_multiple_versions(e, diag, e.crate_cache); warn_if_multiple_versions(e, diag, e.crate_cache);
@ -125,6 +126,20 @@ struct Env {
intr: @ident_interner intr: @ident_interner
} }
fn visit_crate(e: @mut Env, c: ast::crate) {
let cstore = e.cstore;
let link_args = attr::find_attrs_by_name(c.node.attrs, "link_args");
for link_args.each |a| {
match attr::get_meta_item_value_str(attr::attr_meta(*a)) {
Some(ref linkarg) => {
cstore::add_used_link_args(cstore, (/*bad*/copy *linkarg));
}
None => {/* fallthrough */ }
}
}
}
fn visit_view_item(e: @mut Env, i: @ast::view_item) { fn visit_view_item(e: @mut Env, i: @ast::view_item) {
match /*bad*/copy i.node { match /*bad*/copy i.node {
ast::view_item_use(ident, meta_items, id) => { ast::view_item_use(ident, meta_items, id) => {
@ -181,7 +196,7 @@ fn visit_item(e: @mut Env, i: @ast::item) {
for link_args.each |a| { for link_args.each |a| {
match attr::get_meta_item_value_str(attr::attr_meta(*a)) { match attr::get_meta_item_value_str(attr::attr_meta(*a)) {
Some(ref linkarg) => { Some(ref linkarg) => {
cstore::add_used_link_args(cstore, (/*bad*/copy *linkarg)); cstore::add_used_link_args(cstore, *linkarg);
} }
None => {/* fallthrough */ } None => {/* fallthrough */ }
} }

View File

@ -119,7 +119,7 @@ pub fn get_used_libraries(cstore: @mut CStore) -> ~[~str] {
return /*bad*/copy cstore.used_libraries; return /*bad*/copy cstore.used_libraries;
} }
pub fn add_used_link_args(cstore: @mut CStore, args: ~str) { pub fn add_used_link_args(cstore: @mut CStore, args: &str) {
cstore.used_link_args.push_all(str::split_char(args, ' ')); cstore.used_link_args.push_all(str::split_char(args, ' '));
} }