Skip to content

Commit 3c54f68

Browse files
committed
Fill in reference for Copyable
1 parent 8468088 commit 3c54f68

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

stdlib/public/core/Misc.swift

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -171,28 +171,30 @@ func _rethrowsViaClosure(_ fn: () throws -> ()) rethrows {
171171

172172
/// A type whose values can be implicitly or explicitly copied.
173173
///
174-
/// Although this protocol doesn’t have any required methods or properties,
175-
/// it does have semantic requirements that are enforced at compile time.
176-
/// These requirements are listed in the sections below.
177-
/// XXX what are the requirements -- just that copying is ok?
178-
/// Conformance to `Copyable` must be declared
179-
/// in the same file as the type's declaration.
180-
/// <!-- XXX TR: Confirm previous sentence; borrowed from Sendable docs -->
174+
/// Conforming to this protocol indicates that a type's value can be copied;
175+
/// this protocol doesn’t have any required methods or properties.
176+
/// You don't generally need to write an explicit conformance to `Copyable`.
177+
/// The following places implicitly include `Copyable` conformance:
181178
///
182-
/// Conformance to the `Copyable` protocol
183-
/// is implicitly included in the following places:
184-
///
185-
/// * Structures declarations
186-
/// * Enumerations declarations
179+
/// * Structures declarations,
180+
/// unless it has a noncopyable stored property
181+
/// * Enumerations declarations,
182+
/// unless it has a case whose associated value isn't copyable
187183
/// * Class declarations
184+
/// * Actor declarations
188185
/// * Protocol declarations
189186
/// * Associated type declarations
190187
/// * The `Self` type in a protocol extension
191188
///
189+
/// A class or actor can contain noncopyable stored properties,
190+
/// while still being copyable itself ---
191+
/// classes and actors are copied by retaining and releasing references.
192+
///
192193
/// In a declaration that includes generic type parameters,
193194
/// each generic type parameter implicitly includes `Copyable`
194195
/// in its list of requirements.
195-
/// Metatypes and tuples of copyable types are also implicitly copyable.
196+
/// Metatypes and tuples of copyable types are also implicitly copyable,
197+
/// as are boxed protocol types.
196198
/// For example,
197199
/// all of the following pairs of declarations are equivalent:
198200
///
@@ -203,31 +205,29 @@ func _rethrowsViaClosure(_ fn: () throws -> ()) rethrows {
203205
/// protocol MyProtocol { }
204206
/// protocol MyProtocol: Copyable { }
205207
///
206-
/// XXX example of assoc type or Self
208+
/// protocol AnotherProtocol {
209+
/// associatedtype MyType
210+
/// associatedtype MyType: Copyable
211+
/// }
207212
///
208213
/// func genericFunction<T>(t: T) { }
209214
/// func genericFunction<T>(t: T) where T: Copyable { }
215+
///
216+
/// let x = any MyProtocol
217+
/// let x = any MyProtocol & Copyable
210218
/// ```
211219
///
212-
/// To suppress an implicit conformance to `Copyable`
213-
/// you write `~Copyable`.
220+
/// To suppress an implicit conformance to `Copyable` you write `~Copyable`.
214221
/// For example,
215222
/// only copyable types can conform to `MyProtocol` in the example above,
216223
/// but both copyable and noncopyable types
217-
/// can conform to the following protocol:
224+
/// can conform `NoRequirements` in the example below:
218225
///
219226
/// ```swift
220227
/// protocol NoRequirements: ~Copyable { }
221228
/// ```
222229
///
223-
/// Extensions on the `Copyable` protocol are not allowed.
224-
///
225-
/// XXX link to the right chapter
226-
/// For information about the language-level concurrency model that `Task` is part of,
227-
/// see [Concurrency][concurrency] in [The Swift Programming Language][tspl].
228-
///
229-
/// [concurrency]: https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html
230-
/// [tspl]: https://docs.swift.org/swift-book/
230+
/// Extensions to the `Copyable` protocol are not allowed.
231231
@_marker public protocol Copyable {}
232232

233233
@_marker public protocol Escapable {}

0 commit comments

Comments
 (0)