Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 56fc66d

Browse files
committed
migrate: noop_method_call.rs
1 parent 6fb3a38 commit 56fc66d

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

compiler/rustc_lint/src/lints.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ use rustc_span::{Span, Symbol};
66

77
use crate::LateContext;
88

9+
#[derive(LintDiagnostic)]
10+
#[diag(lint_noop_method_call)]
11+
#[note]
12+
pub struct NoopMethodCallDiag<'a> {
13+
pub method: Symbol,
14+
pub receiver_ty: Ty<'a>,
15+
#[label]
16+
pub label: Span,
17+
}
18+
919
#[derive(LintDiagnostic)]
1020
#[diag(lint_pass_by_value)]
1121
pub struct PassByValueDiag {

compiler/rustc_lint/src/noop_method_call.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use crate::context::LintContext;
4+
use crate::lints::NoopMethodCallDiag;
5+
use crate::rustc_middle::ty::TypeVisitable;
26
use crate::LateContext;
37
use crate::LateLintPass;
4-
use rustc_errors::fluent;
58
use rustc_hir::def::DefKind;
69
use rustc_hir::{Expr, ExprKind};
710
use rustc_middle::ty;
@@ -85,11 +88,10 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
8588
}
8689
let expr_span = expr.span;
8790
let span = expr_span.with_lo(receiver.span.hi());
88-
cx.struct_span_lint(NOOP_METHOD_CALL, span, fluent::lint_noop_method_call, |lint| {
89-
lint.set_arg("method", call.ident.name)
90-
.set_arg("receiver_ty", receiver_ty)
91-
.span_label(span, fluent::label)
92-
.note(fluent::note)
93-
});
91+
cx.emit_spanned_lint(
92+
NOOP_METHOD_CALL,
93+
span,
94+
NoopMethodCallDiag { method: call.ident.name, receiver_ty, label: span },
95+
);
9496
}
9597
}

0 commit comments

Comments
 (0)