Skip to content

New lint: generalize exit, todo, mem_forget, etc. #8031

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

Open
2 of 4 tasks
ojeda opened this issue Nov 25, 2021 · 4 comments
Open
2 of 4 tasks

New lint: generalize exit, todo, mem_forget, etc. #8031

ojeda opened this issue Nov 25, 2021 · 4 comments
Labels
A-lint Area: New lints

Comments

@ojeda
Copy link
Contributor

ojeda commented Nov 25, 2021

What it does

The new lint(s) would be a generalization of other lints that check for usage of some functions, types, macros, etc.:

  • exit could be generalized to take a list of functions to check for (including those of the same project, not just the standard library).
  • todo could be generalized to take a list of macros too.
  • undocumented_unsafe_blocks could be generalized to other comments apart from // SAFETY: ... (for unsafe_code).
  • missing_safety_doc could be generalized to # Panics sections (even if it only catches a subset of cases).
  • mem_forget gives another idea for generalization: for each function in the list, optionally give a list of traits to check to (not) be implemented for their arguments.
  • It could also be generalized to take paths only or do the matching textually (possibly including regex support).

etc. It would be a continuation of other lints such as disallowed_methods and disallowed_types.

The new lint(s) would be useful for big projects that may want to avoid particular items coming from dependencies, or to discourage their usage in general (requiring an explicit allow), or to deprecate certain items (while keeping existing ones), etc.

Categories (optional)

  • Kind: restriction.

Drawbacks

None (since projects would be responsible for the lists).

@ojeda ojeda added the A-lint Area: New lints label Nov 25, 2021
@xFrednet
Copy link
Member

We have the disallowed_methods and disallowed_types lints. Having this for functions sounds reasonable. Macros can be a bit iffy but might be worth a try 🙃

@ojeda
Copy link
Contributor Author

ojeda commented Nov 25, 2021

Thanks! I will add the links to the OP message.

@Veykril
Copy link
Member

Veykril commented Nov 9, 2022

We have the disallowed_methods and disallowed_types lints. Having this for functions sounds reasonable. Macros can be a bit iffy but might be worth a try 🙃

If I see this right disallowed_methods already handles functions in general no? Macros seem to be handled since #9495 as well now, what exactly would be left for this issue (I am unsure I understand the remaining points in the main issue text)?

@ojeda
Copy link
Contributor Author

ojeda commented Aug 6, 2023

Indeed, some of this seems to be covered now. I have updated the list above -- we may want to split this into different issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

3 participants