about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-23 17:26:32 -0700
committerbors <bors@rust-lang.org>2013-08-23 17:26:32 -0700
commit7b5a91f4b346b99b4e9171eb8deb52d9bf2525ea (patch)
treee708165d599989ba5183c335ea8455fee8bced46 /src
parent2c0f9bd35493def5e23f0f43ddeba54da9d788b4 (diff)
parent180e235d3dbe00ff3b247552bb83cca0be8cf06d (diff)
downloadrust-7b5a91f4b346b99b4e9171eb8deb52d9bf2525ea.tar.gz
rust-7b5a91f4b346b99b4e9171eb8deb52d9bf2525ea.zip
auto merge of #8724 : thestinger/rust/fix-transmute, r=graydon
Monomorphize's normalization results in a 2% decrease in non-optimized
code size for libstd, so there's a negligible cost to removing it. This
also fixes several visit glue bugs because normalize wasn't considering
the differences in visit glue between types.

Closes #8720
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/trans/monomorphize.rs69
-rw-r--r--src/libstd/repr.rs2
2 files changed, 3 insertions, 68 deletions
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index ab458f2799d..162765350da 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -26,7 +26,6 @@ use middle::trans::type_of;
 use middle::trans::type_use;
 use middle::trans::intrinsic;
 use middle::ty;
-use middle::ty::{FnSig};
 use middle::typeck;
 use util::ppaux::{Repr,ty_to_str};
 
@@ -34,8 +33,6 @@ use syntax::ast;
 use syntax::ast_map;
 use syntax::ast_map::path_name;
 use syntax::ast_util::local_def;
-use syntax::opt_vec;
-use syntax::abi::AbiSet;
 
 pub fn monomorphic_fn(ccx: @mut CrateContext,
                       fn_id: ast::def_id,
@@ -61,17 +58,10 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
     let _icx = push_ctxt("monomorphic_fn");
     let mut must_cast = false;
 
-    let do_normalize = |t: &ty::t| {
-        match normalize_for_monomorphization(ccx.tcx, *t) {
-          Some(t) => { must_cast = true; t }
-          None => *t
-        }
-    };
-
     let psubsts = @param_substs {
-        tys: real_substs.tps.map(|x| do_normalize(x)),
+        tys: real_substs.tps.to_owned(),
         vtables: vtables,
-        self_ty: real_substs.self_ty.map(|x| do_normalize(x)),
+        self_ty: real_substs.self_ty.clone(),
         self_vtables: self_vtables
     };
 
@@ -305,61 +295,6 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
     (lldecl, must_cast)
 }
 
-pub fn normalize_for_monomorphization(tcx: ty::ctxt,
-                                      ty: ty::t) -> Option<ty::t> {
-    // FIXME[mono] could do this recursively. is that worthwhile? (#2529)
-    return match ty::get(ty).sty {
-        ty::ty_box(*) => {
-            Some(ty::mk_opaque_box(tcx))
-        }
-        ty::ty_bare_fn(_) => {
-            Some(ty::mk_bare_fn(
-                tcx,
-                ty::BareFnTy {
-                    purity: ast::impure_fn,
-                    abis: AbiSet::Rust(),
-                    sig: FnSig {bound_lifetime_names: opt_vec::Empty,
-                                inputs: ~[],
-                                output: ty::mk_nil()}}))
-        }
-        ty::ty_closure(ref fty) => {
-            Some(normalized_closure_ty(tcx, fty.sigil))
-        }
-        ty::ty_trait(_, _, ref store, _, _) => {
-            let sigil = match *store {
-                ty::UniqTraitStore => ast::OwnedSigil,
-                ty::BoxTraitStore => ast::ManagedSigil,
-                ty::RegionTraitStore(_) => ast::BorrowedSigil,
-            };
-
-            // Traits have the same runtime representation as closures.
-            Some(normalized_closure_ty(tcx, sigil))
-        }
-        ty::ty_ptr(_) => {
-            Some(ty::mk_uint())
-        }
-        _ => {
-            None
-        }
-    };
-
-    fn normalized_closure_ty(tcx: ty::ctxt,
-                             sigil: ast::Sigil) -> ty::t
-    {
-        ty::mk_closure(
-            tcx,
-            ty::ClosureTy {
-                purity: ast::impure_fn,
-                sigil: sigil,
-                onceness: ast::Many,
-                region: ty::re_static,
-                bounds: ty::EmptyBuiltinBounds(),
-                sig: ty::FnSig {bound_lifetime_names: opt_vec::Empty,
-                                inputs: ~[],
-                                output: ty::mk_nil()}})
-    }
-}
-
 pub fn make_mono_id(ccx: @mut CrateContext,
                     item: ast::def_id,
                     substs: &param_substs,
diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs
index 743a47a812a..0218a0e7f3a 100644
--- a/src/libstd/repr.rs
+++ b/src/libstd/repr.rs
@@ -590,7 +590,7 @@ fn test_repr() {
     exact_test(&(~"he\u10f3llo"), "~\"he\\u10f3llo\"");
 
     exact_test(&(@10), "@10");
-    exact_test(&(@mut 10), "@10"); // FIXME: #4210: incorrect
+    exact_test(&(@mut 10), "@mut 10");
     exact_test(&((@mut 10, 2)), "(@mut 10, 2)");
     exact_test(&(~10), "~10");
     exact_test(&(&10), "&10");