aboutsummaryrefslogtreecommitdiff
path: root/src/comp
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-04-22 19:26:00 -0700
committerPatrick Walton <[email protected]>2011-04-22 19:26:00 -0700
commit94e5ca4df862b1ff3e1fdc1c02828813050845d6 (patch)
treee98ed5b57268b2fcbe2f5c7601c4092e87299f6b /src/comp
parentrustc: Thread the type store through everything that needs to access type str... (diff)
downloadrust-94e5ca4df862b1ff3e1fdc1c02828813050845d6.tar.xz
rust-94e5ca4df862b1ff3e1fdc1c02828813050845d6.zip
rustc: Include the cname in the hash to increase entropy
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/ty.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 86a0db1f..36fb258d 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -120,7 +120,7 @@ fn gen_ty(@type_store tystore, &sty st) -> t {
}
fn gen_ty_full(@type_store tystore, &sty st, option.t[str] cname) -> t {
- auto h = hash_type_structure(st);
+ auto h = hash_type_info(st, cname);
auto new_type = @rec(struct=st, cname=cname, hash=h);
// Is it interned?
@@ -888,6 +888,15 @@ fn hash_type_structure(&sty st) -> uint {
}
}
+fn hash_type_info(&sty st, option.t[str] cname_opt) -> uint {
+ auto h = hash_type_structure(st);
+ alt (cname_opt) {
+ case (none[str]) { /* no-op */ }
+ case (some[str](?s)) { h += h << 5u + _str.hash(s); }
+ }
+ ret h;
+}
+
fn hash_ty(&t typ) -> uint { ret typ.hash; }