I played around a bit with empty data structures ((), [usize;0] , and struct EmptyStruct(), which all don't require any stored bytes...
Interestingly, the MIR I am getting somewhat relies on the fact that there are no stored bytes for these. I have a program like this (example: (), but the same happens for the other types):
const EMPTY: () = ();
fn main() {
let e = ();
assert!(e == EMPTY);
}
The first statement in main (block 0, first statement) becomes _3 <- &_1. which assumes there is nothing to do to initialise _1 to be ().
That assumption is untrue for our semantics, though, where () is represented as Aggregate(variantIdx(0), .List) but we get newValue(...) in _1 and end up with a reference pointing to it in _3.
For my 3 programs with empty data I did not find any point where that reference would be Dereferenced but I cannot be sure. The eq instances for () and EmptyStruct() just return constant true but the one for [usize;0] blindly calls the raw_eq intrinsic.
We should adapt our forthcoming implementation of raw_eq to this.
I played around a bit with empty data structures (
(),[usize;0], andstruct EmptyStruct(), which all don't require any stored bytes...Interestingly, the MIR I am getting somewhat relies on the fact that there are no stored bytes for these. I have a program like this (example:
(), but the same happens for the other types):The first statement in main (block 0, first statement) becomes
_3 <- &_1. which assumes there is nothing to do to initialise_1to be().That assumption is untrue for our semantics, though, where
()is represented asAggregate(variantIdx(0), .List)but we getnewValue(...)in_1and end up with a reference pointing to it in_3.For my 3 programs with empty data I did not find any point where that reference would be
Dereferenced but I cannot be sure. Theeqinstances for()andEmptyStruct()just return constant true but the one for[usize;0]blindly calls theraw_eqintrinsic.We should adapt our forthcoming implementation of
raw_eqto this.