[BasicContainers] Fix RigidSet batch-insertion loop never terminating

insert(addingCount:initializingWith:) batches elements through a
temporary OutputSpan and loops while `remainder > 0`. When the
`UnstableContainersPreview` trait is disabled, the span's `defer`
handler moved elements out of the temporary buffer but never decremented
`remainder`, so the loop spun forever whenever the initializer didn't
fill every batch. Update `remainder` the same way the preview branch
already does, and add a regression test (issue #774).
This commit is contained in:
Aashish committed 2026-10-20 21:18:09 +05:45
1 parent b905c889ff
commit bd5960886c
2 files changed
+44

No files matched your search

@@ -155,6 +155,11 @@ extension RigidSet where Element: ~Copyable {
}
#else
output.withUnsafeMutableBufferPointer { buffer, count in
if count < c {
remainder = 0
} else {
remainder &-= count
}
for i in 0 ..< count {
self.insert(buffer.moveElement(from: i))
}