]> git.lizzy.rs Git - rust.git/commitdiff
Don't emit memcpy's for zero-sized types
authorBjörn Steinbrink <bsteinbr@gmail.com>
Sat, 22 Aug 2015 15:07:37 +0000 (17:07 +0200)
committerBjörn Steinbrink <bsteinbr@gmail.com>
Sat, 22 Aug 2015 17:24:00 +0000 (19:24 +0200)
src/librustc_trans/trans/base.rs

index 6be2bb0846463146ad71490219486f598b209e21..78bbe0d4ebca938ac42d0a4ff635fdacfbf3f9a3 100644 (file)
@@ -956,6 +956,11 @@ pub fn memcpy_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                              t: Ty<'tcx>) {
     let _icx = push_ctxt("memcpy_ty");
     let ccx = bcx.ccx();
+
+    if type_is_zero_size(ccx, t) {
+        return;
+    }
+
     if t.is_structural() {
         let llty = type_of::type_of(ccx, t);
         let llsz = llsize_of(ccx, llty);