Skip to content

Commit 3bc1950

Browse files
Make DiagEmitter::emit take self by value
1 parent f3d639f commit 3bc1950

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ pub fn emit_delayed_lint(lint: &DelayedLint, tcx: TyCtxt<'_>) {
157157
}
158158

159159
impl rustc_lint::EmitDiag for DiagEmitter<'_> {
160-
fn emit(&self, diag: impl for<'a> rustc_errors::Diagnostic<'a, ()>) {
160+
fn emit(self, diag: impl for<'a> rustc_errors::Diagnostic<'a, ()>) {
161161
self.tcx.emit_node_span_lint(self.lint, self.hir_id, self.span, diag);
162162
}
163163
}
164164

165165
match lint {
166166
DelayedLint::AttributeParsing(attribute_lint) => {
167167
rustc_lint::decorate_attribute_lint(
168-
&DiagEmitter {
168+
DiagEmitter {
169169
hir_id: attribute_lint.id,
170170
tcx,
171171
span: attribute_lint.span,

compiler/rustc_lint/src/early.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct EarlyContextAndPass<'ecx, 'tcx, T: EarlyLintPass> {
3434
}
3535

3636
pub trait EmitDiag {
37-
fn emit(&self, diag: impl for<'a> Diagnostic<'a, ()>);
37+
fn emit(self, diag: impl for<'a> Diagnostic<'a, ()>);
3838
}
3939

4040
struct DiagEmitter<'a, 'b> {
@@ -44,8 +44,8 @@ struct DiagEmitter<'a, 'b> {
4444
}
4545

4646
impl EmitDiag for DiagEmitter<'_, '_> {
47-
fn emit(&self, diag: impl for<'a> Diagnostic<'a, ()>) {
48-
self.ctx.opt_span_diag_lint(self.lint, self.span.clone(), diag);
47+
fn emit(self, diag: impl for<'a> Diagnostic<'a, ()>) {
48+
self.ctx.opt_span_diag_lint(self.lint, self.span, diag);
4949
}
5050
}
5151

@@ -56,7 +56,7 @@ impl<'ecx, 'tcx, T: EarlyLintPass> EarlyContextAndPass<'ecx, 'tcx, T> {
5656
match diagnostic {
5757
DecorateDiagCompat::Builtin(b) => {
5858
diagnostics::decorate_builtin_lint(
59-
&DiagEmitter { ctx: &self.context, span, lint: lint_id.lint },
59+
DiagEmitter { ctx: &self.context, span, lint: lint_id.lint },
6060
self.context.sess(),
6161
self.tcx,
6262
b,

compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use crate::{EmitDiag, lints};
1414

1515
mod check_cfg;
1616

17-
pub fn decorate_builtin_lint<D: EmitDiag>(
18-
ctx: &D,
17+
pub fn decorate_builtin_lint(
18+
ctx: impl EmitDiag,
1919
sess: &Session,
2020
tcx: Option<TyCtxt<'_>>,
2121
diagnostic: BuiltinLintDiag,
@@ -298,8 +298,8 @@ pub fn decorate_builtin_lint<D: EmitDiag>(
298298
}
299299
}
300300

301-
pub fn decorate_attribute_lint<D: EmitDiag>(
302-
ctx: &D,
301+
pub fn decorate_attribute_lint(
302+
ctx: impl EmitDiag,
303303
sess: &Session,
304304
tcx: Option<TyCtxt<'_>>,
305305
kind: &AttributeLintKind,

0 commit comments

Comments
 (0)