]> git.lizzy.rs Git - rust.git/commitdiff
Incorporate review comments
authorAustin Hicks <camlorn@camlorn.net>
Wed, 23 Nov 2016 22:43:36 +0000 (17:43 -0500)
committerAustin Hicks <camlorn@camlorn.net>
Wed, 14 Dec 2016 17:28:25 +0000 (12:28 -0500)
src/librustc/ty/layout.rs
src/test/run-pass/closure-immediate.rs
src/test/run-pass/multiple-reprs.rs

index 6f63b15abe8a7c2f3915807f62c6e06dda098d2c..96d66153d777e126eb0c3b5f3aa68eeb7195b2ee 100644 (file)
@@ -459,11 +459,7 @@ fn repr_discr(tcx: TyCtxt, ty: Ty, hints: &[attr::ReprAttr], min: i64, max: i64)
             }
         }
 
-        let at_least = if let Some(i) = min_from_extern {
-            i
-        } else {
-            min_default
-        };
+        let at_least = min_from_extern.unwrap_or(min_default);
 
         // If there are no negative values, we can use the unsigned fit.
         if min >= 0 {
@@ -571,13 +567,11 @@ fn new(dl: &TargetDataLayout, fields: &Vec<&'a Layout>,
         if can_optimize {
             // This exhaustive match makes new reprs force the adder to modify this function.
             // Otherwise, things can silently break.
-            // Note the inversion, return true to stop matching.
+            // Note the inversion, return true to stop optimizing.
             can_optimize = !reprs.iter().any(|r| {
                 match *r {
-                    attr::ReprAny => false,
-                    attr::ReprInt(_) => false,
-                    attr::ReprExtern => true,
-                    attr::ReprPacked => true,
+                    attr::ReprAny | attr::ReprInt(_) => false,
+                    attr::ReprExtern | attr::ReprPacked => true,
                     attr::ReprSimd => bug!("Simd  vectors should be represented as layout::Vector")
                 }
             });
@@ -588,7 +582,7 @@ fn new(dl: &TargetDataLayout, fields: &Vec<&'a Layout>,
             StructKind::MaybeUnsizedUnivariant => (can_optimize, false),
             StructKind::EnumVariant => {
                 assert!(fields.len() >= 1, "Enum variants must have discriminants.");
-                (can_optimize || fields[0].size(dl).bytes() == 1, true)
+                (can_optimize && fields[0].size(dl).bytes() == 1, true)
             }
         };
 
@@ -1189,7 +1183,7 @@ pub fn compute_uncached(ty: Ty<'gcx>,
                     });
                 }
 
-                if !def.is_enum() || def.variants.len() == 1 && hints.len() == 0 {
+                if !def.is_enum() || def.variants.len() == 1 && hints.is_empty() {
                     // Struct, or union, or univariant enum equivalent to a struct.
                     // (Typechecking will reject discriminant-sizing attrs.)
 
@@ -1239,7 +1233,7 @@ pub fn compute_uncached(ty: Ty<'gcx>,
                     v.fields.iter().map(|field| field.ty(tcx, substs)).collect::<Vec<_>>()
                 }).collect::<Vec<_>>();
 
-                if variants.len() == 2 && hints.len() == 0 {
+                if variants.len() == 2 && hints.is_empty() {
                     // Nullable pointer optimization
                     for discr in 0..2 {
                         let other_fields = variants[1 - discr].iter().map(|ty| {
index 69aa16c3fb592a4e7b1e15a31cb12c106b7cb263..e566c10583597520efbe53d8dae22a67ffb26402 100644 (file)
@@ -19,4 +19,4 @@ fn main() {
         assert_eq!(c, 3);
     };
     c(1, 2, 3);
-}
\ No newline at end of file
+}
index 726563e5b498a42ce1963e8a4aa42690162a4cab..c2fe943eed85ad65f617bf88194f9fb266f42630 100644 (file)
@@ -28,7 +28,6 @@ enum E2 {
 }
 
 // From pr 37429
-pub const SIZEOF_QUERY:      usize = 21;
 
 #[repr(C,packed)]
 pub struct p0f_api_query {