about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAustin Hicks <camlorn@camlorn.net>2016-11-21 14:23:15 -0500
committerAustin Hicks <camlorn@camlorn.net>2016-12-14 12:28:21 -0500
commitadae9bc25ecb25b3d0ac03591438bfde72f98291 (patch)
tree0a55d125ac45f9bf55c7a668963abf67104d8c5d
parent3d23dc7956ab31a2758b723213bf6235ba57ed55 (diff)
downloadrust-adae9bc25ecb25b3d0ac03591438bfde72f98291.tar.gz
rust-adae9bc25ecb25b3d0ac03591438bfde72f98291.zip
Make tidy
-rw-r--r--src/librustc/ty/layout.rs25
-rw-r--r--src/librustc_lint/types.rs3
-rw-r--r--src/librustc_trans/debuginfo/metadata.rs8
-rw-r--r--src/test/run-pass/enum-size-variance.rs4
4 files changed, 26 insertions, 14 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs
index bcbafc8a28a..ebda879e908 100644
--- a/src/librustc/ty/layout.rs
+++ b/src/librustc/ty/layout.rs
@@ -538,7 +538,10 @@ impl<'a, 'gcx, 'tcx> Struct {
             min_size: Size::from_bytes(0),
         };
 
-        if is_enum_variant { assert!(fields.len() >= 1, "Enum variants must have at least a discriminant field.") }
+        if is_enum_variant {
+            assert!(fields.len() >= 1, "Enum variants must have at least a discriminant field.")
+        }
+
         if fields.len() == 0 {return Ok(ret)};
 
         ret.offsets = vec![Size::from_bytes(0); fields.len()];
@@ -546,7 +549,8 @@ impl<'a, 'gcx, 'tcx> Struct {
 
         if repr == attr::ReprAny {
             let start = if is_enum_variant {1} else {0};
-            // FIXME(camlorn): we can't reorder the last field because it is possible for structs to be coerced to unsized.
+            // FIXME(camlorn): we can't reorder the last field because
+            // it is possible for structs to be coerced to unsized.
             // Example: struct Foo<T: ?Sized> { x: i32, y: T }
             // We can coerce &Foo<u8> to &Foo<Trait>.
             let end = inverse_memory_index.len()-1;
@@ -554,12 +558,16 @@ impl<'a, 'gcx, 'tcx> Struct {
                 let optimizing  = &mut inverse_memory_index[start..end];
                 optimizing.sort_by_key(|&x| fields[x as usize].align(dl).abi());
             }
-            if is_enum_variant { assert_eq!(inverse_memory_index[0], 0, "Enums must have field 0 as the field with lowest offset.") }
+            if is_enum_variant {
+                assert_eq!(inverse_memory_index[0], 0,
+                  "Enums must have field 0 as the field with lowest offset.")
+            }
         }
-        
+
         // At this point, inverse_memory_index holds field indices by increasing offset.
         // That is, if field 5 has offset 0, the first element of inverse_memory_index is 5.
-        // We now write field offsets to the corresponding offset slot; field 5 with offset 0 puts 0 in offsets[5].
+        // We now write field offsets to the corresponding offset slot;
+        // field 5 with offset 0 puts 0 in offsets[5].
         // At the bottom of this function, we use inverse_memory_index to produce memory_index.
 
         let mut offset = Size::from_bytes(0);
@@ -976,7 +984,10 @@ impl<'a, 'gcx, 'tcx> Layout {
             ty::TyFnPtr(_) => Scalar { value: Pointer, non_zero: true },
 
             // The never type.
-            ty::TyNever => Univariant { variant: Struct::new(dl, &vec![], attr::ReprAny, false, ty)?, non_zero: false },
+            ty::TyNever => Univariant {
+                variant: Struct::new(dl, &vec![], attr::ReprAny, false, ty)?,
+                non_zero: false
+            },
 
             // Potentially-fat pointers.
             ty::TyBox(pointee) |
@@ -1179,7 +1190,7 @@ impl<'a, 'gcx, 'tcx> Layout {
                               .collect::<Result<Vec<_>, _>>()?,
                             hint, false, ty)?;
 
-                        // We have to fix the last element of path here as only we know the right value.
+                        // We have to fix the last element of path here.
                         let mut i = *path.last().unwrap();
                         i = st.memory_index[i as usize];
                         *path.last_mut().unwrap() = i;
diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs
index 49bbcc18efb..751c9c3440f 100644
--- a/src/librustc_lint/types.rs
+++ b/src/librustc_lint/types.rs
@@ -750,7 +750,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
                 if let Layout::General { ref variants, ref size, discr, .. } = *layout {
                     let discr_size = Primitive::Int(discr).size(&cx.tcx.data_layout).bytes();
 
-                    debug!("enum `{}` is {} bytes large with layout:\n{:#?}", t, size.bytes(), layout);
+                    debug!("enum `{}` is {} bytes large with layout:\n{:#?}",
+                      t, size.bytes(), layout);
 
                     let (largest, slargest, largest_index) = enum_definition.variants
                         .iter()
diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs
index ad610396598..f6b5bde6ebb 100644
--- a/src/librustc_trans/debuginfo/metadata.rs
+++ b/src/librustc_trans/debuginfo/metadata.rs
@@ -891,15 +891,15 @@ impl<'tcx> StructMemberDescriptionFactory<'tcx> {
     fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
                                       -> Vec<MemberDescription> {
         let layout = cx.layout_of(self.ty);
-        
-        // The following code is slightly convoluted as to allow us to avoid allocating in the Univariant case.
-        // tmp exists only so we can take a reference to it in the second match arm below.
+
         let tmp;
         let offsets = match *layout {
             layout::Univariant { ref variant, .. } => &variant.offsets,
             layout::Vector { element, count } => {
                 let element_size = element.size(&cx.tcx().data_layout).bytes();
-                tmp = (0..count).map(|i| layout::Size::from_bytes(i*element_size)).collect::<Vec<layout::Size>>();
+                tmp = (0..count).
+                  map(|i| layout::Size::from_bytes(i*element_size))
+                  .collect::<Vec<layout::Size>>();
                 &tmp
             }
             _ => bug!("{} is not a struct", self.ty)
diff --git a/src/test/run-pass/enum-size-variance.rs b/src/test/run-pass/enum-size-variance.rs
index beccbf5eb03..a3e95a15341 100644
--- a/src/test/run-pass/enum-size-variance.rs
+++ b/src/test/run-pass/enum-size-variance.rs
@@ -11,8 +11,8 @@
 #![warn(variant_size_differences)]
 #![allow(dead_code)]
 
-// Note that the following test only works because all fields of the enum variants are of the same size.
-// If this test is modified so that the reordering logic in librustc/ty/layout.rs kicks in, it will fail.
+// Note that the following test works because all fields of the enum variants are of the same size.
+// If this test is modified and the reordering logic in librustc/ty/layout.rs kicks in, it fails.
 
 enum Enum1 { }