msg.push_str(", but expected ");
write!(&mut msg, $($expected_fmt),+).unwrap();
)?
- let path = rustc_middle::ty::print::with_no_trimmed_paths(|| {
+ let path = rustc_middle::ty::print::with_no_trimmed_paths!({
let where_ = &$where;
if !where_.is_empty() {
let mut path = String::new();
{
// A mutable reference inside a const? That does not seem right (except if it is
// a ZST).
- let layout = self.ecx.layout_of(ty)?;
+ let layout = self.ecx.layout_of(*ty)?;
if !layout.is_zst() {
throw_validation_failure!(self.path, { "mutable reference in a `const`" });
}
this.ecx.read_discriminant(op),
this.path,
err_ub!(InvalidTag(val)) =>
- { "{}", val } expected { "a valid enum tag" },
+ { "{:x}", val } expected { "a valid enum tag" },
err_ub!(InvalidUninitBytes(None)) =>
{ "uninitialized bytes" } expected { "a valid enum tag" },
err_unsup!(ReadPointerAsBytes) =>
// This is the length of the array/slice.
let len = mplace.len(self.ecx)?;
// This is the element type size.
- let layout = self.ecx.layout_of(tys)?;
+ let layout = self.ecx.layout_of(*tys)?;
// This is the size in bytes of the whole array. (This checks for overflow.)
let size = layout.size * len;
// to reject those pointers, we just do not have the machinery to
// talk about parts of a pointer.
// We also accept uninit, for consistency with the slow path.
- let alloc = match self.ecx.memory.get(mplace.ptr, size, mplace.align)? {
- Some(a) => a,
- None => {
- // Size 0, nothing more to check.
- return Ok(());
- }
+ let Some(alloc) = self.ecx.memory.get(mplace.ptr, size, mplace.align)? else {
+ // Size 0, nothing more to check.
+ return Ok(());
};
let allow_uninit_and_ptr = !M::enforce_number_validity(self.ecx);
// Fast path for arrays and slices of ZSTs. We only need to check a single ZST element
// of an array and not all of them, because there's only a single value of a specific
// ZST type, so either validation fails for all elements or none.
- ty::Array(tys, ..) | ty::Slice(tys) if self.ecx.layout_of(tys)?.is_zst() => {
+ ty::Array(tys, ..) | ty::Slice(tys) if self.ecx.layout_of(*tys)?.is_zst() => {
// Validate just the first element (if any).
self.walk_aggregate(op, fields.take(1))?
}