1
Fork 0

Auto merge of #121780 - nnethercote:diag-renaming2, r=davidtwco

Diagnostic renaming 2

A sequel to #121489.

r? `@davidtwco`
This commit is contained in:
bors 2024-03-05 02:58:34 +00:00
commit 1547c076bf
95 changed files with 609 additions and 639 deletions

View file

@ -58,7 +58,7 @@ use rustc_middle::ty::GenericArgKind;
use rustc_middle::ty::ToPredicate;
use rustc_middle::ty::TypeVisitableExt;
use rustc_middle::ty::{self, Ty, TyCtxt, VariantDef};
use rustc_session::lint::{BuiltinLintDiagnostics, FutureIncompatibilityReason};
use rustc_session::lint::{BuiltinLintDiag, FutureIncompatibilityReason};
use rustc_span::edition::Edition;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
@ -2831,7 +2831,7 @@ impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels {
Some(target_spans),
fluent::lint_builtin_asm_labels,
|_| {},
BuiltinLintDiagnostics::NamedAsmLabel(
BuiltinLintDiag::NamedAsmLabel(
"only local labels of the form `<number>:` should be used in inline asm"
.to_string(),
),

View file

@ -21,7 +21,7 @@ use crate::passes::{EarlyLintPassObject, LateLintPassObject};
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sync;
use rustc_data_structures::unord::UnordMap;
use rustc_errors::{DecorateLint, Diag, DiagnosticMessage, MultiSpan};
use rustc_errors::{DecorateLint, Diag, DiagMessage, MultiSpan};
use rustc_feature::Features;
use rustc_hir as hir;
use rustc_hir::def::Res;
@ -31,7 +31,7 @@ use rustc_middle::middle::privacy::EffectiveVisibilities;
use rustc_middle::ty::layout::{LayoutError, LayoutOfHelpers, TyAndLayout};
use rustc_middle::ty::print::{with_no_trimmed_paths, PrintError};
use rustc_middle::ty::{self, print::Printer, GenericArg, RegisteredTools, Ty, TyCtxt};
use rustc_session::lint::{BuiltinLintDiagnostics, LintExpectationId};
use rustc_session::lint::{BuiltinLintDiag, LintExpectationId};
use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
use rustc_session::{LintStoreMarker, Session};
use rustc_span::edit_distance::find_best_match_for_names;
@ -536,9 +536,9 @@ pub trait LintContext {
&self,
lint: &'static Lint,
span: Option<impl Into<MultiSpan>>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
diagnostic: BuiltinLintDiagnostics,
diagnostic: BuiltinLintDiag,
) {
// We first generate a blank diagnostic.
self.opt_span_lint(lint, span, msg, |db| {
@ -559,7 +559,7 @@ pub trait LintContext {
&self,
lint: &'static Lint,
span: Option<S>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
);
@ -584,7 +584,7 @@ pub trait LintContext {
&self,
lint: &'static Lint,
span: S,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
) {
self.opt_span_lint(lint, Some(span), msg, decorate);
@ -605,7 +605,7 @@ pub trait LintContext {
fn lint(
&self,
lint: &'static Lint,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
) {
self.opt_span_lint(lint, None as Option<Span>, msg, decorate);
@ -670,7 +670,7 @@ impl<'tcx> LintContext for LateContext<'tcx> {
&self,
lint: &'static Lint,
span: Option<S>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
) {
let hir_id = self.last_node_with_lint_attrs;
@ -697,7 +697,7 @@ impl LintContext for EarlyContext<'_> {
&self,
lint: &'static Lint,
span: Option<S>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
) {
self.builder.opt_span_lint(lint, span.map(|s| s.into()), msg, decorate)

View file

@ -6,15 +6,15 @@ use rustc_errors::{add_elided_lifetime_in_path_suggestion, Diag};
use rustc_errors::{Applicability, SuggestionStyle};
use rustc_middle::middle::stability;
use rustc_session::config::ExpectedValues;
use rustc_session::lint::BuiltinLintDiagnostics;
use rustc_session::lint::BuiltinLintDiag;
use rustc_session::Session;
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::BytePos;
pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag: &mut Diag<'_, ()>) {
pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiag, diag: &mut Diag<'_, ()>) {
match diagnostic {
BuiltinLintDiagnostics::UnicodeTextFlow(span, content) => {
BuiltinLintDiag::UnicodeTextFlow(span, content) => {
let spans: Vec<_> = content
.char_indices()
.filter_map(|(i, c)| {
@ -51,8 +51,8 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
);
}
}
BuiltinLintDiagnostics::Normal => (),
BuiltinLintDiagnostics::AbsPathWithModule(span) => {
BuiltinLintDiag::Normal => (),
BuiltinLintDiag::AbsPathWithModule(span) => {
let (sugg, app) = match sess.source_map().span_to_snippet(span) {
Ok(ref s) => {
// FIXME(Manishearth) ideally the emitting code
@ -65,21 +65,16 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
};
diag.span_suggestion(span, "use `crate`", sugg, app);
}
BuiltinLintDiagnostics::ProcMacroDeriveResolutionFallback(span) => {
BuiltinLintDiag::ProcMacroDeriveResolutionFallback(span) => {
diag.span_label(
span,
"names from parent modules are not accessible without an explicit import",
);
}
BuiltinLintDiagnostics::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => {
BuiltinLintDiag::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => {
diag.span_note(span_def, "the macro is defined here");
}
BuiltinLintDiagnostics::ElidedLifetimesInPaths(
n,
path_span,
incl_angl_brckt,
insertion_span,
) => {
BuiltinLintDiag::ElidedLifetimesInPaths(n, path_span, incl_angl_brckt, insertion_span) => {
add_elided_lifetime_in_path_suggestion(
sess.source_map(),
diag,
@ -89,10 +84,10 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
insertion_span,
);
}
BuiltinLintDiagnostics::UnknownCrateTypes(span, note, sugg) => {
BuiltinLintDiag::UnknownCrateTypes(span, note, sugg) => {
diag.span_suggestion(span, note, sugg, Applicability::MaybeIncorrect);
}
BuiltinLintDiagnostics::UnusedImports(message, replaces, in_test_module) => {
BuiltinLintDiag::UnusedImports(message, replaces, in_test_module) => {
if !replaces.is_empty() {
diag.tool_only_multipart_suggestion(
message,
@ -108,21 +103,21 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
);
}
}
BuiltinLintDiagnostics::RedundantImport(spans, ident) => {
BuiltinLintDiag::RedundantImport(spans, ident) => {
for (span, is_imported) in spans {
let introduced = if is_imported { "imported" } else { "defined" };
diag.span_label(span, format!("the item `{ident}` is already {introduced} here"));
}
}
BuiltinLintDiagnostics::DeprecatedMacro(suggestion, span) => {
BuiltinLintDiag::DeprecatedMacro(suggestion, span) => {
stability::deprecation_suggestion(diag, "macro", suggestion, span)
}
BuiltinLintDiagnostics::UnusedDocComment(span) => {
BuiltinLintDiag::UnusedDocComment(span) => {
diag.span_label(span, "rustdoc does not generate documentation for macro invocations");
diag.help("to document an item produced by a macro, \
the macro must produce the documentation as part of its expansion");
}
BuiltinLintDiagnostics::PatternsInFnsWithoutBody(span, ident) => {
BuiltinLintDiag::PatternsInFnsWithoutBody(span, ident) => {
diag.span_suggestion(
span,
"remove `mut` from the parameter",
@ -130,17 +125,17 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
Applicability::MachineApplicable,
);
}
BuiltinLintDiagnostics::MissingAbi(span, default_abi) => {
BuiltinLintDiag::MissingAbi(span, default_abi) => {
diag.span_label(span, "ABI should be specified here");
diag.help(format!("the default ABI is {}", default_abi.name()));
}
BuiltinLintDiagnostics::LegacyDeriveHelpers(span) => {
BuiltinLintDiag::LegacyDeriveHelpers(span) => {
diag.span_label(span, "the attribute is introduced here");
}
BuiltinLintDiagnostics::ProcMacroBackCompat(note) => {
BuiltinLintDiag::ProcMacroBackCompat(note) => {
diag.note(note);
}
BuiltinLintDiagnostics::OrPatternsBackCompat(span, suggestion) => {
BuiltinLintDiag::OrPatternsBackCompat(span, suggestion) => {
diag.span_suggestion(
span,
"use pat_param to preserve semantics",
@ -148,7 +143,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
Applicability::MachineApplicable,
);
}
BuiltinLintDiagnostics::ReservedPrefix(span) => {
BuiltinLintDiag::ReservedPrefix(span) => {
diag.span_label(span, "unknown prefix");
diag.span_suggestion_verbose(
span.shrink_to_hi(),
@ -157,19 +152,19 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
Applicability::MachineApplicable,
);
}
BuiltinLintDiagnostics::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => {
BuiltinLintDiag::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => {
diag.span_note(
invoc_span,
format!("the built-in attribute `{attr_name}` will be ignored, since it's applied to the macro invocation `{macro_name}`")
);
}
BuiltinLintDiagnostics::TrailingMacro(is_trailing, name) => {
BuiltinLintDiag::TrailingMacro(is_trailing, name) => {
if is_trailing {
diag.note("macro invocations at the end of a block are treated as expressions");
diag.note(format!("to ignore the value produced by the macro, add a semicolon after the invocation of `{name}`"));
}
}
BuiltinLintDiagnostics::BreakWithLabelAndLoop(span) => {
BuiltinLintDiag::BreakWithLabelAndLoop(span) => {
diag.multipart_suggestion(
"wrap this expression in parentheses",
vec![
@ -179,11 +174,11 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
Applicability::MachineApplicable,
);
}
BuiltinLintDiagnostics::NamedAsmLabel(help) => {
BuiltinLintDiag::NamedAsmLabel(help) => {
diag.help(help);
diag.note("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information");
}
BuiltinLintDiagnostics::UnexpectedCfgName((name, name_span), value) => {
BuiltinLintDiag::UnexpectedCfgName((name, name_span), value) => {
#[allow(rustc::potential_query_instability)]
let possibilities: Vec<Symbol> =
sess.psess.check_config.expecteds.keys().copied().collect();
@ -321,7 +316,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
diag.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
}
}
BuiltinLintDiagnostics::UnexpectedCfgValue((name, name_span), value) => {
BuiltinLintDiag::UnexpectedCfgValue((name, name_span), value) => {
let Some(ExpectedValues::Some(values)) = &sess.psess.check_config.expecteds.get(&name)
else {
bug!(
@ -426,7 +421,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
diag.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
}
}
BuiltinLintDiagnostics::DeprecatedWhereclauseLocation(sugg) => {
BuiltinLintDiag::DeprecatedWhereclauseLocation(sugg) => {
let left_sp = diag.span.primary_span().unwrap();
match sugg {
Some((right_sp, sugg)) => diag.multipart_suggestion(
@ -443,7 +438,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
};
diag.note("see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information");
}
BuiltinLintDiagnostics::SingleUseLifetime {
BuiltinLintDiag::SingleUseLifetime {
param_span,
use_span: Some((use_span, elide)),
deletion_span,
@ -474,11 +469,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
diag.multipart_suggestion(msg, suggestions, Applicability::MachineApplicable);
}
}
BuiltinLintDiagnostics::SingleUseLifetime {
param_span: _,
use_span: None,
deletion_span,
} => {
BuiltinLintDiag::SingleUseLifetime { param_span: _, use_span: None, deletion_span } => {
debug!(?deletion_span);
if let Some(deletion_span) = deletion_span {
diag.span_suggestion(
@ -489,7 +480,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
);
}
}
BuiltinLintDiagnostics::NamedArgumentUsedPositionally {
BuiltinLintDiag::NamedArgumentUsedPositionally {
position_sp_to_replace,
position_sp_for_msg,
named_arg_sp,
@ -525,13 +516,13 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
);
}
}
BuiltinLintDiagnostics::ByteSliceInPackedStructWithDerive => {
BuiltinLintDiag::ByteSliceInPackedStructWithDerive => {
diag.help("consider implementing the trait by hand, or remove the `packed` attribute");
}
BuiltinLintDiagnostics::UnusedExternCrate { removal_span } => {
BuiltinLintDiag::UnusedExternCrate { removal_span } => {
diag.span_suggestion(removal_span, "remove it", "", Applicability::MachineApplicable);
}
BuiltinLintDiagnostics::ExternCrateNotIdiomatic { vis_span, ident_span } => {
BuiltinLintDiag::ExternCrateNotIdiomatic { vis_span, ident_span } => {
let suggestion_span = vis_span.between(ident_span);
diag.span_suggestion_verbose(
suggestion_span,
@ -540,10 +531,10 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
Applicability::MachineApplicable,
);
}
BuiltinLintDiagnostics::AmbiguousGlobImports { diag: ambiguity } => {
BuiltinLintDiag::AmbiguousGlobImports { diag: ambiguity } => {
rustc_errors::report_ambiguity_error(diag, ambiguity);
}
BuiltinLintDiagnostics::AmbiguousGlobReexports {
BuiltinLintDiag::AmbiguousGlobReexports {
name,
namespace,
first_reexport_span,
@ -560,7 +551,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
),
);
}
BuiltinLintDiagnostics::HiddenGlobReexports {
BuiltinLintDiag::HiddenGlobReexports {
name,
namespace,
glob_reexport_span,
@ -569,7 +560,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
diag.span_note(glob_reexport_span, format!("the name `{name}` in the {namespace} namespace is supposed to be publicly re-exported here"));
diag.span_note(private_item_span, "but the private item here shadows it".to_owned());
}
BuiltinLintDiagnostics::UnusedQualifications { removal_span } => {
BuiltinLintDiag::UnusedQualifications { removal_span } => {
diag.span_suggestion_verbose(
removal_span,
"remove the unnecessary path segments",
@ -577,7 +568,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
Applicability::MachineApplicable,
);
}
BuiltinLintDiagnostics::AssociatedConstElidedLifetime { elided, span } => {
BuiltinLintDiag::AssociatedConstElidedLifetime { elided, span } => {
diag.span_suggestion_verbose(
if elided { span.shrink_to_hi() } else { span },
"use the `'static` lifetime",
@ -585,7 +576,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
Applicability::MachineApplicable,
);
}
BuiltinLintDiagnostics::RedundantImportVisibility { max_vis, span } => {
BuiltinLintDiag::RedundantImportVisibility { max_vis, span } => {
diag.span_note(span, format!("the most public imported item is `{max_vis}`"));
diag.help(
"reduce the glob import's visibility or increase visibility of imported items",

View file

@ -1,5 +1,5 @@
use crate::fluent_generated as fluent;
use rustc_errors::{codes::*, AddToDiagnostic, Diag, EmissionGuarantee, SubdiagnosticMessageOp};
use rustc_errors::{codes::*, AddToDiagnostic, Diag, EmissionGuarantee, SubdiagMessageOp};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_session::lint::Level;
use rustc_span::{Span, Symbol};
@ -24,7 +24,7 @@ pub enum OverruledAttributeSub {
}
impl AddToDiagnostic for OverruledAttributeSub {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: F,

View file

@ -403,7 +403,7 @@ impl LateLintPass<'_> for Diagnostics {
debug!(?ty);
if let Some(adt_def) = ty.ty_adt_def()
&& let Some(name) = cx.tcx.get_diagnostic_name(adt_def.did())
&& matches!(name, sym::DiagnosticMessage | sym::SubdiagnosticMessage)
&& matches!(name, sym::DiagMessage | sym::SubdiagMessage)
{
found_diagnostic_message = true;
break;

View file

@ -16,7 +16,7 @@ use crate::{
use rustc_ast as ast;
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::{DecorateLint, Diag, DiagnosticMessage, MultiSpan};
use rustc_errors::{DecorateLint, Diag, DiagMessage, MultiSpan};
use rustc_feature::{Features, GateIssue};
use rustc_hir as hir;
use rustc_hir::intravisit::{self, Visitor};
@ -1106,7 +1106,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
&self,
lint: &'static Lint,
span: Option<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
) {
let (level, src) = self.lint_level(lint);

View file

@ -5,8 +5,8 @@ use std::num::NonZero;
use crate::errors::RequestedLevel;
use crate::fluent_generated as fluent;
use rustc_errors::{
codes::*, AddToDiagnostic, Applicability, DecorateLint, Diag, DiagStyledString,
DiagnosticMessage, EmissionGuarantee, SubdiagnosticMessageOp, SuggestionStyle,
codes::*, AddToDiagnostic, Applicability, DecorateLint, Diag, DiagMessage, DiagStyledString,
EmissionGuarantee, SubdiagMessageOp, SuggestionStyle,
};
use rustc_hir::def_id::DefId;
use rustc_macros::{LintDiagnostic, Subdiagnostic};
@ -141,7 +141,7 @@ impl<'a> DecorateLint<'a, ()> for BuiltinMissingDebugImpl<'_> {
diag.arg("debug", self.tcx.def_path_str(self.def_id));
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
fluent::lint_builtin_missing_debug_impl
}
}
@ -251,7 +251,7 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
);
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
fluent::lint_ungated_async_fn_track_caller
}
}
@ -271,7 +271,7 @@ pub struct SuggestChangingAssocTypes<'a, 'b> {
}
impl<'a, 'b> AddToDiagnostic for SuggestChangingAssocTypes<'a, 'b> {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: F,
@ -327,7 +327,7 @@ pub struct BuiltinTypeAliasGenericBoundsSuggestion {
}
impl AddToDiagnostic for BuiltinTypeAliasGenericBoundsSuggestion {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: F,
@ -416,7 +416,7 @@ pub struct BuiltinFeatureIssueNote {
}
pub struct BuiltinUnpermittedTypeInit<'a> {
pub msg: DiagnosticMessage,
pub msg: DiagMessage,
pub ty: Ty<'a>,
pub label: Span,
pub sub: BuiltinUnpermittedTypeInitSub,
@ -437,7 +437,7 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
self.sub.add_to_diagnostic(diag);
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
self.msg.clone()
}
}
@ -448,7 +448,7 @@ pub struct BuiltinUnpermittedTypeInitSub {
}
impl AddToDiagnostic for BuiltinUnpermittedTypeInitSub {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: F,
@ -503,7 +503,7 @@ pub struct BuiltinClashingExternSub<'a> {
}
impl AddToDiagnostic for BuiltinClashingExternSub<'_> {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: F,
@ -785,7 +785,7 @@ pub struct HiddenUnicodeCodepointsDiagLabels {
}
impl AddToDiagnostic for HiddenUnicodeCodepointsDiagLabels {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: F,
@ -803,7 +803,7 @@ pub enum HiddenUnicodeCodepointsDiagSub {
// Used because of multiple multipart_suggestion and note
impl AddToDiagnostic for HiddenUnicodeCodepointsDiagSub {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: F,
@ -951,7 +951,7 @@ pub struct NonBindingLetSub {
}
impl AddToDiagnostic for NonBindingLetSub {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: F,
@ -1179,7 +1179,7 @@ impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
}
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
fluent::lint_non_fmt_panic_unused
}
}
@ -1237,7 +1237,7 @@ pub enum NonSnakeCaseDiagSub {
}
impl AddToDiagnostic for NonSnakeCaseDiagSub {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: F,
@ -1403,7 +1403,7 @@ impl<'a> DecorateLint<'a, ()> for DropTraitConstraintsDiag<'_> {
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
fluent::lint_drop_trait_constraints
}
}
@ -1419,7 +1419,7 @@ impl<'a> DecorateLint<'a, ()> for DropGlue<'_> {
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
fluent::lint_drop_glue
}
}
@ -1479,7 +1479,7 @@ pub enum OverflowingBinHexSign {
}
impl AddToDiagnostic for OverflowingBinHexSign {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_f: F,
@ -1683,12 +1683,12 @@ pub struct ImproperCTypes<'a> {
pub ty: Ty<'a>,
pub desc: &'a str,
pub label: Span,
pub help: Option<DiagnosticMessage>,
pub note: DiagnosticMessage,
pub help: Option<DiagMessage>,
pub note: DiagMessage,
pub span_note: Option<Span>,
}
// Used because of the complexity of Option<DiagnosticMessage>, DiagnosticMessage, and Option<Span>
// Used because of the complexity of Option<DiagMessage>, DiagMessage, and Option<Span>
impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
diag.arg("ty", self.ty);
@ -1703,7 +1703,7 @@ impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
}
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
fluent::lint_improper_ctypes
}
}
@ -1846,7 +1846,7 @@ impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
}
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
fluent::lint_unused_def
}
}
@ -1923,7 +1923,7 @@ impl<'a> DecorateLint<'a, ()> for AsyncFnInTraitDiag {
}
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
fluent::lint_async_fn_in_trait
}
}

View file

@ -14,7 +14,7 @@ use crate::{LateContext, LateLintPass, LintContext};
use rustc_ast as ast;
use rustc_attr as attr;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::DiagnosticMessage;
use rustc_errors::DiagMessage;
use rustc_hir as hir;
use rustc_hir::{is_range_literal, Expr, ExprKind, Node};
use rustc_middle::ty::layout::{IntegerExt, LayoutOf, SizeSkeleton};
@ -959,7 +959,7 @@ struct ImproperCTypesVisitor<'a, 'tcx> {
enum FfiResult<'tcx> {
FfiSafe,
FfiPhantom(Ty<'tcx>),
FfiUnsafe { ty: Ty<'tcx>, reason: DiagnosticMessage, help: Option<DiagnosticMessage> },
FfiUnsafe { ty: Ty<'tcx>, reason: DiagMessage, help: Option<DiagMessage> },
}
pub(crate) fn nonnull_optimization_guaranteed<'tcx>(
@ -1446,8 +1446,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
&mut self,
ty: Ty<'tcx>,
sp: Span,
note: DiagnosticMessage,
help: Option<DiagnosticMessage>,
note: DiagMessage,
help: Option<DiagMessage>,
) {
let lint = match self.mode {
CItemKind::Declaration => IMPROPER_CTYPES,