Skip to content

Strict safety improvements #80357

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 6 commits into from
Mar 28, 2025

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Mar 27, 2025

Fix a few issues with the strict safety checking that I found while migrating code:

  • Allow switch expressions on the right-hand side of unsafe assignments (rdar://147944753)
  • Fix the Fix-It for if let x where x is unsafe (rdar://147944243)
  • Diagnose the use of @safe and @unsafe together (rdar://147943857)
  • Stop propagating @safe and @unsafe from a type definition to its members; these are independent notions (rdar://145899513)

…ements

We were rejecting the use of switch expressions on the right-hand side
of an assignment that was marked `unsafe`. Fixes rdar://147944753.
…alue

When we encounter unsafe code in `if let x`, we would produce a Fix-It
that would change it to the ill-formed `if let unsafe x`. Improve
tracking of the expressions that are synthesized for the right-hand
side of these conditions, so that we can produce a Fix-It that turns
this into the proper

    if let x = unsafe x

Fixes rdar://147944243.
Fixes rdar://147943857.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor enabled auto-merge March 27, 2025 23:52
@DougGregor DougGregor requested review from hnrklssn, Xazax-hun and a team as code owners March 28, 2025 05:07
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test Windows

@DougGregor
Copy link
Member Author

swiftlang/llvm-project#10369

@swift-ci please smoke test Windows

@DougGregor DougGregor merged commit fd24d29 into swiftlang:main Mar 28, 2025
3 checks passed
@DougGregor DougGregor deleted the strict-safety-improvements branch March 28, 2025 19:15
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.

1 participant