From d90d36dd4c60079c880149d5e0957efed160102d Mon Sep 17 00:00:00 2001 From: Johan Engelen Date: Tue, 20 Oct 2020 15:09:08 +0200 Subject: [PATCH 1/2] Help compiler deduce `pure` for moveEmplaceImpl This fixes https://issues.dlang.org/show_bug.cgi?id=21202 . --- std/algorithm/mutation.d | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/std/algorithm/mutation.d b/std/algorithm/mutation.d index 05534221a70..7a8d988d995 100644 --- a/std/algorithm/mutation.d +++ b/std/algorithm/mutation.d @@ -1400,7 +1400,7 @@ private T trustedMoveImpl(T)(ref T source) @trusted move(x, x); } -private void moveEmplaceImpl(T)(ref T source, ref T target) +private void moveEmplaceImpl(T)(ref T source, ref T target) pure { import core.stdc.string : memcpy, memset; import std.traits : hasAliasing, hasElaborateAssign, @@ -1517,6 +1517,26 @@ pure nothrow @nogc @system unittest f(move(ncarray)); } +// https://issues.dlang.org/show_bug.cgi?id=21202 +unittest +{ + static struct Strukt2 + { + this(int* _block) { } + } + + static struct Strukt + { + int* block; + Strukt2 foo() { return Strukt2(null); } + alias foo this; + } + + Strukt a; + Strukt b; + moveEmplace(a, b); +} + // moveAll /** Calls `move(a, b)` for each element `a` in `src` and the corresponding From 1fcbe522e909b9f5b4d752f4046e90aa2b7fc99b Mon Sep 17 00:00:00 2001 From: Johan Engelen Date: Tue, 20 Oct 2020 15:20:54 +0200 Subject: [PATCH 2/2] whitespace fix Fixes issue 21202 --- std/algorithm/mutation.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/algorithm/mutation.d b/std/algorithm/mutation.d index 7a8d988d995..10b8ea676a3 100644 --- a/std/algorithm/mutation.d +++ b/std/algorithm/mutation.d @@ -1534,7 +1534,7 @@ unittest Strukt a; Strukt b; - moveEmplace(a, b); + moveEmplace(a, b); } // moveAll