fix: handle false negative for str_to_string#16512
fix: handle false negative for str_to_string#16512samueltardieu merged 1 commit intorust-lang:masterfrom
str_to_string#16512Conversation
|
rustbot has assigned @samueltardieu. Use |
|
Lintcheck changes for 691e226
This comment will be updated if you push new changes |
Replace `ToString::to_string` with `ToOwned::to_owned` when the function is passed as is:
```rust
fn issue16511(x: Option<&str>) -> String {
// Replace with ToOwned::to_owned
x.map(ToString::to_string)
}
```
|
Thanks |
|
@samueltardieu thx for a quick review! I wonder if there should be a separate similar lint or a bunch of lints for cases like:
and the likes? |
Fix #16569 bug introduced in #16512 changelog: [`str_to_string`]: fix false positive r? @samueltardieu
|
This "fix" introduced a bunch of new false positives if |
|
@TimDiekmann did #16571 fix your issue? |
|
FYI #16571 is not yet propagated to the compiler repository, and thus not available in Clippy nightly. It should be available later this week. But I can confirm that the playground example now does no longer trigger the lint when using the development version of Clippy. |
Replace
ToString::to_stringwithToOwned::to_ownedwhen it is passed as a function parameter.fixes #16511
changelog: [
str_to_string]: handle a case whenToString::to_stringis passed as function parameter