Commit graph

13 commits

Author SHA1 Message Date
Joel Natividad
e5b6d433fb
fix various comment typos 2024-04-10 08:37:02 -04:00
y21
65defdb474 [unconditional_recursion]: catch From -> Into -> From 2024-03-13 17:22:54 +01:00
Oli Scherer
592fe89997 lower bstr version requirement to 1.6.0 2024-02-27 13:34:01 +00:00
bors
62dcbd672b Auto merge of #12177 - y21:issue12154, r=Jarcho
[`unconditional_recursion`]: compare by `Ty`s instead of `DefId`s

Fixes #12154
Fixes #12181 (this was later edited in, so the rest of the description refers to the first linked issue)

Before this change, the lint would work with `DefId`s and use those to compare types. This PR changes it to compare types directly. It fixes the linked issue, but also other false positives I found in a lintcheck run. For example, one of the issues is that some types don't have `DefId`s (primitives, references, etc., leading to possible FNs), and the helper function used to extract a `DefId` didn't handle type parameters.

Another issue was that the lint would use `.peel_refs()` in a few places where that could lead to false positives (one such FP was in the `http` crate). See the doc comment on one of the added functions and also the test case for what I mean.

The code in the linked issue was linted because the receiver type is `T` (a `ty::Param`), which was not handled in `get_ty_def_id` and returned `None`, so this wouldn't actually *get* to comparing `self_arg != ty_id` here, and skip the early-return:
70573af31e/clippy_lints/src/unconditional_recursion.rs (L171-L178)

This alone could be fixed by doing something like `&& get_ty_def_id(ty).map_or(true, |ty_id)| self_arg != ty_id)`, but we don't really need to work with `DefId`s in the first place, I don't think.

changelog: [`unconditional_recursion`]: avoid linting when the other comparison type is a type parameter
2024-02-07 16:18:33 +00:00
Andrew Banchich
6d76d14565 add to_string_trait_impl lint 2024-01-26 19:28:54 -05:00
y21
87a6300b22 add a test for rust-lang/rust-clippy#12181 2024-01-25 19:43:47 +01:00
y21
42d13f8eb0 [unconditional_recursion]: compare by types instead of DefIds 2024-01-25 19:43:47 +01:00
Guillaume Gomez
132667288a Add regression ui test for unconditional_recursion lint on PartialEq 2024-01-12 17:37:09 +01:00
Guillaume Gomez
bf5c0d8334 Add tests for extension of unconditional_recursion lint on Default trait 2024-01-04 17:40:28 +01:00
Guillaume Gomez
7107aa22b2 Add regression tests for unconditional_recursion 2023-12-31 11:20:49 +01:00
Guillaume Gomez
d161f3b559 Add ui test for UNCONDITIONAL_RECURSION lint on ToString impl 2023-12-30 17:11:56 +01:00
Guillaume Gomez
6b444f3092 Also check code generated by macros 2023-12-16 18:45:24 +01:00
Guillaume Gomez
2c867ce01e Add ui tests for unconditional_recursion lint 2023-12-12 15:37:51 +01:00