Commit Graph

11 Commits

Author SHA1 Message Date
Nate Chandler
c10d39e35f [AST] Remove Builtin.copy.
A vestigial remnant of it was left behind after
06921cfe84 in order to avoid a reverse
condfail when building old swiftinterfaces that define

```swift
func _copy<T>(_ value: T) -> T {
  #if $BuiltinCopy
    Builtin.copy(value)
  #else
    value
  #endif
}
```

If the language feature is removed, though, such interfaces should again
be buildable because the branch where the language feature isn't defined
should be expanded.

rdar://127516085
2024-05-04 11:35:17 -07:00
Nate Chandler
06921cfe84 [SIL] Hollow out Builtin.copy, deprecate _copy.
The copy operator has been implemented and doesn't use it.  Remove
`Builtin.copy` and `_copy` as much as currently possible.

Source compatibility requires that `_copy` remain in the stdlib.  It is
deprecated here and just uses the copy operator.

Handling old swiftinterfaces requires that `Builtin.copy` be defined.
Redefine it here as a passthrough--SILGen machinery will produce the
necessary copy_addr.

rdar://127502242
2024-05-03 15:56:25 -07:00
Kuba Mracek
d4a3c404a2 Re-enable test/stdlib/LifetimeManagement.swift 2023-11-06 09:02:45 -08:00
Meghana Gupta
6687d8fa88 Disable LifetimeManagement.swift 2023-03-03 17:25:22 -08:00
Joe Groff
ecceb02e2a Implement consume x operator with the accepted SE-0366 syntax.
Implement it as a contextual operator that only parses as an operator when
followed by an identifier.
2023-03-01 17:37:54 -08:00
Michael Gottesman
f3081d0e9a [move-keyword] Put the move keyword behind the experimental move only flag for now.
Originally move when it was in the stdlib as _move was behind a keyword but we
moved it in front to allow for some testing. Now that we are going with a
keyword (which we can't leave in/deprecate) move it behind the move only
experimental flag until this gets through evolution.
2022-08-10 12:45:17 -07:00
Michael Gottesman
6493886e1d [move-keyword] Wire up support for the move keyword in lvalue/rvalue emission.
I also updated the move function tests to show that this is working. As a nice
bonus, I was able to enable all of the tests also in a non-optimized stdlib.
2022-08-08 12:50:42 -07:00
Michael Gottesman
35a9acfdb9 Fix bots by adding optimized_stdlib flag to a test. 2021-12-15 15:07:55 -08:00
Michael Gottesman
97b19206e2 [moveOnly] Emit an error diagnostic if a user applies _move to a value that the compiler doesn't know how to check (non-let, non-param today).
The error diagnostic tells the user that the compiler can't check the value. It
then instructs the user to make a feature request and provide the test case if
they think it is reasonable. I also provided an option to disable the diagnostic
to unblock people.

The reason why I think this is the right thing to do is we want people to know
that _move means they do not need to worry about the given binding being used
later in the program in some way without having to reason. For now I am doing
this by banning _move on non-lets, non-params. This is implemented by noting
that:

1. _move inserts move_value [allows_diagnostics].
2. The checker always removes [allows_diagnostics] after checking a _move.

Thus we know after we check, any move_value that is still marked with
[allows_diagnostic], it was a _move that we never used in any checking.

I added some test cases where this known triggers. I am either going to
implement some sort of support for performing _move on them or give a more
specific diagnostic. This is just an initial incremental step.
2021-11-06 01:26:43 -07:00
Michael Gottesman
3a5049fa15 [stdlib] Mark _move as public.
Just a thinko on my part.
2021-10-29 15:37:46 -07:00
Michael Gottesman
f9122a79b7 [moveOnly] Implement a new _copy function that performs an explicit copy value.
The key thing is that the move checker will not consider the explicit copy value
to be a copy_value that can be rewritten, ensuring that any uses of the result
of the explicit copy_value (consuming or other wise) are not checked.

Similar to the _move operator I recently introduced, this is a transparent
function so we can perform one level of specialization and thus at least be
generic over all concrete types.
2021-10-29 15:37:46 -07:00