about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2017-12-01 21:24:08 -0500
committerNiko Matsakis <niko@alum.mit.edu>2017-12-04 09:14:39 -0500
commitc1708abb071eb1a627ebadc494ed4b1083e44f2f (patch)
treef5dada2190aad0118487585339029bfb45a39f61
parent506e80c8998d299b61b7e75b8e6cb405bac71d9e (diff)
downloadrust-c1708abb071eb1a627ebadc494ed4b1083e44f2f.tar.gz
rust-c1708abb071eb1a627ebadc494ed4b1083e44f2f.zip
type_check.rs: rustfmt
-rw-r--r--src/librustc_mir/transform/type_check.rs52
1 files changed, 23 insertions, 29 deletions
diff --git a/src/librustc_mir/transform/type_check.rs b/src/librustc_mir/transform/type_check.rs
index 45594613fa4..f0b62e28a0d 100644
--- a/src/librustc_mir/transform/type_check.rs
+++ b/src/librustc_mir/transform/type_check.rs
@@ -104,12 +104,7 @@ impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> {
         }
     }
 
-    fn visit_place(
-        &mut self,
-        place: &Place<'tcx>,
-        context: PlaceContext,
-        location: Location,
-    ) {
+    fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) {
         self.sanitize_place(place, location, context);
     }
 
@@ -164,11 +159,12 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
         }
     }
 
-    fn sanitize_place(&mut self,
-                       place: &Place<'tcx>,
-                       location: Location,
-                       context: PlaceContext)
-                       -> PlaceTy<'tcx> {
+    fn sanitize_place(
+        &mut self,
+        place: &Place<'tcx>,
+        location: Location,
+        context: PlaceContext,
+    ) -> PlaceTy<'tcx> {
         debug!("sanitize_place: {:?}", place);
         let place_ty = match *place {
             Place::Local(index) => PlaceTy::Ty {
@@ -210,9 +206,11 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
         };
         if let PlaceContext::Copy = context {
             let ty = place_ty.to_ty(self.tcx());
-            if self.cx.infcx.type_moves_by_default(self.cx.param_env, ty, DUMMY_SP) {
-                span_mirbug!(self, place,
-                             "attempted copy of non-Copy type ({:?})", ty);
+            if self.cx
+                .infcx
+                .type_moves_by_default(self.cx.param_env, ty, DUMMY_SP)
+            {
+                span_mirbug!(self, place, "attempted copy of non-Copy type ({:?})", ty);
             }
         }
         place_ty
@@ -312,18 +310,16 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
             ProjectionElem::Field(field, fty) => {
                 let fty = self.sanitize_type(place, fty);
                 match self.field_ty(place, base, field, location) {
-                    Ok(ty) => {
-                        if let Err(terr) = self.cx.eq_types(ty, fty, location.at_self()) {
-                            span_mirbug!(
-                                self,
-                                place,
-                                "bad field access ({:?}: {:?}): {:?}",
-                                ty,
-                                fty,
-                                terr
-                            );
-                        }
-                    }
+                    Ok(ty) => if let Err(terr) = self.cx.eq_types(ty, fty, location.at_self()) {
+                        span_mirbug!(
+                            self,
+                            place,
+                            "bad field access ({:?}: {:?}): {:?}",
+                            ty,
+                            fty,
+                            terr
+                        );
+                    },
                     Err(FieldAccessError::OutOfRange { field_count }) => span_mirbug!(
                         self,
                         place,
@@ -358,9 +354,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
                 variant_index,
             } => (&adt_def.variants[variant_index], substs),
             PlaceTy::Ty { ty } => match ty.sty {
-                ty::TyAdt(adt_def, substs) if !adt_def.is_enum() => {
-                    (&adt_def.variants[0], substs)
-                }
+                ty::TyAdt(adt_def, substs) if !adt_def.is_enum() => (&adt_def.variants[0], substs),
                 ty::TyClosure(def_id, substs) => {
                     return match substs.upvar_tys(def_id, tcx).nth(field.index()) {
                         Some(ty) => Ok(ty),