fix: merge conflict

This commit is contained in:
Rejyr 2022-10-04 17:54:47 -04:00
parent dc00aa3114
commit a0614ec2c3
3 changed files with 55 additions and 29 deletions

View File

@ -1,4 +1,4 @@
use rustc_errors::{fluent, AddToDiagnostic, Applicability, DecorateLint, EmissionGuarantee}; use rustc_errors::{fluent, AddToDiagnostic, Applicability, DecorateLint};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_macros::{LintDiagnostic, Subdiagnostic}; use rustc_macros::{LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{Predicate, Ty, TyCtxt}; use rustc_middle::ty::{Predicate, Ty, TyCtxt};
@ -88,9 +88,11 @@ pub struct NonFmtPanicUnused {
pub suggestion: Option<Span>, pub suggestion: Option<Span>,
} }
impl<G: EmissionGuarantee> DecorateLint<'_, G> for NonFmtPanicUnused { impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
fn decorate_lint(self, diag: rustc_errors::LintDiagnosticBuilder<'_, G>) { fn decorate_lint<'b>(
let mut diag = diag.build(fluent::lint_non_fmt_panic_unused); self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
diag.set_arg("count", self.count); diag.set_arg("count", self.count);
diag.note(fluent::note); diag.note(fluent::note);
if let Some(span) = self.suggestion { if let Some(span) = self.suggestion {
@ -107,7 +109,11 @@ impl<G: EmissionGuarantee> DecorateLint<'_, G> for NonFmtPanicUnused {
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} }
diag.emit(); diag
}
fn msg(&self) -> rustc_errors::DiagnosticMessage {
fluent::lint_non_fmt_panic_unused
} }
} }
@ -202,7 +208,7 @@ impl AddToDiagnostic for NonSnakeCaseDiagSub {
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
} }
}; }
} }
} }
@ -262,12 +268,17 @@ pub struct DropTraitConstraintsDiag<'a> {
pub def_id: DefId, pub def_id: DefId,
} }
impl<'a, G: EmissionGuarantee> DecorateLint<'_, G> for DropTraitConstraintsDiag<'a> { impl<'a> DecorateLint<'a, ()> for DropTraitConstraintsDiag<'_> {
fn decorate_lint(self, diag: rustc_errors::LintDiagnosticBuilder<'_, G>) { fn decorate_lint<'b>(
let mut diag = diag.build(fluent::lint_drop_trait_constraints); self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
diag.set_arg("predicate", self.predicate); diag.set_arg("predicate", self.predicate);
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id)); diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id))
diag.emit(); }
fn msg(&self) -> rustc_errors::DiagnosticMessage {
fluent::lint_drop_trait_constraints
} }
} }
@ -276,11 +287,16 @@ pub struct DropGlue<'a> {
pub def_id: DefId, pub def_id: DefId,
} }
impl<'a, G: EmissionGuarantee> DecorateLint<'_, G> for DropGlue<'a> { impl<'a> DecorateLint<'a, ()> for DropGlue<'_> {
fn decorate_lint(self, diag: rustc_errors::LintDiagnosticBuilder<'_, G>) { fn decorate_lint<'b>(
let mut diag = diag.build(fluent::lint_drop_glue); self,
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id)); diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
diag.emit(); ) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
diag.set_arg("needs_drop", self.tcx.def_path_str(self.def_id))
}
fn msg(&self) -> rustc_errors::DiagnosticMessage {
fluent::lint_drop_glue
} }
} }
@ -359,9 +375,11 @@ pub struct OverflowingInt<'a> {
} }
// FIXME: refactor with `Option<&'a str>` in macro // FIXME: refactor with `Option<&'a str>` in macro
impl<'a, G: EmissionGuarantee> DecorateLint<'_, G> for OverflowingInt<'a> { impl<'a> DecorateLint<'a, ()> for OverflowingInt<'_> {
fn decorate_lint(self, diag: rustc_errors::LintDiagnosticBuilder<'_, G>) { fn decorate_lint<'b>(
let mut diag = diag.build(fluent::lint_overflowing_int); self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
diag.set_arg("ty", self.ty); diag.set_arg("ty", self.ty);
diag.set_arg("lit", self.lit); diag.set_arg("lit", self.lit);
diag.set_arg("min", self.min); diag.set_arg("min", self.min);
@ -371,7 +389,11 @@ impl<'a, G: EmissionGuarantee> DecorateLint<'_, G> for OverflowingInt<'a> {
diag.set_arg("suggestion_ty", suggestion_ty); diag.set_arg("suggestion_ty", suggestion_ty);
diag.help(fluent::help); diag.help(fluent::help);
} }
diag.emit(); diag
}
fn msg(&self) -> rustc_errors::DiagnosticMessage {
fluent::lint_overflowing_int
} }
} }
@ -484,9 +506,11 @@ pub struct UnusedDef<'a, 'b> {
} }
// FIXME: refactor with `Option<String>` in macro // FIXME: refactor with `Option<String>` in macro
impl<'a, 'b, G: EmissionGuarantee> DecorateLint<'_, G> for UnusedDef<'a, 'b> { impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
fn decorate_lint(self, diag: rustc_errors::LintDiagnosticBuilder<'_, G>) { fn decorate_lint<'b>(
let mut diag = diag.build(fluent::lint_unused_def); self,
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
diag.set_arg("pre", self.pre); diag.set_arg("pre", self.pre);
diag.set_arg("post", self.post); diag.set_arg("post", self.post);
diag.set_arg("def", self.cx.tcx.def_path_str(self.def_id)); diag.set_arg("def", self.cx.tcx.def_path_str(self.def_id));
@ -494,7 +518,11 @@ impl<'a, 'b, G: EmissionGuarantee> DecorateLint<'_, G> for UnusedDef<'a, 'b> {
if let Some(note) = self.note { if let Some(note) = self.note {
diag.note(note.as_str()); diag.note(note.as_str());
} }
diag.emit(); diag
}
fn msg(&self) -> rustc_errors::DiagnosticMessage {
fluent::lint_unused_def
} }
} }

View File

@ -2,7 +2,6 @@
#![deny(rustc::diagnostic_outside_of_impl)] #![deny(rustc::diagnostic_outside_of_impl)]
use crate::context::LintContext; use crate::context::LintContext;
use crate::lints::NoopMethodCallDiag; use crate::lints::NoopMethodCallDiag;
use crate::rustc_middle::ty::TypeVisitable;
use crate::LateContext; use crate::LateContext;
use crate::LateLintPass; use crate::LateLintPass;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;

View File

@ -1138,10 +1138,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
CItemKind::Definition => "fn", CItemKind::Definition => "fn",
}; };
#[allow(rustc::diagnostic_outside_of_impl)] #[allow(rustc::diagnostic_outside_of_impl)]
let mut diag = lint.build(fluent::lint_improper_ctypes); lint.set_arg("ty", ty);
diag.set_arg("ty", ty); lint.set_arg("desc", item_description);
diag.set_arg("desc", item_description); lint.span_label(sp, fluent::label);
diag.span_label(sp, fluent::label);
if let Some(help) = help { if let Some(help) = help {
lint.help(help); lint.help(help);
} }