Skip to content

Commit

Permalink
Fix #20595 - automatically unittest destroy(T.init)
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator committed Dec 24, 2024
1 parent 3fa3ac8 commit 78d2dc3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions druntime/src/object.d
Original file line number Diff line number Diff line change
Expand Up @@ -3781,6 +3781,17 @@ template RTInfo(T)
enum RTInfo = rtinfoNoPointers;
else
enum RTInfo = RTInfoImpl!(pointerBitmap).ptr;

static if (is (T == struct) && imported!"core.internal.traits".hasElaborateDestructor!T)
{
/// Verify that `destroy` works with `T.init`.
/// TODO: explain why
unittest
{
T t;
.destroy(t);
}
}
}

/**
Expand Down

0 comments on commit 78d2dc3

Please sign in to comment.