-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Rework how the disallowed qualifier in function type diagnostics are generated #142302
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
base: master
Are you sure you want to change the base?
Rework how the disallowed qualifier in function type diagnostics are generated #142302
Conversation
Signed-off-by: Jonathan Brouwer <[email protected]>
43f3afd
to
dc49bef
Compare
LL + pub type W1 = unsafe fn(); | ||
| | ||
|
||
error: expected one of `extern` or `fn`, found keyword `const` |
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.
these two errors in some sense say a very similar thing, so I feel like ideally they're not emitted separately and as one diagnostic that explains both problems
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.
though that might be a separate issue
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.
Would you just want the "expected one of extern or fn, found keyword const" to go, and only have the "an fn pointer type cannot be const"?
That should be relatively easy to do
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.
The latter, with a "allowed keywords are ...."
This pull request fixes two independent issues:
unsafe const fn()
type #142268, which is an issue created by Trim extra whitespace in fn ptr suggestion span #133151. This is fixed by moving the check intoparse_fn_front_matter
, where better span information is available to generate the right suggestions.cargo fix
crashes because "cannot replace slice of data that was already replaced". This is fixed by not generating a suggestion for the "wrong order" diagnostic if the "disallowed qualifier" diagnostic is triggered.There is a commit with failing tests so the test diff is clearer
r? @jdonszelmann