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 0d1bb53
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions druntime/src/object.d
Original file line number Diff line number Diff line change
Expand Up @@ -3781,6 +3781,22 @@ template RTInfo(T)
enum RTInfo = rtinfoNoPointers;
else
enum RTInfo = RTInfoImpl!(pointerBitmap).ptr;

static if (is (T == struct) && is(typeof(T.init) == T))
{
/// Verify that `destroy` works with `T.init`.
/// TODO: explain why
/// TODO: move the `hasElaborateDestructor` out of the `unittest`
unittest
{
import core.internal.traits : hasElaborateDestructor;
static if (hasElaborateDestructor!T)
{
T t = T.init;
.destroy!(true, T)(t);
}
}
}
}

/**
Expand Down

0 comments on commit 0d1bb53

Please sign in to comment.