Rename `DiagnosticMessage` as `DiagMessage`.

This commit is contained in:
Nicholas Nethercote 2024-02-29 11:58:51 +11:00
parent d849f5c225
commit 18715c98c6
49 changed files with 253 additions and 261 deletions

View File

@ -16,8 +16,8 @@ use rustc_data_structures::sync::Lrc;
use rustc_errors::emitter::Emitter;
use rustc_errors::translation::Translate;
use rustc_errors::{
Diag, DiagArgMap, DiagCtxt, DiagnosticMessage, ErrCode, FatalError, FluentBundle, Level,
MultiSpan, Style,
Diag, DiagArgMap, DiagCtxt, DiagMessage, ErrCode, FatalError, FluentBundle, Level, MultiSpan,
Style,
};
use rustc_fs_util::link_or_copy;
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
@ -1015,7 +1015,7 @@ pub struct CguMessage;
// - `emitted_at`: not used for codegen diagnostics.
struct Diagnostic {
level: Level,
messages: Vec<(DiagnosticMessage, Style)>,
messages: Vec<(DiagMessage, Style)>,
code: Option<ErrCode>,
children: Vec<Subdiagnostic>,
args: DiagArgMap,
@ -1026,7 +1026,7 @@ struct Diagnostic {
// - `span`: it doesn't impl `Send`.
pub struct Subdiagnostic {
level: Level,
messages: Vec<(DiagnosticMessage, Style)>,
messages: Vec<(DiagMessage, Style)>,
}
#[derive(PartialEq, Clone, Copy, Debug)]

View File

@ -1,8 +1,6 @@
use std::mem;
use rustc_errors::{
DiagArgName, DiagArgValue, DiagnosticMessage, IntoDiagnostic, IntoDiagnosticArg,
};
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, IntoDiagnostic, IntoDiagnosticArg};
use rustc_hir::CRATE_HIR_ID;
use rustc_middle::mir::AssertKind;
use rustc_middle::query::TyCtxtAt;
@ -25,7 +23,7 @@ pub enum ConstEvalErrKind {
}
impl MachineStopType for ConstEvalErrKind {
fn diagnostic_message(&self) -> DiagnosticMessage {
fn diagnostic_message(&self) -> DiagMessage {
use crate::fluent_generated::*;
use ConstEvalErrKind::*;
match self {

View File

@ -1,8 +1,7 @@
use std::borrow::Cow;
use rustc_errors::{
codes::*, Diag, DiagArgValue, DiagCtxt, DiagnosticMessage, EmissionGuarantee, IntoDiagnostic,
Level,
codes::*, Diag, DiagArgValue, DiagCtxt, DiagMessage, EmissionGuarantee, IntoDiagnostic, Level,
};
use rustc_hir::ConstContext;
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
@ -424,7 +423,7 @@ pub struct UndefinedBehavior {
pub trait ReportErrorExt {
/// Returns the diagnostic message for this error.
fn diagnostic_message(&self) -> DiagnosticMessage;
fn diagnostic_message(&self) -> DiagMessage;
fn add_args<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>);
fn debug(self) -> String
@ -433,7 +432,7 @@ pub trait ReportErrorExt {
{
ty::tls::with(move |tcx| {
let dcx = tcx.dcx();
let mut diag = dcx.struct_allow(DiagnosticMessage::Str(String::new().into()));
let mut diag = dcx.struct_allow(DiagMessage::Str(String::new().into()));
let message = self.diagnostic_message();
self.add_args(&mut diag);
let s = dcx.eagerly_translate_to_string(message, diag.args.iter());
@ -457,7 +456,7 @@ fn bad_pointer_message(msg: CheckInAllocMsg, dcx: &DiagCtxt) -> String {
}
impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
fn diagnostic_message(&self) -> DiagnosticMessage {
fn diagnostic_message(&self) -> DiagMessage {
use crate::fluent_generated::*;
use UndefinedBehaviorInfo::*;
match self {
@ -595,7 +594,7 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
}
impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
fn diagnostic_message(&self) -> DiagnosticMessage {
fn diagnostic_message(&self) -> DiagMessage {
use crate::fluent_generated::*;
use rustc_middle::mir::interpret::ValidationErrorKind::*;
match self.kind {
@ -783,7 +782,7 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
}
impl ReportErrorExt for UnsupportedOpInfo {
fn diagnostic_message(&self) -> DiagnosticMessage {
fn diagnostic_message(&self) -> DiagMessage {
use crate::fluent_generated::*;
match self {
UnsupportedOpInfo::Unsupported(s) => s.clone().into(),
@ -819,7 +818,7 @@ impl ReportErrorExt for UnsupportedOpInfo {
}
impl<'tcx> ReportErrorExt for InterpError<'tcx> {
fn diagnostic_message(&self) -> DiagnosticMessage {
fn diagnostic_message(&self) -> DiagMessage {
match self {
InterpError::UndefinedBehavior(ub) => ub.diagnostic_message(),
InterpError::Unsupported(e) => e.diagnostic_message(),
@ -842,7 +841,7 @@ impl<'tcx> ReportErrorExt for InterpError<'tcx> {
}
impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> {
fn diagnostic_message(&self) -> DiagnosticMessage {
fn diagnostic_message(&self) -> DiagMessage {
use crate::fluent_generated::*;
match self {
InvalidProgramInfo::TooGeneric => const_eval_too_generic,
@ -877,7 +876,7 @@ impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> {
}
impl ReportErrorExt for ResourceExhaustionInfo {
fn diagnostic_message(&self) -> DiagnosticMessage {
fn diagnostic_message(&self) -> DiagMessage {
use crate::fluent_generated::*;
match self {
ResourceExhaustionInfo::StackFrameLimitReached => const_eval_stack_frame_limit_reached,

View File

@ -253,8 +253,8 @@ type FluentId = Cow<'static, str>;
/// translatable and non-translatable diagnostic messages.
///
/// Translatable messages for subdiagnostics are typically attributes attached to a larger Fluent
/// message so messages of this type must be combined with a `DiagnosticMessage` (using
/// `DiagnosticMessage::with_subdiagnostic_message`) before rendering. However, subdiagnostics from
/// message so messages of this type must be combined with a `DiagMessage` (using
/// `DiagMessage::with_subdiagnostic_message`) before rendering. However, subdiagnostics from
/// the `Subdiagnostic` derive refer to Fluent identifiers directly.
#[rustc_diagnostic_item = "SubdiagnosticMessage"]
pub enum SubdiagnosticMessage {
@ -265,7 +265,7 @@ pub enum SubdiagnosticMessage {
/// Some diagnostics have repeated subdiagnostics where the same interpolated variables would
/// be instantiated multiple times with different values. These subdiagnostics' messages
/// are translated when they are added to the parent diagnostic, producing this variant of
/// `DiagnosticMessage`.
/// `DiagMessage`.
Translated(Cow<'static, str>),
/// Identifier of a Fluent message. Instances of this variant are generated by the
/// `Subdiagnostic` derive.
@ -299,8 +299,8 @@ impl From<Cow<'static, str>> for SubdiagnosticMessage {
///
/// Intended to be removed once diagnostics are entirely translatable.
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
#[rustc_diagnostic_item = "DiagnosticMessage"]
pub enum DiagnosticMessage {
#[rustc_diagnostic_item = "DiagMessage"]
pub enum DiagMessage {
/// Non-translatable diagnostic message.
Str(Cow<'static, str>),
/// Translatable message which has been already translated.
@ -308,7 +308,7 @@ pub enum DiagnosticMessage {
/// Some diagnostics have repeated subdiagnostics where the same interpolated variables would
/// be instantiated multiple times with different values. These subdiagnostics' messages
/// are translated when they are added to the parent diagnostic, producing this variant of
/// `DiagnosticMessage`.
/// `DiagMessage`.
Translated(Cow<'static, str>),
/// Identifier for a Fluent message (with optional attribute) corresponding to the diagnostic
/// message. Yet to be translated.
@ -318,85 +318,81 @@ pub enum DiagnosticMessage {
FluentIdentifier(FluentId, Option<FluentId>),
}
impl DiagnosticMessage {
impl DiagMessage {
/// Given a `SubdiagnosticMessage` which may contain a Fluent attribute, create a new
/// `DiagnosticMessage` that combines that attribute with the Fluent identifier of `self`.
/// `DiagMessage` that combines that attribute with the Fluent identifier of `self`.
///
/// - If the `SubdiagnosticMessage` is non-translatable then return the message as a
/// `DiagnosticMessage`.
/// `DiagMessage`.
/// - If `self` is non-translatable then return `self`'s message.
pub fn with_subdiagnostic_message(&self, sub: SubdiagnosticMessage) -> Self {
let attr = match sub {
SubdiagnosticMessage::Str(s) => return DiagnosticMessage::Str(s),
SubdiagnosticMessage::Translated(s) => return DiagnosticMessage::Translated(s),
SubdiagnosticMessage::Str(s) => return DiagMessage::Str(s),
SubdiagnosticMessage::Translated(s) => return DiagMessage::Translated(s),
SubdiagnosticMessage::FluentIdentifier(id) => {
return DiagnosticMessage::FluentIdentifier(id, None);
return DiagMessage::FluentIdentifier(id, None);
}
SubdiagnosticMessage::FluentAttr(attr) => attr,
};
match self {
DiagnosticMessage::Str(s) => DiagnosticMessage::Str(s.clone()),
DiagnosticMessage::Translated(s) => DiagnosticMessage::Translated(s.clone()),
DiagnosticMessage::FluentIdentifier(id, _) => {
DiagnosticMessage::FluentIdentifier(id.clone(), Some(attr))
DiagMessage::Str(s) => DiagMessage::Str(s.clone()),
DiagMessage::Translated(s) => DiagMessage::Translated(s.clone()),
DiagMessage::FluentIdentifier(id, _) => {
DiagMessage::FluentIdentifier(id.clone(), Some(attr))
}
}
}
pub fn as_str(&self) -> Option<&str> {
match self {
DiagnosticMessage::Translated(s) | DiagnosticMessage::Str(s) => Some(s),
DiagnosticMessage::FluentIdentifier(_, _) => None,
DiagMessage::Translated(s) | DiagMessage::Str(s) => Some(s),
DiagMessage::FluentIdentifier(_, _) => None,
}
}
}
impl From<String> for DiagnosticMessage {
impl From<String> for DiagMessage {
fn from(s: String) -> Self {
DiagnosticMessage::Str(Cow::Owned(s))
DiagMessage::Str(Cow::Owned(s))
}
}
impl From<&'static str> for DiagnosticMessage {
impl From<&'static str> for DiagMessage {
fn from(s: &'static str) -> Self {
DiagnosticMessage::Str(Cow::Borrowed(s))
DiagMessage::Str(Cow::Borrowed(s))
}
}
impl From<Cow<'static, str>> for DiagnosticMessage {
impl From<Cow<'static, str>> for DiagMessage {
fn from(s: Cow<'static, str>) -> Self {
DiagnosticMessage::Str(s)
DiagMessage::Str(s)
}
}
/// A workaround for must_produce_diag ICEs when formatting types in disabled lints.
///
/// Delays formatting until `.into(): DiagnosticMessage` is used.
/// Delays formatting until `.into(): DiagMessage` is used.
pub struct DelayDm<F>(pub F);
impl<F: FnOnce() -> String> From<DelayDm<F>> for DiagnosticMessage {
impl<F: FnOnce() -> String> From<DelayDm<F>> for DiagMessage {
fn from(DelayDm(f): DelayDm<F>) -> Self {
DiagnosticMessage::from(f())
DiagMessage::from(f())
}
}
/// Translating *into* a subdiagnostic message from a diagnostic message is a little strange - but
/// the subdiagnostic functions (e.g. `span_label`) take a `SubdiagnosticMessage` and the
/// subdiagnostic derive refers to typed identifiers that are `DiagnosticMessage`s, so need to be
/// able to convert between these, as much as they'll be converted back into `DiagnosticMessage`
/// subdiagnostic derive refers to typed identifiers that are `DiagMessage`s, so need to be
/// able to convert between these, as much as they'll be converted back into `DiagMessage`
/// using `with_subdiagnostic_message` eventually. Don't use this other than for the derive.
impl Into<SubdiagnosticMessage> for DiagnosticMessage {
impl Into<SubdiagnosticMessage> for DiagMessage {
fn into(self) -> SubdiagnosticMessage {
match self {
DiagnosticMessage::Str(s) => SubdiagnosticMessage::Str(s),
DiagnosticMessage::Translated(s) => SubdiagnosticMessage::Translated(s),
DiagnosticMessage::FluentIdentifier(id, None) => {
SubdiagnosticMessage::FluentIdentifier(id)
}
DiagMessage::Str(s) => SubdiagnosticMessage::Str(s),
DiagMessage::Translated(s) => SubdiagnosticMessage::Translated(s),
DiagMessage::FluentIdentifier(id, None) => SubdiagnosticMessage::FluentIdentifier(id),
// There isn't really a sensible behaviour for this because it loses information but
// this is the most sensible of the behaviours.
DiagnosticMessage::FluentIdentifier(_, Some(attr)) => {
SubdiagnosticMessage::FluentAttr(attr)
}
DiagMessage::FluentIdentifier(_, Some(attr)) => SubdiagnosticMessage::FluentAttr(attr),
}
}
}
@ -412,7 +408,7 @@ pub struct SpanLabel {
pub is_primary: bool,
/// What label should we attach to this span (if any)?
pub label: Option<DiagnosticMessage>,
pub label: Option<DiagMessage>,
}
/// A collection of `Span`s.
@ -426,7 +422,7 @@ pub struct SpanLabel {
#[derive(Clone, Debug, Hash, PartialEq, Eq, Encodable, Decodable)]
pub struct MultiSpan {
primary_spans: Vec<Span>,
span_labels: Vec<(Span, DiagnosticMessage)>,
span_labels: Vec<(Span, DiagMessage)>,
}
impl MultiSpan {
@ -444,7 +440,7 @@ impl MultiSpan {
MultiSpan { primary_spans: vec, span_labels: vec![] }
}
pub fn push_span_label(&mut self, span: Span, label: impl Into<DiagnosticMessage>) {
pub fn push_span_label(&mut self, span: Span, label: impl Into<DiagMessage>) {
self.span_labels.push((span, label.into()));
}
@ -487,7 +483,7 @@ impl MultiSpan {
replacements_occurred
}
pub fn pop_span_label(&mut self) -> Option<(Span, DiagnosticMessage)> {
pub fn pop_span_label(&mut self) -> Option<(Span, DiagMessage)> {
self.span_labels.pop()
}

View File

@ -9,8 +9,8 @@ use crate::emitter::FileWithAnnotatedLines;
use crate::snippet::Line;
use crate::translation::{to_fluent_args, Translate};
use crate::{
CodeSuggestion, DiagInner, DiagnosticMessage, Emitter, ErrCode, FluentBundle,
LazyFallbackBundle, Level, MultiSpan, Style, Subdiag,
CodeSuggestion, DiagInner, DiagMessage, Emitter, ErrCode, FluentBundle, LazyFallbackBundle,
Level, MultiSpan, Style, Subdiag,
};
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
use rustc_data_structures::sync::Lrc;
@ -125,7 +125,7 @@ impl AnnotateSnippetEmitter {
fn emit_messages_default(
&mut self,
level: &Level,
messages: &[(DiagnosticMessage, Style)],
messages: &[(DiagMessage, Style)],
args: &FluentArgs<'_>,
code: &Option<ErrCode>,
msp: &MultiSpan,

View File

@ -1,7 +1,7 @@
use crate::snippet::Style;
use crate::{
CodeSuggestion, DiagCtxt, DiagnosticMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level,
MultiSpan, StashKey, SubdiagnosticMessage, Substitution, SubstitutionPart, SuggestionStyle,
CodeSuggestion, DiagCtxt, DiagMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level, MultiSpan,
StashKey, SubdiagnosticMessage, Substitution, SubstitutionPart, SuggestionStyle,
};
use rustc_data_structures::fx::FxIndexMap;
use rustc_error_messages::fluent_value_from_str_list_sep_by_and;
@ -199,7 +199,7 @@ pub trait DecorateLint<'a, G: EmissionGuarantee> {
/// Decorate and emit a lint.
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>);
fn msg(&self) -> DiagnosticMessage;
fn msg(&self) -> DiagMessage;
}
#[derive(Clone, Debug, Encodable, Decodable)]
@ -291,7 +291,7 @@ pub struct DiagInner {
// outside of what methods in this crate themselves allow.
pub(crate) level: Level,
pub messages: Vec<(DiagnosticMessage, Style)>,
pub messages: Vec<(DiagMessage, Style)>,
pub code: Option<ErrCode>,
pub span: MultiSpan,
pub children: Vec<Subdiag>,
@ -312,12 +312,12 @@ pub struct DiagInner {
impl DiagInner {
#[track_caller]
pub fn new<M: Into<DiagnosticMessage>>(level: Level, message: M) -> Self {
pub fn new<M: Into<DiagMessage>>(level: Level, message: M) -> Self {
DiagInner::new_with_messages(level, vec![(message.into(), Style::NoStyle)])
}
#[track_caller]
pub fn new_with_messages(level: Level, messages: Vec<(DiagnosticMessage, Style)>) -> Self {
pub fn new_with_messages(level: Level, messages: Vec<(DiagMessage, Style)>) -> Self {
DiagInner {
level,
messages,
@ -397,7 +397,7 @@ impl DiagInner {
pub(crate) fn subdiagnostic_message_to_diagnostic_message(
&self,
attr: impl Into<SubdiagnosticMessage>,
) -> DiagnosticMessage {
) -> DiagMessage {
let msg =
self.messages.iter().map(|(msg, _)| msg).next().expect("diagnostic with no messages");
msg.with_subdiagnostic_message(attr.into())
@ -429,7 +429,7 @@ impl DiagInner {
&self,
) -> (
&Level,
&[(DiagnosticMessage, Style)],
&[(DiagMessage, Style)],
&Option<ErrCode>,
&MultiSpan,
&[Subdiag],
@ -472,7 +472,7 @@ impl PartialEq for DiagInner {
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
pub struct Subdiag {
pub level: Level,
pub messages: Vec<(DiagnosticMessage, Style)>,
pub messages: Vec<(DiagMessage, Style)>,
pub span: MultiSpan,
}
@ -578,7 +578,7 @@ macro_rules! with_fn {
impl<'a, G: EmissionGuarantee> Diag<'a, G> {
#[rustc_lint_diagnostics]
#[track_caller]
pub fn new<M: Into<DiagnosticMessage>>(dcx: &'a DiagCtxt, level: Level, message: M) -> Self {
pub fn new<M: Into<DiagMessage>>(dcx: &'a DiagCtxt, level: Level, message: M) -> Self {
Self::new_diagnostic(dcx, DiagInner::new(level, message))
}
@ -1203,7 +1203,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
with_fn! { with_primary_message,
/// Add a primary message.
pub fn primary_message(&mut self, msg: impl Into<DiagnosticMessage>) -> &mut Self {
pub fn primary_message(&mut self, msg: impl Into<DiagMessage>) -> &mut Self {
self.messages[0] = (msg.into(), Style::NoStyle);
self
} }
@ -1219,13 +1219,13 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self
} }
/// Helper function that takes a `SubdiagnosticMessage` and returns a `DiagnosticMessage` by
/// Helper function that takes a `SubdiagnosticMessage` and returns a `DiagMessage` by
/// combining it with the primary message of the diagnostic (if translatable, otherwise it just
/// passes the user's string along).
pub(crate) fn subdiagnostic_message_to_diagnostic_message(
&self,
attr: impl Into<SubdiagnosticMessage>,
) -> DiagnosticMessage {
) -> DiagMessage {
self.deref().subdiagnostic_message_to_diagnostic_message(attr)
}
@ -1338,7 +1338,7 @@ impl<G: EmissionGuarantee> Drop for Diag<'_, G> {
Some(diag) if !panicking() => {
self.dcx.emit_diagnostic(DiagInner::new(
Level::Bug,
DiagnosticMessage::from("the following error was constructed but not emitted"),
DiagMessage::from("the following error was constructed but not emitted"),
));
self.dcx.emit_diagnostic(*diag);
panic!("error was constructed but not emitted");

View File

@ -17,7 +17,7 @@ use crate::snippet::{
use crate::styled_buffer::StyledBuffer;
use crate::translation::{to_fluent_args, Translate};
use crate::{
diagnostic::DiagLocation, CodeSuggestion, DiagCtxt, DiagInner, DiagnosticMessage, ErrCode,
diagnostic::DiagLocation, CodeSuggestion, DiagCtxt, DiagInner, DiagMessage, ErrCode,
FluentBundle, LazyFallbackBundle, Level, MultiSpan, Subdiag, SubstitutionHighlight,
SuggestionStyle, TerminalUrl,
};
@ -339,7 +339,7 @@ pub trait Emitter: Translate {
children.push(Subdiag {
level: Level::Note,
messages: vec![(DiagnosticMessage::from(msg), Style::NoStyle)],
messages: vec![(DiagMessage::from(msg), Style::NoStyle)],
span: MultiSpan::new(),
});
}
@ -543,12 +543,10 @@ pub struct SilentEmitter {
pub fatal_note: String,
}
pub fn silent_translate<'a>(
message: &'a DiagnosticMessage,
) -> Result<Cow<'_, str>, TranslateError<'_>> {
pub fn silent_translate<'a>(message: &'a DiagMessage) -> Result<Cow<'_, str>, TranslateError<'_>> {
match message {
DiagnosticMessage::Str(msg) | DiagnosticMessage::Translated(msg) => Ok(Cow::Borrowed(msg)),
DiagnosticMessage::FluentIdentifier(identifier, _) => {
DiagMessage::Str(msg) | DiagMessage::Translated(msg) => Ok(Cow::Borrowed(msg)),
DiagMessage::FluentIdentifier(identifier, _) => {
// Any value works here.
Ok(identifier.clone())
}
@ -568,7 +566,7 @@ impl Translate for SilentEmitter {
// subdiagnostics result in a call to this.
fn translate_message<'a>(
&'a self,
message: &'a DiagnosticMessage,
message: &'a DiagMessage,
_: &'a FluentArgs<'_>,
) -> Result<Cow<'_, str>, TranslateError<'_>> {
silent_translate(message)
@ -1216,7 +1214,7 @@ impl HumanEmitter {
fn msgs_to_buffer(
&self,
buffer: &mut StyledBuffer,
msgs: &[(DiagnosticMessage, Style)],
msgs: &[(DiagMessage, Style)],
args: &FluentArgs<'_>,
padding: usize,
label: &str,
@ -1291,7 +1289,7 @@ impl HumanEmitter {
fn emit_messages_default_inner(
&mut self,
msp: &MultiSpan,
msgs: &[(DiagnosticMessage, Style)],
msgs: &[(DiagMessage, Style)],
args: &FluentArgs<'_>,
code: &Option<ErrCode>,
level: &Level,
@ -2060,7 +2058,7 @@ impl HumanEmitter {
fn emit_messages_default(
&mut self,
level: &Level,
messages: &[(DiagnosticMessage, Style)],
messages: &[(DiagMessage, Style)],
args: &FluentArgs<'_>,
code: &Option<ErrCode>,
span: &MultiSpan,

View File

@ -47,8 +47,8 @@ pub use diagnostic_impls::{
};
pub use emitter::ColorConfig;
pub use rustc_error_messages::{
fallback_fluent_bundle, fluent_bundle, DelayDm, DiagnosticMessage, FluentBundle,
LanguageIdentifier, LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagnosticMessage,
fallback_fluent_bundle, fluent_bundle, DelayDm, DiagMessage, FluentBundle, LanguageIdentifier,
LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagnosticMessage,
};
pub use rustc_lint_defs::{pluralize, Applicability};
pub use rustc_span::fatal_error::{FatalError, FatalErrorMarker};
@ -154,7 +154,7 @@ pub struct CodeSuggestion {
/// ]
/// ```
pub substitutions: Vec<Substitution>,
pub msg: DiagnosticMessage,
pub msg: DiagMessage,
/// Visual representation of this suggestion.
pub style: SuggestionStyle,
/// Whether or not the suggestion is approximate
@ -634,7 +634,7 @@ impl DiagCtxt {
/// Translate `message` eagerly with `args` to `SubdiagnosticMessage::Eager`.
pub fn eagerly_translate<'a>(
&self,
message: DiagnosticMessage,
message: DiagMessage,
args: impl Iterator<Item = DiagArg<'a>>,
) -> SubdiagnosticMessage {
let inner = self.inner.borrow();
@ -644,7 +644,7 @@ impl DiagCtxt {
/// Translate `message` eagerly with `args` to `String`.
pub fn eagerly_translate_to_string<'a>(
&self,
message: DiagnosticMessage,
message: DiagMessage,
args: impl Iterator<Item = DiagArg<'a>>,
) -> String {
let inner = self.inner.borrow();
@ -904,7 +904,7 @@ impl DiagCtxt {
// configuration like `--cap-lints allow --force-warn bare_trait_objects`.
inner.emit_diagnostic(DiagInner::new(
ForceWarning(None),
DiagnosticMessage::Str(warnings),
DiagMessage::Str(warnings),
));
}
(_, 0) => {
@ -1078,13 +1078,13 @@ impl DiagCtxt {
impl DiagCtxt {
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
#[track_caller]
pub fn struct_bug(&self, msg: impl Into<DiagnosticMessage>) -> Diag<'_, BugAbort> {
pub fn struct_bug(&self, msg: impl Into<DiagMessage>) -> Diag<'_, BugAbort> {
Diag::new(self, Bug, msg)
}
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
#[track_caller]
pub fn bug(&self, msg: impl Into<DiagnosticMessage>) -> ! {
pub fn bug(&self, msg: impl Into<DiagMessage>) -> ! {
self.struct_bug(msg).emit()
}
@ -1093,14 +1093,14 @@ impl DiagCtxt {
pub fn struct_span_bug(
&self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
) -> Diag<'_, BugAbort> {
self.struct_bug(msg).with_span(span)
}
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
#[track_caller]
pub fn span_bug(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
pub fn span_bug(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) -> ! {
self.struct_span_bug(span, msg).emit()
}
@ -1116,13 +1116,13 @@ impl DiagCtxt {
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> Diag<'_, FatalAbort> {
pub fn struct_fatal(&self, msg: impl Into<DiagMessage>) -> Diag<'_, FatalAbort> {
Diag::new(self, Fatal, msg)
}
#[rustc_lint_diagnostics]
#[track_caller]
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
pub fn fatal(&self, msg: impl Into<DiagMessage>) -> ! {
self.struct_fatal(msg).emit()
}
@ -1131,14 +1131,14 @@ impl DiagCtxt {
pub fn struct_span_fatal(
&self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
) -> Diag<'_, FatalAbort> {
self.struct_fatal(msg).with_span(span)
}
#[rustc_lint_diagnostics]
#[track_caller]
pub fn span_fatal(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
pub fn span_fatal(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) -> ! {
self.struct_span_fatal(span, msg).emit()
}
@ -1174,13 +1174,13 @@ impl DiagCtxt {
// FIXME: This method should be removed (every error should have an associated error code).
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_err(&self, msg: impl Into<DiagnosticMessage>) -> Diag<'_> {
pub fn struct_err(&self, msg: impl Into<DiagMessage>) -> Diag<'_> {
Diag::new(self, Error, msg)
}
#[rustc_lint_diagnostics]
#[track_caller]
pub fn err(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed {
pub fn err(&self, msg: impl Into<DiagMessage>) -> ErrorGuaranteed {
self.struct_err(msg).emit()
}
@ -1189,7 +1189,7 @@ impl DiagCtxt {
pub fn struct_span_err(
&self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
) -> Diag<'_> {
self.struct_err(msg).with_span(span)
}
@ -1199,7 +1199,7 @@ impl DiagCtxt {
pub fn span_err(
&self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
) -> ErrorGuaranteed {
self.struct_span_err(span, msg).emit()
}
@ -1217,7 +1217,7 @@ impl DiagCtxt {
/// Ensures that an error is printed. See `Level::DelayedBug`.
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
#[track_caller]
pub fn delayed_bug(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed {
pub fn delayed_bug(&self, msg: impl Into<DiagMessage>) -> ErrorGuaranteed {
Diag::<ErrorGuaranteed>::new(self, DelayedBug, msg).emit()
}
@ -1230,20 +1230,20 @@ impl DiagCtxt {
pub fn span_delayed_bug(
&self,
sp: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
) -> ErrorGuaranteed {
Diag::<ErrorGuaranteed>::new(self, DelayedBug, msg).with_span(sp).emit()
}
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> Diag<'_, ()> {
pub fn struct_warn(&self, msg: impl Into<DiagMessage>) -> Diag<'_, ()> {
Diag::new(self, Warning, msg)
}
#[rustc_lint_diagnostics]
#[track_caller]
pub fn warn(&self, msg: impl Into<DiagnosticMessage>) {
pub fn warn(&self, msg: impl Into<DiagMessage>) {
self.struct_warn(msg).emit()
}
@ -1252,14 +1252,14 @@ impl DiagCtxt {
pub fn struct_span_warn(
&self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
) -> Diag<'_, ()> {
self.struct_warn(msg).with_span(span)
}
#[rustc_lint_diagnostics]
#[track_caller]
pub fn span_warn(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) {
pub fn span_warn(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
self.struct_span_warn(span, msg).emit()
}
@ -1275,13 +1275,13 @@ impl DiagCtxt {
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_note(&self, msg: impl Into<DiagnosticMessage>) -> Diag<'_, ()> {
pub fn struct_note(&self, msg: impl Into<DiagMessage>) -> Diag<'_, ()> {
Diag::new(self, Note, msg)
}
#[rustc_lint_diagnostics]
#[track_caller]
pub fn note(&self, msg: impl Into<DiagnosticMessage>) {
pub fn note(&self, msg: impl Into<DiagMessage>) {
self.struct_note(msg).emit()
}
@ -1290,14 +1290,14 @@ impl DiagCtxt {
pub fn struct_span_note(
&self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
) -> Diag<'_, ()> {
self.struct_note(msg).with_span(span)
}
#[rustc_lint_diagnostics]
#[track_caller]
pub fn span_note(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) {
pub fn span_note(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
self.struct_span_note(span, msg).emit()
}
@ -1313,19 +1313,19 @@ impl DiagCtxt {
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_help(&self, msg: impl Into<DiagnosticMessage>) -> Diag<'_, ()> {
pub fn struct_help(&self, msg: impl Into<DiagMessage>) -> Diag<'_, ()> {
Diag::new(self, Help, msg)
}
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_failure_note(&self, msg: impl Into<DiagnosticMessage>) -> Diag<'_, ()> {
pub fn struct_failure_note(&self, msg: impl Into<DiagMessage>) -> Diag<'_, ()> {
Diag::new(self, FailureNote, msg)
}
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_allow(&self, msg: impl Into<DiagnosticMessage>) -> Diag<'_, ()> {
pub fn struct_allow(&self, msg: impl Into<DiagMessage>) -> Diag<'_, ()> {
Diag::new(self, Allow, msg)
}
@ -1333,7 +1333,7 @@ impl DiagCtxt {
#[track_caller]
pub fn struct_expect(
&self,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
id: LintExpectationId,
) -> Diag<'_, ()> {
Diag::new(self, Expect(id), msg)
@ -1556,7 +1556,7 @@ impl DiagCtxtInner {
/// Translate `message` eagerly with `args` to `SubdiagnosticMessage::Eager`.
pub fn eagerly_translate<'a>(
&self,
message: DiagnosticMessage,
message: DiagMessage,
args: impl Iterator<Item = DiagArg<'a>>,
) -> SubdiagnosticMessage {
SubdiagnosticMessage::Translated(Cow::from(self.eagerly_translate_to_string(message, args)))
@ -1565,7 +1565,7 @@ impl DiagCtxtInner {
/// Translate `message` eagerly with `args` to `String`.
pub fn eagerly_translate_to_string<'a>(
&self,
message: DiagnosticMessage,
message: DiagMessage,
args: impl Iterator<Item = DiagArg<'a>>,
) -> String {
let args = crate::translation::to_fluent_args(args);

View File

@ -5,7 +5,7 @@ use crate::FluentBundle;
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError};
use rustc_error_messages::langid;
use rustc_error_messages::DiagnosticMessage;
use rustc_error_messages::DiagMessage;
struct Dummy {
bundle: FluentBundle,
@ -53,7 +53,7 @@ fn wellformed_fluent() {
args.set("name", "Foo");
args.set("ty", "std::string::String");
{
let message = DiagnosticMessage::FluentIdentifier(
let message = DiagMessage::FluentIdentifier(
"mir_build_borrow_of_moved_value".into(),
Some("suggestion".into()),
);
@ -65,7 +65,7 @@ fn wellformed_fluent() {
}
{
let message = DiagnosticMessage::FluentIdentifier(
let message = DiagMessage::FluentIdentifier(
"mir_build_borrow_of_moved_value".into(),
Some("value_borrowed_label".into()),
);
@ -77,7 +77,7 @@ fn wellformed_fluent() {
}
{
let message = DiagnosticMessage::FluentIdentifier(
let message = DiagMessage::FluentIdentifier(
"mir_build_borrow_of_moved_value".into(),
Some("occurs_because_label".into()),
);
@ -88,7 +88,7 @@ fn wellformed_fluent() {
);
{
let message = DiagnosticMessage::FluentIdentifier(
let message = DiagMessage::FluentIdentifier(
"mir_build_borrow_of_moved_value".into(),
Some("label".into()),
);
@ -112,7 +112,7 @@ fn misformed_fluent() {
args.set("name", "Foo");
args.set("ty", "std::string::String");
{
let message = DiagnosticMessage::FluentIdentifier(
let message = DiagMessage::FluentIdentifier(
"mir_build_borrow_of_moved_value".into(),
Some("value_borrowed_label".into()),
);
@ -141,7 +141,7 @@ fn misformed_fluent() {
}
{
let message = DiagnosticMessage::FluentIdentifier(
let message = DiagMessage::FluentIdentifier(
"mir_build_borrow_of_moved_value".into(),
Some("label".into()),
);
@ -168,7 +168,7 @@ fn misformed_fluent() {
}
{
let message = DiagnosticMessage::FluentIdentifier(
let message = DiagMessage::FluentIdentifier(
"mir_build_borrow_of_moved_value".into(),
Some("occurs_because_label".into()),
);

View File

@ -1,6 +1,6 @@
use crate::error::{TranslateError, TranslateErrorKind};
use crate::snippet::Style;
use crate::{DiagArg, DiagnosticMessage, FluentBundle};
use crate::{DiagArg, DiagMessage, FluentBundle};
use rustc_data_structures::sync::Lrc;
pub use rustc_error_messages::FluentArgs;
use std::borrow::Cow;
@ -37,10 +37,10 @@ pub trait Translate {
/// unavailable for the requested locale.
fn fallback_fluent_bundle(&self) -> &FluentBundle;
/// Convert `DiagnosticMessage`s to a string, performing translation if necessary.
/// Convert `DiagMessage`s to a string, performing translation if necessary.
fn translate_messages(
&self,
messages: &[(DiagnosticMessage, Style)],
messages: &[(DiagMessage, Style)],
args: &FluentArgs<'_>,
) -> Cow<'_, str> {
Cow::Owned(
@ -51,18 +51,18 @@ pub trait Translate {
)
}
/// Convert a `DiagnosticMessage` to a string, performing translation if necessary.
/// Convert a `DiagMessage` to a string, performing translation if necessary.
fn translate_message<'a>(
&'a self,
message: &'a DiagnosticMessage,
message: &'a DiagMessage,
args: &'a FluentArgs<'_>,
) -> Result<Cow<'_, str>, TranslateError<'_>> {
trace!(?message, ?args);
let (identifier, attr) = match message {
DiagnosticMessage::Str(msg) | DiagnosticMessage::Translated(msg) => {
DiagMessage::Str(msg) | DiagMessage::Translated(msg) => {
return Ok(Cow::Borrowed(msg));
}
DiagnosticMessage::FluentIdentifier(identifier, attr) => (identifier, attr),
DiagMessage::FluentIdentifier(identifier, attr) => (identifier, attr),
};
let translate_with_bundle =
|bundle: &'a FluentBundle| -> Result<Cow<'_, str>, TranslateError<'_>> {

View File

@ -7,7 +7,7 @@ use crate::mbe::{
use rustc_ast::token::{self, Token, TokenKind};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, Diag, DiagCtxt, DiagnosticMessage};
use rustc_errors::{Applicability, Diag, DiagCtxt, DiagMessage};
use rustc_parse::parser::{Parser, Recovery};
use rustc_span::source_map::SourceMap;
use rustc_span::symbol::Ident;
@ -227,12 +227,12 @@ pub(super) fn emit_frag_parse_err(
) -> ErrorGuaranteed {
// FIXME(davidtwco): avoid depending on the error message text
if parser.token == token::Eof
&& let DiagnosticMessage::Str(message) = &e.messages[0].0
&& let DiagMessage::Str(message) = &e.messages[0].0
&& message.ends_with(", found `<eof>`")
{
let msg = &e.messages[0];
e.messages[0] = (
DiagnosticMessage::from(format!(
DiagMessage::from(format!(
"macro expansion ends with an incomplete expression: {}",
message.replace(", found `<eof>`", ""),
)),

View File

@ -110,7 +110,7 @@ use crate::mbe::{KleeneToken, TokenTree};
use rustc_ast::token::{Delimiter, IdentIsRaw, Token, TokenKind};
use rustc_ast::{NodeId, DUMMY_NODE_ID};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{DiagnosticMessage, MultiSpan};
use rustc_errors::{DiagMessage, MultiSpan};
use rustc_session::lint::builtin::{META_VARIABLE_MISUSE, MISSING_FRAGMENT_SPECIFIER};
use rustc_session::parse::ParseSess;
use rustc_span::symbol::kw;
@ -648,7 +648,7 @@ fn buffer_lint(
psess: &ParseSess,
span: MultiSpan,
node_id: NodeId,
message: impl Into<DiagnosticMessage>,
message: impl Into<DiagMessage>,
) {
// Macros loaded from other crates have dummy node ids.
if node_id != DUMMY_NODE_ID {

View File

@ -512,7 +512,7 @@ impl server::FreeFunctions for Rustc<'_, '_> {
}
fn emit_diagnostic(&mut self, diagnostic: Diagnostic<Self::Span>) {
let message = rustc_errors::DiagnosticMessage::from(diagnostic.message);
let message = rustc_errors::DiagMessage::from(diagnostic.message);
let mut diag: Diag<'_, ()> =
Diag::new(&self.psess().dcx, diagnostic.level.to_internal(), message);
diag.span(MultiSpan::from_spans(diagnostic.spans));

View File

@ -244,8 +244,11 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
format!("Constant referring to Fluent message `{name}` from `{crate_name}`");
constants.extend(quote! {
#[doc = #docstr]
pub const #snake_name: rustc_errors::DiagnosticMessage =
rustc_errors::DiagnosticMessage::FluentIdentifier(std::borrow::Cow::Borrowed(#name), None);
pub const #snake_name: rustc_errors::DiagMessage =
rustc_errors::DiagMessage::FluentIdentifier(
std::borrow::Cow::Borrowed(#name),
None
);
});
for Attribute { id: Identifier { name: attr_name }, .. } in attributes {

View File

@ -35,10 +35,10 @@ mod fluent;
///
/// mod fluent_generated {
/// mod typeck {
/// pub const field_multiply_specified_in_initializer: DiagnosticMessage =
/// DiagnosticMessage::fluent("typeck_field_multiply_specified_in_initializer");
/// pub const field_multiply_specified_in_initializer_label_previous_use: DiagnosticMessage =
/// DiagnosticMessage::fluent_attr(
/// pub const field_multiply_specified_in_initializer: DiagMessage =
/// DiagMessage::fluent("typeck_field_multiply_specified_in_initializer");
/// pub const field_multiply_specified_in_initializer_label_previous_use: DiagMessage =
/// DiagMessage::fluent_attr(
/// "typeck_field_multiply_specified_in_initializer",
/// "previous_use_label"
/// );

View File

@ -7,7 +7,7 @@ use crate::errors::{
WrongNumberOfGenericArgumentsToIntrinsic,
};
use rustc_errors::{codes::*, struct_span_code_err, DiagnosticMessage};
use rustc_errors::{codes::*, struct_span_code_err, DiagMessage};
use rustc_hir as hir;
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::{self, Ty, TyCtxt};
@ -139,7 +139,7 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -
if has_safe_attr != is_in_list {
tcx.dcx().struct_span_err(
tcx.def_span(intrinsic_id),
DiagnosticMessage::from(format!(
DiagMessage::from(format!(
"intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `{}`",
tcx.item_name(intrinsic_id.into())
)

View File

@ -1,6 +1,6 @@
use hir::GenericParamKind;
use rustc_errors::{
codes::*, AddToDiagnostic, Applicability, Diag, DiagStyledString, DiagnosticMessage,
codes::*, AddToDiagnostic, Applicability, Diag, DiagMessage, DiagStyledString,
EmissionGuarantee, IntoDiagnosticArg, MultiSpan, SubdiagnosticMessageOp,
};
use rustc_hir as hir;
@ -209,11 +209,11 @@ impl<'a> SourceKindMultiSuggestion<'a> {
pub enum RegionOriginNote<'a> {
Plain {
span: Span,
msg: DiagnosticMessage,
msg: DiagMessage,
},
WithName {
span: Span,
msg: DiagnosticMessage,
msg: DiagMessage,
name: &'a str,
continues: bool,
},
@ -230,7 +230,7 @@ impl AddToDiagnostic for RegionOriginNote<'_> {
diag: &mut Diag<'_, G>,
_f: F,
) {
let mut label_or_note = |span, msg: DiagnosticMessage| {
let mut label_or_note = |span, msg: DiagMessage| {
let sub_count = diag.children.iter().filter(|d| d.span.is_dummy()).count();
let expanded_sub_count = diag.children.iter().filter(|d| !d.span.is_dummy()).count();
let span_is_primary = diag.span.primary_spans().iter().all(|&sp| sp == span);
@ -766,7 +766,7 @@ impl AddToDiagnostic for ConsiderBorrowingParamHelp {
) {
let mut type_param_span: MultiSpan = self.spans.clone().into();
for &span in &self.spans {
// Seems like we can't call f() here as Into<DiagnosticMessage> is required
// Seems like we can't call f() here as Into<DiagMessage> is required
type_param_span.push_span_label(span, fluent::infer_tid_consider_borrowing);
}
let msg = f(diag, fluent::infer_tid_param_help.into());

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;
@ -536,7 +536,7 @@ 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,
) {
@ -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

@ -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::SubdiagnosticMessage)
{
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, SubdiagnosticMessageOp, 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
}
}
@ -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()
}
}
@ -1179,7 +1179,7 @@ impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
}
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
fluent::lint_non_fmt_panic_unused
}
}
@ -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
}
}
@ -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,

View File

@ -8,7 +8,7 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::stable_hasher::{
HashStable, StableCompare, StableHasher, ToStableHashKey,
};
use rustc_error_messages::{DiagnosticMessage, MultiSpan};
use rustc_error_messages::{DiagMessage, MultiSpan};
use rustc_hir::HashStableContext;
use rustc_hir::HirId;
use rustc_span::edition::Edition;
@ -674,7 +674,7 @@ pub struct BufferedEarlyLint {
pub span: MultiSpan,
/// The lint message.
pub msg: DiagnosticMessage,
pub msg: DiagMessage,
/// The `NodeId` of the AST node that generated the lint.
pub node_id: NodeId,
@ -703,7 +703,7 @@ impl LintBuffer {
lint: &'static Lint,
node_id: NodeId,
span: MultiSpan,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
diagnostic: BuiltinLintDiagnostics,
) {
let lint_id = LintId::of(lint);
@ -721,7 +721,7 @@ impl LintBuffer {
lint: &'static Lint,
id: NodeId,
sp: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
) {
self.add_lint(lint, id, sp.into(), msg, BuiltinLintDiagnostics::Normal)
}
@ -731,7 +731,7 @@ impl LintBuffer {
lint: &'static Lint,
id: NodeId,
sp: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
diagnostic: BuiltinLintDiagnostics,
) {
self.add_lint(lint, id, sp.into(), msg, diagnostic)

View File

@ -165,7 +165,7 @@ impl<'a> LintDiagnosticDerive<'a> {
#implementation;
}
fn msg(&self) -> rustc_errors::DiagnosticMessage {
fn msg(&self) -> rustc_errors::DiagMessage {
#msg
}
}

View File

@ -1,6 +1,6 @@
use std::fmt;
use rustc_errors::{codes::*, DiagArgName, DiagArgValue, DiagnosticMessage};
use rustc_errors::{codes::*, DiagArgName, DiagArgValue, DiagMessage};
use rustc_macros::Diagnostic;
use rustc_span::{Span, Symbol};
@ -93,16 +93,16 @@ pub(super) struct ConstNotUsedTraitAlias {
}
pub struct CustomSubdiagnostic<'a> {
pub msg: fn() -> DiagnosticMessage,
pub msg: fn() -> DiagMessage,
pub add_args: Box<dyn FnOnce(&mut dyn FnMut(DiagArgName, DiagArgValue)) + 'a>,
}
impl<'a> CustomSubdiagnostic<'a> {
pub fn label(x: fn() -> DiagnosticMessage) -> Self {
pub fn label(x: fn() -> DiagMessage) -> Self {
Self::label_and_then(x, |_| {})
}
pub fn label_and_then<F: FnOnce(&mut dyn FnMut(DiagArgName, DiagArgValue)) + 'a>(
msg: fn() -> DiagnosticMessage,
msg: fn() -> DiagMessage,
f: F,
) -> Self {
Self { msg, add_args: Box::new(move |x| f(x)) }

View File

@ -2,7 +2,7 @@ use std::cmp;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_errors::{Diag, DiagnosticMessage, MultiSpan};
use rustc_errors::{Diag, DiagMessage, MultiSpan};
use rustc_hir::{HirId, ItemLocalId};
use rustc_session::lint::{
builtin::{self, FORBIDDEN_LINT_GROUPS},
@ -268,7 +268,7 @@ pub fn lint_level(
level: Level,
src: LintLevelSource,
span: Option<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
) {
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
@ -280,7 +280,7 @@ pub fn lint_level(
level: Level,
src: LintLevelSource,
span: Option<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
decorate: Box<dyn '_ + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>)>,
) {
// Check for future incompatibility lints and issue a stronger warning.

View File

@ -6,9 +6,7 @@ use crate::ty::{layout, tls, Ty, TyCtxt, ValTree};
use rustc_ast_ir::Mutability;
use rustc_data_structures::sync::Lock;
use rustc_errors::{
DiagArgName, DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg,
};
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg};
use rustc_macros::HashStable;
use rustc_session::CtfeBacktrace;
use rustc_span::{def_id::DefId, Span, DUMMY_SP};
@ -489,7 +487,7 @@ pub enum ResourceExhaustionInfo {
/// A trait for machine-specific errors (or other "machine stop" conditions).
pub trait MachineStopType: Any + fmt::Debug + Send {
/// The diagnostic message for this error
fn diagnostic_message(&self) -> DiagnosticMessage;
fn diagnostic_message(&self) -> DiagMessage;
/// Add diagnostic arguments by passing name and value pairs to `adder`, which are passed to
/// fluent for formatting the translated diagnostic message.
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagArgName, DiagArgValue));

View File

@ -14,9 +14,7 @@ use crate::ty::{AdtDef, InstanceDef, UserTypeAnnotationIndex};
use crate::ty::{GenericArg, GenericArgsRef};
use rustc_data_structures::captures::Captures;
use rustc_errors::{
DiagArgName, DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg,
};
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg};
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
use rustc_hir::{self, CoroutineDesugaring, CoroutineKind, ImplicitSelfKind};

View File

@ -251,7 +251,7 @@ impl<O> AssertKind<O> {
/// `AssertKind::description` and the lang items mentioned in its docs).
/// Note that we deliberately show more details here than we do at runtime, such as the actual
/// numbers that overflowed -- it is much easier to do so here than at runtime.
pub fn diagnostic_message(&self) -> DiagnosticMessage {
pub fn diagnostic_message(&self) -> DiagMessage {
use crate::fluent_generated::*;
use AssertKind::*;

View File

@ -43,7 +43,7 @@ use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, WorkerLocal};
#[cfg(parallel_compiler)]
use rustc_data_structures::sync::{DynSend, DynSync};
use rustc_data_structures::unord::UnordSet;
use rustc_errors::{DecorateLint, Diag, DiagCtxt, DiagnosticMessage, ErrorGuaranteed, MultiSpan};
use rustc_errors::{DecorateLint, Diag, DiagCtxt, DiagMessage, ErrorGuaranteed, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
@ -2097,7 +2097,7 @@ impl<'tcx> TyCtxt<'tcx> {
lint: &'static Lint,
hir_id: HirId,
span: impl Into<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_at_node(lint, hir_id);
@ -2127,7 +2127,7 @@ impl<'tcx> TyCtxt<'tcx> {
self,
lint: &'static Lint,
id: HirId,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
) {
let (level, src) = self.lint_level_at_node(lint, id);

View File

@ -3,7 +3,7 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use crate::query::TyCtxtAt;
use crate::ty::normalize_erasing_regions::NormalizationError;
use crate::ty::{self, ConstKind, Ty, TyCtxt, TypeVisitableExt};
use rustc_error_messages::DiagnosticMessage;
use rustc_error_messages::DiagMessage;
use rustc_errors::{
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
};
@ -205,7 +205,7 @@ pub enum LayoutError<'tcx> {
}
impl<'tcx> LayoutError<'tcx> {
pub fn diagnostic_message(&self) -> DiagnosticMessage {
pub fn diagnostic_message(&self) -> DiagMessage {
use crate::fluent_generated::*;
use LayoutError::*;
match self {

View File

@ -13,9 +13,7 @@ use crate::ty::{GenericArg, GenericArgs, GenericArgsRef};
use crate::ty::{List, ParamEnv};
use hir::def::DefKind;
use rustc_data_structures::captures::Captures;
use rustc_errors::{
DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan,
};
use rustc_errors::{DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::LangItem;
@ -1545,7 +1543,7 @@ impl<'tcx> Ty<'tcx> {
pub fn new_error_with_message<S: Into<MultiSpan>>(
tcx: TyCtxt<'tcx>,
span: S,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
) -> Ty<'tcx> {
let reported = tcx.dcx().span_delayed_bug(span, msg);
Ty::new(tcx, Error(reported))

View File

@ -36,7 +36,7 @@ pub(crate) macro throw_machine_stop_str($($tt:tt)*) {{
}
impl rustc_middle::mir::interpret::MachineStopType for Zst {
fn diagnostic_message(&self) -> rustc_errors::DiagnosticMessage {
fn diagnostic_message(&self) -> rustc_errors::DiagMessage {
self.to_string().into()
}

View File

@ -1,7 +1,7 @@
use std::borrow::Cow;
use rustc_errors::{
codes::*, Applicability, DecorateLint, Diag, DiagArgValue, DiagCtxt, DiagnosticMessage,
codes::*, Applicability, DecorateLint, Diag, DiagArgValue, DiagCtxt, DiagMessage,
EmissionGuarantee, IntoDiagnostic, Level,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
@ -149,7 +149,7 @@ impl RequiresUnsafeDetail {
}
}
fn label(&self) -> DiagnosticMessage {
fn label(&self) -> DiagMessage {
use UnsafetyViolationDetails::*;
match self.violation {
CallToUnsafeFunction => fluent::mir_transform_call_to_unsafe_label,
@ -199,7 +199,7 @@ impl<'a> DecorateLint<'a, ()> for UnsafeOpInUnsafeFn {
}
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
fluent::mir_transform_unsafe_op_in_unsafe_fn
}
}
@ -224,7 +224,7 @@ impl<'a, P: std::fmt::Debug> DecorateLint<'a, ()> for AssertLint<P> {
diag.span_label(self.span, message);
}
fn msg(&self) -> DiagnosticMessage {
fn msg(&self) -> DiagMessage {
match self.lint_kind {
AssertLintKind::ArithmeticOverflow => fluent::mir_transform_arithmetic_overflow,
AssertLintKind::UnconditionalPanic => fluent::mir_transform_operation_will_panic,
@ -281,7 +281,7 @@ impl<'a> DecorateLint<'a, ()> for MustNotSupend<'_, '_> {
diag.arg("post", self.post);
}
fn msg(&self) -> rustc_errors::DiagnosticMessage {
fn msg(&self) -> rustc_errors::DiagMessage {
fluent::mir_transform_must_not_suspend
}
}

View File

@ -3,8 +3,8 @@ use std::num::NonZero;
use rustc_ast::token;
use rustc_ast::util::literal::LitError;
use rustc_errors::{
codes::*, Diag, DiagCtxt, DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed,
IntoDiagnostic, Level, MultiSpan,
codes::*, Diag, DiagCtxt, DiagMessage, EmissionGuarantee, ErrorGuaranteed, IntoDiagnostic,
Level, MultiSpan,
};
use rustc_macros::Diagnostic;
use rustc_span::{Span, Symbol};
@ -14,7 +14,7 @@ use crate::parse::ParseSess;
pub struct FeatureGateError {
pub span: MultiSpan,
pub explain: DiagnosticMessage,
pub explain: DiagMessage,
}
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for FeatureGateError {

View File

@ -15,8 +15,8 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
use rustc_errors::emitter::{stderr_destination, HumanEmitter, SilentEmitter};
use rustc_errors::{
fallback_fluent_bundle, ColorConfig, Diag, DiagCtxt, DiagnosticMessage, EmissionGuarantee,
MultiSpan, StashKey,
fallback_fluent_bundle, ColorConfig, Diag, DiagCtxt, DiagMessage, EmissionGuarantee, MultiSpan,
StashKey,
};
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
use rustc_span::edition::Edition;
@ -85,7 +85,7 @@ pub fn feature_err(
sess: &Session,
feature: Symbol,
span: impl Into<MultiSpan>,
explain: impl Into<DiagnosticMessage>,
explain: impl Into<DiagMessage>,
) -> Diag<'_> {
feature_err_issue(sess, feature, span, GateIssue::Language, explain)
}
@ -100,7 +100,7 @@ pub fn feature_err_issue(
feature: Symbol,
span: impl Into<MultiSpan>,
issue: GateIssue,
explain: impl Into<DiagnosticMessage>,
explain: impl Into<DiagMessage>,
) -> Diag<'_> {
let span = span.into();
@ -290,7 +290,7 @@ impl ParseSess {
lint: &'static Lint,
span: impl Into<MultiSpan>,
node_id: NodeId,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
) {
self.buffered_lints.with_lock(|buffered_lints| {
buffered_lints.push(BufferedEarlyLint {
@ -308,7 +308,7 @@ impl ParseSess {
lint: &'static Lint,
span: impl Into<MultiSpan>,
node_id: NodeId,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
diagnostic: BuiltinLintDiagnostics,
) {
self.buffered_lints.with_lock(|buffered_lints| {

View File

@ -22,8 +22,8 @@ use rustc_errors::emitter::{stderr_destination, DynEmitter, HumanEmitter, HumanR
use rustc_errors::json::JsonEmitter;
use rustc_errors::registry::Registry;
use rustc_errors::{
codes::*, fallback_fluent_bundle, Diag, DiagCtxt, DiagnosticMessage, ErrorGuaranteed,
FatalAbort, FluentBundle, IntoDiagnostic, LazyFallbackBundle, TerminalUrl,
codes::*, fallback_fluent_bundle, Diag, DiagCtxt, DiagMessage, ErrorGuaranteed, FatalAbort,
FluentBundle, IntoDiagnostic, LazyFallbackBundle, TerminalUrl,
};
use rustc_macros::HashStable_Generic;
pub use rustc_span::def_id::StableCrateId;
@ -1419,38 +1419,38 @@ impl EarlyDiagCtxt {
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_note(&self, msg: impl Into<DiagnosticMessage>) {
pub fn early_note(&self, msg: impl Into<DiagMessage>) {
self.dcx.note(msg)
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_help(&self, msg: impl Into<DiagnosticMessage>) {
pub fn early_help(&self, msg: impl Into<DiagMessage>) {
self.dcx.struct_help(msg).emit()
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
#[must_use = "ErrorGuaranteed must be returned from `run_compiler` in order to exit with a non-zero status code"]
pub fn early_err(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed {
pub fn early_err(&self, msg: impl Into<DiagMessage>) -> ErrorGuaranteed {
self.dcx.err(msg)
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
pub fn early_fatal(&self, msg: impl Into<DiagMessage>) -> ! {
self.dcx.fatal(msg)
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> Diag<'_, FatalAbort> {
pub fn early_struct_fatal(&self, msg: impl Into<DiagMessage>) -> Diag<'_, FatalAbort> {
self.dcx.struct_fatal(msg)
}
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_warn(&self, msg: impl Into<DiagnosticMessage>) {
pub fn early_warn(&self, msg: impl Into<DiagMessage>) {
self.dcx.warn(msg)
}

View File

@ -187,7 +187,7 @@ symbols! {
DecorateLint,
Default,
Deref,
DiagnosticMessage,
DiagMessage,
DirBuilder,
Display,
DoubleEndedIterator,

View File

@ -1266,8 +1266,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
if has_custom_message {
err.note(msg);
} else {
err.messages =
vec![(rustc_errors::DiagnosticMessage::from(msg), Style::NoStyle)];
err.messages = vec![(rustc_errors::DiagMessage::from(msg), Style::NoStyle)];
}
let mut file = None;
err.span_label(

View File

@ -27,7 +27,7 @@
//! ```
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{Diag, DiagnosticMessage};
use rustc_errors::{Diag, DiagMessage};
use rustc_hir::def_id::DefId;
use rustc_middle::ty::TyCtxt;
pub(crate) use rustc_resolve::rustdoc::main_body_opts;
@ -828,7 +828,7 @@ impl<'tcx> ExtraInfo<'tcx> {
ExtraInfo { def_id, sp, tcx }
}
fn error_invalid_codeblock_attr(&self, msg: impl Into<DiagnosticMessage>) {
fn error_invalid_codeblock_attr(&self, msg: impl Into<DiagMessage>) {
if let Some(def_id) = self.def_id.as_local() {
self.tcx.node_span_lint(
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
@ -842,7 +842,7 @@ impl<'tcx> ExtraInfo<'tcx> {
fn error_invalid_codeblock_attr_with_help(
&self,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
f: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
) {
if let Some(def_id) = self.def_id.as_local() {
@ -952,7 +952,7 @@ impl<'a, 'tcx> TagIterator<'a, 'tcx> {
Self { inner: data.char_indices().peekable(), data, is_in_attribute_block: false, extra }
}
fn emit_error(&self, err: impl Into<DiagnosticMessage>) {
fn emit_error(&self, err: impl Into<DiagMessage>) {
if let Some(extra) = self.extra {
extra.error_invalid_codeblock_attr(err);
}

View File

@ -8,7 +8,7 @@ use rustc_data_structures::{
fx::{FxHashMap, FxHashSet},
intern::Interned,
};
use rustc_errors::{Applicability, Diag, DiagnosticMessage};
use rustc_errors::{Applicability, Diag, DiagMessage};
use rustc_hir::def::Namespace::*;
use rustc_hir::def::{DefKind, Namespace, PerNS};
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
@ -1674,7 +1674,7 @@ impl Suggestion {
fn report_diagnostic(
tcx: TyCtxt<'_>,
lint: &'static Lint,
msg: impl Into<DiagnosticMessage> + Display,
msg: impl Into<DiagMessage> + Display,
DiagnosticInfo { item, ori_link: _, dox, link_range }: &DiagnosticInfo<'_>,
decorate: impl FnOnce(&mut Diag<'_, ()>, Option<rustc_span::Span>, MarkdownLinkRange),
) {
@ -2010,7 +2010,7 @@ fn disambiguator_error(
cx: &DocContext<'_>,
mut diag_info: DiagnosticInfo<'_>,
disambiguator_range: MarkdownLinkRange,
msg: impl Into<DiagnosticMessage> + Display,
msg: impl Into<DiagMessage> + Display,
) {
diag_info.link_range = disambiguator_range;
report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp, _link_range| {

View File

@ -5,12 +5,17 @@ extern crate rustc_hir;
extern crate rustc_lint;
extern crate rustc_middle;
use rustc_errors::{DiagnosticMessage, MultiSpan};
use rustc_errors::{DiagMessage, MultiSpan};
use rustc_hir::hir_id::HirId;
use rustc_lint::{Lint, LintContext};
use rustc_middle::ty::TyCtxt;
pub fn a(cx: impl LintContext, lint: &'static Lint, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) {
pub fn a(
cx: impl LintContext,
lint: &'static Lint,
span: impl Into<MultiSpan>,
msg: impl Into<DiagMessage>)
{
cx.span_lint(lint, span, msg, |_| {});
}
@ -19,7 +24,7 @@ pub fn b(
lint: &'static Lint,
hir_id: HirId,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
msg: impl Into<DiagMessage>,
) {
tcx.node_span_lint(lint, hir_id, span, msg, |_| {});
}

View File

@ -1,7 +1,7 @@
use std::fmt::{self, Write};
use std::num::NonZero;
use rustc_errors::{Diag, DiagnosticMessage, Level};
use rustc_errors::{Diag, DiagMessage, Level};
use rustc_span::{SpanData, Symbol, DUMMY_SP};
use rustc_target::abi::{Align, Size};
@ -95,7 +95,7 @@ impl fmt::Debug for TerminationInfo {
}
impl MachineStopType for TerminationInfo {
fn diagnostic_message(&self) -> DiagnosticMessage {
fn diagnostic_message(&self) -> DiagMessage {
self.to_string().into()
}
fn add_args(

View File

@ -44,7 +44,7 @@ impl Translate for SilentEmitter {
// subdiagnostics result in a call to this.
fn translate_message<'a>(
&'a self,
message: &'a rustc_errors::DiagnosticMessage,
message: &'a rustc_errors::DiagMessage,
_: &'a rustc_errors::translation::FluentArgs<'_>,
) -> Result<Cow<'_, str>, rustc_errors::error::TranslateError<'_>> {
rustc_errors::emitter::silent_translate(message)

View File

@ -5,9 +5,9 @@
extern crate rustc_errors;
extern crate rustc_fluent_macro;
/// Copy of the relevant `DiagnosticMessage` variant constructed by `fluent_messages` as it
/// expects `crate::DiagnosticMessage` to exist.
pub enum DiagnosticMessage {
/// Copy of the relevant `DiagMessage` variant constructed by `fluent_messages` as it
/// expects `crate::DiagMessage` to exist.
pub enum DiagMessage {
FluentIdentifier(std::borrow::Cow<'static, str>, Option<std::borrow::Cow<'static, str>>),
}

View File

@ -19,7 +19,7 @@ extern crate rustc_macros;
extern crate rustc_session;
extern crate rustc_span;
use rustc_errors::{Applicability, DiagnosticMessage, SubdiagnosticMessage};
use rustc_errors::{Applicability, DiagMessage, SubdiagnosticMessage};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::Span;

View File

@ -25,7 +25,7 @@ extern crate rustc_middle;
use rustc_middle::ty::Ty;
extern crate rustc_errors;
use rustc_errors::{Applicability, DiagnosticMessage, ErrCode, MultiSpan, SubdiagnosticMessage};
use rustc_errors::{Applicability, DiagMessage, ErrCode, MultiSpan, SubdiagnosticMessage};
extern crate rustc_session;

View File

@ -10,7 +10,7 @@ extern crate rustc_fluent_macro;
extern crate rustc_macros;
extern crate rustc_errors;
use rustc_macros::Diagnostic;
use rustc_errors::{SubdiagnosticMessage, DiagnosticMessage};
use rustc_errors::{DiagMessage, SubdiagnosticMessage};
extern crate rustc_session;
rustc_fluent_macro::fluent_messages! { "./example.ftl" }

View File

@ -17,7 +17,7 @@ extern crate rustc_macros;
extern crate rustc_session;
extern crate rustc_span;
use rustc_errors::{Applicability, DiagnosticMessage, SubdiagnosticMessage};
use rustc_errors::{Applicability, DiagMessage, SubdiagnosticMessage};
use rustc_macros::Subdiagnostic;
use rustc_span::Span;