Re-format let-else per rustfmt update
This commit is contained in:
@@ -604,7 +604,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
// the last field). Can't have foreign types here, how would we
|
||||
// adjust alignment and size for them?
|
||||
let field = layout.field(self, layout.fields.count() - 1);
|
||||
let Some((unsized_size, mut unsized_align)) = self.size_and_align_of(metadata, &field)? else {
|
||||
let Some((unsized_size, mut unsized_align)) =
|
||||
self.size_and_align_of(metadata, &field)?
|
||||
else {
|
||||
// A field with an extern type. We don't know the actual dynamic size
|
||||
// or the alignment.
|
||||
return Ok(None);
|
||||
|
||||
@@ -1060,11 +1060,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
let size = Size::from_bytes(len);
|
||||
let Some(alloc_ref) = self.get_ptr_alloc_mut(ptr, size, Align::ONE)? else {
|
||||
// zero-sized access
|
||||
assert_matches!(
|
||||
src.next(),
|
||||
None,
|
||||
"iterator said it was empty but returned an element"
|
||||
);
|
||||
assert_matches!(src.next(), None, "iterator said it was empty but returned an element");
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
|
||||
@@ -545,14 +545,17 @@ where
|
||||
// wrong type.
|
||||
|
||||
let tcx = *self.tcx;
|
||||
let Some(mut alloc) = self.get_place_alloc_mut(&MPlaceTy { mplace: dest, layout, align })? else {
|
||||
let Some(mut alloc) =
|
||||
self.get_place_alloc_mut(&MPlaceTy { mplace: dest, layout, align })?
|
||||
else {
|
||||
// zero-sized access
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
match value {
|
||||
Immediate::Scalar(scalar) => {
|
||||
let Abi::Scalar(s) = layout.abi else { span_bug!(
|
||||
let Abi::Scalar(s) = layout.abi else {
|
||||
span_bug!(
|
||||
self.cur_span(),
|
||||
"write_immediate_to_mplace: invalid Scalar layout: {layout:#?}",
|
||||
)
|
||||
@@ -565,7 +568,8 @@ where
|
||||
// We checked `ptr_align` above, so all fields will have the alignment they need.
|
||||
// We would anyway check against `ptr_align.restrict_for_offset(b_offset)`,
|
||||
// which `ptr.offset(b_offset)` cannot possibly fail to satisfy.
|
||||
let Abi::ScalarPair(a, b) = layout.abi else { span_bug!(
|
||||
let Abi::ScalarPair(a, b) = layout.abi else {
|
||||
span_bug!(
|
||||
self.cur_span(),
|
||||
"write_immediate_to_mplace: invalid ScalarPair layout: {:#?}",
|
||||
layout
|
||||
|
||||
@@ -390,7 +390,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
));
|
||||
// Allocate enough memory to hold `src`.
|
||||
let Some((size, align)) = self.size_and_align_of_mplace(&src)? else {
|
||||
span_bug!(self.cur_span(), "unsized fn arg with `extern` type tail should not be allowed")
|
||||
span_bug!(
|
||||
self.cur_span(),
|
||||
"unsized fn arg with `extern` type tail should not be allowed"
|
||||
)
|
||||
};
|
||||
let ptr = self.allocate_ptr(size, align, MemoryKind::Stack)?;
|
||||
let dest_place =
|
||||
@@ -468,10 +471,18 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
| ty::InstanceDef::ThreadLocalShim(..)
|
||||
| ty::InstanceDef::Item(_) => {
|
||||
// We need MIR for this fn
|
||||
let Some((body, instance)) =
|
||||
M::find_mir_or_eval_fn(self, instance, caller_abi, args, destination, target, unwind)? else {
|
||||
return Ok(());
|
||||
};
|
||||
let Some((body, instance)) = M::find_mir_or_eval_fn(
|
||||
self,
|
||||
instance,
|
||||
caller_abi,
|
||||
args,
|
||||
destination,
|
||||
target,
|
||||
unwind,
|
||||
)?
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
// Compute callee information using the `instance` returned by
|
||||
// `find_mir_or_eval_fn`.
|
||||
@@ -702,8 +713,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
.tcx
|
||||
.struct_tail_erasing_lifetimes(receiver_place.layout.ty, self.param_env);
|
||||
let ty::Dynamic(data, _, ty::Dyn) = receiver_tail.kind() else {
|
||||
span_bug!(self.cur_span(), "dynamic call on non-`dyn` type {}", receiver_tail)
|
||||
};
|
||||
span_bug!(
|
||||
self.cur_span(),
|
||||
"dynamic call on non-`dyn` type {}",
|
||||
receiver_tail
|
||||
)
|
||||
};
|
||||
assert!(receiver_place.layout.is_unsized());
|
||||
|
||||
// Get the required information from the vtable.
|
||||
@@ -721,7 +736,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
|
||||
// Now determine the actual method to call. We can do that in two different ways and
|
||||
// compare them to ensure everything fits.
|
||||
let Some(ty::VtblEntry::Method(fn_inst)) = self.get_vtable_entries(vptr)?.get(idx).copied() else {
|
||||
let Some(ty::VtblEntry::Method(fn_inst)) =
|
||||
self.get_vtable_entries(vptr)?.get(idx).copied()
|
||||
else {
|
||||
// FIXME(fee1-dead) these could be variants of the UB info enum instead of this
|
||||
throw_ub_custom!(fluent::const_eval_dyn_call_not_a_method);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user