Closed as not planned
Description
Rustfmt fails to format this file:
use std::mem;
// We have three fields to avoid the ScalarPair optimization.
#[allow(unused)]
enum E {
None,
Some(&'static (), &'static (), usize),
}
fn main() { unsafe {
let mut p: mem::MaybeUninit<E> = mem::MaybeUninit::zeroed();
// The copy when `E` is returned from `transmute` should destroy padding
// (even when we use `write_unaligned`, which under the hood uses an untyped copy).
p.as_mut_ptr().write_unaligned(mem::transmute((0usize, 0usize, 0usize)));
// This is a `None`, so everything but the discriminant is padding.
assert!(matches!(*p.as_ptr(), E::None));
// Turns out the discriminant is (currently) stored
// in the 2nd pointer, so the first half is padding.
let c = &p as *const _ as *const u8;
let _val = *c.add(0); // Get a padding byte.
//~^ERROR: uninitialized
} }
with these settings:
version = "Two"
The error is:
error[internal]: left behind trailing whitespace
--> /home/r/src/rust/miri/tests/fail/uninit/padding-enum.rs:23:23:1
|
23 |
| ^^^^^^^^
|
If I comment out the "version" setting, formatting works fine.
I saw a bunch of other issues with similar errors but it is not clear to me which one of them this could be a duplicate of.