Skip to content
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

Pointer and function pointer casting #5921

Open
Coder-256 opened this issue Aug 18, 2020 · 2 comments
Open

Pointer and function pointer casting #5921

Coder-256 opened this issue Aug 18, 2020 · 2 comments
Labels
A-lint Area: New lints C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages S-needs-discussion Status: Needs further discussion before merging or work can be started

Comments

@Coder-256
Copy link

Continuing the conversation from Discord regarding #5906.

@flip1995 flip1995 added S-needs-discussion Status: Needs further discussion before merging or work can be started C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages A-lint Area: New lints labels Aug 18, 2020
@Coder-256
Copy link
Author

Coder-256 commented Aug 18, 2020

To summarize the consensus:

  1. Forcing the user to cast to a function pointer is considered bloating, just use a regular pointer instead
  2. Whenever the lint is triggered, keep the existing suggestion (foo as *const ()), but also suggest calling the function in certain circumstances
  3. Turbofish as usize should be linted

Some points that still need discussion:

  1. When/whether to lint non-turbofish functions, or functions that take many arguments
  2. When to suggest calling the function (and what to suggest for arguments)
  3. How we should separate the lints

Also, I think we still need to discuss pointer casts in general (function and regular) to numeric types. E.g. *const T as i8, fn_ptr as i8. Maybe non-fn pointers are a separate topic but IMHO we should make the rules consistent and treat them the same as normal pointers when it comes to casting, and decide what to do about truncating/non-usize casts. (I also wonder if function pointers need to be reconsidered for some existing lints involving pointers, but that's probably off topic)

@kraktus
Copy link
Contributor

kraktus commented Sep 24, 2022

I think this can be closed as implemented by #7705

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages S-needs-discussion Status: Needs further discussion before merging or work can be started
Projects
None yet
Development

No branches or pull requests

3 participants