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

Commit a0614ec

Browse files
committed
fix: merge conflict
1 parent dc00aa3 commit a0614ec

File tree

3 files changed

+55
-29
lines changed

3 files changed

+55
-29
lines changed

compiler/rustc_lint/src/lints.rs

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::{fluent, AddToDiagnostic, Applicability, DecorateLint, EmissionGuarantee};
1+
use rustc_errors::{fluent, AddToDiagnostic, Applicability, DecorateLint};
22
use rustc_hir::def_id::DefId;
33
use rustc_macros::{LintDiagnostic, Subdiagnostic};
44
use rustc_middle::ty::{Predicate, Ty, TyCtxt};
@@ -88,9 +88,11 @@ pub struct NonFmtPanicUnused {
8888
pub suggestion: Option<Span>,
8989
}
9090

91-
impl<G: EmissionGuarantee> DecorateLint<'_, G> for NonFmtPanicUnused {
92-
fn decorate_lint(self, diag: rustc_errors::LintDiagnosticBuilder<'_, G>) {
93-
let mut diag = diag.build(fluent::lint_non_fmt_panic_unused);
91+
impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
92+
fn decorate_lint<'b>(
93+
self,
94+
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
95+
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
9496
diag.set_arg("count", self.count);
9597
diag.note(fluent::note);
9698
if let Some(span) = self.suggestion {
@@ -107,7 +109,11 @@ impl<G: EmissionGuarantee> DecorateLint<'_, G> for NonFmtPanicUnused {
107109
Applicability::MachineApplicable,
108110
);
109111
}
110-
diag.emit();
112+
diag
113+
}
114+
115+
fn msg(&self) -> rustc_errors::DiagnosticMessage {
116+
fluent::lint_non_fmt_panic_unused
111117
}
112118
}
113119

@@ -202,7 +208,7 @@ impl AddToDiagnostic for NonSnakeCaseDiagSub {
202208
Applicability::MaybeIncorrect,
203209
);
204210
}
205-
};
211+
}
206212
}
207213
}
208214

@@ -262,12 +268,17 @@ pub struct DropTraitConstraintsDiag<'a> {
262268
pub def_id: DefId,
263269
}
264270

265-
impl<'a, G: EmissionGuarantee> DecorateLint<'_, G> for DropTraitConstraintsDiag<'a> {
266-
fn decorate_lint(self, diag: rustc_errors::LintDiagnosticBuilder<'_, G>) {
267-
let mut diag = diag.build(fluent::lint_drop_trait_constraints);
271+
impl<'a> DecorateLint<'a, ()> for DropTraitConstraintsDiag<'_> {
272+
fn decorate_lint<'b>(
273+
self,
274+
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
275+
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
268276
diag.set_arg("predicate", self.predicate);
269-
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id));
270-
diag.emit();
277+
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id))
278+
}
279+
280+
fn msg(&self) -> rustc_errors::DiagnosticMessage {
281+
fluent::lint_drop_trait_constraints
271282
}
272283
}
273284

@@ -276,11 +287,16 @@ pub struct DropGlue<'a> {
276287
pub def_id: DefId,
277288
}
278289

279-
impl<'a, G: EmissionGuarantee> DecorateLint<'_, G> for DropGlue<'a> {
280-
fn decorate_lint(self, diag: rustc_errors::LintDiagnosticBuilder<'_, G>) {
281-
let mut diag = diag.build(fluent::lint_drop_glue);
282-
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id));
283-
diag.emit();
290+
impl<'a> DecorateLint<'a, ()> for DropGlue<'_> {
291+
fn decorate_lint<'b>(
292+
self,
293+
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
294+
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
295+
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id))
296+
}
297+
298+
fn msg(&self) -> rustc_errors::DiagnosticMessage {
299+
fluent::lint_drop_glue
284300
}
285301
}
286302

@@ -359,9 +375,11 @@ pub struct OverflowingInt<'a> {
359375
}
360376

361377
// FIXME: refactor with `Option<&'a str>` in macro
362-
impl<'a, G: EmissionGuarantee> DecorateLint<'_, G> for OverflowingInt<'a> {
363-
fn decorate_lint(self, diag: rustc_errors::LintDiagnosticBuilder<'_, G>) {
364-
let mut diag = diag.build(fluent::lint_overflowing_int);
378+
impl<'a> DecorateLint<'a, ()> for OverflowingInt<'_> {
379+
fn decorate_lint<'b>(
380+
self,
381+
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
382+
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
365383
diag.set_arg("ty", self.ty);
366384
diag.set_arg("lit", self.lit);
367385
diag.set_arg("min", self.min);
@@ -371,7 +389,11 @@ impl<'a, G: EmissionGuarantee> DecorateLint<'_, G> for OverflowingInt<'a> {
371389
diag.set_arg("suggestion_ty", suggestion_ty);
372390
diag.help(fluent::help);
373391
}
374-
diag.emit();
392+
diag
393+
}
394+
395+
fn msg(&self) -> rustc_errors::DiagnosticMessage {
396+
fluent::lint_overflowing_int
375397
}
376398
}
377399

@@ -484,17 +506,23 @@ pub struct UnusedDef<'a, 'b> {
484506
}
485507

486508
// FIXME: refactor with `Option<String>` in macro
487-
impl<'a, 'b, G: EmissionGuarantee> DecorateLint<'_, G> for UnusedDef<'a, 'b> {
488-
fn decorate_lint(self, diag: rustc_errors::LintDiagnosticBuilder<'_, G>) {
489-
let mut diag = diag.build(fluent::lint_unused_def);
509+
impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
510+
fn decorate_lint<'b>(
511+
self,
512+
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
513+
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
490514
diag.set_arg("pre", self.pre);
491515
diag.set_arg("post", self.post);
492516
diag.set_arg("def", self.cx.tcx.def_path_str(self.def_id));
493517
// check for #[must_use = "..."]
494518
if let Some(note) = self.note {
495519
diag.note(note.as_str());
496520
}
497-
diag.emit();
521+
diag
522+
}
523+
524+
fn msg(&self) -> rustc_errors::DiagnosticMessage {
525+
fluent::lint_unused_def
498526
}
499527
}
500528

compiler/rustc_lint/src/noop_method_call.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![deny(rustc::diagnostic_outside_of_impl)]
33
use crate::context::LintContext;
44
use crate::lints::NoopMethodCallDiag;
5-
use crate::rustc_middle::ty::TypeVisitable;
65
use crate::LateContext;
76
use crate::LateLintPass;
87
use rustc_hir::def::DefKind;

compiler/rustc_lint/src/types.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,10 +1138,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
11381138
CItemKind::Definition => "fn",
11391139
};
11401140
#[allow(rustc::diagnostic_outside_of_impl)]
1141-
let mut diag = lint.build(fluent::lint_improper_ctypes);
1142-
diag.set_arg("ty", ty);
1143-
diag.set_arg("desc", item_description);
1144-
diag.span_label(sp, fluent::label);
1141+
lint.set_arg("ty", ty);
1142+
lint.set_arg("desc", item_description);
1143+
lint.span_label(sp, fluent::label);
11451144
if let Some(help) = help {
11461145
lint.help(help);
11471146
}

0 commit comments

Comments
 (0)