about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/ty/layout.rs20
-rw-r--r--src/test/run-pass/closure-immediate.rs2
-rw-r--r--src/test/run-pass/multiple-reprs.rs1
3 files changed, 8 insertions, 15 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs
index 6f63b15abe8..96d66153d77 100644
--- a/src/librustc/ty/layout.rs
+++ b/src/librustc/ty/layout.rs
@@ -459,11 +459,7 @@ impl Integer {
             }
         }
 
-        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 @@ impl<'a, 'gcx, 'tcx> Struct {
         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 @@ impl<'a, 'gcx, 'tcx> Struct {
             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 @@ impl<'a, 'gcx, 'tcx> Layout {
                     });
                 }
 
-                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 @@ impl<'a, 'gcx, 'tcx> Layout {
                     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| {
diff --git a/src/test/run-pass/closure-immediate.rs b/src/test/run-pass/closure-immediate.rs
index 69aa16c3fb5..e566c105835 100644
--- a/src/test/run-pass/closure-immediate.rs
+++ b/src/test/run-pass/closure-immediate.rs
@@ -19,4 +19,4 @@ fn main() {
         assert_eq!(c, 3);
     };
     c(1, 2, 3);
-}
\ No newline at end of file
+}
diff --git a/src/test/run-pass/multiple-reprs.rs b/src/test/run-pass/multiple-reprs.rs
index 726563e5b49..c2fe943eed8 100644
--- a/src/test/run-pass/multiple-reprs.rs
+++ b/src/test/run-pass/multiple-reprs.rs
@@ -28,7 +28,6 @@ enum E2 {
 }
 
 // From pr 37429
-pub const SIZEOF_QUERY:      usize = 21;
 
 #[repr(C,packed)]
 pub struct p0f_api_query {