Skip to content

Commit 228b68e

Browse files
committed
Provide an example of diagnosing a conformance to an unsafe type
1 parent 3c30530 commit 228b68e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

proposals/nnnn-strict-memory-safety.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,17 @@ extension ConformsToP: @unsafe P {
291291
}
292292
```
293293

294-
Use of an `@unsafe` conformance for any reason (e.g., when that conformance is needed to call a generic function with a `ConformsToP` requirement) is diagnosed as an unsafe use, much like use of an `@unsafe` declaration.
294+
Use of an `@unsafe` conformance for any reason (e.g., when that conformance is needed to call a generic function with a `ConformsToP` requirement) is diagnosed as an unsafe use, much like use of an `@unsafe` declaration. For example
295+
296+
```swift
297+
func acceptP<T: P>(_: T.Type) { }
298+
299+
func passUnsafe() {
300+
acceptP(ConformsToP.self) // warning: use of @unsafe conformance of 'ConformsToP' to protocol 'P'
301+
}
302+
```
303+
304+
295305

296306
### Strict safety mode and escalatable warnings
297307

0 commit comments

Comments
 (0)