Skip to content

Commit 6de477c

Browse files
committed
Fix inconsistent use of substs in trans_unboxing_shim
Substs were not applied when calling `untuple_arguments_if_necessary`. Just apply them once at the start of the function, rebinding `fty`. Also change the function to take them by reference since we don't need to consume them at all. Closes #18883
1 parent e82f60e commit 6de477c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/librustc/middle/trans/callee.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,14 @@ pub fn trans_unboxing_shim(bcx: Block,
253253
llshimmedfn: ValueRef,
254254
fty: &ty::BareFnTy,
255255
method_id: ast::DefId,
256-
substs: subst::Substs)
256+
substs: &subst::Substs)
257257
-> ValueRef {
258258
let _icx = push_ctxt("trans_unboxing_shim");
259259
let ccx = bcx.ccx();
260260
let tcx = bcx.tcx();
261261

262+
let fty = fty.subst(tcx, substs);
263+
262264
// Transform the self type to `Box<self_type>`.
263265
let self_type = fty.sig.inputs[0];
264266
let boxed_self_type = ty::mk_uniq(tcx, self_type);
@@ -279,8 +281,7 @@ pub fn trans_unboxing_shim(bcx: Block,
279281
abi: fty.abi,
280282
sig: boxed_function_type,
281283
};
282-
let boxed_function_type =
283-
ty::mk_bare_fn(tcx, boxed_function_type).subst(tcx, &substs);
284+
let boxed_function_type = ty::mk_bare_fn(tcx, boxed_function_type);
284285
let function_type = match fty.abi {
285286
synabi::RustCall => {
286287
// We're passing through to a RustCall ABI function, but
@@ -301,10 +302,10 @@ pub fn trans_unboxing_shim(bcx: Block,
301302
abi: synabi::Rust,
302303
sig: fake_ty,
303304
};
304-
ty::mk_bare_fn(tcx, fake_ty).subst(tcx, &substs)
305+
ty::mk_bare_fn(tcx, fake_ty)
305306
}
306307
_ => {
307-
ty::mk_bare_fn(tcx, (*fty).clone()).subst(tcx, &substs)
308+
ty::mk_bare_fn(tcx, fty)
308309
}
309310
};
310311

src/librustc/middle/trans/meth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ pub fn get_vtable(bcx: Block,
624624
llfn,
625625
&closure_type,
626626
closure_def_id,
627-
substs);
627+
&substs);
628628
}
629629
}
630630

@@ -723,7 +723,7 @@ fn emit_vtable_methods(bcx: Block,
723723
fn_ref,
724724
&m.fty,
725725
m_id,
726-
substs.clone());
726+
&substs);
727727
}
728728
Some(fn_ref).into_iter()
729729
}

0 commit comments

Comments
 (0)