From 3fd1af5fdb59a49e9eb5e05ff15fef6b8514ae31 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 3 Jan 2020 13:33:28 +0100 Subject: [PATCH] let rustfmt undo most of my edits :( --- src/librustc/mir/interpret/error.rs | 3 +-- src/librustc_mir/interpret/cast.rs | 20 +++++++++----------- src/librustc_mir/interpret/eval_context.rs | 12 +++--------- src/librustc_mir/interpret/memory.rs | 3 +-- src/librustc_mir/interpret/operand.rs | 4 +--- src/librustc_mir/interpret/validity.rs | 6 ++---- 6 files changed, 17 insertions(+), 31 deletions(-) diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 29b3b045ca5..42d896af801 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -137,8 +137,7 @@ impl<'tcx> ConstEvalErr<'tcx> { ) -> Result, 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), diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index 6d0b6bf70ad..9461a066902 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -118,17 +118,15 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } // 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. diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 3d590fb8203..206d3d15673 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -152,16 +152,10 @@ impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> { &mut self, ) -> InterpResult<'tcx, Result<&mut LocalValue, MemPlace>> { 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)), } } } diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 3386254c93b..0bcdf9ae3c1 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -580,8 +580,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { let layout = self.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); Ok((layout.size, layout.align.abi)) } - Some(GlobalAlloc::Memory(alloc)) => - { + Some(GlobalAlloc::Memory(alloc)) => { // Need to duplicate the logic here, because the global allocations have // different associated types than the interpreter-local ones. Ok((alloc.size, alloc.align)) diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 34a32daaab6..d1c08da6cbe 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -543,9 +543,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { | 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))?; diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index d0fef08bb60..9f713dfd5e6 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -114,8 +114,7 @@ fn write_path(out: &mut String, path: &Vec) { ClosureVar(name) => write!(out, ".", name), TupleElem(idx) => write!(out, ".{}", idx), ArrayElem(idx) => write!(out, "[{}]", idx), - Deref => - { + 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, @@ -206,8 +205,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M ty::Adt(def, ..) if def.is_enum() => { // we might be projecting *to* a variant, or to a field *in*a variant. match layout.variants { - layout::Variants::Single { index } => - { + layout::Variants::Single { index } => { // Inside a variant PathElem::Field(def.variants[index].fields[field].ident.name) }