about summary refs log tree commit diff
path: root/src/librustc_trans
diff options
context:
space:
mode:
authorMark Simulacrum <mark.simulacrum@gmail.com>2017-05-12 18:57:33 -0600
committerGitHub <noreply@github.com>2017-05-12 18:57:33 -0600
commitcf4fac6ec5add119dafb798790e233e08ba64d01 (patch)
tree43a43c15903e30a424dba1ff8ef23e2aeae3f518 /src/librustc_trans
parentee1c102cac456d01bd539a2d359d3e7c38e892c4 (diff)
parent68c1ce91701a322601dec0e0c8845e535909f9b2 (diff)
downloadrust-cf4fac6ec5add119dafb798790e233e08ba64d01.tar.gz
rust-cf4fac6ec5add119dafb798790e233e08ba64d01.zip
Rollup merge of #41923 - eddyb:issue-41744, r=arielb1
rustc_trans: do not attempt to truncate an i1 const to i1.

Fixes #41744 by skipping the truncation when it'd be a noop anyway.
Diffstat (limited to 'src/librustc_trans')
-rw-r--r--src/librustc_trans/mir/constant.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs
index 6ba00c7e103..cd27ddda1b1 100644
--- a/src/librustc_trans/mir/constant.rs
+++ b/src/librustc_trans/mir/constant.rs
@@ -415,8 +415,11 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
                                           Value(base));
                             }
                             if projected_ty.is_bool() {
-                                unsafe {
-                                    val = llvm::LLVMConstTrunc(val, Type::i1(self.ccx).to_ref());
+                                let i1_type = Type::i1(self.ccx);
+                                if val_ty(val) != i1_type {
+                                    unsafe {
+                                        val = llvm::LLVMConstTrunc(val, i1_type.to_ref());
+                                    }
                                 }
                             }
                             (Base::Value(val), extra)