about summary refs log tree commit diff
path: root/clippy_lints/src/methods/mod.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-04-13 20:31:22 +0000
committerbors <bors@rust-lang.org>2021-04-13 20:31:22 +0000
commit8f3c2450c2dff0d4ae82395699809d3ea726d6c2 (patch)
tree7c429833696b8844dcea2cfcd60c8ab54732362b /clippy_lints/src/methods/mod.rs
parente9728b80ce38a1ab94d90d125726d5503e6ab3bb (diff)
parent76bd5d232c767dbdab63005eca07a9563982e9dd (diff)
Auto merge of #7074 - camsteffen:diag-methods, r=llogiq
Split `is_diagnostic_assoc_item`

changelog: none

* Split `is_diagnostic_assoc_item` into `is_diag_item_method` and `is_diag_trait_item`
  * `is_diag_item_method` is a bit more nuanced with the `tcx.type_of(impl_id).ty_adt_def()` step, so it seems better to keep that separate.
  * No need to generalize over traits and Adt's since we know which one we want at compile time
  * "item" vs. "method" because a trait may have associated items.
* Replaces the usage of the `sym::slice` diagnostic item with the `slice_alloc` lang item. The diagnostic item should be removed from rustc because it is on the `slice_alloc` impl, not slice itself (and it's not needed).
Diffstat (limited to 'clippy_lints/src/methods/mod.rs')
-rw-r--r--clippy_lints/src/methods/mod.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs
index fc18849b07c..b2faaef0786 100644
--- a/clippy_lints/src/methods/mod.rs
+++ b/clippy_lints/src/methods/mod.rs
@@ -1987,10 +1987,9 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio
                 }
             },
             ("step_by", [arg]) => iterator_step_by_zero::check(cx, expr, arg),
-            ("to_os_string", []) => implicit_clone::check(cx, expr, sym::OsStr),
-            ("to_owned", []) => implicit_clone::check(cx, expr, sym::ToOwned),
-            ("to_path_buf", []) => implicit_clone::check(cx, expr, sym::Path),
-            ("to_vec", []) => implicit_clone::check(cx, expr, sym::slice),
+            ("to_os_string" | "to_owned" | "to_path_buf" | "to_vec", []) => {
+                implicit_clone::check(cx, name, expr, recv, span);
+            },
             ("unwrap", []) => match method_call!(recv) {
                 Some(("get", [recv, get_arg], _)) => get_unwrap::check(cx, expr, recv, get_arg, false),
                 Some(("get_mut", [recv, get_arg], _)) => get_unwrap::check(cx, expr, recv, get_arg, true),