Skip to content

Commit 2b89b43

Browse files
committed
Normalize self types for monomorphization.
1 parent 82ae2fa commit 2b89b43

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/librustc/middle/trans/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub fn trans_fn_ref_with_vtables(
250250
def_id: ast::def_id, // def id of fn
251251
ref_id: ast::node_id, // node id of use of fn; may be zero if N/A
252252
type_params: &[ty::t], // values for fn's ty params
253-
vtables: Option<typeck::vtable_res>)
253+
vtables: Option<typeck::vtable_res>) // vtables for the call
254254
-> FnData {
255255
//!
256256
//

src/librustc/middle/trans/monomorphize.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,26 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
6363
assert!(real_substs.tps.iter().all(|t| !ty::type_needs_infer(*t)));
6464
let _icx = push_ctxt("monomorphic_fn");
6565
let mut must_cast = false;
66-
let substs = real_substs.tps.iter().transform(|t| {
66+
67+
let do_normalize = |t: &ty::t| {
6768
match normalize_for_monomorphization(ccx.tcx, *t) {
6869
Some(t) => { must_cast = true; t }
6970
None => *t
7071
}
71-
}).collect::<~[ty::t]>();
72-
73-
for real_substs.tps.iter().advance |s| { assert!(!ty::type_has_params(*s)); }
74-
for substs.iter().advance |s| { assert!(!ty::type_has_params(*s)); }
75-
let param_uses = type_use::type_uses_for(ccx, fn_id, substs.len());
72+
};
7673

7774
let psubsts = @param_substs {
78-
tys: substs,
75+
tys: real_substs.tps.map(|x| do_normalize(x)),
7976
vtables: vtables,
80-
self_ty: real_substs.self_ty,
77+
self_ty: real_substs.self_ty.map(|x| do_normalize(x)),
8178
self_vtable: self_vtable
8279
};
8380

81+
for real_substs.tps.iter().advance |s| { assert!(!ty::type_has_params(*s)); }
82+
for psubsts.tys.iter().advance |s| { assert!(!ty::type_has_params(*s)); }
83+
let param_uses = type_use::type_uses_for(ccx, fn_id, psubsts.tys.len());
84+
85+
8486
let hash_id = make_mono_id(ccx, fn_id, impl_did_opt,
8587
&*psubsts,
8688
Some(param_uses));

0 commit comments

Comments
 (0)