Rollup merge of #68288 - RalfJung:fmt, r=oli-obk

Fix some of the rustfmt fallout in Miri

re-post of https://github.com/rust-lang/rust/pull/67833 without the `rustfmt::skip`

r? @oli-obk
This commit is contained in:
Dylan DPC 2020-01-17 11:16:39 +05:30 committed by GitHub
commit c411c22eb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 31 deletions

View 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"
),
}
}

View 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
}

View File

@ -580,10 +580,9 @@ pub fn get_size_and_align(
let layout = self.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap();
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.
{
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))
}
Some(GlobalAlloc::Function(_)) => bug!("We already checked function pointers above"),

View File

@ -684,16 +684,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)

View 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"),

View File

@ -114,14 +114,11 @@ fn write_path(out: &mut String, path: &Vec<PathElem>) {
ClosureVar(name) => write!(out, ".<closure-var({})>", name),
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
// `.<deref>` 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>")
}
Deref => write!(out, ".<deref>"),
Tag => write!(out, ".<enum-tag>"),
DynDowncast => write!(out, ".<dyn-downcast>"),
}
@ -206,9 +203,8 @@ fn aggregate_field_path_elem(&mut self, layout: TyLayout<'tcx>, field: usize) ->
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 } =>
// Inside a variant
{
layout::Variants::Single { index } => {
// Inside a variant
PathElem::Field(def.variants[index].fields[field].ident.name)
}
_ => bug!(),