-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SE-0458] Improvements to strict memory safety checking based on the ongoing review #2689
Open
DougGregor
wants to merge
7
commits into
swiftlang:main
Choose a base branch
from
DougGregor:se-0458-adjustments
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Detailed Design was becoming a grab-bag of sections, so give it more structure. First, we describe all of the sources of memory unsafety in Swift. Then, note the role of the @safe attribute. Finally, describe all of the ways in which one can acknowledge unsafety. One drive-by fix here is to document the unsafe conformances of the `UnsafeBufferPointer` family of types to the `Collection` protocol hierarchy.
…edge them This was lost in my restructuring
|
||
Implementing a protocol requirement that is safe (and not part of an `@unsafe` protocol) within an `@unsafe` declaration introduces unsafety, so it will produce a diagnostic in the strict safety mode: | ||
Swift's `for..in` loops are effectively implemented as syntactic sugar over the `Sequence` and `IteratorProtocol` protocols, where the `for..in` creates a new iterator (with `Sequence.makeIterator()`) and then calls its `next()` operation for each loop iteration. If the conformances to `Sequence` are `IteratorProtocol` is `@unsafe`, the loop will introduce a warning: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling:
... `Sequence` are `IteratorProtocol` is `@unsafe`, the loop will introduce a warning:
^~~ and
@@ -740,7 +824,14 @@ We could introduce an optional `message` argument to the `@unsafe` attribute, wh | |||
|
|||
## Revision history | |||
|
|||
* **Revision 2 (following first review)** | |||
* **Revision 3 (following second review eextension)** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling:
**Revision 3 (following second review eextension)**
^~~~~~~~~~ extension
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request improves the proposal in number of ways:
@unsafe
; it is implied. They may be marked@safe
to indicate that they are actually safe.unsafe
for iteration via thefor..in
syntax.@unsafe
for C types that involve pointers.UnsafeBufferPointer
family of types to theCollection
protocol hierarchy.