about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTimo <30553356+y21@users.noreply.github.com>2025-02-20 14:53:45 +0000
committerGitHub <noreply@github.com>2025-02-20 14:53:45 +0000
commitbbf65f008d92fbbdeae21dd8d5f886b4c0bc526b (patch)
tree78d34def5fa3633bbb434862834201bf5061e858
parent7c889ac4495aff7f04521ecee61074d6745ccdd1 (diff)
parent83f5cbad188a905ec5793002b36e5d27a7a20890 (diff)
downloadrust-bbf65f008d92fbbdeae21dd8d5f886b4c0bc526b.tar.gz
rust-bbf65f008d92fbbdeae21dd8d5f886b4c0bc526b.zip
add `owned_cow` lint (#13948)
Closes #13697.

---

changelog: add [`owned_cow`] lint
-rw-r--r--CHANGELOG.md1
-rw-r--r--book/src/lint_configuration.md1
-rw-r--r--clippy_config/src/conf.rs1
-rw-r--r--clippy_lints/src/declared_lints.rs1
-rw-r--r--clippy_lints/src/types/mod.rs62
-rw-r--r--clippy_lints/src/types/owned_cow.rs66
-rw-r--r--tests/ui/owned_cow.fixed23
-rw-r--r--tests/ui/owned_cow.rs23
-rw-r--r--tests/ui/owned_cow.stderr41
-rw-r--r--tests/ui/unnecessary_to_owned.fixed3
-rw-r--r--tests/ui/unnecessary_to_owned.rs3
-rw-r--r--tests/ui/unnecessary_to_owned.stderr186
12 files changed, 315 insertions, 96 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f25c5b061f4..04a7eebb359 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5984,6 +5984,7 @@ Released 2018-09-13
 [`out_of_bounds_indexing`]: https://rust-lang.github.io/rust-clippy/master/index.html#out_of_bounds_indexing
 [`overflow_check_conditional`]: https://rust-lang.github.io/rust-clippy/master/index.html#overflow_check_conditional
 [`overly_complex_bool_expr`]: https://rust-lang.github.io/rust-clippy/master/index.html#overly_complex_bool_expr
+[`owned_cow`]: https://rust-lang.github.io/rust-clippy/master/index.html#owned_cow
 [`panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic
 [`panic_in_result_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_in_result_fn
 [`panic_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_params
diff --git a/book/src/lint_configuration.md b/book/src/lint_configuration.md
index 0e264cdcd4a..1fb59ca85fe 100644
--- a/book/src/lint_configuration.md
+++ b/book/src/lint_configuration.md
@@ -380,6 +380,7 @@ Suppress lints whenever the suggested change would cause breakage for other crat
 * [`linkedlist`](https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist)
 * [`needless_pass_by_ref_mut`](https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut)
 * [`option_option`](https://rust-lang.github.io/rust-clippy/master/index.html#option_option)
+* [`owned_cow`](https://rust-lang.github.io/rust-clippy/master/index.html#owned_cow)
 * [`rc_buffer`](https://rust-lang.github.io/rust-clippy/master/index.html#rc_buffer)
 * [`rc_mutex`](https://rust-lang.github.io/rust-clippy/master/index.html#rc_mutex)
 * [`redundant_allocation`](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_allocation)
diff --git a/clippy_config/src/conf.rs b/clippy_config/src/conf.rs
index cac4408fff0..9436ba7f180 100644
--- a/clippy_config/src/conf.rs
+++ b/clippy_config/src/conf.rs
@@ -438,6 +438,7 @@ define_Conf! {
         linkedlist,
         needless_pass_by_ref_mut,
         option_option,
+        owned_cow,
         rc_buffer,
         rc_mutex,
         redundant_allocation,
diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs
index 4b439d3a7a2..011eed25552 100644
--- a/clippy_lints/src/declared_lints.rs
+++ b/clippy_lints/src/declared_lints.rs
@@ -745,6 +745,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
     crate::types::BOX_COLLECTION_INFO,
     crate::types::LINKEDLIST_INFO,
     crate::types::OPTION_OPTION_INFO,
+    crate::types::OWNED_COW_INFO,
     crate::types::RC_BUFFER_INFO,
     crate::types::RC_MUTEX_INFO,
     crate::types::REDUNDANT_ALLOCATION_INFO,
diff --git a/clippy_lints/src/types/mod.rs b/clippy_lints/src/types/mod.rs
index 579cbf447a2..7385b13578d 100644
--- a/clippy_lints/src/types/mod.rs
+++ b/clippy_lints/src/types/mod.rs
@@ -2,6 +2,7 @@ mod borrowed_box;
 mod box_collection;
 mod linked_list;
 mod option_option;
+mod owned_cow;
 mod rc_buffer;
 mod rc_mutex;
 mod redundant_allocation;
@@ -355,13 +356,63 @@ declare_clippy_lint! {
     "usage of `Rc<Mutex<T>>`"
 }
 
+declare_clippy_lint! {
+    /// ### What it does
+    /// Detects needlessly owned `Cow` types.
+    ///
+    /// ### Why is this bad?
+    /// The borrowed types are usually more flexible, in that e.g. a
+    /// `Cow<'_, str>` can accept both `&str` and `String` while
+    /// `Cow<'_, String>` can only accept `&String` and `String`. In
+    /// particular, `&str` is more general, because it allows for string
+    /// literals while `&String` can only be borrowed from a heap-owned
+    /// `String`).
+    ///
+    /// ### Known Problems
+    /// The lint does not check for usage of the type. There may be external
+    /// interfaces that require the use of an owned type.
+    ///
+    /// At least the `CString` type also has a different API than `CStr`: The
+    /// former has an `as_bytes` method which the latter calls `to_bytes`.
+    /// There is no guarantee that other types won't gain additional methods
+    /// leading to a similar mismatch.
+    ///
+    /// In addition, the lint only checks for the known problematic types
+    /// `String`, `Vec<_>`, `CString`, `OsString` and `PathBuf`. Custom types
+    /// that implement `ToOwned` will not be detected.
+    ///
+    /// ### Example
+    /// ```no_run
+    /// let wrogn: std::borrow::Cow<'_, Vec<u8>>;
+    /// ```
+    /// Use instead:
+    /// ```no_run
+    /// let right: std::borrow::Cow<'_, [u8]>;
+    /// ```
+    #[clippy::version = "1.85.0"]
+    pub OWNED_COW,
+    style,
+    "needlessly owned Cow type"
+}
+
 pub struct Types {
     vec_box_size_threshold: u64,
     type_complexity_threshold: u64,
     avoid_breaking_exported_api: bool,
 }
 
-impl_lint_pass!(Types => [BOX_COLLECTION, VEC_BOX, OPTION_OPTION, LINKEDLIST, BORROWED_BOX, REDUNDANT_ALLOCATION, RC_BUFFER, RC_MUTEX, TYPE_COMPLEXITY]);
+impl_lint_pass!(Types => [
+    BOX_COLLECTION,
+    VEC_BOX,
+    OPTION_OPTION,
+    LINKEDLIST,
+    BORROWED_BOX,
+    REDUNDANT_ALLOCATION,
+    RC_BUFFER,
+    RC_MUTEX,
+    TYPE_COMPLEXITY,
+    OWNED_COW
+]);
 
 impl<'tcx> LateLintPass<'tcx> for Types {
     fn check_fn(
@@ -561,6 +612,7 @@ impl Types {
                         triggered |= option_option::check(cx, hir_ty, qpath, def_id);
                         triggered |= linked_list::check(cx, hir_ty, def_id);
                         triggered |= rc_mutex::check(cx, hir_ty, qpath, def_id);
+                        triggered |= owned_cow::check(cx, qpath, def_id);
 
                         if triggered {
                             return;
@@ -612,6 +664,14 @@ impl Types {
                     QPath::LangItem(..) => {},
                 }
             },
+            TyKind::Path(ref qpath) => {
+                let res = cx.qpath_res(qpath, hir_ty.hir_id);
+                if let Some(def_id) = res.opt_def_id()
+                    && self.is_type_change_allowed(context)
+                {
+                    owned_cow::check(cx, qpath, def_id);
+                }
+            },
             TyKind::Ref(lt, ref mut_ty) => {
                 context.is_nested_call = true;
                 if !borrowed_box::check(cx, hir_ty, lt, mut_ty) {
diff --git a/clippy_lints/src/types/owned_cow.rs b/clippy_lints/src/types/owned_cow.rs
new file mode 100644
index 00000000000..8933994d185
--- /dev/null
+++ b/clippy_lints/src/types/owned_cow.rs
@@ -0,0 +1,66 @@
+use clippy_utils::diagnostics::span_lint_and_sugg;
+use clippy_utils::source::snippet_opt;
+use rustc_errors::Applicability;
+use rustc_hir::def_id::DefId;
+use rustc_hir::{self as hir};
+use rustc_lint::LateContext;
+use rustc_span::{Span, sym};
+
+pub(super) fn check(cx: &LateContext<'_>, qpath: &hir::QPath<'_>, def_id: DefId) -> bool {
+    if cx.tcx.is_diagnostic_item(sym::Cow, def_id)
+        && let hir::QPath::Resolved(_, path) = qpath
+        && let [.., last_seg] = path.segments
+        && let Some(args) = last_seg.args
+        && let [_lt, carg] = args.args
+        && let hir::GenericArg::Type(cty) = carg
+        && let Some((span, repl)) = replacement(cx, cty.as_unambig_ty())
+    {
+        span_lint_and_sugg(
+            cx,
+            super::OWNED_COW,
+            span,
+            "needlessly owned Cow type",
+            "use",
+            repl,
+            Applicability::Unspecified,
+        );
+        return true;
+    }
+    false
+}
+
+fn replacement(cx: &LateContext<'_>, cty: &hir::Ty<'_>) -> Option<(Span, String)> {
+    if clippy_utils::is_path_lang_item(cx, cty, hir::LangItem::String) {
+        return Some((cty.span, "str".into()));
+    }
+    if clippy_utils::is_path_diagnostic_item(cx, cty, sym::Vec) {
+        return if let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = cty.kind
+            && let [.., last_seg] = path.segments
+            && let Some(args) = last_seg.args
+            && let [t, ..] = args.args
+            && let Some(snip) = snippet_opt(cx, t.span())
+        {
+            Some((cty.span, format!("[{snip}]")))
+        } else {
+            None
+        };
+    }
+    if clippy_utils::is_path_diagnostic_item(cx, cty, sym::cstring_type) {
+        return Some((
+            cty.span,
+            (if clippy_utils::is_no_std_crate(cx) {
+                "core::ffi::CStr"
+            } else {
+                "std::ffi::CStr"
+            })
+            .into(),
+        ));
+    }
+    // Neither OsString nor PathBuf are available outside std
+    for (diag, repl) in [(sym::OsString, "std::ffi::OsStr"), (sym::PathBuf, "std::path::Path")] {
+        if clippy_utils::is_path_diagnostic_item(cx, cty, diag) {
+            return Some((cty.span, repl.into()));
+        }
+    }
+    None
+}
diff --git a/tests/ui/owned_cow.fixed b/tests/ui/owned_cow.fixed
new file mode 100644
index 00000000000..b62e9107a56
--- /dev/null
+++ b/tests/ui/owned_cow.fixed
@@ -0,0 +1,23 @@
+#![warn(clippy::owned_cow)]
+
+use std::borrow::Cow;
+use std::ffi::{CString, OsString};
+use std::path::PathBuf;
+
+fn main() {
+    let x: Cow<'static, str> = Cow::Owned(String::from("Hi!"));
+    //~^ ERROR: needlessly owned Cow type
+    let y: Cow<'_, [u8]> = Cow::Owned(vec![]);
+    //~^ ERROR: needlessly owned Cow type
+    let z: Cow<'_, [_]> = Cow::Owned(vec![2_i32]);
+    //~^ ERROR: needlessly owned Cow type
+    let o: Cow<'_, std::ffi::OsStr> = Cow::Owned(OsString::new());
+    //~^ ERROR: needlessly owned Cow type
+    let c: Cow<'_, std::ffi::CStr> = Cow::Owned(CString::new("").unwrap());
+    //~^ ERROR: needlessly owned Cow type
+    let p: Cow<'_, std::path::Path> = Cow::Owned(PathBuf::new());
+    //~^ ERROR: needlessly owned Cow type
+
+    // false positive: borrowed type
+    let b: Cow<'_, str> = Cow::Borrowed("Hi!");
+}
diff --git a/tests/ui/owned_cow.rs b/tests/ui/owned_cow.rs
new file mode 100644
index 00000000000..0e0f14711b7
--- /dev/null
+++ b/tests/ui/owned_cow.rs
@@ -0,0 +1,23 @@
+#![warn(clippy::owned_cow)]
+
+use std::borrow::Cow;
+use std::ffi::{CString, OsString};
+use std::path::PathBuf;
+
+fn main() {
+    let x: Cow<'static, String> = Cow::Owned(String::from("Hi!"));
+    //~^ ERROR: needlessly owned Cow type
+    let y: Cow<'_, Vec<u8>> = Cow::Owned(vec![]);
+    //~^ ERROR: needlessly owned Cow type
+    let z: Cow<'_, Vec<_>> = Cow::Owned(vec![2_i32]);
+    //~^ ERROR: needlessly owned Cow type
+    let o: Cow<'_, OsString> = Cow::Owned(OsString::new());
+    //~^ ERROR: needlessly owned Cow type
+    let c: Cow<'_, CString> = Cow::Owned(CString::new("").unwrap());
+    //~^ ERROR: needlessly owned Cow type
+    let p: Cow<'_, PathBuf> = Cow::Owned(PathBuf::new());
+    //~^ ERROR: needlessly owned Cow type
+
+    // false positive: borrowed type
+    let b: Cow<'_, str> = Cow::Borrowed("Hi!");
+}
diff --git a/tests/ui/owned_cow.stderr b/tests/ui/owned_cow.stderr
new file mode 100644
index 00000000000..8985d6db623
--- /dev/null
+++ b/tests/ui/owned_cow.stderr
@@ -0,0 +1,41 @@
+error: needlessly owned Cow type
+  --> tests/ui/owned_cow.rs:8:25
+   |
+LL |     let x: Cow<'static, String> = Cow::Owned(String::from("Hi!"));
+   |                         ^^^^^^ help: use: `str`
+   |
+   = note: `-D clippy::owned-cow` implied by `-D warnings`
+   = help: to override `-D warnings` add `#[allow(clippy::owned_cow)]`
+
+error: needlessly owned Cow type
+  --> tests/ui/owned_cow.rs:10:20
+   |
+LL |     let y: Cow<'_, Vec<u8>> = Cow::Owned(vec![]);
+   |                    ^^^^^^^ help: use: `[u8]`
+
+error: needlessly owned Cow type
+  --> tests/ui/owned_cow.rs:12:20
+   |
+LL |     let z: Cow<'_, Vec<_>> = Cow::Owned(vec![2_i32]);
+   |                    ^^^^^^ help: use: `[_]`
+
+error: needlessly owned Cow type
+  --> tests/ui/owned_cow.rs:14:20
+   |
+LL |     let o: Cow<'_, OsString> = Cow::Owned(OsString::new());
+   |                    ^^^^^^^^ help: use: `std::ffi::OsStr`
+
+error: needlessly owned Cow type
+  --> tests/ui/owned_cow.rs:16:20
+   |
+LL |     let c: Cow<'_, CString> = Cow::Owned(CString::new("").unwrap());
+   |                    ^^^^^^^ help: use: `std::ffi::CStr`
+
+error: needlessly owned Cow type
+  --> tests/ui/owned_cow.rs:18:20
+   |
+LL |     let p: Cow<'_, PathBuf> = Cow::Owned(PathBuf::new());
+   |                    ^^^^^^^ help: use: `std::path::Path`
+
+error: aborting due to 6 previous errors
+
diff --git a/tests/ui/unnecessary_to_owned.fixed b/tests/ui/unnecessary_to_owned.fixed
index 136dafda27e..bf271aef763 100644
--- a/tests/ui/unnecessary_to_owned.fixed
+++ b/tests/ui/unnecessary_to_owned.fixed
@@ -3,7 +3,8 @@
     clippy::needless_borrows_for_generic_args,
     clippy::ptr_arg,
     clippy::manual_async_fn,
-    clippy::needless_lifetimes
+    clippy::needless_lifetimes,
+    clippy::owned_cow
 )]
 #![warn(clippy::unnecessary_to_owned, clippy::redundant_clone)]
 
diff --git a/tests/ui/unnecessary_to_owned.rs b/tests/ui/unnecessary_to_owned.rs
index 0948ac5de3e..95b95ab6bd2 100644
--- a/tests/ui/unnecessary_to_owned.rs
+++ b/tests/ui/unnecessary_to_owned.rs
@@ -3,7 +3,8 @@
     clippy::needless_borrows_for_generic_args,
     clippy::ptr_arg,
     clippy::manual_async_fn,
-    clippy::needless_lifetimes
+    clippy::needless_lifetimes,
+    clippy::owned_cow
 )]
 #![warn(clippy::unnecessary_to_owned, clippy::redundant_clone)]
 
diff --git a/tests/ui/unnecessary_to_owned.stderr b/tests/ui/unnecessary_to_owned.stderr
index f8ad85dbed0..4daa3876e60 100644
--- a/tests/ui/unnecessary_to_owned.stderr
+++ b/tests/ui/unnecessary_to_owned.stderr
@@ -1,11 +1,11 @@
 error: redundant clone
-  --> tests/ui/unnecessary_to_owned.rs:224:64
+  --> tests/ui/unnecessary_to_owned.rs:225:64
    |
 LL |     require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned());
    |                                                                ^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> tests/ui/unnecessary_to_owned.rs:224:20
+  --> tests/ui/unnecessary_to_owned.rs:225:20
    |
 LL |     require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned());
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -13,55 +13,55 @@ LL |     require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned())
    = help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]`
 
 error: redundant clone
-  --> tests/ui/unnecessary_to_owned.rs:226:40
+  --> tests/ui/unnecessary_to_owned.rs:227:40
    |
 LL |     require_os_str(&OsString::from("x").to_os_string());
    |                                        ^^^^^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> tests/ui/unnecessary_to_owned.rs:226:21
+  --> tests/ui/unnecessary_to_owned.rs:227:21
    |
 LL |     require_os_str(&OsString::from("x").to_os_string());
    |                     ^^^^^^^^^^^^^^^^^^^
 
 error: redundant clone
-  --> tests/ui/unnecessary_to_owned.rs:228:48
+  --> tests/ui/unnecessary_to_owned.rs:229:48
    |
 LL |     require_path(&std::path::PathBuf::from("x").to_path_buf());
    |                                                ^^^^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> tests/ui/unnecessary_to_owned.rs:228:19
+  --> tests/ui/unnecessary_to_owned.rs:229:19
    |
 LL |     require_path(&std::path::PathBuf::from("x").to_path_buf());
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: redundant clone
-  --> tests/ui/unnecessary_to_owned.rs:230:35
+  --> tests/ui/unnecessary_to_owned.rs:231:35
    |
 LL |     require_str(&String::from("x").to_string());
    |                                   ^^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> tests/ui/unnecessary_to_owned.rs:230:18
+  --> tests/ui/unnecessary_to_owned.rs:231:18
    |
 LL |     require_str(&String::from("x").to_string());
    |                  ^^^^^^^^^^^^^^^^^
 
 error: redundant clone
-  --> tests/ui/unnecessary_to_owned.rs:232:39
+  --> tests/ui/unnecessary_to_owned.rs:233:39
    |
 LL |     require_slice(&[String::from("x")].to_owned());
    |                                       ^^^^^^^^^^^ help: remove this
    |
 note: this value is dropped without further use
-  --> tests/ui/unnecessary_to_owned.rs:232:20
+  --> tests/ui/unnecessary_to_owned.rs:233:20
    |
 LL |     require_slice(&[String::from("x")].to_owned());
    |                    ^^^^^^^^^^^^^^^^^^^
 
 error: unnecessary use of `into_owned`
-  --> tests/ui/unnecessary_to_owned.rs:64:36
+  --> tests/ui/unnecessary_to_owned.rs:65:36
    |
 LL |     require_c_str(&Cow::from(c_str).into_owned());
    |                                    ^^^^^^^^^^^^^ help: remove this
@@ -70,415 +70,415 @@ LL |     require_c_str(&Cow::from(c_str).into_owned());
    = help: to override `-D warnings` add `#[allow(clippy::unnecessary_to_owned)]`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:66:19
+  --> tests/ui/unnecessary_to_owned.rs:67:19
    |
 LL |     require_c_str(&c_str.to_owned());
    |                   ^^^^^^^^^^^^^^^^^ help: use: `c_str`
 
 error: unnecessary use of `to_os_string`
-  --> tests/ui/unnecessary_to_owned.rs:69:20
+  --> tests/ui/unnecessary_to_owned.rs:70:20
    |
 LL |     require_os_str(&os_str.to_os_string());
    |                    ^^^^^^^^^^^^^^^^^^^^^^ help: use: `os_str`
 
 error: unnecessary use of `into_owned`
-  --> tests/ui/unnecessary_to_owned.rs:71:38
+  --> tests/ui/unnecessary_to_owned.rs:72:38
    |
 LL |     require_os_str(&Cow::from(os_str).into_owned());
    |                                      ^^^^^^^^^^^^^ help: remove this
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:73:20
+  --> tests/ui/unnecessary_to_owned.rs:74:20
    |
 LL |     require_os_str(&os_str.to_owned());
    |                    ^^^^^^^^^^^^^^^^^^ help: use: `os_str`
 
 error: unnecessary use of `to_path_buf`
-  --> tests/ui/unnecessary_to_owned.rs:76:18
+  --> tests/ui/unnecessary_to_owned.rs:77:18
    |
 LL |     require_path(&path.to_path_buf());
    |                  ^^^^^^^^^^^^^^^^^^^ help: use: `path`
 
 error: unnecessary use of `into_owned`
-  --> tests/ui/unnecessary_to_owned.rs:78:34
+  --> tests/ui/unnecessary_to_owned.rs:79:34
    |
 LL |     require_path(&Cow::from(path).into_owned());
    |                                  ^^^^^^^^^^^^^ help: remove this
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:80:18
+  --> tests/ui/unnecessary_to_owned.rs:81:18
    |
 LL |     require_path(&path.to_owned());
    |                  ^^^^^^^^^^^^^^^^ help: use: `path`
 
 error: unnecessary use of `to_string`
-  --> tests/ui/unnecessary_to_owned.rs:83:17
+  --> tests/ui/unnecessary_to_owned.rs:84:17
    |
 LL |     require_str(&s.to_string());
    |                 ^^^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `into_owned`
-  --> tests/ui/unnecessary_to_owned.rs:85:30
+  --> tests/ui/unnecessary_to_owned.rs:86:30
    |
 LL |     require_str(&Cow::from(s).into_owned());
    |                              ^^^^^^^^^^^^^ help: remove this
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:87:17
+  --> tests/ui/unnecessary_to_owned.rs:88:17
    |
 LL |     require_str(&s.to_owned());
    |                 ^^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_string`
-  --> tests/ui/unnecessary_to_owned.rs:89:17
+  --> tests/ui/unnecessary_to_owned.rs:90:17
    |
 LL |     require_str(&x_ref.to_string());
    |                 ^^^^^^^^^^^^^^^^^^ help: use: `x_ref.as_ref()`
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:92:19
+  --> tests/ui/unnecessary_to_owned.rs:93:19
    |
 LL |     require_slice(&slice.to_vec());
    |                   ^^^^^^^^^^^^^^^ help: use: `slice`
 
 error: unnecessary use of `into_owned`
-  --> tests/ui/unnecessary_to_owned.rs:94:36
+  --> tests/ui/unnecessary_to_owned.rs:95:36
    |
 LL |     require_slice(&Cow::from(slice).into_owned());
    |                                    ^^^^^^^^^^^^^ help: remove this
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:96:19
+  --> tests/ui/unnecessary_to_owned.rs:97:19
    |
 LL |     require_slice(&array.to_owned());
    |                   ^^^^^^^^^^^^^^^^^ help: use: `array.as_ref()`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:98:19
+  --> tests/ui/unnecessary_to_owned.rs:99:19
    |
 LL |     require_slice(&array_ref.to_owned());
    |                   ^^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref.as_ref()`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:100:19
+  --> tests/ui/unnecessary_to_owned.rs:101:19
    |
 LL |     require_slice(&slice.to_owned());
    |                   ^^^^^^^^^^^^^^^^^ help: use: `slice`
 
 error: unnecessary use of `into_owned`
-  --> tests/ui/unnecessary_to_owned.rs:104:42
+  --> tests/ui/unnecessary_to_owned.rs:105:42
    |
 LL |     require_x(&Cow::<X>::Owned(x.clone()).into_owned());
    |                                          ^^^^^^^^^^^^^ help: remove this
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:108:25
+  --> tests/ui/unnecessary_to_owned.rs:109:25
    |
 LL |     require_deref_c_str(c_str.to_owned());
    |                         ^^^^^^^^^^^^^^^^ help: use: `c_str`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:110:26
+  --> tests/ui/unnecessary_to_owned.rs:111:26
    |
 LL |     require_deref_os_str(os_str.to_owned());
    |                          ^^^^^^^^^^^^^^^^^ help: use: `os_str`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:112:24
+  --> tests/ui/unnecessary_to_owned.rs:113:24
    |
 LL |     require_deref_path(path.to_owned());
    |                        ^^^^^^^^^^^^^^^ help: use: `path`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:114:23
+  --> tests/ui/unnecessary_to_owned.rs:115:23
    |
 LL |     require_deref_str(s.to_owned());
    |                       ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:116:25
+  --> tests/ui/unnecessary_to_owned.rs:117:25
    |
 LL |     require_deref_slice(slice.to_owned());
    |                         ^^^^^^^^^^^^^^^^ help: use: `slice`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:119:30
+  --> tests/ui/unnecessary_to_owned.rs:120:30
    |
 LL |     require_impl_deref_c_str(c_str.to_owned());
    |                              ^^^^^^^^^^^^^^^^ help: use: `c_str`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:121:31
+  --> tests/ui/unnecessary_to_owned.rs:122:31
    |
 LL |     require_impl_deref_os_str(os_str.to_owned());
    |                               ^^^^^^^^^^^^^^^^^ help: use: `os_str`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:123:29
+  --> tests/ui/unnecessary_to_owned.rs:124:29
    |
 LL |     require_impl_deref_path(path.to_owned());
    |                             ^^^^^^^^^^^^^^^ help: use: `path`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:125:28
+  --> tests/ui/unnecessary_to_owned.rs:126:28
    |
 LL |     require_impl_deref_str(s.to_owned());
    |                            ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:127:30
+  --> tests/ui/unnecessary_to_owned.rs:128:30
    |
 LL |     require_impl_deref_slice(slice.to_owned());
    |                              ^^^^^^^^^^^^^^^^ help: use: `slice`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:130:29
+  --> tests/ui/unnecessary_to_owned.rs:131:29
    |
 LL |     require_deref_str_slice(s.to_owned(), slice.to_owned());
    |                             ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:130:43
+  --> tests/ui/unnecessary_to_owned.rs:131:43
    |
 LL |     require_deref_str_slice(s.to_owned(), slice.to_owned());
    |                                           ^^^^^^^^^^^^^^^^ help: use: `slice`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:133:29
+  --> tests/ui/unnecessary_to_owned.rs:134:29
    |
 LL |     require_deref_slice_str(slice.to_owned(), s.to_owned());
    |                             ^^^^^^^^^^^^^^^^ help: use: `slice`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:133:47
+  --> tests/ui/unnecessary_to_owned.rs:134:47
    |
 LL |     require_deref_slice_str(slice.to_owned(), s.to_owned());
    |                                               ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:137:26
+  --> tests/ui/unnecessary_to_owned.rs:138:26
    |
 LL |     require_as_ref_c_str(c_str.to_owned());
    |                          ^^^^^^^^^^^^^^^^ help: use: `c_str`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:139:27
+  --> tests/ui/unnecessary_to_owned.rs:140:27
    |
 LL |     require_as_ref_os_str(os_str.to_owned());
    |                           ^^^^^^^^^^^^^^^^^ help: use: `os_str`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:141:25
+  --> tests/ui/unnecessary_to_owned.rs:142:25
    |
 LL |     require_as_ref_path(path.to_owned());
    |                         ^^^^^^^^^^^^^^^ help: use: `path`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:143:24
+  --> tests/ui/unnecessary_to_owned.rs:144:24
    |
 LL |     require_as_ref_str(s.to_owned());
    |                        ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:145:24
+  --> tests/ui/unnecessary_to_owned.rs:146:24
    |
 LL |     require_as_ref_str(x.to_owned());
    |                        ^^^^^^^^^^^^ help: use: `&x`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:147:26
+  --> tests/ui/unnecessary_to_owned.rs:148:26
    |
 LL |     require_as_ref_slice(array.to_owned());
    |                          ^^^^^^^^^^^^^^^^ help: use: `array`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:149:26
+  --> tests/ui/unnecessary_to_owned.rs:150:26
    |
 LL |     require_as_ref_slice(array_ref.to_owned());
    |                          ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:151:26
+  --> tests/ui/unnecessary_to_owned.rs:152:26
    |
 LL |     require_as_ref_slice(slice.to_owned());
    |                          ^^^^^^^^^^^^^^^^ help: use: `slice`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:154:31
+  --> tests/ui/unnecessary_to_owned.rs:155:31
    |
 LL |     require_impl_as_ref_c_str(c_str.to_owned());
    |                               ^^^^^^^^^^^^^^^^ help: use: `c_str`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:156:32
+  --> tests/ui/unnecessary_to_owned.rs:157:32
    |
 LL |     require_impl_as_ref_os_str(os_str.to_owned());
    |                                ^^^^^^^^^^^^^^^^^ help: use: `os_str`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:158:30
+  --> tests/ui/unnecessary_to_owned.rs:159:30
    |
 LL |     require_impl_as_ref_path(path.to_owned());
    |                              ^^^^^^^^^^^^^^^ help: use: `path`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:160:29
+  --> tests/ui/unnecessary_to_owned.rs:161:29
    |
 LL |     require_impl_as_ref_str(s.to_owned());
    |                             ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:162:29
+  --> tests/ui/unnecessary_to_owned.rs:163:29
    |
 LL |     require_impl_as_ref_str(x.to_owned());
    |                             ^^^^^^^^^^^^ help: use: `&x`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:164:31
+  --> tests/ui/unnecessary_to_owned.rs:165:31
    |
 LL |     require_impl_as_ref_slice(array.to_owned());
    |                               ^^^^^^^^^^^^^^^^ help: use: `array`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:166:31
+  --> tests/ui/unnecessary_to_owned.rs:167:31
    |
 LL |     require_impl_as_ref_slice(array_ref.to_owned());
    |                               ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:168:31
+  --> tests/ui/unnecessary_to_owned.rs:169:31
    |
 LL |     require_impl_as_ref_slice(slice.to_owned());
    |                               ^^^^^^^^^^^^^^^^ help: use: `slice`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:171:30
+  --> tests/ui/unnecessary_to_owned.rs:172:30
    |
 LL |     require_as_ref_str_slice(s.to_owned(), array.to_owned());
    |                              ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:171:44
+  --> tests/ui/unnecessary_to_owned.rs:172:44
    |
 LL |     require_as_ref_str_slice(s.to_owned(), array.to_owned());
    |                                            ^^^^^^^^^^^^^^^^ help: use: `array`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:174:30
+  --> tests/ui/unnecessary_to_owned.rs:175:30
    |
 LL |     require_as_ref_str_slice(s.to_owned(), array_ref.to_owned());
    |                              ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:174:44
+  --> tests/ui/unnecessary_to_owned.rs:175:44
    |
 LL |     require_as_ref_str_slice(s.to_owned(), array_ref.to_owned());
    |                                            ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:177:30
+  --> tests/ui/unnecessary_to_owned.rs:178:30
    |
 LL |     require_as_ref_str_slice(s.to_owned(), slice.to_owned());
    |                              ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:177:44
+  --> tests/ui/unnecessary_to_owned.rs:178:44
    |
 LL |     require_as_ref_str_slice(s.to_owned(), slice.to_owned());
    |                                            ^^^^^^^^^^^^^^^^ help: use: `slice`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:180:30
+  --> tests/ui/unnecessary_to_owned.rs:181:30
    |
 LL |     require_as_ref_slice_str(array.to_owned(), s.to_owned());
    |                              ^^^^^^^^^^^^^^^^ help: use: `array`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:180:48
+  --> tests/ui/unnecessary_to_owned.rs:181:48
    |
 LL |     require_as_ref_slice_str(array.to_owned(), s.to_owned());
    |                                                ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:183:30
+  --> tests/ui/unnecessary_to_owned.rs:184:30
    |
 LL |     require_as_ref_slice_str(array_ref.to_owned(), s.to_owned());
    |                              ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:183:52
+  --> tests/ui/unnecessary_to_owned.rs:184:52
    |
 LL |     require_as_ref_slice_str(array_ref.to_owned(), s.to_owned());
    |                                                    ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:186:30
+  --> tests/ui/unnecessary_to_owned.rs:187:30
    |
 LL |     require_as_ref_slice_str(slice.to_owned(), s.to_owned());
    |                              ^^^^^^^^^^^^^^^^ help: use: `slice`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:186:48
+  --> tests/ui/unnecessary_to_owned.rs:187:48
    |
 LL |     require_as_ref_slice_str(slice.to_owned(), s.to_owned());
    |                                                ^^^^^^^^^^^^ help: use: `s`
 
 error: unnecessary use of `to_string`
-  --> tests/ui/unnecessary_to_owned.rs:190:20
+  --> tests/ui/unnecessary_to_owned.rs:191:20
    |
 LL |     let _ = x.join(&x_ref.to_string());
    |                    ^^^^^^^^^^^^^^^^^^ help: use: `x_ref`
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:193:13
+  --> tests/ui/unnecessary_to_owned.rs:194:13
    |
 LL |     let _ = slice.to_vec().into_iter();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:195:13
+  --> tests/ui/unnecessary_to_owned.rs:196:13
    |
 LL |     let _ = slice.to_owned().into_iter();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()`
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:197:13
+  --> tests/ui/unnecessary_to_owned.rs:198:13
    |
 LL |     let _ = [std::path::PathBuf::new()][..].to_vec().into_iter();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:199:13
+  --> tests/ui/unnecessary_to_owned.rs:200:13
    |
 LL |     let _ = [std::path::PathBuf::new()][..].to_owned().into_iter();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()`
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:202:13
+  --> tests/ui/unnecessary_to_owned.rs:203:13
    |
 LL |     let _ = IntoIterator::into_iter(slice.to_vec());
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:204:13
+  --> tests/ui/unnecessary_to_owned.rs:205:13
    |
 LL |     let _ = IntoIterator::into_iter(slice.to_owned());
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()`
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:206:13
+  --> tests/ui/unnecessary_to_owned.rs:207:13
    |
 LL |     let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_vec());
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:208:13
+  --> tests/ui/unnecessary_to_owned.rs:209:13
    |
 LL |     let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_owned());
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()`
 
 error: allocating a new `String` only to create a temporary `&str` from it
-  --> tests/ui/unnecessary_to_owned.rs:236:26
+  --> tests/ui/unnecessary_to_owned.rs:237:26
    |
 LL |     let _ref_str: &str = &String::from_utf8(slice.to_vec()).expect("not UTF-8");
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -490,7 +490,7 @@ LL +     let _ref_str: &str = core::str::from_utf8(&slice).expect("not UTF-8");
    |
 
 error: allocating a new `String` only to create a temporary `&str` from it
-  --> tests/ui/unnecessary_to_owned.rs:238:26
+  --> tests/ui/unnecessary_to_owned.rs:239:26
    |
 LL |     let _ref_str: &str = &String::from_utf8(b"foo".to_vec()).unwrap();
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -502,7 +502,7 @@ LL +     let _ref_str: &str = core::str::from_utf8(b"foo").unwrap();
    |
 
 error: allocating a new `String` only to create a temporary `&str` from it
-  --> tests/ui/unnecessary_to_owned.rs:240:26
+  --> tests/ui/unnecessary_to_owned.rs:241:26
    |
 LL |     let _ref_str: &str = &String::from_utf8(b"foo".as_slice().to_owned()).unwrap();
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -514,7 +514,7 @@ LL +     let _ref_str: &str = core::str::from_utf8(b"foo".as_slice()).unwrap();
    |
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:298:14
+  --> tests/ui/unnecessary_to_owned.rs:299:14
    |
 LL |     for t in file_types.to_vec() {
    |              ^^^^^^^^^^^^^^^^^^^
@@ -527,61 +527,61 @@ LL ~         let path = match get_file_path(t) {
    |
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:322:14
+  --> tests/ui/unnecessary_to_owned.rs:323:14
    |
 LL |     let _ = &["x"][..].to_vec().into_iter();
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().cloned()`
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:328:14
+  --> tests/ui/unnecessary_to_owned.rs:329:14
    |
 LL |     let _ = &["x"][..].to_vec().into_iter();
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().copied()`
 
 error: unnecessary use of `to_string`
-  --> tests/ui/unnecessary_to_owned.rs:377:24
+  --> tests/ui/unnecessary_to_owned.rs:378:24
    |
 LL |         Box::new(build(y.to_string()))
    |                        ^^^^^^^^^^^^^ help: use: `y`
 
 error: unnecessary use of `to_string`
-  --> tests/ui/unnecessary_to_owned.rs:487:12
+  --> tests/ui/unnecessary_to_owned.rs:488:12
    |
 LL |         id("abc".to_string())
    |            ^^^^^^^^^^^^^^^^^ help: use: `"abc"`
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:631:37
+  --> tests/ui/unnecessary_to_owned.rs:632:37
    |
 LL |         IntoFuture::into_future(foo([].to_vec(), &0));
    |                                     ^^^^^^^^^^^ help: use: `[]`
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:642:18
+  --> tests/ui/unnecessary_to_owned.rs:643:18
    |
 LL |         s.remove(&a.to_vec());
    |                  ^^^^^^^^^^^ help: replace it with: `a`
 
 error: unnecessary use of `to_owned`
-  --> tests/ui/unnecessary_to_owned.rs:647:14
+  --> tests/ui/unnecessary_to_owned.rs:648:14
    |
 LL |     s.remove(&"b".to_owned());
    |              ^^^^^^^^^^^^^^^ help: replace it with: `"b"`
 
 error: unnecessary use of `to_string`
-  --> tests/ui/unnecessary_to_owned.rs:649:14
+  --> tests/ui/unnecessary_to_owned.rs:650:14
    |
 LL |     s.remove(&"b".to_string());
    |              ^^^^^^^^^^^^^^^^ help: replace it with: `"b"`
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:655:14
+  --> tests/ui/unnecessary_to_owned.rs:656:14
    |
 LL |     s.remove(&["b"].to_vec());
    |              ^^^^^^^^^^^^^^^ help: replace it with: `["b"].as_slice()`
 
 error: unnecessary use of `to_vec`
-  --> tests/ui/unnecessary_to_owned.rs:657:14
+  --> tests/ui/unnecessary_to_owned.rs:658:14
    |
 LL |     s.remove(&(&["b"]).to_vec());
    |              ^^^^^^^^^^^^^^^^^^ help: replace it with: `(&["b"]).as_slice()`