diff --git a/stdlib/src/builtin/tuple.mojo b/stdlib/src/builtin/tuple.mojo index 50fdf9f708..00bede563f 100644 --- a/stdlib/src/builtin/tuple.mojo +++ b/stdlib/src/builtin/tuple.mojo @@ -81,8 +81,10 @@ struct Tuple[*element_types: CollectionElement](Sized, CollectionElement): UnsafePointer.address_of(self[i]) ) - # Mark the elements as destroyed. - storage._is_owned = False + # Do not destroy the elements when 'storage' goes away. + __mlir_op.`lit.ownership.mark_destroyed`( + __get_mvalue_as_litref(storage) + ) fn __del__(owned self): """Destructor that destroys all of the elements.""" @@ -126,6 +128,7 @@ struct Tuple[*element_types: CollectionElement](Sized, CollectionElement): UnsafePointer.address_of(existing[i]).move_pointee_into( UnsafePointer.address_of(self[i]) ) + # Note: The destructor on `existing` is auto-disabled in a moveinit. @always_inline @staticmethod