Skip to content

Commit

Permalink
auto merge of #4979 : z0w0/rust/issue-1301, r=catamorphism
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Feb 18, 2013
2 parents a2068f1 + 0991437 commit 1171a21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub fn read_crates(diag: span_handler,
visit_view_item: |a| visit_view_item(e, a),
visit_item: |a| visit_item(e, a),
.. *visit::default_simple_visitor()});
visit_crate(e, crate);
visit::visit_crate(crate, (), v);
dump_crates(e.crate_cache);
warn_if_multiple_versions(e, diag, e.crate_cache);
Expand Down Expand Up @@ -125,6 +126,20 @@ struct Env {
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) {
match /*bad*/copy i.node {
ast::view_item_use(ident, meta_items, id) => {
Expand Down Expand Up @@ -181,7 +196,7 @@ fn visit_item(e: @mut Env, i: @ast::item) {
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));
cstore::add_used_link_args(cstore, *linkarg);
}
None => {/* fallthrough */ }
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub fn get_used_libraries(cstore: @mut CStore) -> ~[~str] {
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, ' '));
}

Expand Down

0 comments on commit 1171a21

Please sign in to comment.