about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/noop_method_call.rs
diff options
context:
space:
mode:
authorRyan Levick <ryan.levick@gmail.com>2021-01-05 16:14:39 +0100
committerRyan Levick <me@ryanlevick.com>2021-03-03 11:22:17 +0100
commitf49ed7a6b7aa3a44dd0444b508a1d0ddc09b0f15 (patch)
treec6b01189571ac4abb30d9a37c3c3459407b3dcc8 /compiler/rustc_lint/src/noop_method_call.rs
parent040735c110026bbd494a23c86182ebda201d720b (diff)
downloadrust-f49ed7a6b7aa3a44dd0444b508a1d0ddc09b0f15.tar.gz
rust-f49ed7a6b7aa3a44dd0444b508a1d0ddc09b0f15.zip
Add tests and support two more noop methods
Diffstat (limited to 'compiler/rustc_lint/src/noop_method_call.rs')
-rw-r--r--compiler/rustc_lint/src/noop_method_call.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/compiler/rustc_lint/src/noop_method_call.rs b/compiler/rustc_lint/src/noop_method_call.rs
index 098c50d5abe..3ab3fab4272 100644
--- a/compiler/rustc_lint/src/noop_method_call.rs
+++ b/compiler/rustc_lint/src/noop_method_call.rs
@@ -54,11 +54,19 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
                         // Resolve the trait method instance
                         if let Ok(Some(i)) = ty::Instance::resolve(cx.tcx, param_env, did, substs) {
                             // Check that it implements the noop diagnostic
-                            if cx.tcx.is_diagnostic_item(sym::ref_clone_method, i.def_id()) {
+                            tracing::debug!("Resolves to: {:?}", i.def_id());
+                            if [
+                                sym::noop_method_borrow,
+                                sym::noop_method_clone,
+                                sym::noop_method_deref,
+                            ]
+                            .iter()
+                            .any(|s| cx.tcx.is_diagnostic_item(*s, i.def_id()))
+                            {
                                 let span = expr.span;
 
                                 cx.struct_span_lint(NOOP_METHOD_CALL, span, |lint| {
-                                    let message = "Call to noop method";
+                                    let message = "call to noop method";
                                     lint.build(&message).emit()
                                 });
                             }