Skip to content

[cxx-interop] Document some caveats of safe interop #1094

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions documentation/cxx-interop/safe-interop/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ struct SWIFT_NONESCAPABLE StringRef { ... };
Now the Swift compiler imports `StringRef` as a safe type and no longer
emits a warning about using an unsafe type.

<div class="info" markdown="1">
Some containers and protocols do not yet support non-escapable types in Swift 6.2.
</div>

### Annotating C++ APIs

Building the code again will emit a new diagnostic for the `fileName` function about
Expand Down Expand Up @@ -387,6 +391,13 @@ compiler can bridge those span-like parameters to Swift's
and [`MutableSpan`](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0467-MutableSpan.md)
types, and the user with a safe and convenient interface to those imported APIs.

<div class="info" markdown="1">
At the time of writing, the features described in this section
are behind an experimental feature flag on the Swift 6.2 release branch.
To enable these features, pass `-enable-experimental-feature SafeInteropWrappers`
to the Swift compiler.
</div>

### C++ `std::span` Support

APIs taking or returning C++'s `std::span` with sufficient lifetime
Expand Down