]> git.lizzy.rs Git - rust.git/commit
Auto merge of #9796 - smoelius:issue-9771, r=flip1995
authorbors <bors@rust-lang.org>
Tue, 22 Nov 2022 12:50:08 +0000 (12:50 +0000)
committerbors <bors@rust-lang.org>
Tue, 22 Nov 2022 12:50:08 +0000 (12:50 +0000)
commit94ce4465e5746bd3ef4d60a16c5aba1e8f0a5b80
treec71a5ff5c3e69a917578753ef305f09574decdcf
parentf4083c5ae72f5f80bf19e881528c4d39b38db0e7
parentf27ca5c00a96d2dbd1e2b5dceee918d829891bc1
Auto merge of #9796 - smoelius:issue-9771, r=flip1995

Fix #9771 (`unnecessary_to_owned` false positive)

Fixes #9771

In that issue's example(s), the lint tried to add a `&` to a value, which implicitly changed the type of a field to a reference. The fix is to add the reference to `receiver_ty` (the type of the receiver of the `to_owned`-like method), before passing `receiver_ty` to `can_change_type`. `can_change_type` properly rejects the modified `receiver_ty`.

cc: `@mikerite` just because I think he was the author of `can_change_type`.

changelog: fix `unnecessary_to_owned` false positive which implicitly tried to change the type of a field to a reference
clippy_lints/src/methods/unnecessary_to_owned.rs