Skip to content

[Diagnostics] Add InFlightDiagnostic::warnUntilSwiftVersion to downgrade errors to warnings #38302

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
merged 3 commits into from
Jul 8, 2021

Conversation

hborla
Copy link
Member

@hborla hborla commented Jul 7, 2021

warnUntilSwiftVersion limits the diagnostic behavior to a warning until the specified language version. This helper can be used to stage in fixes for stricter diagnostics as warnings until the next major language version.

diagnostic behavior to a warning until the specified language version.

This helper can be used to stage in fixes for stricter diagnostics
as warnings until the next major language version.
@hborla hborla requested review from xedin and beccadax July 7, 2021 23:56
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.

Great improvement!

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

This is great, thank you!

@@ -44,6 +44,10 @@ NOTE(previous_decldef,none,
NOTE(brace_stmt_suggest_do,none,
"did you mean to use a 'do' statement?", ())

WARNING(error_in_future_swift_version,none,
"%0; this will be an error in Swift %1",
(DiagnosticInfo *, unsigned))
Copy link
Member

Choose a reason for hiding this comment

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

The diagnostic wrapping approach here is very cool. The "will be" wording feels a little off for existing warnings, because "will be an error in Swift 5" should really be "is an error in Swift 5". Should we say "is an error in Swift 5" instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. As soon as you use warnUntilSwiftVersion, that diagnostic is already an error under that language version. I'll update the wording to your suggestion 👍

WARNING(ownership_invalid_in_protocols_compat_warning,none,
"%0 should not be applied to a property declaration "
"in a protocol and will be disallowed in future versions",
(ReferenceOwnership))
Copy link
Member

Choose a reason for hiding this comment

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

Good find. I have so many places I'd like to use this!

hborla added 2 commits July 7, 2021 17:37
warnUntilSwiftVersion, specify when the diagnostic will become an
error in the message.
…protocols

diagnostic and remove ownership_invalid_in_protocols_compat_warning.
@hborla hborla force-pushed the warn-until-Swift-6 branch from 4713e0d to b9040c7 Compare July 8, 2021 01:03
@hborla
Copy link
Member Author

hborla commented Jul 8, 2021

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Jul 8, 2021

@swift-ci please test Linux platform

@hborla
Copy link
Member Author

hborla commented Jul 8, 2021

@swift-ci please smoke test Linux platform

@hborla
Copy link
Member Author

hborla commented Jul 8, 2021

@swift-ci please test Windows platform

1 similar comment
@hborla
Copy link
Member Author

hborla commented Jul 8, 2021

@swift-ci please test Windows platform

@hborla hborla merged commit 89b58d5 into swiftlang:main Jul 8, 2021
@hborla hborla deleted the warn-until-Swift-6 branch July 8, 2021 18:23
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