Skip to content

Commit f21fb3a

Browse files
committed
rustc: Cleaning up bad copies and other XXXes
1 parent 799d9fa commit f21fb3a

File tree

15 files changed

+37
-48
lines changed

15 files changed

+37
-48
lines changed

src/librustc/middle/trans/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ pub fn GEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
602602
// Simple wrapper around GEP that takes an array of ints and wraps them
603603
// in C_i32()
604604
//
605-
// XXX: Use a small-vector optimization to avoid allocations here.
605+
// FIXME #6571: Use a small-vector optimization to avoid allocations here.
606606
pub fn GEPi(cx: block, base: ValueRef, ixs: &[uint]) -> ValueRef {
607607
let v = do vec::map(ixs) |i| { C_i32(*i as i32) };
608608
count_insn(cx, "gepi");

src/librustc/middle/trans/closure.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub fn mk_tuplified_uniq_cbox_ty(tcx: ty::ctxt, cdata_ty: ty::t) -> ty::t {
137137

138138
// Given a closure ty, emits a corresponding tuple ty
139139
pub fn mk_closure_tys(tcx: ty::ctxt,
140-
bound_values: ~[EnvValue])
140+
bound_values: &[EnvValue])
141141
-> ty::t {
142142
// determine the types of the values in the env. Note that this
143143
// is the actual types that will be stored in the map, not the
@@ -203,8 +203,7 @@ pub fn store_environment(bcx: block,
203203
let ccx = bcx.ccx(), tcx = ccx.tcx;
204204

205205
// compute the shape of the closure
206-
// XXX: Bad copy.
207-
let cdata_ty = mk_closure_tys(tcx, copy bound_values);
206+
let cdata_ty = mk_closure_tys(tcx, bound_values);
208207

209208
// allocate closure in the heap
210209
let Result {bcx: bcx, val: llbox} = allocate_cbox(bcx, sigil, cdata_ty);

src/librustc/middle/trans/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ pub fn is_null(val: ValueRef) -> bool {
13251325
// Used to identify cached monomorphized functions and vtables
13261326
#[deriving(Eq)]
13271327
pub enum mono_param_id {
1328-
mono_precise(ty::t, Option<~[mono_id]>),
1328+
mono_precise(ty::t, Option<@~[mono_id]>),
13291329
mono_any,
13301330
mono_repr(uint /* size */,
13311331
uint /* align */,

src/librustc/middle/trans/datum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ pub impl Datum {
652652
ByRef => {
653653
// Recast lv.val as a pointer to the newtype rather
654654
// than a pointer to the struct type.
655-
// XXX: This isn't correct for structs with
655+
// FIXME #6572: This isn't correct for structs with
656656
// destructors.
657657
(
658658
Some(Datum {

src/librustc/middle/trans/expr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
576576
};
577577
}
578578
ast::expr_struct(_, ref fields, base) => {
579-
return trans_rec_or_struct(bcx, (*fields), base, expr.id, dest);
579+
return trans_rec_or_struct(bcx, (*fields), base, expr.span, expr.id, dest);
580580
}
581581
ast::expr_tup(ref args) => {
582582
let repr = adt::represent_type(bcx.ccx(), expr_ty(bcx, expr));
@@ -721,7 +721,7 @@ fn trans_def_dps_unadjusted(bcx: block, ref_expr: @ast::expr,
721721
}
722722
ast::def_struct(*) => {
723723
// Nothing to do here.
724-
// XXX: May not be true in the case of classes with destructors.
724+
// FIXME #6572: May not be true in the case of classes with destructors.
725725
return bcx;
726726
}
727727
_ => {
@@ -1129,6 +1129,7 @@ pub fn with_field_tys<R>(tcx: ty::ctxt,
11291129
fn trans_rec_or_struct(bcx: block,
11301130
fields: &[ast::field],
11311131
base: Option<@ast::expr>,
1132+
expr_span: codemap::span,
11321133
id: ast::node_id,
11331134
dest: Dest) -> block
11341135
{
@@ -1167,8 +1168,7 @@ fn trans_rec_or_struct(bcx: block,
11671168
}
11681169
None => {
11691170
if need_base.any(|b| *b) {
1170-
// XXX should be span bug
1171-
tcx.sess.bug(~"missing fields and no base expr")
1171+
tcx.sess.span_bug(expr_span, ~"missing fields and no base expr")
11721172
}
11731173
None
11741174
}
@@ -1232,8 +1232,8 @@ fn trans_adt(bcx: block, repr: &adt::Repr, discr: int,
12321232
temp_cleanups.push(dest);
12331233
}
12341234
for optbase.each |base| {
1235-
// XXX is it sound to use the destination's repr on the base?
1236-
// XXX would it ever be reasonable to be here with discr != 0?
1235+
// FIXME #6573: is it sound to use the destination's repr on the base?
1236+
// And, would it ever be reasonable to be here with discr != 0?
12371237
let base_datum = unpack_datum!(bcx, trans_to_datum(bcx, base.expr));
12381238
for base.fields.each |&(i, t)| {
12391239
let datum = do base_datum.get_element(bcx, t, ZeroMem) |srcval| {

src/librustc/middle/trans/foreign.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,13 @@ pub fn trans_intrinsic(ccx: @CrateContext,
550550

551551
let output_type = ty::ty_fn_ret(ty::node_id_to_type(ccx.tcx, item.id));
552552

553-
// XXX: Bad copy.
554553
let fcx = new_fn_ctxt_w_id(ccx,
555554
path,
556555
decl,
557556
item.id,
558557
output_type,
559558
None,
560-
Some(copy substs),
559+
Some(substs),
561560
Some(item.span));
562561

563562
// Set the fixed stack segment flag if necessary.

src/librustc/middle/trans/glue.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
669669
let llsize = llsize_of(ccx, llty);
670670
let llalign = llalign_of(ccx, llty);
671671
let addrspace = declare_tydesc_addrspace(ccx, t);
672-
//XXX this triggers duplicate LLVM symbols
672+
// FIXME #6574: this triggers duplicate LLVM symbols
673673
let name = @(if false /*ccx.sess.opts.debuginfo*/ {
674674
mangle_internal_name_by_type_only(ccx, t, "tydesc")
675675
} else {
@@ -703,14 +703,13 @@ pub fn declare_generic_glue(ccx: @CrateContext, t: ty::t, llfnty: TypeRef,
703703
name: ~str) -> ValueRef {
704704
let _icx = ccx.insn_ctxt("declare_generic_glue");
705705
let name = name;
706-
//XXX this triggers duplicate LLVM symbols
706+
// FIXME #6574 this triggers duplicate LLVM symbols
707707
let fn_nm = @(if false /*ccx.sess.opts.debuginfo*/ {
708708
mangle_internal_name_by_type_only(ccx, t, (~"glue_" + name))
709709
} else {
710710
mangle_internal_name_by_seq(ccx, (~"glue_" + name))
711711
});
712712
debug!("%s is for type %s", *fn_nm, ppaux::ty_to_str(ccx.tcx, t));
713-
// XXX: Bad copy.
714713
note_unique_llvm_symbol(ccx, fn_nm);
715714
let llfn = decl_cdecl_fn(ccx.llmod, *fn_nm, llfnty);
716715
set_glue_inlining(llfn, t);

src/librustc/middle/trans/meth.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ pub fn method_with_name_or_default(ccx: @CrateContext,
401401
Some(pmis) => {
402402
for pmis.each |pmi| {
403403
if pmi.method_info.ident == name {
404-
debug!("XXX %?", pmi.method_info.did);
404+
debug!("pmi.method_info.did = %?", pmi.method_info.did);
405405
return pmi.method_info.did;
406406
}
407407
}
@@ -734,15 +734,15 @@ pub fn trans_trait_callee_from_llval(bcx: block,
734734
}
735735

736736
pub fn vtable_id(ccx: @CrateContext,
737-
origin: typeck::vtable_origin)
737+
origin: &typeck::vtable_origin)
738738
-> mono_id {
739739
match origin {
740-
typeck::vtable_static(impl_id, substs, sub_vtables) => {
740+
&typeck::vtable_static(impl_id, ref substs, sub_vtables) => {
741741
monomorphize::make_mono_id(
742742
ccx,
743743
impl_id,
744-
substs,
745-
if (*sub_vtables).len() == 0u {
744+
*substs,
745+
if sub_vtables.is_empty() {
746746
None
747747
} else {
748748
Some(sub_vtables)
@@ -759,8 +759,7 @@ pub fn vtable_id(ccx: @CrateContext,
759759
pub fn get_vtable(ccx: @CrateContext,
760760
origin: typeck::vtable_origin)
761761
-> ValueRef {
762-
// XXX: Bad copy.
763-
let hash_id = vtable_id(ccx, copy origin);
762+
let hash_id = vtable_id(ccx, &origin);
764763
match ccx.vtables.find(&hash_id) {
765764
Some(&val) => val,
766765
None => match origin {

src/librustc/middle/trans/monomorphize.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
7070
for real_substs.each() |s| { assert!(!ty::type_has_params(*s)); }
7171
for substs.each() |s| { assert!(!ty::type_has_params(*s)); }
7272
let param_uses = type_use::type_uses_for(ccx, fn_id, substs.len());
73-
// XXX: Bad copy.
74-
let hash_id = make_mono_id(ccx, fn_id, copy substs, vtables, impl_did_opt,
73+
let hash_id = make_mono_id(ccx, fn_id, substs, vtables, impl_did_opt,
7574
Some(param_uses));
7675
if vec::any(hash_id.params,
7776
|p| match *p { mono_precise(_, _) => false, _ => true }) {
@@ -350,10 +349,10 @@ pub fn make_mono_id(ccx: @CrateContext,
350349
vec::map_zip(*item_ty.generics.type_param_defs, substs, |type_param_def, subst| {
351350
let mut v = ~[];
352351
for type_param_def.bounds.trait_bounds.each |_bound| {
353-
v.push(meth::vtable_id(ccx, /*bad*/copy vts[i]));
352+
v.push(meth::vtable_id(ccx, &vts[i]));
354353
i += 1;
355354
}
356-
(*subst, if !v.is_empty() { Some(v) } else { None })
355+
(*subst, if !v.is_empty() { Some(@v) } else { None })
357356
})
358357
}
359358
None => {
@@ -369,8 +368,7 @@ pub fn make_mono_id(ccx: @CrateContext,
369368
}
370369
} else {
371370
match *id {
372-
// XXX: Bad copy.
373-
(a, copy b@Some(_)) => mono_precise(a, b),
371+
(a, b@Some(_)) => mono_precise(a, b),
374372
(subst, None) => {
375373
if *uses == 0 {
376374
mono_any

src/librustc/middle/trans/reflect.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub impl Reflector {
8484
self.c_tydesc(mt.ty)]
8585
}
8686

87-
fn visit(&mut self, ty_name: ~str, args: ~[ValueRef]) {
87+
fn visit(&mut self, ty_name: ~str, args: &[ValueRef]) {
8888
let tcx = self.bcx.tcx();
8989
let mth_idx = ty::method_idx(
9090
tcx.sess.ident_of(~"visit_" + ty_name),
@@ -121,10 +121,9 @@ pub impl Reflector {
121121

122122
fn bracketed(&mut self,
123123
bracket_name: ~str,
124-
extra: ~[ValueRef],
124+
extra: &[ValueRef],
125125
inner: &fn(&mut Reflector)) {
126-
// XXX: Bad copy.
127-
self.visit(~"enter_" + bracket_name, copy extra);
126+
self.visit(~"enter_" + bracket_name, extra);
128127
inner(self);
129128
self.visit(~"leave_" + bracket_name, extra);
130129
}
@@ -226,7 +225,7 @@ pub impl Reflector {
226225
self.c_uint(sigilval),
227226
self.c_uint(fty.sig.inputs.len()),
228227
self.c_uint(retval)];
229-
self.visit(~"enter_fn", copy extra); // XXX: Bad copy.
228+
self.visit(~"enter_fn", extra);
230229
self.visit_sig(retval, &fty.sig);
231230
self.visit(~"leave_fn", extra);
232231
}
@@ -241,7 +240,7 @@ pub impl Reflector {
241240
self.c_uint(sigilval),
242241
self.c_uint(fty.sig.inputs.len()),
243242
self.c_uint(retval)];
244-
self.visit(~"enter_fn", copy extra); // XXX: Bad copy.
243+
self.visit(~"enter_fn", extra);
245244
self.visit_sig(retval, &fty.sig);
246245
self.visit(~"leave_fn", extra);
247246
}

src/librustc/middle/trans/type_of.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn type_of_fn(cx: @CrateContext, inputs: &[ty::t], output: ty::t)
4545
if !output_is_immediate {
4646
atys.push(T_ptr(lloutputtype));
4747
} else {
48-
// XXX: Eliminate this.
48+
// FIXME #6575: Eliminate this.
4949
atys.push(T_ptr(T_i8()));
5050
}
5151

@@ -200,7 +200,6 @@ pub fn type_of(cx: @CrateContext, t: ty::t) -> TypeRef {
200200
return llty;
201201
}
202202

203-
// XXX: This is a terrible terrible copy.
204203
let llty = match ty::get(t).sty {
205204
ty::ty_nil | ty::ty_bot => T_nil(),
206205
ty::ty_bool => T_bool(),
@@ -219,7 +218,7 @@ pub fn type_of(cx: @CrateContext, t: ty::t) -> TypeRef {
219218
common::T_named_struct(llvm_type_name(cx,
220219
an_enum,
221220
did,
222-
/*bad*/copy substs.tps))
221+
substs.tps))
223222
}
224223
ty::ty_estr(ty::vstore_box) => {
225224
T_box_ptr(T_box(cx, T_vec(cx, T_i8())))
@@ -280,7 +279,7 @@ pub fn type_of(cx: @CrateContext, t: ty::t) -> TypeRef {
280279
T_named_struct(llvm_type_name(cx,
281280
a_struct,
282281
did,
283-
/*bad*/ copy substs.tps))
282+
substs.tps))
284283
}
285284
}
286285
ty::ty_self(*) => cx.tcx.sess.unimpl(~"type_of: ty_self"),

src/librustc/middle/ty.rs

-4
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ pub enum type_err {
681681
terr_trait_stores_differ(terr_vstore_kind, expected_found<TraitStore>),
682682
terr_in_field(@type_err, ast::ident),
683683
terr_sorts(expected_found<t>),
684-
terr_self_substs,
685684
terr_integer_as_char,
686685
terr_int_mismatch(expected_found<IntVarValue>),
687686
terr_float_mismatch(expected_found<ast::float_ty>),
@@ -3722,9 +3721,6 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str {
37223721
values.found.user_string(cx))
37233722
}
37243723
}
3725-
terr_self_substs => {
3726-
~"inconsistent self substitution" // XXX this is more of a bug
3727-
}
37283724
terr_integer_as_char => {
37293725
fmt!("expected an integral type but found char")
37303726
}

src/librustc/middle/typeck/check/method.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ pub impl<'self> LookupContext<'self> {
438438
return; // inapplicable
439439
}
440440
ast::sty_region(_) => vstore_slice(r)
441-
ast::sty_box(_) => vstore_box, // XXX NDM mutability
441+
ast::sty_box(_) => vstore_box, // NDM mutability, as per #5762
442442
ast::sty_uniq(_) => vstore_uniq
443443
}
444444
*/
@@ -594,7 +594,7 @@ pub impl<'self> LookupContext<'self> {
594594
let method = ty::method(self.tcx(),
595595
provided_method_info.method_info.did);
596596

597-
// XXX: Needs to support generics.
597+
// FIXME #4099 (?) Needs to support generics.
598598
let dummy_substs = substs {
599599
self_r: None,
600600
self_ty: None,

src/librustc/middle/typeck/check/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,6 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
18171817
let mut class_field_map = HashMap::new();
18181818
let mut fields_found = 0;
18191819
for field_types.each |field| {
1820-
// XXX: Check visibility here.
18211820
class_field_map.insert(field.ident, (field.id, false));
18221821
}
18231822

src/librustc/middle/typeck/infer/combine.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ pub fn super_self_tys<C:Combine>(
286286
// I think it should never happen that we unify two substs and
287287
// one of them has a self_ty and one doesn't...? I could be
288288
// wrong about this.
289-
Err(ty::terr_self_substs)
289+
this.infcx().tcx.sess.bug(
290+
fmt!("substitution a had a self_ty and substitution b didn't, \
291+
or vice versa"));
290292
}
291293
}
292294
}

0 commit comments

Comments
 (0)