Skip to content

Commit c411c22

Browse files
authored
Rollup merge of #68288 - RalfJung:fmt, r=oli-obk
Fix some of the rustfmt fallout in Miri re-post of #67833 without the `rustfmt::skip` r? @oli-obk
2 parents de01a29 + c781d15 commit c411c22

File tree

6 files changed

+23
-31
lines changed

6 files changed

+23
-31
lines changed

src/librustc/mir/interpret/error.rs

+1-1
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
}

src/librustc/mir/interpret/mod.rs

+2-2
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/memory.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
580580
let layout = self.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap();
581581
Ok((layout.size, layout.align.abi))
582582
}
583-
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.
586-
{
583+
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.
587586
Ok((alloc.size, alloc.align))
588587
}
589588
Some(GlobalAlloc::Function(_)) => bug!("We already checked function pointers above"),

src/librustc_mir/interpret/operand.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -684,16 +684,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
684684
let variant_index = variants_start
685685
.checked_add(variant_index_relative)
686686
.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-
);
687+
let variants_len = rval
688+
.layout
689+
.ty
690+
.ty_adt_def()
691+
.expect("tagged layout for non adt")
692+
.variants
693+
.len();
694+
assert!((variant_index as usize) < variants_len);
697695
(u128::from(variant_index), VariantIdx::from_u32(variant_index))
698696
} else {
699697
(u128::from(dataful_variant.as_u32()), dataful_variant)

src/librustc_mir/interpret/place.rs

+5-6
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

+4-8
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,11 @@ fn write_path(out: &mut String, path: &Vec<PathElem>) {
114114
ClosureVar(name) => write!(out, ".<closure-var({})>", name),
115115
TupleElem(idx) => write!(out, ".{}", idx),
116116
ArrayElem(idx) => write!(out, "[{}]", idx),
117-
Deref =>
118-
// This does not match Rust syntax, but it is more readable for long paths -- and
117+
// `.<deref>` does not match Rust syntax, but it is more readable for long paths -- and
119118
// some of the other items here also are not Rust syntax. Actually we can't
120119
// even use the usual syntax because we are just showing the projections,
121120
// not the root.
122-
{
123-
write!(out, ".<deref>")
124-
}
121+
Deref => write!(out, ".<deref>"),
125122
Tag => write!(out, ".<enum-tag>"),
126123
DynDowncast => write!(out, ".<dyn-downcast>"),
127124
}
@@ -206,9 +203,8 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
206203
ty::Adt(def, ..) if def.is_enum() => {
207204
// we might be projecting *to* a variant, or to a field *in*a variant.
208205
match layout.variants {
209-
layout::Variants::Single { index } =>
210-
// Inside a variant
211-
{
206+
layout::Variants::Single { index } => {
207+
// Inside a variant
212208
PathElem::Field(def.variants[index].fields[field].ident.name)
213209
}
214210
_ => bug!(),

0 commit comments

Comments
 (0)