]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_ssa/glue.rs
Auto merge of #67900 - nikic:prepare-llvm-10, r=nagisa
[rust.git] / src / librustc_codegen_ssa / glue.rs
index 9818bb78e757b984de7d2a0de87e4f989dec5f48..a43e84272868c07585f2adcdef77ec904b48266d 100644 (file)
@@ -2,10 +2,10 @@
 //
 // Code relating to drop glue.
 
-use rustc::ty::{self, Ty};
 use crate::common::IntPredicate;
 use crate::meth;
 use crate::traits::*;
+use rustc::ty::{self, Ty};
 
 pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
     bx: &mut Bx,
@@ -13,8 +13,7 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
     info: Option<Bx::Value>,
 ) -> (Bx::Value, Bx::Value) {
     let layout = bx.layout_of(t);
-    debug!("size_and_align_of_dst(ty={}, info={:?}): layout: {:?}",
-           t, info, layout);
+    debug!("size_and_align_of_dst(ty={}, info={:?}): layout: {:?}", t, info, layout);
     if !layout.is_unsized() {
         let size = bx.const_usize(layout.size.bytes());
         let align = bx.const_usize(layout.align.abi.bytes());
@@ -30,8 +29,10 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
             let unit = layout.field(bx, 0);
             // The info in this case is the length of the str, so the size is that
             // times the unit size.
-            (bx.mul(info.unwrap(), bx.const_usize(unit.size.bytes())),
-             bx.const_usize(unit.align.abi.bytes()))
+            (
+                bx.mul(info.unwrap(), bx.const_usize(unit.size.bytes())),
+                bx.const_usize(unit.align.abi.bytes()),
+            )
         }
         _ => {
             // First get the size of all statically known fields.
@@ -43,8 +44,7 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
             let i = layout.fields.count() - 1;
             let sized_size = layout.fields.offset(i).bytes();
             let sized_align = layout.align.abi.bytes();
-            debug!("DST {} statically sized prefix size: {} align: {}",
-                   t, sized_size, sized_align);
+            debug!("DST {} statically sized prefix size: {} align: {}", t, sized_size, sized_align);
             let sized_size = bx.const_usize(sized_size);
             let sized_align = bx.const_usize(sized_align);
 
@@ -72,8 +72,10 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
 
             // Choose max of two known alignments (combined value must
             // be aligned according to more restrictive of the two).
-            let align = match (bx.const_to_opt_u128(sized_align, false),
-                               bx.const_to_opt_u128(unsized_align, false)) {
+            let align = match (
+                bx.const_to_opt_u128(sized_align, false),
+                bx.const_to_opt_u128(unsized_align, false),
+            ) {
                 (Some(sized_align), Some(unsized_align)) => {
                     // If both alignments are constant, (the sized_align should always be), then
                     // pick the correct alignment statically.
@@ -98,7 +100,7 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
             let one = bx.const_usize(1);
             let addend = bx.sub(align, one);
             let add = bx.add(size, addend);
-            let neg =  bx.neg(align);
+            let neg = bx.neg(align);
             let size = bx.and(add, neg);
 
             (size, align)