-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
redundant_clone: false positive using ToOwned #6729
Comments
The problem is that your function takes a value instead of a reference. But it would be better if |
In fact, it really should be |
@camsteffen - I had similar issue and if I change function to take a reference it would still cause complains from clippy. |
9 pub fn new<P: AsRef<Path> + ToOwned<Owned = PathBuf>>(root_path: &P) -> Self {
8 Configuration {
7 #[allow(clippy::redundant_clone)]
6 root_path: root_path.to_owned(),
5 stream_read_ahead: 10,
4 stream_buffer_size: CHUNK_BYTES_SIZE,
3 }
2 } |
@humb1t I wasn't able to reproduce your issue (playground) Perhaps it's been fixed. Can you provide a complete example? |
@pitaj looks like it was fixed. Thank you! |
Just noticed that the original example still triggers the lint. |
Lint still triggers on current rust playground (1.70), another short example: fn example<T: ToOwned<Owned = String>>(v: T) -> String {
v.to_owned()
} |
The following code :
generates the following lint:
However, removing the
.to_owned
leads to a compilation error since the return types are different.May be related to #5700
Meta
cargo clippy -V
: clippy 0.1.52 (e9920ef 2021-02-11)rustc -Vv
:The text was updated successfully, but these errors were encountered: