Skip to content

Commit 003c35e

Browse files
committed
Fix tests and have rustpkg inject pkgid instead of link meta.
1 parent 7408c14 commit 003c35e

File tree

6 files changed

+12
-83
lines changed

6 files changed

+12
-83
lines changed

src/librustpkg/util.rs

+9-16
Original file line numberDiff line numberDiff line change
@@ -290,23 +290,16 @@ pub fn compile_input(context: &BuildContext,
290290
addl_lib_search_paths.insert(p);
291291
});
292292

293-
// Inject the link attributes so we get the right package name and version
294-
if attr::find_linkage_metas(crate.attrs).is_empty() {
295-
let name_to_use = match what {
296-
Test => format!("{}test", pkg_id.short_name).to_managed(),
297-
Bench => format!("{}bench", pkg_id.short_name).to_managed(),
298-
_ => pkg_id.short_name.to_managed()
299-
};
300-
debug!("Injecting link name: {}", name_to_use);
293+
// Inject the pkgid attribute so we get the right package name and version
294+
295+
if !attr::contains_name(crate.attrs, "pkgid") {
301296
// FIXME (#9639): This needs to handle non-utf8 paths
302-
let link_options =
303-
~[attr::mk_name_value_item_str(@"name", name_to_use),
304-
attr::mk_name_value_item_str(@"vers", pkg_id.version.to_str().to_managed())] +
305-
~[attr::mk_name_value_item_str(@"package_id",
306-
pkg_id.path.as_str().unwrap().to_managed())];
307-
308-
debug!("link options: {:?}", link_options);
309-
crate.attrs = ~[attr::mk_attr(attr::mk_list_item(@"link", link_options))];
297+
let pkgid_attr =
298+
attr::mk_name_value_item_str(@"pkgid",
299+
pkg_id.path.as_str().unwrap().to_managed());
300+
301+
debug!("pkgid attr: {:?}", pkgid_attr);
302+
crate.attrs = ~[attr::mk_attr(pkgid_attr)];
310303
}
311304

312305
debug!("calling compile_crate_from_input, workspace = {},

src/test/compile-fail/dup-link-name.rs

-17
This file was deleted.

src/test/run-pass/crateresolve6.rs

-25
This file was deleted.

src/test/run-pass/crateresolve7.rs

-22
This file was deleted.

src/test/run-pass/crateresolve8.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#[pkgid="crateresolve8#0.1"];
1515

16-
extern mod crateresolve8(vers = "0.1", package_id="crateresolve8");
16+
extern mod crateresolve8(vers = "0.1", package_id="crateresolve8#0.1");
1717
//extern mod crateresolve8(vers = "0.1");
1818

1919
pub fn main() {

src/test/run-pass/issue-6919.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
#[pkgid="issue-6919"];
1515

16-
extern mod iss ( name = "iss6919_3" );
16+
extern mod issue6919_3;
1717

1818
pub fn main() {
19-
iss::D.k;
19+
issue6919_3::D.k;
2020
}
2121

0 commit comments

Comments
 (0)