Skip to content

Commit 396f911

Browse files
committed
auto merge of #5017 : catamorphism/rust/less-copy, r=catamorphism
2 parents 6e40314 + 43dc67b commit 396f911

File tree

7 files changed

+28
-27
lines changed

7 files changed

+28
-27
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ pub fn set_glue_inlining(f: ValueRef, t: ty::t) {
456456
// Double-check that we never ask LLVM to declare the same symbol twice. It
457457
// silently mangles such symbols, breaking our linkage model.
458458
pub fn note_unique_llvm_symbol(ccx: @crate_ctxt, +sym: ~str) {
459-
// XXX: Bad copy.
460459
if ccx.all_llvm_symbols.contains_key(&sym) {
461460
ccx.sess.bug(~"duplicate LLVM symbol: " + sym);
462461
}
@@ -628,7 +627,10 @@ pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
628627
for vec::each(fn_ty.sig.inputs) |a| {
629628
let llfldp_a = GEP_enum(cx, a_tup, tid, v_id,
630629
/*bad*/copy tps, j);
631-
// XXX: Is "None" right here?
630+
// This assumes the self type is absent (it passes
631+
// None for the self_ty_opt arg of substs_tps).
632+
// I think that's ok since you can't have an enum
633+
// inside a trait.
632634
let ty_subst = ty::subst_tps(ccx.tcx, tps, None, a.ty);
633635
cx = f(cx, llfldp_a, ty_subst);
634636
j += 1u;
@@ -1038,8 +1040,7 @@ pub fn load_if_immediate(cx: block, v: ValueRef, t: ty::t) -> ValueRef {
10381040
pub fn trans_trace(bcx: block, sp_opt: Option<span>, +trace_str: ~str) {
10391041
if !bcx.sess().trace() { return; }
10401042
let _icx = bcx.insn_ctxt("trans_trace");
1041-
// XXX: Bad copy.
1042-
add_comment(bcx, copy trace_str);
1043+
add_comment(bcx, trace_str);
10431044
let V_trace_str = C_cstr(bcx.ccx(), trace_str);
10441045
let {V_filename, V_line} = match sp_opt {
10451046
Some(sp) => {
@@ -1551,7 +1552,7 @@ pub fn new_fn_ctxt_w_id(ccx: @crate_ctxt,
15511552
llfndecl: ValueRef,
15521553
id: ast::node_id,
15531554
impl_id: Option<ast::def_id>,
1554-
+param_substs: Option<param_substs>,
1555+
param_substs: Option<@param_substs>,
15551556
sp: Option<span>) -> fn_ctxt {
15561557
let llbbs = mk_standard_basic_blocks(llfndecl);
15571558
return @fn_ctxt_ {
@@ -1740,7 +1741,7 @@ pub fn trans_closure(ccx: @crate_ctxt,
17401741
body: &ast::blk,
17411742
llfndecl: ValueRef,
17421743
ty_self: self_arg,
1743-
+param_substs: Option<param_substs>,
1744+
param_substs: Option<@param_substs>,
17441745
id: ast::node_id,
17451746
impl_id: Option<ast::def_id>,
17461747
maybe_load_env: fn(fn_ctxt),
@@ -1804,7 +1805,7 @@ pub fn trans_fn(ccx: @crate_ctxt,
18041805
body: &ast::blk,
18051806
llfndecl: ValueRef,
18061807
ty_self: self_arg,
1807-
+param_substs: Option<param_substs>,
1808+
param_substs: Option<@param_substs>,
18081809
id: ast::node_id,
18091810
impl_id: Option<ast::def_id>) {
18101811
let do_time = ccx.sess.trans_stats();
@@ -1813,8 +1814,8 @@ pub fn trans_fn(ccx: @crate_ctxt,
18131814
debug!("trans_fn(ty_self=%?)", ty_self);
18141815
let _icx = ccx.insn_ctxt("trans_fn");
18151816
ccx.stats.n_fns += 1;
1816-
// XXX: Bad copy of `path`.
1817-
trans_closure(ccx, copy path, decl, body, llfndecl, ty_self,
1817+
let the_path_str = path_str(ccx.sess, path);
1818+
trans_closure(ccx, path, decl, body, llfndecl, ty_self,
18181819
param_substs, id, impl_id,
18191820
|fcx| {
18201821
if ccx.sess.opts.extra_debuginfo {
@@ -1824,7 +1825,7 @@ pub fn trans_fn(ccx: @crate_ctxt,
18241825
|_bcx| { });
18251826
if do_time {
18261827
let end = time::get_time();
1827-
log_fn_time(ccx, path_str(ccx.sess, path), start, end);
1828+
log_fn_time(ccx, the_path_str, start, end);
18281829
}
18291830
}
18301831

@@ -1834,7 +1835,7 @@ pub fn trans_enum_variant(ccx: @crate_ctxt,
18341835
args: ~[ast::variant_arg],
18351836
disr: int,
18361837
is_degen: bool,
1837-
+param_substs: Option<param_substs>,
1838+
param_substs: Option<@param_substs>,
18381839
llfndecl: ValueRef) {
18391840
let _icx = ccx.insn_ctxt("trans_enum_variant");
18401841
// Translate variant arguments to function arguments.
@@ -1850,9 +1851,8 @@ pub fn trans_enum_variant(ccx: @crate_ctxt,
18501851
id: varg.id,
18511852
}
18521853
};
1853-
// XXX: Bad copy of `param_substs`.
18541854
let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, variant.node.id, None,
1855-
copy param_substs, None);
1855+
param_substs, None);
18561856
// XXX: Bad copy.
18571857
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, copy fn_args);
18581858
let ty_param_substs = match param_substs {
@@ -1897,7 +1897,7 @@ pub fn trans_enum_variant(ccx: @crate_ctxt,
18971897
pub fn trans_tuple_struct(ccx: @crate_ctxt,
18981898
fields: ~[@ast::struct_field],
18991899
ctor_id: ast::node_id,
1900-
+param_substs: Option<param_substs>,
1900+
param_substs: Option<@param_substs>,
19011901
llfndecl: ValueRef) {
19021902
let _icx = ccx.insn_ctxt("trans_tuple_struct");
19031903
@@ -1951,7 +1951,7 @@ pub fn trans_struct_dtor(ccx: @crate_ctxt,
19511951
+path: path,
19521952
body: &ast::blk,
19531953
dtor_id: ast::node_id,
1954-
+psubsts: Option<param_substs>,
1954+
psubsts: Option<@param_substs>,
19551955
hash_id: Option<mono_id>,
19561956
parent_id: ast::def_id)
19571957
-> ValueRef {
@@ -1968,7 +1968,7 @@ pub fn trans_struct_dtor(ccx: @crate_ctxt,
19681968
let lldty = type_of_dtor(ccx, class_ty);
19691969
19701970
// XXX: Bad copies.
1971-
let s = get_dtor_symbol(ccx, copy path, dtor_id, copy psubsts);
1971+
let s = get_dtor_symbol(ccx, copy path, dtor_id, psubsts);
19721972
19731973
/* Register the dtor as a function. It has external linkage */
19741974
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 {
22962296
pub fn get_dtor_symbol(ccx: @crate_ctxt,
22972297
+path: path,
22982298
id: ast::node_id,
2299-
+substs: Option<param_substs>)
2299+
substs: Option<@param_substs>)
23002300
-> ~str {
23012301
let t = ty::node_id_to_type(ccx.tcx, id);
23022302
match ccx.item_symbols.find(&id) {

src/librustc/middle/trans/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ pub fn add_span_comment(bcx: block, sp: span, text: ~str) {
834834
}
835835
}
836836
837-
pub fn add_comment(bcx: block, text: ~str) {
837+
pub fn add_comment(bcx: block, text: &str) {
838838
unsafe {
839839
let ccx = bcx.ccx();
840840
if !ccx.sess.no_asm_comments() {

src/librustc/middle/trans/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ pub struct fn_ctxt_ {
311311

312312
// If this function is being monomorphized, this contains the type
313313
// substitutions used.
314-
param_substs: Option<param_substs>,
314+
param_substs: Option<@param_substs>,
315315

316316
// The source span and nesting context where this function comes from, for
317317
// error reporting and symbol generation.
@@ -1395,7 +1395,7 @@ pub fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, +vt: typeck::vtable_origin)
13951395
}
13961396
typeck::vtable_param(n_param, n_bound) => {
13971397
match fcx.param_substs {
1398-
Some(ref substs) => {
1398+
Some(substs) => {
13991399
find_vtable(tcx, substs, n_param, n_bound)
14001400
}
14011401
_ => {

src/librustc/middle/trans/datum.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ pub impl Datum {
524524
if bcx.sess().trace() {
525525
trans_trace(
526526
bcx, None,
527-
fmt!("preserving until end of scope %d", root_info.scope));
527+
fmt!("preserving until end of scope %d",
528+
root_info.scope));
528529
}
529530

530531
let scratch = scratch_datum(bcx, self.ty, true);

src/librustc/middle/trans/foreign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ pub fn trans_intrinsic(ccx: @crate_ctxt,
332332
decl: ValueRef,
333333
item: @ast::foreign_item,
334334
+path: ast_map::path,
335-
+substs: param_substs,
335+
substs: @param_substs,
336336
ref_id: Option<ast::node_id>) {
337337
debug!("trans_intrinsic(item.ident=%s)", ccx.sess.str_of(item.ident));
338338

src/librustc/middle/trans/meth.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn trans_impl(ccx: @crate_ctxt, +path: path, name: ast::ident,
6666
match self_ty {
6767
None => param_substs_opt = None,
6868
Some(self_ty) => {
69-
param_substs_opt = Some(param_substs {
69+
param_substs_opt = Some(@param_substs {
7070
tys: ~[],
7171
vtables: None,
7272
bounds: @~[],
@@ -99,7 +99,7 @@ Translates a (possibly monomorphized) method body.
9999
pub fn trans_method(ccx: @crate_ctxt,
100100
+path: path,
101101
method: &ast::method,
102-
+param_substs: Option<param_substs>,
102+
param_substs: Option<@param_substs>,
103103
base_self_ty: Option<ty::t>,
104104
llfn: ValueRef,
105105
impl_id: ast::def_id) {
@@ -118,7 +118,7 @@ pub fn trans_method(ccx: @crate_ctxt,
118118
}
119119
let self_ty = match param_substs {
120120
None => self_ty,
121-
Some(param_substs {tys: ref tys, _}) => {
121+
Some(@param_substs {tys: ref tys, _}) => {
122122
ty::subst_tps(ccx.tcx, *tys, None, self_ty)
123123
}
124124
};
@@ -247,7 +247,7 @@ pub fn trans_method_callee(bcx: block,
247247
bound_num: b
248248
}) => {
249249
match bcx.fcx.param_substs {
250-
Some(ref substs) => {
250+
Some(substs) => {
251251
let vtbl = find_vtable(bcx.tcx(), substs, p, b);
252252
trans_monomorphized_callee(bcx, callee_id, self, mentry,
253253
trait_id, off, vtbl)

src/librustc/middle/trans/monomorphize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub fn monomorphic_fn(ccx: @crate_ctxt,
156156
lldecl
157157
};
158158

159-
let psubsts = Some(param_substs {
159+
let psubsts = Some(@param_substs {
160160
tys: substs,
161161
vtables: vtables,
162162
bounds: tpt.bounds,

0 commit comments

Comments
 (0)