]> git.lizzy.rs Git - rust.git/commitdiff
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)
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

1  2 
clippy_lints/src/methods/unnecessary_to_owned.rs