]> git.lizzy.rs Git - rust.git/commitdiff
fix rustfmt fallout
authorRalf Jung <post@ralfj.de>
Fri, 3 Jan 2020 12:31:56 +0000 (13:31 +0100)
committerRalf Jung <post@ralfj.de>
Thu, 16 Jan 2020 17:43:51 +0000 (18:43 +0100)
src/librustc/mir/interpret/error.rs
src/librustc/mir/interpret/mod.rs
src/librustc_mir/interpret/cast.rs
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/interpret/memory.rs
src/librustc_mir/interpret/operand.rs
src/librustc_mir/interpret/place.rs
src/librustc_mir/interpret/validity.rs

index 8643bd63d8cba29e9ab99dbf4e14fcba938c2ed1..29b3b045ca5fe6ca173838da9c2007834d9cab79 100644 (file)
@@ -33,7 +33,7 @@ pub fn assert_reported(self) {
             ErrorHandled::Reported => {}
             ErrorHandled::TooGeneric => bug!(
                 "MIR interpretation failed without reporting an error \
-                                              even though it was fully monomorphized"
+                 even though it was fully monomorphized"
             ),
         }
     }
@@ -137,7 +137,8 @@ fn struct_generic(
     ) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
         let must_error = match self.error {
             InterpError::MachineStop(_) => bug!("CTFE does not stop"),
-            err_inval!(Layout(LayoutError::Unknown(_))) | err_inval!(TooGeneric) => {
+            err_inval!(Layout(LayoutError::Unknown(_)))
+            | err_inval!(TooGeneric) => {
                 return Err(ErrorHandled::TooGeneric);
             }
             err_inval!(TypeckError) => return Err(ErrorHandled::Reported),
index 47f067590b9d5e0803928734380999f45327a7a9..e554b280ef78cbc8723d559869c455a66a847fb4 100644 (file)
@@ -403,8 +403,8 @@ pub fn reserve(&mut self) -> AllocId {
         let next = self.next_id;
         self.next_id.0 = self.next_id.0.checked_add(1).expect(
             "You overflowed a u64 by incrementing by 1... \
-                     You've just earned yourself a free drink if we ever meet. \
-                     Seriously, how did you do that?!",
+             You've just earned yourself a free drink if we ever meet. \
+             Seriously, how did you do that?!",
         );
         next
     }
index 9461a066902128b1801409e54c30e4cafee495cb..6d0b6bf70ad8c624eae75b451fd99a5031ce0ddd 100644 (file)
@@ -118,15 +118,17 @@ fn cast_immediate(
             }
             // The rest is integer/pointer-"like", including fn ptr casts and casts from enums that
             // are represented as integers.
-            _ => assert!(
-                src.layout.ty.is_bool()
-                    || src.layout.ty.is_char()
-                    || src.layout.ty.is_enum()
-                    || src.layout.ty.is_integral()
-                    || src.layout.ty.is_any_ptr(),
-                "Unexpected cast from type {:?}",
-                src.layout.ty
-            ),
+            _ => {
+                assert!(
+                    src.layout.ty.is_bool()
+                        || src.layout.ty.is_char()
+                        || src.layout.ty.is_enum()
+                        || src.layout.ty.is_integral()
+                        || src.layout.ty.is_any_ptr(),
+                    "Unexpected cast from type {:?}",
+                    src.layout.ty
+                )
+            }
         }
 
         // Handle cast from a univariant (ZST) enum.
index 206d3d156735ec758b952e3dc5df5f06e5322511..3d590fb8203595e5a7aa1a33f91dc52a2c1869bb 100644 (file)
@@ -152,10 +152,16 @@ pub fn access_mut(
         &mut self,
     ) -> InterpResult<'tcx, Result<&mut LocalValue<Tag>, MemPlace<Tag>>> {
         match self.value {
-            LocalValue::Dead => throw_unsup!(DeadLocal),
-            LocalValue::Live(Operand::Indirect(mplace)) => Ok(Err(mplace)),
+            LocalValue::Dead => {
+                throw_unsup!(DeadLocal)
+            }
+            LocalValue::Live(Operand::Indirect(mplace)) => {
+                Ok(Err(mplace))
+            }
             ref mut local @ LocalValue::Live(Operand::Immediate(_))
-            | ref mut local @ LocalValue::Uninitialized => Ok(Ok(local)),
+            | ref mut local @ LocalValue::Uninitialized => {
+                Ok(Ok(local))
+            }
         }
     }
 }
index cb676821fd438ee407774a6e1eea3d34ed0d42cf..3386254c93b75a560dc19418078a5b179993ac47 100644 (file)
@@ -581,9 +581,9 @@ pub fn get_size_and_align(
                 Ok((layout.size, layout.align.abi))
             }
             Some(GlobalAlloc::Memory(alloc)) =>
-            // Need to duplicate the logic here, because the global allocations have
-            // different associated types than the interpreter-local ones.
             {
+                // Need to duplicate the logic here, because the global allocations have
+                // different associated types than the interpreter-local ones.
                 Ok((alloc.size, alloc.align))
             }
             Some(GlobalAlloc::Function(_)) => bug!("We already checked function pointers above"),
index b37eff3f40626a44691236aebd04761982d09822..34a32daaab65fcb511226f460ef8ccf0d694661c 100644 (file)
@@ -543,7 +543,9 @@ pub(super) fn eval_operands(
             | ty::ConstKind::Placeholder(..) => {
                 bug!("eval_const_to_op: Unexpected ConstKind {:?}", val)
             }
-            ty::ConstKind::Value(val_val) => val_val,
+            ty::ConstKind::Value(val_val) => {
+                val_val
+            }
         };
         // Other cases need layout.
         let layout = from_known_layout(layout, || self.layout_of(val.ty))?;
@@ -684,16 +686,14 @@ pub fn read_discriminant(
                             let variant_index = variants_start
                                 .checked_add(variant_index_relative)
                                 .expect("oveflow computing absolute variant idx");
-                            assert!(
-                                (variant_index as usize)
-                                    < rval
-                                        .layout
-                                        .ty
-                                        .ty_adt_def()
-                                        .expect("tagged layout for non adt")
-                                        .variants
-                                        .len()
-                            );
+                            let variants_len = rval
+                                .layout
+                                .ty
+                                .ty_adt_def()
+                                .expect("tagged layout for non adt")
+                                .variants
+                                .len();
+                            assert!((variant_index as usize) < variants_len);
                             (u128::from(variant_index), VariantIdx::from_u32(variant_index))
                         } else {
                             (u128::from(dataful_variant.as_u32()), dataful_variant)
index 8888e3fd4632a2a3e1549dea0f646c29e537257f..4f96cb698915d25146c45e2bff6d9528bf49e772 100644 (file)
@@ -432,12 +432,11 @@ pub fn mplace_field(
             // happens at run-time so that's okay.
             let align = match self.size_and_align_of(base.meta, field_layout)? {
                 Some((_, align)) => align,
-                None if offset == Size::ZERO =>
-                // An extern type at offset 0, we fall back to its static alignment.
-                // FIXME: Once we have made decisions for how to handle size and alignment
-                // of `extern type`, this should be adapted.  It is just a temporary hack
-                // to get some code to work that probably ought to work.
-                {
+                None if offset == Size::ZERO => {
+                    // An extern type at offset 0, we fall back to its static alignment.
+                    // FIXME: Once we have made decisions for how to handle size and alignment
+                    // of `extern type`, this should be adapted.  It is just a temporary hack
+                    // to get some code to work that probably ought to work.
                     field_layout.align.abi
                 }
                 None => bug!("Cannot compute offset for extern type field at non-0 offset"),
index 2f0fb81fffd13db3322a64153e465dfdfa4d4fc5..d0fef08bb60c743034e73da2dcc9f8b83be79a8b 100644 (file)
@@ -115,11 +115,11 @@ fn write_path(out: &mut String, path: &Vec<PathElem>) {
             TupleElem(idx) => write!(out, ".{}", idx),
             ArrayElem(idx) => write!(out, "[{}]", idx),
             Deref =>
-            // This does not match Rust syntax, but it is more readable for long paths -- and
-            // some of the other items here also are not Rust syntax.  Actually we can't
-            // even use the usual syntax because we are just showing the projections,
-            // not the root.
             {
+                // This does not match Rust syntax, but it is more readable for long paths -- and
+                // some of the other items here also are not Rust syntax.  Actually we can't
+                // even use the usual syntax because we are just showing the projections,
+                // not the root.
                 write!(out, ".<deref>")
             }
             Tag => write!(out, ".<enum-tag>"),
@@ -207,8 +207,8 @@ fn aggregate_field_path_elem(&mut self, layout: TyLayout<'tcx>, field: usize) ->
                 // we might be projecting *to* a variant, or to a field *in*a variant.
                 match layout.variants {
                     layout::Variants::Single { index } =>
-                    // Inside a variant
                     {
+                        // Inside a variant
                         PathElem::Field(def.variants[index].fields[field].ident.name)
                     }
                     _ => bug!(),