Skip to content

Commit 9dee5d5

Browse files
committed
fix rustfmt fallout
1 parent c74353c commit 9dee5d5

File tree

8 files changed

+48
-40
lines changed

8 files changed

+48
-40
lines changed

src/librustc/mir/interpret/error.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl ErrorHandled {
3333
ErrorHandled::Reported => {}
3434
ErrorHandled::TooGeneric => bug!(
3535
"MIR interpretation failed without reporting an error \
36-
even though it was fully monomorphized"
36+
even though it was fully monomorphized"
3737
),
3838
}
3939
}
@@ -137,7 +137,8 @@ impl<'tcx> ConstEvalErr<'tcx> {
137137
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
138138
let must_error = match self.error {
139139
InterpError::MachineStop(_) => bug!("CTFE does not stop"),
140-
err_inval!(Layout(LayoutError::Unknown(_))) | err_inval!(TooGeneric) => {
140+
err_inval!(Layout(LayoutError::Unknown(_)))
141+
| err_inval!(TooGeneric) => {
141142
return Err(ErrorHandled::TooGeneric);
142143
}
143144
err_inval!(TypeckError) => return Err(ErrorHandled::Reported),

src/librustc/mir/interpret/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ impl<'tcx> AllocMap<'tcx> {
403403
let next = self.next_id;
404404
self.next_id.0 = self.next_id.0.checked_add(1).expect(
405405
"You overflowed a u64 by incrementing by 1... \
406-
You've just earned yourself a free drink if we ever meet. \
407-
Seriously, how did you do that?!",
406+
You've just earned yourself a free drink if we ever meet. \
407+
Seriously, how did you do that?!",
408408
);
409409
next
410410
}

src/librustc_mir/interpret/cast.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,17 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
118118
}
119119
// The rest is integer/pointer-"like", including fn ptr casts and casts from enums that
120120
// are represented as integers.
121-
_ => assert!(
122-
src.layout.ty.is_bool()
123-
|| src.layout.ty.is_char()
124-
|| src.layout.ty.is_enum()
125-
|| src.layout.ty.is_integral()
126-
|| src.layout.ty.is_any_ptr(),
127-
"Unexpected cast from type {:?}",
128-
src.layout.ty
129-
),
121+
_ => {
122+
assert!(
123+
src.layout.ty.is_bool()
124+
|| src.layout.ty.is_char()
125+
|| src.layout.ty.is_enum()
126+
|| src.layout.ty.is_integral()
127+
|| src.layout.ty.is_any_ptr(),
128+
"Unexpected cast from type {:?}",
129+
src.layout.ty
130+
)
131+
}
130132
}
131133

132134
// Handle cast from a univariant (ZST) enum.

src/librustc_mir/interpret/eval_context.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,16 @@ impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> {
152152
&mut self,
153153
) -> InterpResult<'tcx, Result<&mut LocalValue<Tag>, MemPlace<Tag>>> {
154154
match self.value {
155-
LocalValue::Dead => throw_unsup!(DeadLocal),
156-
LocalValue::Live(Operand::Indirect(mplace)) => Ok(Err(mplace)),
155+
LocalValue::Dead => {
156+
throw_unsup!(DeadLocal)
157+
}
158+
LocalValue::Live(Operand::Indirect(mplace)) => {
159+
Ok(Err(mplace))
160+
}
157161
ref mut local @ LocalValue::Live(Operand::Immediate(_))
158-
| ref mut local @ LocalValue::Uninitialized => Ok(Ok(local)),
162+
| ref mut local @ LocalValue::Uninitialized => {
163+
Ok(Ok(local))
164+
}
159165
}
160166
}
161167
}

src/librustc_mir/interpret/memory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
581581
Ok((layout.size, layout.align.abi))
582582
}
583583
Some(GlobalAlloc::Memory(alloc)) =>
584-
// Need to duplicate the logic here, because the global allocations have
585-
// different associated types than the interpreter-local ones.
586584
{
585+
// Need to duplicate the logic here, because the global allocations have
586+
// different associated types than the interpreter-local ones.
587587
Ok((alloc.size, alloc.align))
588588
}
589589
Some(GlobalAlloc::Function(_)) => bug!("We already checked function pointers above"),

src/librustc_mir/interpret/operand.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
543543
| ty::ConstKind::Placeholder(..) => {
544544
bug!("eval_const_to_op: Unexpected ConstKind {:?}", val)
545545
}
546-
ty::ConstKind::Value(val_val) => val_val,
546+
ty::ConstKind::Value(val_val) => {
547+
val_val
548+
}
547549
};
548550
// Other cases need layout.
549551
let layout = from_known_layout(layout, || self.layout_of(val.ty))?;
@@ -684,16 +686,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
684686
let variant_index = variants_start
685687
.checked_add(variant_index_relative)
686688
.expect("oveflow computing absolute variant idx");
687-
assert!(
688-
(variant_index as usize)
689-
< rval
690-
.layout
691-
.ty
692-
.ty_adt_def()
693-
.expect("tagged layout for non adt")
694-
.variants
695-
.len()
696-
);
689+
let variants_len = rval
690+
.layout
691+
.ty
692+
.ty_adt_def()
693+
.expect("tagged layout for non adt")
694+
.variants
695+
.len();
696+
assert!((variant_index as usize) < variants_len);
697697
(u128::from(variant_index), VariantIdx::from_u32(variant_index))
698698
} else {
699699
(u128::from(dataful_variant.as_u32()), dataful_variant)

src/librustc_mir/interpret/place.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,11 @@ where
432432
// happens at run-time so that's okay.
433433
let align = match self.size_and_align_of(base.meta, field_layout)? {
434434
Some((_, align)) => align,
435-
None if offset == Size::ZERO =>
436-
// An extern type at offset 0, we fall back to its static alignment.
437-
// FIXME: Once we have made decisions for how to handle size and alignment
438-
// of `extern type`, this should be adapted. It is just a temporary hack
439-
// to get some code to work that probably ought to work.
440-
{
435+
None if offset == Size::ZERO => {
436+
// An extern type at offset 0, we fall back to its static alignment.
437+
// FIXME: Once we have made decisions for how to handle size and alignment
438+
// of `extern type`, this should be adapted. It is just a temporary hack
439+
// to get some code to work that probably ought to work.
441440
field_layout.align.abi
442441
}
443442
None => bug!("Cannot compute offset for extern type field at non-0 offset"),

src/librustc_mir/interpret/validity.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ fn write_path(out: &mut String, path: &Vec<PathElem>) {
115115
TupleElem(idx) => write!(out, ".{}", idx),
116116
ArrayElem(idx) => write!(out, "[{}]", idx),
117117
Deref =>
118-
// This does not match Rust syntax, but it is more readable for long paths -- and
119-
// some of the other items here also are not Rust syntax. Actually we can't
120-
// even use the usual syntax because we are just showing the projections,
121-
// not the root.
122118
{
119+
// This does not match Rust syntax, but it is more readable for long paths -- and
120+
// some of the other items here also are not Rust syntax. Actually we can't
121+
// even use the usual syntax because we are just showing the projections,
122+
// not the root.
123123
write!(out, ".<deref>")
124124
}
125125
Tag => write!(out, ".<enum-tag>"),
@@ -207,8 +207,8 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
207207
// we might be projecting *to* a variant, or to a field *in*a variant.
208208
match layout.variants {
209209
layout::Variants::Single { index } =>
210-
// Inside a variant
211210
{
211+
// Inside a variant
212212
PathElem::Field(def.variants[index].fields[field].ident.name)
213213
}
214214
_ => bug!(),

0 commit comments

Comments
 (0)