use crate::context::LintContext;
-use crate::rustc_middle::ty::TypeFoldable;
+use crate::rustc_middle::ty::TypeVisitable;
use crate::LateContext;
use crate::LateLintPass;
+use rustc_errors::fluent;
use rustc_hir::def::DefKind;
use rustc_hir::{Expr, ExprKind};
use rustc_middle::ty;
) {
return;
}
- let method = &call.ident.name;
let receiver = &elements[0];
let receiver_ty = cx.typeck_results().expr_ty(receiver);
let expr_ty = cx.typeck_results().expr_ty_adjusted(expr);
return;
}
let expr_span = expr.span;
- let note = format!(
- "the type `{:?}` which `{}` is being called on is the same as \
- the type returned from `{}`, so the method call does not do \
- anything and can be removed",
- receiver_ty, method, method,
- );
-
let span = expr_span.with_lo(receiver.span.hi());
cx.struct_span_lint(NOOP_METHOD_CALL, span, |lint| {
- let method = &call.ident.name;
- let message =
- format!("call to `.{}()` on a reference in this situation does nothing", &method,);
- lint.build(&message).span_label(span, "unnecessary method call").note(¬e).emit();
+ lint.build(fluent::lint::noop_method_call)
+ .set_arg("method", call.ident.name)
+ .set_arg("receiver_ty", receiver_ty)
+ .span_label(span, fluent::lint::label)
+ .note(fluent::lint::note)
+ .emit();
});
}
}