From 1d4972e0e923bd5fffb11465373c824be109375f Mon Sep 17 00:00:00 2001 From: Hans Kratz Date: Mon, 9 Aug 2021 12:59:23 +0000 Subject: [PATCH] Avoid unnecessary allocation. --- compiler/rustc_codegen_llvm/src/type_of.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index 225044c848857..180da1a6046e6 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -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> {