Skip to content

Conversation

@DougGregor
Copy link
Member

In addition to upcoming and experimental features, handle migration for "optional" features (the only one now being StrictMemorySafety). Read optional features from the supported-features JSON coming from the compiler and use their provided flags.

While here, use the newly-introduced "categories" field from the JSON to filter the list of categories rather than assuming it's the same as the feature name.

In addition to upcoming and experimental features, handle migration for
"optional" features (the only one now being StrictMemorySafety). Read
optional features from the supported-features JSON coming from the
compiler and use their provided flags.

While here, use the newly-introduced "categories" field from the JSON to
filter the list of categories rather than assuming it's the same as
the feature name.
@DougGregor
Copy link
Member Author

@swift-ci please test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

Look good, thank you!

@xedin
Copy link
Contributor

xedin commented May 22, 2025

@DougGregor looks like the failure is related to manifest update:

2025-05-22T17:21:57.914Z] stderr: error: Could not update manifest for 'Diagnostics' ('strictMemorySafety' doesn't have an argument). Please enable '.strictMemorySafety()' features manually.
[2025-05-22T17:21:57.914Z] 
[2025-05-22T17:21:57.914Z] <EXPR>:0: error: PackageCommandNativeTests.testMigrateCommand : threw error "terminated(1): /home/build-user/build/buildbot_incremental/swiftpm-linux-x86_64/x86_64-unknown-linux-gnu/release/swift-package-manager --package-path /tmp/SwiftMigrate_StrictMemorySafetyMigration.oH8L7a/SwiftMigrate_StrictMemorySafetyMigration --configuration debug --build-system native migrate --to-feature StrictMemorySafety output:
[2025-05-22T17:21:57.914Z]     > Starting the build.
[2025-05-22T17:21:57.914Z]     Building for debugging...
[2025-05-22T17:21:57.914Z]     [0/2] Write sources
[2025-05-22T17:21:57.914Z]     [1/2] Write swift-version-6FB92013CB97DDE1.txt
[2025-05-22T17:21:57.914Z]     [3/4] Emitting module Diagnostics
[2025-05-22T17:21:57.914Z]     [4/4] Compiling Diagnostics Test.swift
[2025-05-22T17:21:57.914Z]     Build complete! (1.43s)
[2025-05-22T17:21:57.914Z]     > Applying fix-its.
[2025-05-22T17:21:57.914Z]     > Updating manifest.
[2025-05-22T17:21:57.914Z]     error: Could not update manifest for 'Diagnostics' ('strictMemorySafety' doesn't have an argument). Please enable '.strictMemorySafety()' features manually."

@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

I had a bad merge; fixed that and improved testing of the "categories" part.

@DougGregor
Copy link
Member Author

@swift-ci please test Linux

@DougGregor
Copy link
Member Author

@swift-ci please test Windows

Copy link
Contributor

@AnthonyLatsis AnthonyLatsis left a comment

Choose a reason for hiding this comment

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

Awesome, thank you!

Comment on lines +62 to +69
public var categories: [String] {
switch self {
case .optional(name: _, migratable: _, categories: let categories, flagName: _),
.upcoming(name: _, migratable: _, categories: let categories, enabledIn: _),
.experimental(name: _, migratable: _, categories: let categories):
categories
}
}
Copy link
Contributor

@AnthonyLatsis AnthonyLatsis May 23, 2025

Choose a reason for hiding this comment

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

Makes me want a feature to write self.categories.

…w comments

Pass migration flags for optional features through -Xfrontend. The
driver will get updated, but separately.

Address some code review comments from improve the code. Thanks, Anthony!
@DougGregor
Copy link
Member Author

@swift-ci please test

@dschaefer2
Copy link
Member

@swift-ci please test windows

@dschaefer2
Copy link
Member

@swift-ci please test self hosted windows

@DougGregor
Copy link
Member Author

@swift-ci please test windows

@AnthonyLatsis
Copy link
Contributor

@swift-ci please test self hosted Windows

@AnthonyLatsis
Copy link
Contributor

Merging to unblock #8684.

@AnthonyLatsis AnthonyLatsis merged commit 789ace3 into swiftlang:main May 24, 2025
6 checks passed
@DougGregor DougGregor deleted the migrate-optional-and-categories branch May 30, 2025 18:28
DougGregor added a commit to DougGregor/swift-package-manager that referenced this pull request May 30, 2025
In addition to upcoming and experimental features, handle migration for
"optional" features (the only one now being StrictMemorySafety). Read
optional features from the supported-features JSON coming from the
compiler and use their provided flags.

While here, use the newly-introduced "categories" field from the JSON to
filter the list of categories rather than assuming it's the same as the
feature name.
DougGregor added a commit that referenced this pull request May 31, 2025
…8748)

Explanation: Expand migration support to cover optional features like
strict memory safety, in addition to upcoming features. While here, also
add a test for migration to inferring isolated conformances.
Scope: Limited to the migrator.
Original PR:
#8711
Risk: Very low; it's limited to the migrator.
Testing: CI
Reviewed by: @xedin, @AnthonyLatsis
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.

4 participants