Skip to content

Commit a3cd293

Browse files
committed
Don't perform a double substitution in some cases
1 parent 98c83d2 commit a3cd293

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/common.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,17 @@ impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> {
305305
impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> {
306306
pub(crate) fn monomorphize<T>(&self, value: &T) -> T
307307
where
308-
T: TypeFoldable<'tcx>,
308+
T: TypeFoldable<'tcx> + Copy,
309309
{
310-
self.tcx.subst_and_normalize_erasing_regions(
311-
self.instance.substs,
312-
ty::ParamEnv::reveal_all(),
313-
value,
314-
)
310+
if let Some(substs) = self.instance.substs_for_mir_body() {
311+
self.tcx.subst_and_normalize_erasing_regions(
312+
substs,
313+
ty::ParamEnv::reveal_all(),
314+
value,
315+
)
316+
} else {
317+
self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value)
318+
}
315319
}
316320

317321
pub(crate) fn clif_type(&self, ty: Ty<'tcx>) -> Option<Type> {

0 commit comments

Comments
 (0)