about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-02-18 22:06:33 -0800
committerbors <bors@rust-lang.org>2013-02-18 22:06:33 -0800
commit396f9119256c7f675bd6cc58aaa4defb36c09760 (patch)
tree414f2a7f4c1e84c83f02e771f9322be64dc337e8
parent6e40314bbf9c6e810e836296018de082c0e15d12 (diff)
parent43dc67b74a9b2599a38a59cc572e74f91213672f (diff)
downloadrust-396f9119256c7f675bd6cc58aaa4defb36c09760.tar.gz
rust-396f9119256c7f675bd6cc58aaa4defb36c09760.zip
auto merge of #5017 : catamorphism/rust/less-copy, r=catamorphism
-rw-r--r--src/librustc/middle/trans/base.rs34
-rw-r--r--src/librustc/middle/trans/build.rs2
-rw-r--r--src/librustc/middle/trans/common.rs4
-rw-r--r--src/librustc/middle/trans/datum.rs3
-rw-r--r--src/librustc/middle/trans/foreign.rs2
-rw-r--r--src/librustc/middle/trans/meth.rs8
-rw-r--r--src/librustc/middle/trans/monomorphize.rs2
7 files changed, 28 insertions, 27 deletions
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index 13f29724ba8..8204c798278 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -456,7 +456,6 @@ pub fn set_glue_inlining(f: ValueRef, t: ty::t) {
 // Double-check that we never ask LLVM to declare the same symbol twice. It
 // silently mangles such symbols, breaking our linkage model.
 pub fn note_unique_llvm_symbol(ccx: @crate_ctxt, +sym: ~str) {
-    // XXX: Bad copy.
     if ccx.all_llvm_symbols.contains_key(&sym) {
         ccx.sess.bug(~"duplicate LLVM symbol: " + sym);
     }
@@ -628,7 +627,10 @@ pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
             for vec::each(fn_ty.sig.inputs) |a| {
                 let llfldp_a = GEP_enum(cx, a_tup, tid, v_id,
                                         /*bad*/copy tps, j);
-                // XXX: Is "None" right here?
+                // This assumes the self type is absent (it passes
+                // None for the self_ty_opt arg of substs_tps).
+                // I think that's ok since you can't have an enum
+                // inside a trait.
                 let ty_subst = ty::subst_tps(ccx.tcx, tps, None, a.ty);
                 cx = f(cx, llfldp_a, ty_subst);
                 j += 1u;
@@ -1038,8 +1040,7 @@ pub fn load_if_immediate(cx: block, v: ValueRef, t: ty::t) -> ValueRef {
 pub fn trans_trace(bcx: block, sp_opt: Option<span>, +trace_str: ~str) {
     if !bcx.sess().trace() { return; }
     let _icx = bcx.insn_ctxt("trans_trace");
-    // XXX: Bad copy.
-    add_comment(bcx, copy trace_str);
+    add_comment(bcx, trace_str);
     let V_trace_str = C_cstr(bcx.ccx(), trace_str);
     let {V_filename, V_line} = match sp_opt {
       Some(sp) => {
@@ -1551,7 +1552,7 @@ pub fn new_fn_ctxt_w_id(ccx: @crate_ctxt,
                         llfndecl: ValueRef,
                         id: ast::node_id,
                         impl_id: Option<ast::def_id>,
-                        +param_substs: Option<param_substs>,
+                        param_substs: Option<@param_substs>,
                         sp: Option<span>) -> fn_ctxt {
     let llbbs = mk_standard_basic_blocks(llfndecl);
     return @fn_ctxt_ {
@@ -1740,7 +1741,7 @@ pub fn trans_closure(ccx: @crate_ctxt,
                      body: &ast::blk,
                      llfndecl: ValueRef,
                      ty_self: self_arg,
-                     +param_substs: Option<param_substs>,
+                     param_substs: Option<@param_substs>,
                      id: ast::node_id,
                      impl_id: Option<ast::def_id>,
                      maybe_load_env: fn(fn_ctxt),
@@ -1804,7 +1805,7 @@ pub fn trans_fn(ccx: @crate_ctxt,
                 body: &ast::blk,
                 llfndecl: ValueRef,
                 ty_self: self_arg,
-                +param_substs: Option<param_substs>,
+                param_substs: Option<@param_substs>,
                 id: ast::node_id,
                 impl_id: Option<ast::def_id>) {
     let do_time = ccx.sess.trans_stats();
@@ -1813,8 +1814,8 @@ pub fn trans_fn(ccx: @crate_ctxt,
     debug!("trans_fn(ty_self=%?)", ty_self);
     let _icx = ccx.insn_ctxt("trans_fn");
     ccx.stats.n_fns += 1;
-    // XXX: Bad copy of `path`.
-    trans_closure(ccx, copy path, decl, body, llfndecl, ty_self,
+    let the_path_str = path_str(ccx.sess, path);
+    trans_closure(ccx, path, decl, body, llfndecl, ty_self,
                   param_substs, id, impl_id,
                   |fcx| {
                       if ccx.sess.opts.extra_debuginfo {
@@ -1824,7 +1825,7 @@ pub fn trans_fn(ccx: @crate_ctxt,
                   |_bcx| { });
     if do_time {
         let end = time::get_time();
-        log_fn_time(ccx, path_str(ccx.sess, path), start, end);
+        log_fn_time(ccx, the_path_str, start, end);
     }
 }
 
@@ -1834,7 +1835,7 @@ pub fn trans_enum_variant(ccx: @crate_ctxt,
                           args: ~[ast::variant_arg],
                           disr: int,
                           is_degen: bool,
-                          +param_substs: Option<param_substs>,
+                          param_substs: Option<@param_substs>,
                           llfndecl: ValueRef) {
     let _icx = ccx.insn_ctxt("trans_enum_variant");
     // Translate variant arguments to function arguments.
@@ -1850,9 +1851,8 @@ pub fn trans_enum_variant(ccx: @crate_ctxt,
             id: varg.id,
         }
     };
-    // XXX: Bad copy of `param_substs`.
     let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, variant.node.id, None,
-                               copy param_substs, None);
+                               param_substs, None);
     // XXX: Bad copy.
     let raw_llargs = create_llargs_for_fn_args(fcx, no_self, copy fn_args);
     let ty_param_substs = match param_substs {
@@ -1897,7 +1897,7 @@ pub fn trans_enum_variant(ccx: @crate_ctxt,
 pub fn trans_tuple_struct(ccx: @crate_ctxt,
                           fields: ~[@ast::struct_field],
                           ctor_id: ast::node_id,
-                          +param_substs: Option<param_substs>,
+                          param_substs: Option<@param_substs>,
                           llfndecl: ValueRef) {
     let _icx = ccx.insn_ctxt("trans_tuple_struct");
 
@@ -1951,7 +1951,7 @@ pub fn trans_struct_dtor(ccx: @crate_ctxt,
                          +path: path,
                          body: &ast::blk,
                          dtor_id: ast::node_id,
-                         +psubsts: Option<param_substs>,
+                         psubsts: Option<@param_substs>,
                          hash_id: Option<mono_id>,
                          parent_id: ast::def_id)
                       -> ValueRef {
@@ -1968,7 +1968,7 @@ pub fn trans_struct_dtor(ccx: @crate_ctxt,
   let lldty = type_of_dtor(ccx, class_ty);
 
   // XXX: Bad copies.
-  let s = get_dtor_symbol(ccx, copy path, dtor_id, copy psubsts);
+  let s = get_dtor_symbol(ccx, copy path, dtor_id, psubsts);
 
   /* Register the dtor as a function. It has external linkage */
   let lldecl = decl_internal_cdecl_fn(ccx.llmod, s, lldty);
@@ -2296,7 +2296,7 @@ pub fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path {
 pub fn get_dtor_symbol(ccx: @crate_ctxt,
                        +path: path,
                        id: ast::node_id,
-                       +substs: Option<param_substs>)
+                       substs: Option<@param_substs>)
                     -> ~str {
   let t = ty::node_id_to_type(ccx.tcx, id);
   match ccx.item_symbols.find(&id) {
diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs
index 43953b68f59..da9dcc7c9af 100644
--- a/src/librustc/middle/trans/build.rs
+++ b/src/librustc/middle/trans/build.rs
@@ -834,7 +834,7 @@ pub fn add_span_comment(bcx: block, sp: span, text: ~str) {
     }
 }
 
-pub fn add_comment(bcx: block, text: ~str) {
+pub fn add_comment(bcx: block, text: &str) {
     unsafe {
         let ccx = bcx.ccx();
         if !ccx.sess.no_asm_comments() {
diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs
index b0ec0e1b907..82c510031bf 100644
--- a/src/librustc/middle/trans/common.rs
+++ b/src/librustc/middle/trans/common.rs
@@ -311,7 +311,7 @@ pub struct fn_ctxt_ {
 
     // If this function is being monomorphized, this contains the type
     // substitutions used.
-    param_substs: Option<param_substs>,
+    param_substs: Option<@param_substs>,
 
     // The source span and nesting context where this function comes from, for
     // error reporting and symbol generation.
@@ -1395,7 +1395,7 @@ pub fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, +vt: typeck::vtable_origin)
         }
         typeck::vtable_param(n_param, n_bound) => {
             match fcx.param_substs {
-                Some(ref substs) => {
+                Some(substs) => {
                     find_vtable(tcx, substs, n_param, n_bound)
                 }
                 _ => {
diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs
index 49779b9bbcc..206ee50111f 100644
--- a/src/librustc/middle/trans/datum.rs
+++ b/src/librustc/middle/trans/datum.rs
@@ -524,7 +524,8 @@ pub impl Datum {
         if bcx.sess().trace() {
             trans_trace(
                 bcx, None,
-                fmt!("preserving until end of scope %d", root_info.scope));
+                fmt!("preserving until end of scope %d",
+                     root_info.scope));
         }
 
         let scratch = scratch_datum(bcx, self.ty, true);
diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs
index 718f41de00a..92852930a66 100644
--- a/src/librustc/middle/trans/foreign.rs
+++ b/src/librustc/middle/trans/foreign.rs
@@ -332,7 +332,7 @@ pub fn trans_intrinsic(ccx: @crate_ctxt,
                        decl: ValueRef,
                        item: @ast::foreign_item,
                        +path: ast_map::path,
-                       +substs: param_substs,
+                       substs: @param_substs,
                        ref_id: Option<ast::node_id>) {
     debug!("trans_intrinsic(item.ident=%s)", ccx.sess.str_of(item.ident));
 
diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs
index bc4ec8c07c2..b28362dfbd6 100644
--- a/src/librustc/middle/trans/meth.rs
+++ b/src/librustc/middle/trans/meth.rs
@@ -66,7 +66,7 @@ pub fn trans_impl(ccx: @crate_ctxt, +path: path, name: ast::ident,
             match self_ty {
                 None => param_substs_opt = None,
                 Some(self_ty) => {
-                    param_substs_opt = Some(param_substs {
+                    param_substs_opt = Some(@param_substs {
                         tys: ~[],
                         vtables: None,
                         bounds: @~[],
@@ -99,7 +99,7 @@ Translates a (possibly monomorphized) method body.
 pub fn trans_method(ccx: @crate_ctxt,
                     +path: path,
                     method: &ast::method,
-                    +param_substs: Option<param_substs>,
+                    param_substs: Option<@param_substs>,
                     base_self_ty: Option<ty::t>,
                     llfn: ValueRef,
                     impl_id: ast::def_id) {
@@ -118,7 +118,7 @@ pub fn trans_method(ccx: @crate_ctxt,
         }
         let self_ty = match param_substs {
             None => self_ty,
-            Some(param_substs {tys: ref tys, _}) => {
+            Some(@param_substs {tys: ref tys, _}) => {
                 ty::subst_tps(ccx.tcx, *tys, None, self_ty)
             }
         };
@@ -247,7 +247,7 @@ pub fn trans_method_callee(bcx: block,
             bound_num: b
         }) => {
             match bcx.fcx.param_substs {
-                Some(ref substs) => {
+                Some(substs) => {
                     let vtbl = find_vtable(bcx.tcx(), substs, p, b);
                     trans_monomorphized_callee(bcx, callee_id, self, mentry,
                                                trait_id, off, vtbl)
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index b09a41f2b7f..bb289eec33e 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -156,7 +156,7 @@ pub fn monomorphic_fn(ccx: @crate_ctxt,
         lldecl
     };
 
-    let psubsts = Some(param_substs {
+    let psubsts = Some(@param_substs {
         tys: substs,
         vtables: vtables,
         bounds: tpt.bounds,