-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[FixCode] Add a diagnosis/fixit to help users convert void pointers. #4108
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
Conversation
…Pointer<Void> to Unsafe[Mutable]RawPointer. rdar://27730408
@swift-ci smoke test OS X platform |
@jrose-apple mind reviewing this? |
@swift-ci smoke test OS X platform |
@swift-ci smoke test OS X platform |
IsMutable = BGT->getDecl() == Ctx.getUnsafeMutablePointerDecl(); | ||
assert(BGT->getGenericArgs().size() == 1); | ||
auto CanTy = BGT->getGenericArgs().front()->getCanonicalType(); | ||
return CanTy->isVoid(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can skip the getCanonicalType
step here.
I'm a little unhappy with hardcoding this in the compiler, and I'm not sure that |
Hard-coding this into the compiler is a last ditch effort to get decent diagnostics (I spent lots of time last week exploring the limits of availability annotations). I'm not sure "deprecated" is the right language. UnsafePointer will always be a valid type in generic contexts, but people should be strongly discouraged from using it in a concrete bound generic. If they do, it will cause a number of confusing downstream errors, and the diagnostics for those errors will be better if they first rename to UnsafeRawPointer. |
@jrose-apple |
@atrick Should the warning be "Unsafe%0Pointer has been replaced by Unsafe%0RawPointer" or "Unsafe%0Pointer has been replaced by Unsafe%0RawPointer"? I thought the later is the case we are handling here specifically. |
:-) I think you both fell prey to Markdown's HTML embedding. "Unsafe%0Pointer" (written |
I think we both didn't quote the warning string properly. I think it should be #4114 has been merged. |
@jrose-apple @atrick Right, I realized what happened the moment I saw my message posting. |
@swift-ci test |
@swift-ci test |
@swift-ci test |
Slave went offline during the build. |
This patch warns the usage of Unsafe[Mutable]Pointer, and fix users' code by replacing it with Unsafe[Mutable]RawPointer.
Resolved bug number: (SR-)
Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
A smoke test on macOS does the following:
device standard libraries are not built.
version of these tests are not run.
A smoke test on Linux does the following:
tests are not run.
Validation Testing
Lint Testing
Note: Only members of the Apple organization can trigger swift-ci.
…Pointer to Unsafe[Mutable]RawPointer. rdar://27730408