From feabd4ddea1b64936b261ed852253c5260500b96 Mon Sep 17 00:00:00 2001 From: Manu Evans Date: Sun, 17 Nov 2024 13:44:03 +1000 Subject: [PATCH] traits for opPostMove needed a different approach. --- druntime/src/core/internal/moving.d | 7 ++++--- druntime/src/core/internal/traits.d | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/druntime/src/core/internal/moving.d b/druntime/src/core/internal/moving.d index 9c97d2966f7b..7be9206ec64c 100644 --- a/druntime/src/core/internal/moving.d +++ b/druntime/src/core/internal/moving.d @@ -40,9 +40,10 @@ void __move_post_blt(S)(ref S newLocation, ref S oldLocation) nothrow static if (__traits(hasMember, S, "opPostMove")) { - import core.internal.traits : lvalueOf, rvalueOf; - static assert( is(typeof(S.init.opPostMove(lvalueOf!S))) && - !is(typeof(S.init.opPostMove(rvalueOf!S))), + import core.internal.traits : Parameters; + static assert(Parameters!(S.init.opPostMove).length == 1 && + is(Parameters!(S.init.opPostMove)[0] : const S) && + __traits(getParameterStorageClasses, S.init.opPostMove, 0)[0] == "ref", "`" ~ S.stringof ~ ".opPostMove` must take exactly one argument of type `" ~ S.stringof ~ "` by reference"); newLocation.opPostMove(oldLocation); diff --git a/druntime/src/core/internal/traits.d b/druntime/src/core/internal/traits.d index 7eaa8f3c2baa..2c16fdaa5a78 100644 --- a/druntime/src/core/internal/traits.d +++ b/druntime/src/core/internal/traits.d @@ -248,8 +248,10 @@ template hasElaborateMove(S) } else static if (is(S == struct)) { - enum hasElaborateMove = (is(typeof(S.init.opPostMove(lvalueOf!S))) && - !is(typeof(S.init.opPostMove(rvalueOf!S)))) || + enum hasElaborateMove = (is(typeof(S.init.opPostMove)) && + Parameters!(S.init.opPostMove).length == 1 && + is(Parameters!(S.init.opPostMove)[0] : const S) && + __traits(getParameterStorageClasses, S.init.opPostMove, 0)[0] == "ref") || anySatisfy!(.hasElaborateMove, Fields!S); } else