diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-06-14 11:10:32 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-06-14 11:10:32 -0700 |
| commit | 87af3f3ccab541a59996f289c39ccf7ddad1e29f (patch) | |
| tree | 13e33b96f013ea367e032bb53975caf795ca30c5 | |
| parent | e38eaed9789a2eb9abc2f767d9487708e17ea3dd (diff) | |
| download | rust-87af3f3ccab541a59996f289c39ccf7ddad1e29f.tar.gz rust-87af3f3ccab541a59996f289c39ccf7ddad1e29f.zip | |
Dead code elimination
| -rw-r--r-- | src/rustc/middle/typeck.rs | 9 | ||||
| -rw-r--r-- | src/rustc/middle/typeck/check.rs | 33 |
2 files changed, 4 insertions, 38 deletions
diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index f8b24d004b7..146a007b95d 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -118,13 +118,6 @@ type ty_table = hashmap<ast::def_id, ty::t>; type crate_ctxt = {impl_map: resolve::impl_map, method_map: method_map, vtable_map: vtable_map, - // Not at all sure it's right to put these here - /* node_id for the class this fn is in -- - none if it's not in a class */ - enclosing_class_id: option<ast::node_id>, - /* map from node_ids for enclosing-class - vars and methods to types */ - enclosing_class: class_map, tcx: ty::ctxt}; type class_map = hashmap<ast::node_id, ty::t>; @@ -246,8 +239,6 @@ fn check_crate(tcx: ty::ctxt, impl_map: resolve::impl_map, let ccx = @{impl_map: impl_map, method_map: std::map::int_hash(), vtable_map: std::map::int_hash(), - enclosing_class_id: none, - enclosing_class: std::map::int_hash(), tcx: tcx}; collect::collect_item_types(ccx, crate); check::check_item_types(ccx, crate); diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 079228ada78..929b5d5641e 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -320,26 +320,6 @@ fn check_method(ccx: @crate_ctxt, method: @ast::method, self_ty: ty::t) { check_bare_fn(ccx, method.decl, method.body, method.id, some(self_ty)); } -fn class_types(ccx: @crate_ctxt, members: [@ast::class_member], - rp: ast::region_param) -> class_map { - - let rslt = int_hash::<ty::t>(); - let rs = rscope::type_rscope(rp); - for members.each { |m| - alt m.node { - ast::instance_var(_,t,_,id,_) { - rslt.insert(id, ccx.to_ty(rs, t)); - } - ast::class_method(mth) { - rslt.insert(mth.id, - ty::mk_fn(ccx.tcx, - collect::ty_of_method(ccx, mth, rp).fty)); - } - } - } - rslt -} - fn check_class_member(ccx: @crate_ctxt, class_t: ty::t, cm: @ast::class_member) { alt cm.node { @@ -368,15 +348,10 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { for ms.each {|m| check_method(ccx, m, self_ty);} } ast::item_class(tps, ifaces, members, ctor, m_dtor, rp) { - let cid = some(it.id), tcx = ccx.tcx; + let tcx = ccx.tcx; let class_t = ty::node_id_to_type(tcx, it.id); - let members_info = class_types(ccx, members, rp); - // can also ditch the enclosing_class stuff once we move to self - // FIXME - let class_ccx = @{enclosing_class_id:cid, - enclosing_class:members_info with *ccx}; // typecheck the ctor - check_bare_fn(class_ccx, ctor.node.dec, + check_bare_fn(ccx, ctor.node.dec, ctor.node.body, ctor.node.id, some(class_t)); // Write the ctor's self's type @@ -384,14 +359,14 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { option::iter(m_dtor) {|dtor| // typecheck the dtor - check_bare_fn(class_ccx, ast_util::dtor_dec(), + check_bare_fn(ccx, ast_util::dtor_dec(), dtor.node.body, dtor.node.id, some(class_t)); // Write the dtor's self's type write_ty_to_tcx(tcx, dtor.node.self_id, class_t); }; // typecheck the members - for members.each {|m| check_class_member(class_ccx, class_t, m); } + for members.each {|m| check_class_member(ccx, class_t, m); } // Check that there's at least one field let (fields,_) = split_class_items(members); if fields.len() < 1u { |
