mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
make move use =wasMoved internally (#22032)
* make `move` use `=wasMoved` internally * fixes tests * fixes spawn finally * fixes views * rename to internalMove * add a test case
This commit is contained in:
@@ -147,10 +147,26 @@ proc wasMoved*[T](obj: var T) {.inline, noSideEffect.} =
|
||||
{.cast(raises: []), cast(tags: []).}:
|
||||
`=wasMoved`(obj)
|
||||
|
||||
proc move*[T](x: var T): T {.magic: "Move", noSideEffect.} =
|
||||
result = x
|
||||
{.cast(raises: []), cast(tags: []).}:
|
||||
`=wasMoved`(x)
|
||||
const notJSnotNims = not defined(js) and not defined(nimscript)
|
||||
const arcLikeMem = defined(gcArc) or defined(gcAtomicArc) or defined(gcOrc)
|
||||
|
||||
when notJSnotNims and arcLikeMem:
|
||||
proc internalMove[T](x: var T): T {.magic: "Move", noSideEffect, compilerproc.} =
|
||||
result = x
|
||||
|
||||
proc move*[T](x: var T): T {.noSideEffect, nodestroy.} =
|
||||
{.cast(noSideEffect).}:
|
||||
when nimvm:
|
||||
result = internalMove(x)
|
||||
else:
|
||||
result = internalMove(x)
|
||||
{.cast(raises: []), cast(tags: []).}:
|
||||
`=wasMoved`(x)
|
||||
else:
|
||||
proc move*[T](x: var T): T {.magic: "Move", noSideEffect.} =
|
||||
result = x
|
||||
{.cast(raises: []), cast(tags: []).}:
|
||||
`=wasMoved`(x)
|
||||
|
||||
type
|
||||
range*[T]{.magic: "Range".} ## Generic type to construct range types.
|
||||
@@ -415,7 +431,6 @@ include "system/inclrtl"
|
||||
const NoFakeVars = defined(nimscript) ## `true` if the backend doesn't support \
|
||||
## "fake variables" like `var EBADF {.importc.}: cint`.
|
||||
|
||||
const notJSnotNims = not defined(js) and not defined(nimscript)
|
||||
|
||||
when not defined(js) and not defined(nimSeqsV2):
|
||||
type
|
||||
|
||||
Reference in New Issue
Block a user