Skip to content

Commit a6e748a

Browse files
committed
rustc: Hash the CMH into symbol names
1 parent 0094ffd commit a6e748a

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

src/rustc/back/link.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,7 @@ fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: ty::t, link_meta: link_meta) ->
420420
sha.reset();
421421
sha.input_str(link_meta.name);
422422
sha.input_str("-");
423-
// FIXME: This wants to be link_meta.meta_hash
424-
sha.input_str(link_meta.name);
423+
sha.input_str(link_meta.extras_hash);
425424
sha.input_str("-");
426425
sha.input_str(encoder::encoded_ty(tcx, t));
427426
let hash = truncated_sha1_result(sha);

src/test/auxiliary/crateresolve6-1.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[link(name = "crateresolve6",
2+
vers = "0.1",
3+
calories = "100")];
4+
5+
#[crate_type = "lib"];
6+
7+
fn f() -> int { 100 }

src/test/auxiliary/crateresolve6-2.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[link(name = "crateresolve6",
2+
vers = "0.1",
3+
calories = "200")];
4+
5+
#[crate_type = "lib"];
6+
7+
fn f() -> int { 200 }

src/test/run-pass/crateresolve6.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// xfail-fast
2+
// aux-build:crateresolve6-1.rs
3+
// aux-build:crateresolve6-2.rs
4+
// error-pattern:mismatched types
5+
6+
// These both have the same version but differ in other metadata
7+
use cr6_1 (name = "crateresolve6", vers = "0.1", calories="100");
8+
use cr6_2 (name = "crateresolve6", vers = "0.1", calories="200");
9+
10+
fn main() {
11+
assert cr6_1::f() == 100;
12+
assert cr6_2::f() == 200;
13+
}

0 commit comments

Comments
 (0)