Commit Graph

7762 Commits

Author SHA1 Message Date
Guillaume Lessard
71258c4a2a [stdlib] add failure explanations to debug preconditions
addresses rdar://128543858
2024-05-24 14:02:57 -07:00
Nate Chandler
746cf2ff5b [BitwiseCopyable] Drop req from SIMD/Storage.
There are conformers to SIMDStorage (like that in the added test case)
which involve an Array (a type that can't conform to BitwiseCopyable).
So lift the constraint on SIMDStorage.  This in turn requires lifting
the constraint on SIMD (otherwise, e.g. `SIMD8<Scalar>` would fail to
conform since it has as a member some SIMD8Storage which is only
constrained to conform to `SIMDStorage`; the `SIMD8Storage`
associatedtype also cannot be constrained to `BitwiseCopyable` because
that storage may again not conform as in the test example).

rdar://128661878
2024-05-24 12:32:10 -07:00
Holly Borla
2590b2d7ac [Concurrency] Obsolete a few deprecated typealiases to Sendable in
Swift 6.
2024-05-24 08:58:41 -07:00
Alex Martini
65a5216a7b Merge pull request #73238 from amartini51/copyable_126377559
Add reference for Copyable

Fixes: rdar://126377559
2024-05-22 15:55:47 -07:00
eeckstein
7c69bec9b4 Merge pull request #73782 from eeckstein/static-arrays-in-embedded
IRGen: support read-only statically initialized arrays in embedded swift
2024-05-22 19:34:42 +02:00
Alejandro Alonso
4221d9f76a Merge pull request #73734 from Azoy/bitwisecopyable-atomic-reps
[stdlib] Enforce that atomic representations are BitwiseCopyable
2024-05-22 08:19:06 -07:00
Erik Eckstein
162139364e IRGen: support read-only statically initialized arrays in embedded swift
Arrays buffers need to be initialized with a (minimal) metatype and with an immortal reference count.
2024-05-21 18:04:10 +02:00
Alejandro Alonso
3053c81259 Enforce that atomic representations are bitwisecopyable 2024-05-18 10:18:32 -07:00
Guillaume Lessard
a27d9c426a Merge pull request #71912 from oscbyspro/better-joined-distance-from-to-int-min
FlattenSequence/distance(from:to:) untrapping Int.min
2024-05-17 16:17:01 -07:00
Allan Shortlidge
f0551920c5 Merge pull request #73700 from tshortli/borrowing-switch-condfail
stdlib: Fix a borrowing switch condfail
2024-05-17 09:16:39 -07:00
Allan Shortlidge
ca70312879 stdlib: Fix a borrowing switch condfail.
Resolves rdar://128249510
2024-05-16 23:35:25 -07:00
Allan Shortlidge
5b252da7e2 stdlib: Fix warnings in Duration.swift. 2024-05-16 23:34:44 -07:00
Alex Martini
b57dbae317 Fix typo in docs code example
Co-authored-by: Kavon Farvardin <kfarvardin@apple.com>
2024-05-16 16:33:12 -07:00
Alex Martini
97790c03a7 Indent code listings, to match style used elsewhere 2024-05-16 14:35:29 -07:00
Alex Martini
6fa34bdabf Add a missing implicit Copyable constraint
Co-authored-by: Kavon Farvardin <kfarvardin@apple.com>
Co-authored-by: Slava Pestov <spestov@apple.com>
2024-05-16 13:47:36 -07:00
Alejandro Alonso
db9232f246 Merge pull request #73550 from Azoy/string-debugger-changes
[debug] Print strings using their description in the debugger
2024-05-16 11:40:00 -07:00
Erik Eckstein
15acfbb268 stdlib: improve debug performance of UnsafePointer.pointer(to:)
Making those functions transparent enables to completely remove the creation of keypaths, even with -Onone.
rdar://127793797
2024-05-16 10:15:53 +02:00
Erik Eckstein
fb036e9019 stdlib: more efficient pointer overflow checks in the UnsafePointer.pointer(to:) functions
Saves the optional nil check for unwrapping the pointer and one condition
2024-05-16 10:15:42 +02:00
Joe Groff
2c6bfa23c8 Merge pull request #72967 from jckarter/enable-borrowing-switch-frontend
Enable 'BorrowingSwitch' feature.
2024-05-15 10:57:07 -07:00
Alejandro Alonso
b2f21bbfb3 Update DebuggerSupport.swift 2024-05-15 10:02:35 -07:00
Karoy Lorentey
6e6a5ba1d0 Merge pull request #73400 from lorentey/fix-managedbuffer-abi-mixup
[stdlib] ManagedBuffer: Fix misapplied linkage names for legacy entry points
2024-05-14 20:52:17 -07:00
Joe Groff
10f9289ef8 Enable 'BorrowingSwitch' feature. 2024-05-14 07:31:59 -07:00
Kuba Mracek
e68195b8f2 [embedded] Avoid using UInt64 in int->string code (which triggers allocations on 32-bit systems) 2024-05-12 22:11:40 -07:00
Kuba Mracek
7120279755 [embedded] Avoid using a metatype variable in _allocateUninitializedArray 2024-05-12 22:07:00 -07:00
Alejandro Alonso
180a11fdc2 Print strings using their description in the debugger 2024-05-09 14:36:57 -07:00
Kuba Mracek
92c20a699b [embedded] Avoid unsafeBitCast, use Builtin.castFromNativeObject instead, add armv7 test 2024-05-08 21:29:11 -07:00
Nate Chandler
2671652085 [BitwiseCopyable] Avoid a condfail.
The standard library defines
```
protocol BitwiseCopyable {}
typealias _BitwiseCopyable = BitwiseCopyable
```
For current compilers, `BitwiseCopyable` is a "known protocol".

For older compilers, it is not; instead `_BitwiseCopyable` is.  So
print the following into the swiftinterface for those older compilers:
```
protocol _BitwiseCopyable {}
typealias BitwiseCopyable = _BitwiseCopyable
```

rdar://127755503
2024-05-08 16:53:14 -07:00
Nate Chandler
acd9b72833 [BitwiseCopyable] Only deprecate underscored.
Rather than immediately outright banning the old protocol, just make it
be a deprecated typealias for the real one.
2024-05-08 16:52:51 -07:00
Kuba Mracek
7ae20b7039 [embedded] Port Swift.String to embedded Swift 2024-05-08 11:11:37 -07:00
nate-chandler
bcd08c0c9a Merge pull request #73235 from nate-chandler/bitwise-copyable/enable
[BitwiseCopyable] Promote to feature.
2024-05-04 10:16:40 -07:00
Stephen Canon
102df47a4c Make static [milli/micro/nano]seconds members on Duration inlinable (#73429)
This means that they can't use _Int128 for their implementation, but efficient implementation of these using only 64b arithmetic is pretty straightforward, so that's OK. This allows them to be specialized and mostly optimized away in release builds.
2024-05-04 10:39:17 -04: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
Karoy Lorentey
3061531cb6 [stdlib] ManagedBuffer: Fix misapplied linkage names for legacy entry points
I accidentally copy and pasted the mangled symbol names in the wrong order, so existing callers got directed to the wrong entry points, and things got terribly, terribly wrong.

(We badly need a sensible replacement for these `@_silgen_name` hacks.)

Huge thanks to @edymtt for spotting this!

rdar://127016847
2024-05-02 14:24:55 -07:00
Kuba Mracek
1d48f28d84 [KeyPath] Fix regression in == on keypaths 2024-04-30 12:50:03 -07:00
Allan Shortlidge
250758335c Merge pull request #73306 from tshortli/the-condfails-never-end
stdlib: Fix more typed throws and non-copyable generics condfails
2024-04-27 16:07:28 -07:00
Allan Shortlidge
7fc2179c31 stdlib: Fix more typed throws and non-copyable generics condfails.
There were two categories of problem for older compilers that consume the
stdlib `.swiftinterface`:

- The `case .some(borrowing x)` syntax isn't accepted; use `_borrowing`
- Various functions that addopted `~Copyable` generic constraints conflict with
  the `@usableFromInline` ABI stubs that were left in to preserve compatibility
  when the functions are printed with `~Copyable` constraints stripped. The stubs
  need to have different names to get out of the way.

Resolves rdar://127132742
2024-04-26 16:37:09 -07:00
Karoy Lorentey
775aab0c8e [stdlib] Optional.map, .flatMap: Remove @_disfavoredOverload
We don’t need this to worka round the known source compat issue, and it is triggering “expression too complex” errors, causing harm.

rdar://127015095
2024-04-26 11:58:09 -07:00
Joe Groff
2f954ef5d7 Merge pull request #73259 from jckarter/external-key-path-generic-environment-binding
IRGen: Fix key path generic environment marshalling for external property descriptors.
2024-04-25 16:24:42 -07:00
Nate Chandler
b12def9c6a [BitwiseCopyable] Deprecate unbound overloads.
The unconstrained overloads of loadUnaligned and storeBytes were
deprecated in SE-0426.
2024-04-25 11:44:15 -07:00
Nate Chandler
f9ad81e106 [BitwiseCopyable] Remove #ifs. 2024-04-25 11:44:15 -07:00
Nate Chandler
b1fbe4ea91 [BitwiseCopyable] Remove underscore. 2024-04-25 11:44:15 -07:00
Alex Martini
587c79b6f1 Fix plurals
Incorporates feedback from Slava Pestov <spestov@apple.com>
2024-04-25 11:05:35 -07:00
Joe Groff
02e1f2ea15 IRGen: Fix key path generic environment marshalling for external property descriptors.
The layout of a computed key path component carries an argument buffer for captures, which has
the following layout:

```
---
captured values (subscript indices)
---
generic arguments
---
```

When we reference an externally-defined public property or subscript from a key path, and the
external declaration has a property descriptor, then the generic arguments for the external
declaration get appended to the end of this buffer, giving:

```
---
captured values (subscript indices)
---
generic arguments
---
external property's generic arguments
---
```

The convention for key path accessors to bind their generic environment is thus to unpack them
from the end of the argument buffer, so that the external keypath's accessors can find the
arguments to bind the external generic environment while still allowing the enclosing key path
to save the original captured generic environment (which may be necessary to capture the
appropriate conditional and/or retroactive `Equatable` and `Hashable` conformances for
subscript indices).

However, our code generation for binding the generic arguments out of the argument buffer
contained a flawed optimization: for a property, we know there are never any captured values,
so I had assumed that the generic parameters could always be bound from the beginning of the
argument buffer, assuming that the generic parameters make up the totality of the buffer. This
falls over for external property descriptor references when the key path itself captures a
generic environment, since the external property's expected generic environment appears after
the key path's original generic environment. We can fix this by removing the conditional
entirely, and always adjusting the offset we load the generic environment from to look at the
end of the buffer. Fixes rdar://125886333.
2024-04-25 10:36:13 -07:00
Alex Martini
3c54f6819b Fill in reference for Copyable 2024-04-24 16:58:00 -07:00
Nate Chandler
6e975da805 [BitwiseCopyable] Promote ConformanceSuppression.
The ability to suppress conformance to BitwiseCopyable was part of the
accepted SE-428.
2024-04-24 15:52:20 -07:00
Nate Chandler
ed5c7ef7ae [BitwiseCopyable] Promote to feature.
SE-0426 was accepted.
2024-04-24 15:52:20 -07:00
Alex Martini
8468088e55 Add requirements & sketch TSPL cross reference 2024-04-23 09:12:15 -07:00
Kavon Farvardin
f0a69a3ef1 prevent uses of Escapable in general
This protocol appears in the stdlib as scaffolding for the
`NonescapableTypes` feature, which is still experimental and not gone
through evolution as an approved addition to the stdlib.

Rather than delete it from the stdlib, because it needs to still remain
to support that feature work, gate references to it behind a feature
flag.

Additionally, prevent documentation from seeing this declaration.

rdar://126705184
2024-04-22 20:40:11 -07:00
GG
739ff6f0c2 Fix typo in Result.swift 2024-04-21 21:17:22 +09:00
Dave Lee
e57f70bd4d [Debugging] Add DebugDescriptionMacro experimental feature (#73107)
This removes the leading underscore from the macro.
2024-04-18 17:25:44 -07:00