mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 04:55:22 +03:00
2d6c2386f5
Add .as_ref() to suggestion to remove .to_string() The case of `.to_owned().split(…)` is treated specially in the `unnecessary_to_owned` lint. Test cases check that it works both for slices and for strings, but they missed a corner case: `x.to_string().split(…)` when `x` implements `AsRef<str>` but not `Deref<Target = str>`. In this case, it is wrong to suggest to remove `.to_string()` without adding `.as_ref()` instead. Fix #12068 changelog: [`unnecessary_to_owned`]: suggest replacing `.to_string()` by `.as_ref()`