1
Fork 0
This commit is contained in:
Deadbeef 2023-05-25 05:21:44 +00:00
parent 33ec4e4bb0
commit 626efab67f
11 changed files with 33 additions and 29 deletions

View file

@ -85,10 +85,9 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
let Some(trait_id) = cx.tcx.trait_of_item(did) else { return };
if !matches!(
cx.tcx.get_diagnostic_name(trait_id),
Some(sym::Borrow | sym::Clone | sym::Deref)
) {
let Some(trait_) = cx.tcx.get_diagnostic_name(trait_id) else { return };
if !matches!(trait_, sym::Borrow | sym::Clone | sym::Deref) {
return;
};
@ -113,11 +112,13 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
let expr_span = expr.span;
let span = expr_span.with_lo(receiver.span.hi());
let orig_ty = expr_ty.peel_refs();
if receiver_ty == expr_ty {
cx.emit_spanned_lint(
NOOP_METHOD_CALL,
span,
NoopMethodCallDiag { method: call.ident.name, receiver_ty, label: span },
NoopMethodCallDiag { method: call.ident.name, orig_ty, trait_, label: span },
);
} else {
match name {