diff --git a/std/algorithm/mutation.d b/std/algorithm/mutation.d index fbef28e5d56..c59234a47fa 100644 --- a/std/algorithm/mutation.d +++ b/std/algorithm/mutation.d @@ -1184,6 +1184,16 @@ pure nothrow @safe @nogc unittest assert(s53 is s51); } +unittest +{ + static struct S + { + immutable int i; + ~this() @safe {} + } + static assert(!__traits(compiles, { S a, b; move(a, b); })); +} + /// Ditto T move(T)(return scope ref T source) { @@ -1414,6 +1424,7 @@ private T trustedMoveImpl(T)(ref return scope T source) @trusted } private void moveEmplaceImpl(T)(ref scope T target, ref return scope T source) +if (__traits(compiles, target = T.init)) { import core.stdc.string : memcpy, memset; import std.traits : hasAliasing, hasElaborateAssign,