]> git.lizzy.rs Git - rust.git/commitdiff
Avoid unnecessary allocation.
authorHans Kratz <hans@appfour.com>
Mon, 9 Aug 2021 12:59:23 +0000 (12:59 +0000)
committerHans Kratz <hans@appfour.com>
Mon, 9 Aug 2021 12:59:23 +0000 (12:59 +0000)
compiler/rustc_codegen_llvm/src/type_of.rs

index 225044c84885703101dd428e8ee37bb4344fdf45..180da1a6046e652267508add6d08cdd1d01e3878 100644 (file)
@@ -150,8 +150,8 @@ fn struct_llfields<'a, 'tcx>(
     } else {
         debug!("struct_llfields: offset: {:?} stride: {:?}", offset, layout.size);
     }
-
-    (result, packed, padding_used.then_some(Box::new(field_remapping)))
+    let field_remapping = if padding_used { Some(Box::new(field_remapping)) } else { None };
+    (result, packed, field_remapping)
 }
 
 impl<'a, 'tcx> CodegenCx<'a, 'tcx> {