Skip to content

Commit 6c95e40

Browse files
committed
repair more hash functions
1 parent 03a6e54 commit 6c95e40

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/comp/middle/ty.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,23 +1299,23 @@ fn type_autoderef(cx: ctxt, t: ty::t) -> ty::t {
12991299
fn hash_type_structure(st: sty) -> uint {
13001300
fn hash_uint(id: uint, n: uint) -> uint {
13011301
let h = id;
1302-
h += h << 5u + n;
1302+
h += (h << 5u) + n;
13031303
ret h;
13041304
}
13051305
fn hash_def(id: uint, did: ast::def_id) -> uint {
13061306
let h = id;
1307-
h += h << 5u + (did.crate as uint);
1308-
h += h << 5u + (did.node as uint);
1307+
h += (h << 5u) + (did.crate as uint);
1308+
h += (h << 5u) + (did.node as uint);
13091309
ret h;
13101310
}
13111311
fn hash_subty(id: uint, subty: t) -> uint {
13121312
let h = id;
1313-
h += h << 5u + hash_ty(subty);
1313+
h += (h << 5u) + hash_ty(subty);
13141314
ret h;
13151315
}
13161316
fn hash_type_constr(id: uint, c: @type_constr) -> uint {
13171317
let h = id;
1318-
h += h << 5u + hash_def(h, c.node.id);
1318+
h += (h << 5u) + hash_def(h, c.node.id);
13191319
ret hash_type_constr_args(h, c.node.args);
13201320
}
13211321
fn hash_type_constr_args(id: uint, args: [@ty_constr_arg]) -> uint {
@@ -1338,8 +1338,8 @@ fn hash_type_structure(st: sty) -> uint {
13381338

13391339
fn hash_fn(id: uint, args: [arg], rty: t) -> uint {
13401340
let h = id;
1341-
for a: arg in args { h += h << 5u + hash_ty(a.ty); }
1342-
h += h << 5u + hash_ty(rty);
1341+
for a: arg in args { h += (h << 5u) + hash_ty(a.ty); }
1342+
h += (h << 5u) + hash_ty(rty);
13431343
ret h;
13441344
}
13451345
alt st {
@@ -1366,19 +1366,19 @@ fn hash_type_structure(st: sty) -> uint {
13661366
ty_str. { ret 17u; }
13671367
ty_tag(did, tys) {
13681368
let h = hash_def(18u, did);
1369-
for typ: t in tys { h += h << 5u + hash_ty(typ); }
1369+
for typ: t in tys { h += (h << 5u) + hash_ty(typ); }
13701370
ret h;
13711371
}
13721372
ty_box(mt) { ret hash_subty(19u, mt.ty); }
13731373
ty_vec(mt) { ret hash_subty(21u, mt.ty); }
13741374
ty_rec(fields) {
13751375
let h = 26u;
1376-
for f: field in fields { h += h << 5u + hash_ty(f.mt.ty); }
1376+
for f: field in fields { h += (h << 5u) + hash_ty(f.mt.ty); }
13771377
ret h;
13781378
}
13791379
ty_tup(ts) {
13801380
let h = 25u;
1381-
for tt in ts { h += h << 5u + hash_ty(tt); }
1381+
for tt in ts { h += (h << 5u) + hash_ty(tt); }
13821382
ret h;
13831383
}
13841384

@@ -1389,7 +1389,7 @@ fn hash_type_structure(st: sty) -> uint {
13891389
ty_native_fn(args, rty) { ret hash_fn(28u, args, rty); }
13901390
ty_obj(methods) {
13911391
let h = 29u;
1392-
for m: method in methods { h += h << 5u + str::hash(m.ident); }
1392+
for m: method in methods { h += (h << 5u) + str::hash(m.ident); }
13931393
ret h;
13941394
}
13951395
ty_var(v) { ret hash_uint(30u, v as uint); }
@@ -1400,23 +1400,23 @@ fn hash_type_structure(st: sty) -> uint {
14001400
ty_ptr(mt) { ret hash_subty(35u, mt.ty); }
14011401
ty_res(did, sub, tps) {
14021402
let h = hash_subty(hash_def(18u, did), sub);
1403-
for tp: t in tps { h += h << 5u + hash_ty(tp); }
1403+
for tp: t in tps { h += (h << 5u) + hash_ty(tp); }
14041404
ret h;
14051405
}
14061406
ty_constr(t, cs) {
14071407
let h = 36u;
1408-
for c: @type_constr in cs { h += h << 5u + hash_type_constr(h, c); }
1408+
for c: @type_constr in cs { h += (h << 5u) + hash_type_constr(h, c); }
14091409
ret h;
14101410
}
1411-
ty_uniq(mt) { let h = 37u; h += h << 5u + hash_ty(mt.ty); ret h; }
1411+
ty_uniq(mt) { let h = 37u; h += (h << 5u) + hash_ty(mt.ty); ret h; }
14121412
}
14131413
}
14141414

14151415
fn hash_type_info(st: sty, cname_opt: option::t<str>) -> uint {
14161416
let h = hash_type_structure(st);
14171417
alt cname_opt {
14181418
none. {/* no-op */ }
1419-
some(s) { h += h << 5u + str::hash(s); }
1419+
some(s) { h += (h << 5u) + str::hash(s); }
14201420
}
14211421
ret h;
14221422
}

src/comp/syntax/ast_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn hash_ty(&&t: @ty) -> uint {
199199
}
200200

201201
fn hash_def_id(&&id: def_id) -> uint {
202-
id.crate as uint << 16u + (id.node as uint)
202+
(id.crate as uint << 16u) + (id.node as uint)
203203
}
204204

205205
fn eq_def_id(&&a: def_id, &&b: def_id) -> bool {

src/libstd/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ fn char_range_at(s: str, i: uint) -> {ch: char, next: uint} {
324324
// Clunky way to get the right bits from the first byte. Uses two shifts,
325325
// the first to clip off the marker bits at the left of the byte, and then
326326
// a second (as uint) to get it to the right position.
327-
val += (b0 << (w + 1u as u8) as uint) << (w - 1u) * 6u - w - 1u;
327+
val += (b0 << (w + 1u as u8) as uint) << ((w - 1u) * 6u - w - 1u);
328328
ret {ch: val as char, next: i};
329329
}
330330

0 commit comments

Comments
 (0)