mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Rename SubdiagnosticMessage
as SubdiagMessage
.
This commit is contained in:
parent
f16a8d0390
commit
60ea6e2831
@ -256,8 +256,8 @@ type FluentId = Cow<'static, str>;
|
||||
/// 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 {
|
||||
#[rustc_diagnostic_item = "SubdiagMessage"]
|
||||
pub enum SubdiagMessage {
|
||||
/// Non-translatable diagnostic message.
|
||||
Str(Cow<'static, str>),
|
||||
/// Translatable message which has already been translated eagerly.
|
||||
@ -278,19 +278,19 @@ pub enum SubdiagnosticMessage {
|
||||
FluentAttr(FluentId),
|
||||
}
|
||||
|
||||
impl From<String> for SubdiagnosticMessage {
|
||||
impl From<String> for SubdiagMessage {
|
||||
fn from(s: String) -> Self {
|
||||
SubdiagnosticMessage::Str(Cow::Owned(s))
|
||||
SubdiagMessage::Str(Cow::Owned(s))
|
||||
}
|
||||
}
|
||||
impl From<&'static str> for SubdiagnosticMessage {
|
||||
impl From<&'static str> for SubdiagMessage {
|
||||
fn from(s: &'static str) -> Self {
|
||||
SubdiagnosticMessage::Str(Cow::Borrowed(s))
|
||||
SubdiagMessage::Str(Cow::Borrowed(s))
|
||||
}
|
||||
}
|
||||
impl From<Cow<'static, str>> for SubdiagnosticMessage {
|
||||
impl From<Cow<'static, str>> for SubdiagMessage {
|
||||
fn from(s: Cow<'static, str>) -> Self {
|
||||
SubdiagnosticMessage::Str(s)
|
||||
SubdiagMessage::Str(s)
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,20 +319,19 @@ pub enum DiagMessage {
|
||||
}
|
||||
|
||||
impl DiagMessage {
|
||||
/// Given a `SubdiagnosticMessage` which may contain a Fluent attribute, create a new
|
||||
/// Given a `SubdiagMessage` which may contain a Fluent attribute, create a new
|
||||
/// `DiagMessage` that combines that attribute with the Fluent identifier of `self`.
|
||||
///
|
||||
/// - If the `SubdiagnosticMessage` is non-translatable then return the message as a
|
||||
/// `DiagMessage`.
|
||||
/// - If the `SubdiagMessage` is non-translatable then return the message as a `DiagMessage`.
|
||||
/// - If `self` is non-translatable then return `self`'s message.
|
||||
pub fn with_subdiagnostic_message(&self, sub: SubdiagnosticMessage) -> Self {
|
||||
pub fn with_subdiagnostic_message(&self, sub: SubdiagMessage) -> Self {
|
||||
let attr = match sub {
|
||||
SubdiagnosticMessage::Str(s) => return DiagMessage::Str(s),
|
||||
SubdiagnosticMessage::Translated(s) => return DiagMessage::Translated(s),
|
||||
SubdiagnosticMessage::FluentIdentifier(id) => {
|
||||
SubdiagMessage::Str(s) => return DiagMessage::Str(s),
|
||||
SubdiagMessage::Translated(s) => return DiagMessage::Translated(s),
|
||||
SubdiagMessage::FluentIdentifier(id) => {
|
||||
return DiagMessage::FluentIdentifier(id, None);
|
||||
}
|
||||
SubdiagnosticMessage::FluentAttr(attr) => attr,
|
||||
SubdiagMessage::FluentAttr(attr) => attr,
|
||||
};
|
||||
|
||||
match self {
|
||||
@ -380,19 +379,19 @@ impl<F: FnOnce() -> String> From<DelayDm<F>> for DiagMessage {
|
||||
}
|
||||
|
||||
/// 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
|
||||
/// the subdiagnostic functions (e.g. `span_label`) take a `SubdiagMessage` and the
|
||||
/// 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 DiagMessage {
|
||||
fn into(self) -> SubdiagnosticMessage {
|
||||
impl Into<SubdiagMessage> for DiagMessage {
|
||||
fn into(self) -> SubdiagMessage {
|
||||
match self {
|
||||
DiagMessage::Str(s) => SubdiagnosticMessage::Str(s),
|
||||
DiagMessage::Translated(s) => SubdiagnosticMessage::Translated(s),
|
||||
DiagMessage::FluentIdentifier(id, None) => SubdiagnosticMessage::FluentIdentifier(id),
|
||||
DiagMessage::Str(s) => SubdiagMessage::Str(s),
|
||||
DiagMessage::Translated(s) => SubdiagMessage::Translated(s),
|
||||
DiagMessage::FluentIdentifier(id, None) => SubdiagMessage::FluentIdentifier(id),
|
||||
// There isn't really a sensible behaviour for this because it loses information but
|
||||
// this is the most sensible of the behaviours.
|
||||
DiagMessage::FluentIdentifier(_, Some(attr)) => SubdiagnosticMessage::FluentAttr(attr),
|
||||
DiagMessage::FluentIdentifier(_, Some(attr)) => SubdiagMessage::FluentAttr(attr),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::snippet::Style;
|
||||
use crate::{
|
||||
CodeSuggestion, DiagCtxt, DiagMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level, MultiSpan,
|
||||
StashKey, SubdiagnosticMessage, Substitution, SubstitutionPart, SuggestionStyle,
|
||||
StashKey, SubdiagMessage, Substitution, SubstitutionPart, SuggestionStyle,
|
||||
};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_error_messages::fluent_value_from_str_list_sep_by_and;
|
||||
@ -189,8 +189,7 @@ where
|
||||
);
|
||||
}
|
||||
|
||||
pub trait SubdiagnosticMessageOp<G> =
|
||||
Fn(&mut Diag<'_, G>, SubdiagnosticMessage) -> SubdiagnosticMessage;
|
||||
pub trait SubdiagnosticMessageOp<G> = Fn(&mut Diag<'_, G>, SubdiagMessage) -> SubdiagMessage;
|
||||
|
||||
/// Trait implemented by lint types. This should not be implemented manually. Instead, use
|
||||
/// `#[derive(LintDiagnostic)]` -- see [rustc_macros::LintDiagnostic].
|
||||
@ -396,7 +395,7 @@ impl DiagInner {
|
||||
// See comment on `Diag::subdiagnostic_message_to_diagnostic_message`.
|
||||
pub(crate) fn subdiagnostic_message_to_diagnostic_message(
|
||||
&self,
|
||||
attr: impl Into<SubdiagnosticMessage>,
|
||||
attr: impl Into<SubdiagMessage>,
|
||||
) -> DiagMessage {
|
||||
let msg =
|
||||
self.messages.iter().map(|(msg, _)| msg).next().expect("diagnostic with no messages");
|
||||
@ -406,7 +405,7 @@ impl DiagInner {
|
||||
pub(crate) fn sub(
|
||||
&mut self,
|
||||
level: Level,
|
||||
message: impl Into<SubdiagnosticMessage>,
|
||||
message: impl Into<SubdiagMessage>,
|
||||
span: MultiSpan,
|
||||
) {
|
||||
let sub = Subdiag {
|
||||
@ -623,7 +622,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
/// ["primary span"][`MultiSpan`]; only the `Span` supplied when creating the diagnostic is
|
||||
/// primary.
|
||||
#[rustc_lint_diagnostics]
|
||||
pub fn span_label(&mut self, span: Span, label: impl Into<SubdiagnosticMessage>) -> &mut Self {
|
||||
pub fn span_label(&mut self, span: Span, label: impl Into<SubdiagMessage>) -> &mut Self {
|
||||
let msg = self.subdiagnostic_message_to_diagnostic_message(label);
|
||||
self.span.push_span_label(span, msg);
|
||||
self
|
||||
@ -718,7 +717,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
with_fn! { with_note,
|
||||
/// Add a note attached to this diagnostic.
|
||||
#[rustc_lint_diagnostics]
|
||||
pub fn note(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self {
|
||||
pub fn note(&mut self, msg: impl Into<SubdiagMessage>) -> &mut Self {
|
||||
self.sub(Level::Note, msg, MultiSpan::new());
|
||||
self
|
||||
} }
|
||||
@ -729,7 +728,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
}
|
||||
|
||||
/// This is like [`Diag::note()`], but it's only printed once.
|
||||
pub fn note_once(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self {
|
||||
pub fn note_once(&mut self, msg: impl Into<SubdiagMessage>) -> &mut Self {
|
||||
self.sub(Level::OnceNote, msg, MultiSpan::new());
|
||||
self
|
||||
}
|
||||
@ -741,7 +740,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn span_note(
|
||||
&mut self,
|
||||
sp: impl Into<MultiSpan>,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
) -> &mut Self {
|
||||
self.sub(Level::Note, msg, sp.into());
|
||||
self
|
||||
@ -752,7 +751,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn span_note_once<S: Into<MultiSpan>>(
|
||||
&mut self,
|
||||
sp: S,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
) -> &mut Self {
|
||||
self.sub(Level::OnceNote, msg, sp.into());
|
||||
self
|
||||
@ -761,7 +760,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
with_fn! { with_warn,
|
||||
/// Add a warning attached to this diagnostic.
|
||||
#[rustc_lint_diagnostics]
|
||||
pub fn warn(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self {
|
||||
pub fn warn(&mut self, msg: impl Into<SubdiagMessage>) -> &mut Self {
|
||||
self.sub(Level::Warning, msg, MultiSpan::new());
|
||||
self
|
||||
} }
|
||||
@ -772,7 +771,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn span_warn<S: Into<MultiSpan>>(
|
||||
&mut self,
|
||||
sp: S,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
) -> &mut Self {
|
||||
self.sub(Level::Warning, msg, sp.into());
|
||||
self
|
||||
@ -781,13 +780,13 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
with_fn! { with_help,
|
||||
/// Add a help message attached to this diagnostic.
|
||||
#[rustc_lint_diagnostics]
|
||||
pub fn help(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self {
|
||||
pub fn help(&mut self, msg: impl Into<SubdiagMessage>) -> &mut Self {
|
||||
self.sub(Level::Help, msg, MultiSpan::new());
|
||||
self
|
||||
} }
|
||||
|
||||
/// This is like [`Diag::help()`], but it's only printed once.
|
||||
pub fn help_once(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self {
|
||||
pub fn help_once(&mut self, msg: impl Into<SubdiagMessage>) -> &mut Self {
|
||||
self.sub(Level::OnceHelp, msg, MultiSpan::new());
|
||||
self
|
||||
}
|
||||
@ -804,7 +803,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn span_help<S: Into<MultiSpan>>(
|
||||
&mut self,
|
||||
sp: S,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
) -> &mut Self {
|
||||
self.sub(Level::Help, msg, sp.into());
|
||||
self
|
||||
@ -841,7 +840,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
/// In other words, multiple changes need to be applied as part of this suggestion.
|
||||
pub fn multipart_suggestion(
|
||||
&mut self,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestion: Vec<(Span, String)>,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
@ -857,7 +856,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
/// In other words, multiple changes need to be applied as part of this suggestion.
|
||||
pub fn multipart_suggestion_verbose(
|
||||
&mut self,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestion: Vec<(Span, String)>,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
@ -872,7 +871,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
/// [`Diag::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
|
||||
pub fn multipart_suggestion_with_style(
|
||||
&mut self,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
mut suggestion: Vec<(Span, String)>,
|
||||
applicability: Applicability,
|
||||
style: SuggestionStyle,
|
||||
@ -914,7 +913,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
/// improve understandability.
|
||||
pub fn tool_only_multipart_suggestion(
|
||||
&mut self,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestion: Vec<(Span, String)>,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
@ -947,7 +946,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn span_suggestion(
|
||||
&mut self,
|
||||
sp: Span,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestion: impl ToString,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
@ -965,7 +964,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn span_suggestion_with_style(
|
||||
&mut self,
|
||||
sp: Span,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestion: impl ToString,
|
||||
applicability: Applicability,
|
||||
style: SuggestionStyle,
|
||||
@ -990,7 +989,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn span_suggestion_verbose(
|
||||
&mut self,
|
||||
sp: Span,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestion: impl ToString,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
@ -1010,7 +1009,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn span_suggestions(
|
||||
&mut self,
|
||||
sp: Span,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestions: impl IntoIterator<Item = String>,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
@ -1026,7 +1025,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn span_suggestions_with_style(
|
||||
&mut self,
|
||||
sp: Span,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestions: impl IntoIterator<Item = String>,
|
||||
applicability: Applicability,
|
||||
style: SuggestionStyle,
|
||||
@ -1055,7 +1054,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
/// See also [`Diag::multipart_suggestion()`].
|
||||
pub fn multipart_suggestions(
|
||||
&mut self,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestions: impl IntoIterator<Item = Vec<(Span, String)>>,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
@ -1102,7 +1101,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn span_suggestion_short(
|
||||
&mut self,
|
||||
sp: Span,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestion: impl ToString,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
@ -1125,7 +1124,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn span_suggestion_hidden(
|
||||
&mut self,
|
||||
sp: Span,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestion: impl ToString,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
@ -1148,7 +1147,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
pub fn tool_only_span_suggestion(
|
||||
&mut self,
|
||||
sp: Span,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
suggestion: impl ToString,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
@ -1219,12 +1218,12 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
self
|
||||
} }
|
||||
|
||||
/// Helper function that takes a `SubdiagnosticMessage` and returns a `DiagMessage` by
|
||||
/// Helper function that takes a `SubdiagMessage` 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>,
|
||||
attr: impl Into<SubdiagMessage>,
|
||||
) -> DiagMessage {
|
||||
self.deref().subdiagnostic_message_to_diagnostic_message(attr)
|
||||
}
|
||||
@ -1233,7 +1232,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||
/// public methods above.
|
||||
///
|
||||
/// Used by `proc_macro_server` for implementing `server::Diagnostic`.
|
||||
pub fn sub(&mut self, level: Level, message: impl Into<SubdiagnosticMessage>, span: MultiSpan) {
|
||||
pub fn sub(&mut self, level: Level, message: impl Into<SubdiagMessage>, span: MultiSpan) {
|
||||
self.deref_mut().sub(level, message, span);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ pub use diagnostic_impls::{
|
||||
pub use emitter::ColorConfig;
|
||||
pub use rustc_error_messages::{
|
||||
fallback_fluent_bundle, fluent_bundle, DelayDm, DiagMessage, FluentBundle, LanguageIdentifier,
|
||||
LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagnosticMessage,
|
||||
LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagMessage,
|
||||
};
|
||||
pub use rustc_lint_defs::{pluralize, Applicability};
|
||||
pub use rustc_span::fatal_error::{FatalError, FatalErrorMarker};
|
||||
@ -631,12 +631,12 @@ impl DiagCtxt {
|
||||
}
|
||||
}
|
||||
|
||||
/// Translate `message` eagerly with `args` to `SubdiagnosticMessage::Eager`.
|
||||
/// Translate `message` eagerly with `args` to `SubdiagMessage::Eager`.
|
||||
pub fn eagerly_translate<'a>(
|
||||
&self,
|
||||
message: DiagMessage,
|
||||
args: impl Iterator<Item = DiagArg<'a>>,
|
||||
) -> SubdiagnosticMessage {
|
||||
) -> SubdiagMessage {
|
||||
let inner = self.inner.borrow();
|
||||
inner.eagerly_translate(message, args)
|
||||
}
|
||||
@ -1553,13 +1553,13 @@ impl DiagCtxtInner {
|
||||
self.has_errors().or_else(|| self.delayed_bugs.get(0).map(|(_, guar)| guar).copied())
|
||||
}
|
||||
|
||||
/// Translate `message` eagerly with `args` to `SubdiagnosticMessage::Eager`.
|
||||
/// Translate `message` eagerly with `args` to `SubdiagMessage::Eager`.
|
||||
pub fn eagerly_translate<'a>(
|
||||
&self,
|
||||
message: DiagMessage,
|
||||
args: impl Iterator<Item = DiagArg<'a>>,
|
||||
) -> SubdiagnosticMessage {
|
||||
SubdiagnosticMessage::Translated(Cow::from(self.eagerly_translate_to_string(message, args)))
|
||||
) -> SubdiagMessage {
|
||||
SubdiagMessage::Translated(Cow::from(self.eagerly_translate_to_string(message, args)))
|
||||
}
|
||||
|
||||
/// Translate `message` eagerly with `args` to `String`.
|
||||
@ -1575,8 +1575,8 @@ impl DiagCtxtInner {
|
||||
fn eagerly_translate_for_subdiag(
|
||||
&self,
|
||||
diag: &DiagInner,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
) -> SubdiagnosticMessage {
|
||||
msg: impl Into<SubdiagMessage>,
|
||||
) -> SubdiagMessage {
|
||||
let msg = diag.subdiagnostic_message_to_diagnostic_message(msg);
|
||||
self.eagerly_translate(msg, diag.args.iter())
|
||||
}
|
||||
|
@ -54,20 +54,20 @@ fn finish(body: TokenStream, resource: TokenStream) -> proc_macro::TokenStream {
|
||||
/// identifiers for different subdiagnostic kinds.
|
||||
pub mod _subdiag {
|
||||
/// Default for `#[help]`
|
||||
pub const help: rustc_errors::SubdiagnosticMessage =
|
||||
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("help"));
|
||||
pub const help: rustc_errors::SubdiagMessage =
|
||||
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed("help"));
|
||||
/// Default for `#[note]`
|
||||
pub const note: rustc_errors::SubdiagnosticMessage =
|
||||
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("note"));
|
||||
pub const note: rustc_errors::SubdiagMessage =
|
||||
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed("note"));
|
||||
/// Default for `#[warn]`
|
||||
pub const warn: rustc_errors::SubdiagnosticMessage =
|
||||
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("warn"));
|
||||
pub const warn: rustc_errors::SubdiagMessage =
|
||||
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed("warn"));
|
||||
/// Default for `#[label]`
|
||||
pub const label: rustc_errors::SubdiagnosticMessage =
|
||||
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("label"));
|
||||
pub const label: rustc_errors::SubdiagMessage =
|
||||
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed("label"));
|
||||
/// Default for `#[suggestion]`
|
||||
pub const suggestion: rustc_errors::SubdiagnosticMessage =
|
||||
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("suggestion"));
|
||||
pub const suggestion: rustc_errors::SubdiagMessage =
|
||||
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed("suggestion"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -275,8 +275,8 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
|
||||
);
|
||||
constants.extend(quote! {
|
||||
#[doc = #msg]
|
||||
pub const #snake_name: rustc_errors::SubdiagnosticMessage =
|
||||
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed(#attr_name));
|
||||
pub const #snake_name: rustc_errors::SubdiagMessage =
|
||||
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed(#attr_name));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ pub use self::suggest::SelfSource;
|
||||
pub use self::MethodError::*;
|
||||
|
||||
use crate::FnCtxt;
|
||||
use rustc_errors::{Applicability, Diag, SubdiagnosticMessage};
|
||||
use rustc_errors::{Applicability, Diag, SubdiagMessage};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorOf, DefKind, Namespace};
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -127,7 +127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
pub(crate) fn suggest_method_call(
|
||||
&self,
|
||||
err: &mut Diag<'_>,
|
||||
msg: impl Into<SubdiagnosticMessage> + std::fmt::Debug,
|
||||
msg: impl Into<SubdiagMessage> + std::fmt::Debug,
|
||||
method_name: Ident,
|
||||
self_ty: Ty<'tcx>,
|
||||
call_expr: &hir::Expr<'tcx>,
|
||||
|
@ -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::DiagMessage | sym::SubdiagnosticMessage)
|
||||
&& matches!(name, sym::DiagMessage | sym::SubdiagMessage)
|
||||
{
|
||||
found_diagnostic_message = true;
|
||||
break;
|
||||
|
@ -304,7 +304,7 @@ symbols! {
|
||||
SpanCtxt,
|
||||
String,
|
||||
StructuralPartialEq,
|
||||
SubdiagnosticMessage,
|
||||
SubdiagMessage,
|
||||
Sync,
|
||||
T,
|
||||
Target,
|
||||
|
@ -11,9 +11,9 @@ pub enum DiagMessage {
|
||||
FluentIdentifier(std::borrow::Cow<'static, str>, Option<std::borrow::Cow<'static, str>>),
|
||||
}
|
||||
|
||||
/// Copy of the relevant `SubdiagnosticMessage` variant constructed by `fluent_messages` as it
|
||||
/// expects `crate::SubdiagnosticMessage` to exist.
|
||||
pub enum SubdiagnosticMessage {
|
||||
/// Copy of the relevant `SubdiagMessage` variant constructed by `fluent_messages` as it
|
||||
/// expects `crate::SubdiagMessage` to exist.
|
||||
pub enum SubdiagMessage {
|
||||
FluentAttr(std::borrow::Cow<'static, str>),
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ extern crate rustc_macros;
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
|
||||
use rustc_errors::{Applicability, DiagMessage, SubdiagnosticMessage};
|
||||
use rustc_errors::{Applicability, DiagMessage, SubdiagMessage};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::Span;
|
||||
|
||||
|
@ -25,7 +25,7 @@ extern crate rustc_middle;
|
||||
use rustc_middle::ty::Ty;
|
||||
|
||||
extern crate rustc_errors;
|
||||
use rustc_errors::{Applicability, DiagMessage, ErrCode, MultiSpan, SubdiagnosticMessage};
|
||||
use rustc_errors::{Applicability, DiagMessage, ErrCode, MultiSpan, SubdiagMessage};
|
||||
|
||||
extern crate rustc_session;
|
||||
|
||||
|
@ -10,7 +10,7 @@ extern crate rustc_fluent_macro;
|
||||
extern crate rustc_macros;
|
||||
extern crate rustc_errors;
|
||||
use rustc_macros::Diagnostic;
|
||||
use rustc_errors::{DiagMessage, SubdiagnosticMessage};
|
||||
use rustc_errors::{DiagMessage, SubdiagMessage};
|
||||
extern crate rustc_session;
|
||||
|
||||
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
|
||||
|
@ -17,7 +17,7 @@ extern crate rustc_macros;
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
|
||||
use rustc_errors::{Applicability, DiagMessage, SubdiagnosticMessage};
|
||||
use rustc_errors::{Applicability, DiagMessage, SubdiagMessage};
|
||||
use rustc_macros::Subdiagnostic;
|
||||
use rustc_span::Span;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user