Skip to content

Commit 384906c

Browse files
committed
Remove unused hokey-hashes from typeck and region inference.
1 parent bac89ea commit 384906c

File tree

2 files changed

+1
-119
lines changed

2 files changed

+1
-119
lines changed

src/rustc/middle/ty.rs

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,120 +2645,10 @@ impl sty : to_bytes::IterBytes {
26452645
}
26462646
}
26472647
2648-
pure fn hash_bound_region(br: &bound_region) -> uint {
2649-
match *br { // no idea if this is any good
2650-
ty::br_self => 0u,
2651-
ty::br_anon(idx) => 1u | (idx << 2),
2652-
ty::br_named(ident) => 2u | (ident << 2),
2653-
ty::br_cap_avoid(id, br) =>
2654-
3u | (id as uint << 2) | hash_bound_region(br)
2655-
}
2656-
}
2657-
26582648
fn br_hashmap<V:Copy>() -> HashMap<bound_region, V> {
26592649
map::HashMap()
26602650
}
26612651
2662-
pure fn hash_region(r: &region) -> uint {
2663-
match *r { // no idea if this is any good
2664-
re_bound(br) => (hash_bound_region(&br)) << 2u | 0u,
2665-
re_free(id, br) => ((id as uint) << 4u) |
2666-
(hash_bound_region(&br)) << 2u | 1u,
2667-
re_scope(id) => ((id as uint) << 2u) | 2u,
2668-
re_var(id) => (id.to_uint() << 2u) | 3u,
2669-
re_static => 4u
2670-
}
2671-
}
2672-
2673-
// Type hashing.
2674-
pure fn hash_type_structure(st: &sty) -> uint {
2675-
pure fn hash_uint(id: uint, n: uint) -> uint { (id << 2u) + n }
2676-
pure fn hash_def(id: uint, did: ast::def_id) -> uint {
2677-
let h = (id << 2u) + (did.crate as uint);
2678-
(h << 2u) + (did.node as uint)
2679-
}
2680-
pure fn hash_subty(id: uint, subty: t) -> uint {
2681-
(id << 2u) + type_id(subty)
2682-
}
2683-
pure fn hash_subtys(id: uint, subtys: ~[t]) -> uint {
2684-
let mut h = id;
2685-
for vec::each(subtys) |s| { h = (h << 2u) + type_id(*s) }
2686-
h
2687-
}
2688-
pure fn hash_substs(h: uint, substs: &substs) -> uint {
2689-
let h = hash_subtys(h, substs.tps);
2690-
h + substs.self_r.map_default(0u, |r| hash_region(&r))
2691-
}
2692-
match *st {
2693-
ty_nil => 0u,
2694-
ty_bool => 1u,
2695-
ty_int(t) => match t {
2696-
ast::ty_i => 2u,
2697-
ast::ty_char => 3u,
2698-
ast::ty_i8 => 4u,
2699-
ast::ty_i16 => 5u,
2700-
ast::ty_i32 => 6u,
2701-
ast::ty_i64 => 7u
2702-
},
2703-
ty_uint(t) => match t {
2704-
ast::ty_u => 8u,
2705-
ast::ty_u8 => 9u,
2706-
ast::ty_u16 => 10u,
2707-
ast::ty_u32 => 11u,
2708-
ast::ty_u64 => 12u
2709-
},
2710-
ty_float(t) => match t {
2711-
ast::ty_f => 13u,
2712-
ast::ty_f32 => 14u,
2713-
ast::ty_f64 => 15u
2714-
},
2715-
ty_estr(_) => 16u,
2716-
ty_enum(did, ref substs) => {
2717-
let mut h = hash_def(18u, did);
2718-
hash_substs(h, substs)
2719-
}
2720-
ty_box(mt) => hash_subty(19u, mt.ty),
2721-
ty_evec(mt, _) => hash_subty(20u, mt.ty),
2722-
ty_unboxed_vec(mt) => hash_subty(22u, mt.ty),
2723-
ty_tup(ts) => hash_subtys(25u, ts),
2724-
ty_rec(fields) => {
2725-
let mut h = 26u;
2726-
for vec::each(fields) |f| { h = hash_subty(h, f.mt.ty); }
2727-
h
2728-
}
2729-
ty_fn(ref f) => {
2730-
let mut h = 27u;
2731-
for vec::each(f.sig.inputs) |a| {
2732-
h = hash_subty(h, a.ty);
2733-
}
2734-
hash_subty(h, f.sig.output)
2735-
}
2736-
ty_self => 28u,
2737-
ty_infer(v) => hash_uint(29u, v.to_hash()),
2738-
ty_param(p) => hash_def(hash_uint(31u, p.idx), p.def_id),
2739-
ty_type => 32u,
2740-
ty_bot => 34u,
2741-
ty_ptr(mt) => hash_subty(35u, mt.ty),
2742-
ty_uniq(mt) => hash_subty(37u, mt.ty),
2743-
ty_trait(did, ref substs, _) => {
2744-
let mut h = hash_def(40u, did);
2745-
hash_substs(h, substs)
2746-
}
2747-
ty_opaque_closure_ptr(ck_block) => 41u,
2748-
ty_opaque_closure_ptr(ck_box) => 42u,
2749-
ty_opaque_closure_ptr(ck_uniq) => 43u,
2750-
ty_opaque_box => 44u,
2751-
ty_class(did, ref substs) => {
2752-
let mut h = hash_def(45u, did);
2753-
hash_substs(h, substs)
2754-
}
2755-
ty_rptr(region, mt) => {
2756-
let mut h = (46u << 2u) + hash_region(&region);
2757-
hash_subty(h, mt.ty)
2758-
}
2759-
}
2760-
}
2761-
27622652
fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
27632653
//io::println(fmt!("%?/%?", id, cx.node_types.size()));
27642654
match smallintmap::find(*cx.node_types, id as uint) {

src/rustc/middle/typeck/infer/region_var_bindings.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ use std::map::{HashMap, uint_hash};
312312
use std::cell::{Cell, empty_cell};
313313
use std::list::{List, Nil, Cons};
314314

315-
use ty::{region, RegionVid, hash_region};
315+
use ty::{region, RegionVid};
316316
use region::is_subregion_of;
317317
use syntax::codemap;
318318
use to_str::to_str;
@@ -429,14 +429,6 @@ fn CombineMap() -> CombineMap {
429429
return HashMap();
430430
}
431431

432-
pure fn hash_constraint(rc: &Constraint) -> uint {
433-
match *rc {
434-
ConstrainVarSubVar(a, b) => *a ^ *b,
435-
ConstrainRegSubVar(ref r, b) => ty::hash_region(r) ^ *b,
436-
ConstrainVarSubReg(a, ref r) => *a ^ ty::hash_region(r)
437-
}
438-
}
439-
440432
impl RegionVarBindings {
441433
fn in_snapshot() -> bool {
442434
self.undo_log.len() > 0

0 commit comments

Comments
 (0)