[6.0] Suppress pointer conversion warnings for BitwiseCopyable elements. #73726
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Now that BitwiseCopyable is accepted, it should work as the recommended workaround for unsafe pointer conversion warnings:
Forming 'UnsafeMutableRawPointer' to a variable of type 'S'; this is likely incorrect because 'S' may contain an object reference.
The check for trivial element types is in SILGenExpr, diagnoseImplicitRawConversion. For now, we can hack SILGenExpr to specifically disable the warning for BitwiseCopyable, just as it was done for FixedWidthInteger in prior releases.
Fixes rdar://128229439 (Conversion from BitwiseCopyable to UnsafeRawPointer should not warn.)
(cherry picked from commit 6bd0ef0)
--- CCC ---
Explanation: Suppress pointer conversion warnings for BitwiseCopyable elements.
Scope: Many Swift devs have complained about this warning and asked for a workaround. BitwiseCopyable was always the recommeded workaround, but only recently landed. Now they can deploy this workaround when building against 6.0.
Radar/SR Issue: rdar://128229439 (Conversion from BitwiseCopyable to UnsafeRawPointer should not warn.)
Original PR: #73687
Risk: None. This disables a warning for new adopters of BitwiseCopyable.
Testing: Dozens of unit tests.
Reviewer: @nate-chandler