-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
When using a Cow type clippy warns about the usage of into_owned but it's suggested alternative doesn't work.
Lint Name
clippy::unnecessary_to_owned
Reproducer
I tried this code:
use std::borrow::Cow;
fn main() {
test_function();
}
fn test_function() -> impl IntoIterator {
let cow: Cow<'_, Vec<String>> = Cow::Owned(vec![String::from("example")]);
// Suggestion which fails to compile
// return cow.iter().cloned();
cow.into_owned().into_iter()
}I saw this happen:
unnecessary use of `into_owned`
for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned
`#[warn(clippy::unnecessary_to_owned)]` on by default
I expected to see this happen:
Either no warning, or a suggestion that works
Version
rustc 1.80.1 (3f5fd8dd4 2024-08-06)
binary: rustc
commit-hash: 3f5fd8dd41153bc5fdca9427e9e05be2c767ba23
commit-date: 2024-08-06
host: x86_64-unknown-linux-gnu
release: 1.80.1
LLVM version: 18.1.7
Additional Labels
No response
aznhe21
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have