Skip to content

[stdlib] adjust addressable attribute on String type family #82013

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

Merged

Conversation

glessard
Copy link
Contributor

@glessard glessard commented Jun 5, 2025

This rearranges the @_addressableForDependencies attributes in the String family to be applied to _StringGuts, which is where the information is located. Other types inherit the characteristic transitively.

Addresses rdar://152615917

@glessard glessard requested a review from a team as a code owner June 5, 2025 05:34
@glessard
Copy link
Contributor Author

glessard commented Jun 5, 2025

@swift-ci please smoke test

@glessard glessard requested a review from atrick June 5, 2025 05:36
@glessard glessard force-pushed the rdar152615917-addressable-string-types branch from 7fad0d5 to 682f904 Compare June 5, 2025 12:58
@glessard glessard requested a review from eeckstein as a code owner June 5, 2025 13:16
@glessard glessard force-pushed the rdar152615917-addressable-string-types branch from e066e87 to cd7bb99 Compare June 5, 2025 13:31
@glessard
Copy link
Contributor Author

glessard commented Jun 5, 2025

@swift-ci please smoke test

@@ -417,7 +417,7 @@ public func testTrivialInoutBorrow(p: inout UnsafePointer<Int>) -> Span<Int> {

private let immortalInt = 0

private let immortalString = ""
private let immortalStrings: [String] = []
Copy link
Contributor Author

@glessard glessard Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If String is marked addressable, escape diagnostics behave slightly differently when it is a global. This seems incidental and could be addressed separately if it is an issue. I changed the type of this variable to get the expected diagnostics out of this test.

@glessard
Copy link
Contributor Author

glessard commented Jun 5, 2025

@swift-ci please smoke test Windows platform

@glessard
Copy link
Contributor Author

glessard commented Jun 5, 2025

@swift-ci please smoke test Linux platform

@@ -17,6 +17,7 @@ import SwiftShims
// functionality and guidance for efficiently working with Strings.
//
@frozen
@_addressableForDependencies
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, d'oh. Shouldn't this also be applied to _StringObject? Substring? The Slice within that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Slice should not need to be @_addressableForDependencies. Only a value that has an in-line array-like representation that isn't using InlineArray already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding was that it would be transitively applied from whatever holds a _StringGuts (in a non-opaque way.) _StringObject is lower, but we don't need it directly to make a span, the information from _StringGuts is enough.

@glessard glessard force-pushed the rdar152615917-addressable-string-types branch from cd7bb99 to 998b329 Compare June 6, 2025 15:22
@glessard
Copy link
Contributor Author

glessard commented Jun 6, 2025

@swift-ci please smoke test

@glessard glessard merged commit d38b961 into swiftlang:main Jun 6, 2025
3 checks passed
@glessard glessard deleted the rdar152615917-addressable-string-types branch June 6, 2025 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants