Make pointer_structural_match normal and warn#110166
Closed
est31 wants to merge 2 commits intorust-lang:masterfrom
Closed
Make pointer_structural_match normal and warn#110166est31 wants to merge 2 commits intorust-lang:masterfrom
est31 wants to merge 2 commits intorust-lang:masterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR does two things:
pointer_structural_matchfrom allow to warnpointer_structural_matchinto a normal lint instead of being a forward compatibility lintThe
pointer_structural_matchlint was added in #70743 to look for code that matches on a function pointer. As pointed out in #70861, and #54685, LLVM's behaviour makes function pointers behave in unexpected ways: function pointers might not be equal to "themselves" if function pointers for the same function were created in two different crates, and on the other hand, two different functions might end up with the same address if LLVM detects that they have the same body. See the linked issues for examples.Thus, in #70743 an allow-by-default forward compatibility lint was added to address matching on pointers.
In #70861 (comment) preferences were expressed that there should be a lint for matching on function pointers, but it should not be disallowed completely. I'd interpret that as wanting a warn-by-default non forward compatibility lint. Therefore, there are two possible ways forward:
pointer_structural_matchinto a normal lint that's not a forward compatibility lint, and make it warn by default, ORI think one should at least do one of the two things, even if it is only going to be a warning lint in the end.
The lang team has given the green light for the first approach. There is still the possibility that it will be forbidden in the future, but this will require concrete deprecation plans which don't exist right now.
cc @eddyb @pnkfelix @oli-obk