about summary refs log tree commit diff
path: root/compiler
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
parent040735c110026bbd494a23c86182ebda201d720b (diff)
downloadrust-f49ed7a6b7aa3a44dd0444b508a1d0ddc09b0f15.tar.gz
rust-f49ed7a6b7aa3a44dd0444b508a1d0ddc09b0f15.zip
Add tests and support two more noop methods
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_lint/src/noop_method_call.rs12
-rw-r--r--compiler/rustc_span/src/symbol.rs4
2 files changed, 13 insertions, 3 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()
                                 });
                             }
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index 2207deb8fb5..d39fbd61962 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -789,6 +789,9 @@ symbols! {
         none_error,
         nontemporal_store,
         nontrapping_dash_fptoint: "nontrapping-fptoint",
+        noop_method_borrow,
+        noop_method_clone,
+        noop_method_deref,
         noreturn,
         nostack,
         not,
@@ -915,7 +918,6 @@ symbols! {
         receiver,
         recursion_limit,
         reexport_test_harness_main,
-        ref_clone_method,
         reference,
         reflect,
         reg,