diff options
| author | bors <bors@rust-lang.org> | 2023-12-16 18:21:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-16 18:21:01 +0000 |
| commit | 9907b90b1e014fb910c082612b2627dd375704fe (patch) | |
| tree | eaa6cc997c0cc7fc473d51fe8d266b941469a43e /clippy_lints/src/declared_lints.rs | |
| parent | b91843471717907abe2588cac98608dc23305584 (diff) | |
| parent | 6b444f3092bc9133bbbf67cc989b6dd74a228494 (diff) | |
| download | rust-9907b90b1e014fb910c082612b2627dd375704fe.tar.gz rust-9907b90b1e014fb910c082612b2627dd375704fe.zip | |
Auto merge of #11938 - GuillaumeGomez:unconditional_recursion, r=llogiq
Add new `unconditional_recursion` lint
Currently, rustc `unconditional_recursion` doesn't detect cases like:
```rust
enum Foo {
A,
B,
}
impl PartialEq for Foo {
fn eq(&self, other: &Self) -> bool {
self == other
}
}
```
This is because the lint is currently implemented only for one level, and in the above code, `self == other` will then call `impl PartialEq for &T`, escaping from the detection. The fix for it seems to be a bit tricky (I started investigating potential solution to add one extra level of recursion [here](https://github.com/rust-lang/rust/compare/master...GuillaumeGomez:rust:trait-impl-recursion?expand=1) but completely broken at the moment).
I expect that this situation will remain for a while. In the meantime, I think it's acceptable to check it directly into clippy for the time being as a lot of easy cases like this one can be easily checked (next I plan to extend it to cover other traits like `ToString`).
changelog: Add new `unconditional_recursion` lint
Diffstat (limited to 'clippy_lints/src/declared_lints.rs')
| -rw-r--r-- | clippy_lints/src/declared_lints.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index 1220eb89013..546a100f9a4 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -676,6 +676,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::types::REDUNDANT_ALLOCATION_INFO, crate::types::TYPE_COMPLEXITY_INFO, crate::types::VEC_BOX_INFO, + crate::unconditional_recursion::UNCONDITIONAL_RECURSION_INFO, crate::undocumented_unsafe_blocks::UNDOCUMENTED_UNSAFE_BLOCKS_INFO, crate::undocumented_unsafe_blocks::UNNECESSARY_SAFETY_COMMENT_INFO, crate::unicode::INVISIBLE_CHARACTERS_INFO, |
