diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2020-06-24 12:10:20 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2020-06-24 12:10:20 +0200 |
| commit | a3cd293148e0678074cbbec06e5d3e9159a14ea0 (patch) | |
| tree | 9b329dd71c612ffcfd998511c0dae7712ddbf1eb | |
| parent | 98c83d21f55b5b66e55f6908f31dbd0cd1a96f59 (diff) | |
| download | rust-a3cd293148e0678074cbbec06e5d3e9159a14ea0.tar.gz rust-a3cd293148e0678074cbbec06e5d3e9159a14ea0.zip | |
Don't perform a double substitution in some cases
| -rw-r--r-- | src/common.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/common.rs b/src/common.rs index ec58a7d3d29..1d69018be50 100644 --- a/src/common.rs +++ b/src/common.rs @@ -305,13 +305,17 @@ impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> { impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { pub(crate) fn monomorphize<T>(&self, value: &T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable<'tcx> + Copy, { - self.tcx.subst_and_normalize_erasing_regions( - self.instance.substs, - ty::ParamEnv::reveal_all(), - value, - ) + if let Some(substs) = self.instance.substs_for_mir_body() { + self.tcx.subst_and_normalize_erasing_regions( + substs, + ty::ParamEnv::reveal_all(), + value, + ) + } else { + self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) + } } pub(crate) fn clif_type(&self, ty: Ty<'tcx>) -> Option<Type> { |
