-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add direct-recursion Lint #15006
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?
Add direct-recursion Lint #15006
Conversation
@PLeVasseur WIP. I think the implementation is correct. I'll complete the documentation later, hopefully this weekend ^^ |
Nice! Thanks for taking on the implementation. |
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.
Hey @felix91gr -- thanks for writing this up.
One thing I was unclear on: should this lint also check for recursion that's due to macros or only functions?
tests/ui/direct_recursion.rs
Outdated
fn i_call_myself_in_a_bounded_way(bound: u8) { | ||
if bound > 0 { | ||
// "Author has audited this function and determined that its recursive call is fine." | ||
#[allow(clippy::direct_recursion)] |
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.
Could you change this from an allow
to an expect
? It gives us some future proofing.
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.
If I understood correctly, expect
makes it so Clippy checks that this "allow" is being used, right? So if I, for example, put an expect
line for this lint in a file where this lint isn't being used, Clippy would issue an error because I'm telling it that I expect this lint to be active and it's not.
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 did add it to the documentation, btw! Thanks ❤️ )
Well... since it's a |
d955bfc
to
e06510b
Compare
Sorry for the CI churn. It took me a while to understand why it was failing the |
e06510b
to
30beb95
Compare
rustbot has assigned @samueltardieu. Use |
This comment has been minimized.
This comment has been minimized.
changelog: new lint: [`direct_recursion`]
30beb95
to
1f8f785
Compare
I feel like this should be in the quick CI checks (like the |
Something that I'd like to add in a later PR, is a link to the Safety Critical Coding Guidelines where recursion is addressed. Currently the |
Checklist:
.stderr
file)cargo test
passes locallycargo dev update_lints
cargo dev fmt
changelog: new lint: [
direct_recursion
]Fixes #428
After we're done with this, I'll open a follow-up issue for the indirect recursion lint