Skip to content
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

[Concurrency] Diagnose a redundant nonisolated(unsafe) #72078

Merged
merged 3 commits into from
Mar 16, 2024

Conversation

simanerush
Copy link
Contributor

@simanerush simanerush commented Mar 5, 2024

With a static constant property of a struct with a Sendable type, warn the user that nonisolated(unsafe) is redundant.

  • Diagnose the redundant attribute in the case of immutable storage
  • When dealing with a public actor, suggest to remove only the (unsafe) part
  • Test that the fix-its are working correctly

Notes: this is my first concurrency bug fix, so I would appreciate feedback on the diagnostics messages!

Resolves #71546.

@simanerush simanerush marked this pull request as ready for review March 5, 2024 01:44
@simanerush simanerush force-pushed the redundant-nonisolated-unsafe branch 2 times, most recently from 13092e0 to 1123bc0 Compare March 5, 2024 02:59
lib/Sema/TypeCheckAttr.cpp Outdated Show resolved Hide resolved
lib/Sema/TypeCheckAttr.cpp Outdated Show resolved Hide resolved
@simanerush simanerush force-pushed the redundant-nonisolated-unsafe branch from 355a3aa to c9b5791 Compare March 7, 2024 00:58
@simanerush
Copy link
Contributor Author

@swift-ci please smoke test macos

@simanerush simanerush requested a review from hborla March 7, 2024 04:36
@simanerush
Copy link
Contributor Author

@swift-ci please smoke test

@simanerush
Copy link
Contributor Author

@hborla this should be ready now!

Copy link
Member

@hborla hborla left a comment

Choose a reason for hiding this comment

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

Thank you!

@hborla hborla merged commit ee197ae into swiftlang:main Mar 16, 2024
3 checks passed
@simanerush simanerush deleted the redundant-nonisolated-unsafe branch March 17, 2024 06:55
@mattmassicotte
Copy link

Just wanted to say this rocks

@simanerush
Copy link
Contributor Author

@mattmassicotte Thank you!

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.

Unnecessary nonisolated(unsafe) produces no warning
4 participants