diff options
| author | Ryan Levick <ryan.levick@gmail.com> | 2021-01-05 16:14:39 +0100 |
|---|---|---|
| committer | Ryan Levick <me@ryanlevick.com> | 2021-03-03 11:22:17 +0100 |
| commit | f49ed7a6b7aa3a44dd0444b508a1d0ddc09b0f15 (patch) | |
| tree | c6b01189571ac4abb30d9a37c3c3459407b3dcc8 /compiler/rustc_lint/src/noop_method_call.rs | |
| parent | 040735c110026bbd494a23c86182ebda201d720b (diff) | |
| download | rust-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.rs | 12 |
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() }); } |
