]> git.lizzy.rs Git - rust.git/commitdiff
Incorporate review comments.
authorAustin Hicks <camlorn@camlorn.net>
Fri, 16 Dec 2016 17:06:12 +0000 (12:06 -0500)
committerAustin Hicks <camlorn@camlorn.net>
Fri, 16 Dec 2016 17:06:12 +0000 (12:06 -0500)
src/librustc/ty/layout.rs
src/librustc_trans/debuginfo/metadata.rs

index 7a8a34788d2779562cee43ba11c3c5cd2a19ef1d..53ed103ad914106c27847f2277b867c7d2bb91c8 100644 (file)
@@ -557,8 +557,6 @@ fn new(dl: &TargetDataLayout, fields: &Vec<&'a Layout>,
             min_size: Size::from_bytes(0),
         };
 
-        if fields.len() == 0 {return Ok(ret)};
-
         // Anything with ReprExtern or ReprPacked doesn't optimize.
         // Neither do  1-member and 2-member structs.
         // In addition, code in trans assume that 2-element structs can become pairs.
@@ -590,9 +588,9 @@ fn new(dl: &TargetDataLayout, fields: &Vec<&'a Layout>,
         let mut inverse_memory_index: Vec<u32> = (0..fields.len() as u32).collect();
 
         if optimize {
-            let start = if let StructKind::EnumVariant = kind {1} else {0};
+            let start = if let StructKind::EnumVariant = kind { 1 } else { 0 };
             let end = if let StructKind::MaybeUnsizedUnivariant = kind {
-                fields.len()-1
+                fields.len() - 1
             } else {
                 fields.len()
             };
@@ -717,12 +715,12 @@ pub fn field_index_by_increasing_offset<'b>(&'b self) -> impl iter::Iterator<Ite
 
     /// Find the path leading to a non-zero leaf field, starting from
     /// the given type and recursing through aggregates.
-    /// The tuple is `(path, source_path)1,
+    /// The tuple is `(path, source_path)`,
     /// where `path` is in memory order and `source_path` in source order.
     // FIXME(eddyb) track value ranges and traverse already optimized enums.
     fn non_zero_field_in_type(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
-                                  ty: Ty<'gcx>)
-                                  -> Result<Option<(FieldPath, FieldPath)>, LayoutError<'gcx>> {
+                               ty: Ty<'gcx>)
+                               -> Result<Option<(FieldPath, FieldPath)>, LayoutError<'gcx>> {
         let tcx = infcx.tcx.global_tcx();
         match (ty.layout(infcx)?, &ty.sty) {
             (&Scalar { non_zero: true, .. }, _) |
@@ -792,7 +790,7 @@ fn non_zero_field_in_type(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
 
     /// Find the path leading to a non-zero leaf field, starting from
     /// the given set of fields and recursing through aggregates.
-    // / Returns Some((path, source_path)) on success.
+    /// Returns Some((path, source_path)) on success.
     /// `path` is translated to memory order. `source_path` is not.
     fn non_zero_field_paths<I>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
                                   fields: I,
@@ -1363,7 +1361,7 @@ pub fn compute_uncached(ty: Ty<'gcx>,
                         for i in variant.offsets.iter_mut() {
                             // The first field is the discrimminant, at offset 0.
                             // These aren't in order, and we need to skip it.
-                            if *i <= old_ity_size && *i > Size::from_bytes(0){
+                            if *i <= old_ity_size && *i > Size::from_bytes(0) {
                                 *i = new_ity_size;
                             }
                         }
index f9600be1c6618de0f191152526793cb96c3bebbd..dc89caf02016c7745d33229180f9846379d288b7 100644 (file)
@@ -1309,7 +1309,7 @@ fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
 // Creates MemberDescriptions for the fields of a single enum variant.
 struct VariantMemberDescriptionFactory<'tcx> {
     // Cloned from the layout::Struct describing the variant.
-    offsets: Vec<layout::Size>,
+    offsets: &'tcx [layout::Size],
     args: Vec<(String, Ty<'tcx>)>,
     discriminant_type_metadata: Option<DIType>,
     span: Span,
@@ -1346,7 +1346,7 @@ enum EnumDiscriminantInfo {
 // full RecursiveTypeDescription.
 fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                                    enum_type: Ty<'tcx>,
-                                   struct_def: &layout::Struct,
+                                   struct_def: &'tcx layout::Struct,
                                    variant: &'tcx ty::VariantDef,
                                    discriminant_info: EnumDiscriminantInfo,
                                    containing_scope: DIScope,
@@ -1430,7 +1430,7 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
     let member_description_factory =
         VariantMDF(VariantMemberDescriptionFactory {
-            offsets: struct_def.offsets.clone(),
+            offsets: &struct_def.offsets[..],
             args: args,
             discriminant_type_metadata: match discriminant_info {
                 RegularDiscriminant(discriminant_type_metadata) => {