]> git.lizzy.rs Git - rust.git/commit
Auto merge of #10027 - smoelius:fix-10021, r=dswij
authorbors <bors@rust-lang.org>
Sun, 4 Dec 2022 01:58:43 +0000 (01:58 +0000)
committerbors <bors@rust-lang.org>
Sun, 4 Dec 2022 01:58:43 +0000 (01:58 +0000)
commitcb8df45333786fc89cd566bbaa71447bb4b105bd
tree129c61f85a65dedda7e80e19e38ba438867a8586
parent4c123a06ba3c2ec17d3a4dfa251dccdc5368b712
parent2701a4076f3d18edc06781d7a9b3091ee5dbd05f
Auto merge of #10027 - smoelius:fix-10021, r=dswij

Fix 10021

This PR proposes a fix for #10021.

The problem is similar to the one that `@mikerite` described in #9505. The compiler is generating an empty substitution for a call, even though the type of `Self` seems to be needed for a predicate. In `@mikerite's` case, the call was to [`IntoFuture::into_future`](https://doc.rust-lang.org/std/future/trait.IntoFuture.html#tymethod.into_future). In this case, the call is to [`Try::branch`](https://doc.rust-lang.org/std/ops/trait.Try.html#tymethod.branch).

The proposed fix is to verify that the parameter whose type is changing has an index within the substitution. The strikes me as a reasonable approach, since if the check were to fail, the following code would be a no-op:

https://github.com/rust-lang/rust-clippy/blob/4c123a06ba3c2ec17d3a4dfa251dccdc5368b712/clippy_lints/src/methods/unnecessary_to_owned.rs#L420-L428

Like `@mikerite's` original solution, this solution turns ICEs into false negatives.

changelog: fix `unnecessary_to_owned` false positive involving `Try::branch`