mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 15:32:06 +00:00
migrate: noop_method_call.rs
This commit is contained in:
parent
6fb3a38f9b
commit
56fc66d196
@ -6,6 +6,16 @@ use rustc_span::{Span, Symbol};
|
||||
|
||||
use crate::LateContext;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_noop_method_call)]
|
||||
#[note]
|
||||
pub struct NoopMethodCallDiag<'a> {
|
||||
pub method: Symbol,
|
||||
pub receiver_ty: Ty<'a>,
|
||||
#[label]
|
||||
pub label: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_pass_by_value)]
|
||||
pub struct PassByValueDiag {
|
||||
|
@ -1,7 +1,10 @@
|
||||
#![deny(rustc::untranslatable_diagnostic)]
|
||||
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||
use crate::context::LintContext;
|
||||
use crate::lints::NoopMethodCallDiag;
|
||||
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;
|
||||
@ -85,11 +88,10 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
|
||||
}
|
||||
let expr_span = expr.span;
|
||||
let span = expr_span.with_lo(receiver.span.hi());
|
||||
cx.struct_span_lint(NOOP_METHOD_CALL, span, fluent::lint_noop_method_call, |lint| {
|
||||
lint.set_arg("method", call.ident.name)
|
||||
.set_arg("receiver_ty", receiver_ty)
|
||||
.span_label(span, fluent::label)
|
||||
.note(fluent::note)
|
||||
});
|
||||
cx.emit_spanned_lint(
|
||||
NOOP_METHOD_CALL,
|
||||
span,
|
||||
NoopMethodCallDiag { method: call.ident.name, receiver_ty, label: span },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user