@@ -1087,6 +1087,18 @@ This eliminates any `Deref` projections from the place, and also resolves `Index
10871087 // rule #projectionsFor(CtxPointerOffset(OFFSET, ORIGIN_LENGTH) CTXS, PROJS) => #projectionsFor(CTXS, projectionElemSubslice(OFFSET, ORIGIN_LENGTH, false) PROJS)
10881088 rule #projectionsFor(CtxPointerOffset( _, OFFSET, ORIGIN_LENGTH) CTXS, PROJS) => #projectionsFor(CTXS, PointerOffset(OFFSET, ORIGIN_LENGTH) PROJS)
10891089
1090+ // Borrowing a zero-sized local that is still `NewLocal`: initialise it, then reuse the regular rule.
1091+ rule <k> rvalueRef(REGION, KIND, place(local(I), PROJS))
1092+ => #forceSetLocal(local(I), Aggregate(variantIdx(0), .List))
1093+ ~> rvalueRef(REGION, KIND, place(local(I), PROJS))
1094+ ...
1095+ </k>
1096+ <locals> LOCALS </locals>
1097+ requires 0 <=Int I andBool I <Int size(LOCALS)
1098+ andBool isNewLocal(LOCALS[I])
1099+ andBool #zeroSizedType(lookupTy(tyOfLocal(getLocal(LOCALS, I))))
1100+ [preserves-definedness] // valid list indexing checked, zero-sized locals materialise trivially
1101+
10901102 rule <k> rvalueRef(_REGION, KIND, place(local(I), PROJS))
10911103 => #traverseProjection(toLocal(I), getValue(LOCALS, I), PROJS, .Contexts)
10921104 ~> #forRef(#mutabilityOf(KIND), metadata(#metadataSize(tyOfLocal({LOCALS[I]}:>TypedLocal), PROJS), 0, noMetadataSize)) // TODO: Sus on this rule
0 commit comments