Rename DiagnosticMessage
as DiagMessage
.
This commit is contained in:
parent
d849f5c225
commit
18715c98c6
@ -16,8 +16,8 @@ use rustc_data_structures::sync::Lrc;
|
|||||||
use rustc_errors::emitter::Emitter;
|
use rustc_errors::emitter::Emitter;
|
||||||
use rustc_errors::translation::Translate;
|
use rustc_errors::translation::Translate;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
Diag, DiagArgMap, DiagCtxt, DiagnosticMessage, ErrCode, FatalError, FluentBundle, Level,
|
Diag, DiagArgMap, DiagCtxt, DiagMessage, ErrCode, FatalError, FluentBundle, Level, MultiSpan,
|
||||||
MultiSpan, Style,
|
Style,
|
||||||
};
|
};
|
||||||
use rustc_fs_util::link_or_copy;
|
use rustc_fs_util::link_or_copy;
|
||||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||||
@ -1015,7 +1015,7 @@ pub struct CguMessage;
|
|||||||
// - `emitted_at`: not used for codegen diagnostics.
|
// - `emitted_at`: not used for codegen diagnostics.
|
||||||
struct Diagnostic {
|
struct Diagnostic {
|
||||||
level: Level,
|
level: Level,
|
||||||
messages: Vec<(DiagnosticMessage, Style)>,
|
messages: Vec<(DiagMessage, Style)>,
|
||||||
code: Option<ErrCode>,
|
code: Option<ErrCode>,
|
||||||
children: Vec<Subdiagnostic>,
|
children: Vec<Subdiagnostic>,
|
||||||
args: DiagArgMap,
|
args: DiagArgMap,
|
||||||
@ -1026,7 +1026,7 @@ struct Diagnostic {
|
|||||||
// - `span`: it doesn't impl `Send`.
|
// - `span`: it doesn't impl `Send`.
|
||||||
pub struct Subdiagnostic {
|
pub struct Subdiagnostic {
|
||||||
level: Level,
|
level: Level,
|
||||||
messages: Vec<(DiagnosticMessage, Style)>,
|
messages: Vec<(DiagMessage, Style)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Copy, Debug)]
|
#[derive(PartialEq, Clone, Copy, Debug)]
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use rustc_errors::{
|
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, IntoDiagnostic, IntoDiagnosticArg};
|
||||||
DiagArgName, DiagArgValue, DiagnosticMessage, IntoDiagnostic, IntoDiagnosticArg,
|
|
||||||
};
|
|
||||||
use rustc_hir::CRATE_HIR_ID;
|
use rustc_hir::CRATE_HIR_ID;
|
||||||
use rustc_middle::mir::AssertKind;
|
use rustc_middle::mir::AssertKind;
|
||||||
use rustc_middle::query::TyCtxtAt;
|
use rustc_middle::query::TyCtxtAt;
|
||||||
@ -25,7 +23,7 @@ pub enum ConstEvalErrKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MachineStopType for ConstEvalErrKind {
|
impl MachineStopType for ConstEvalErrKind {
|
||||||
fn diagnostic_message(&self) -> DiagnosticMessage {
|
fn diagnostic_message(&self) -> DiagMessage {
|
||||||
use crate::fluent_generated::*;
|
use crate::fluent_generated::*;
|
||||||
use ConstEvalErrKind::*;
|
use ConstEvalErrKind::*;
|
||||||
match self {
|
match self {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, Diag, DiagArgValue, DiagCtxt, DiagnosticMessage, EmissionGuarantee, IntoDiagnostic,
|
codes::*, Diag, DiagArgValue, DiagCtxt, DiagMessage, EmissionGuarantee, IntoDiagnostic, Level,
|
||||||
Level,
|
|
||||||
};
|
};
|
||||||
use rustc_hir::ConstContext;
|
use rustc_hir::ConstContext;
|
||||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||||
@ -424,7 +423,7 @@ pub struct UndefinedBehavior {
|
|||||||
|
|
||||||
pub trait ReportErrorExt {
|
pub trait ReportErrorExt {
|
||||||
/// Returns the diagnostic message for this error.
|
/// 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 add_args<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>);
|
||||||
|
|
||||||
fn debug(self) -> String
|
fn debug(self) -> String
|
||||||
@ -433,7 +432,7 @@ pub trait ReportErrorExt {
|
|||||||
{
|
{
|
||||||
ty::tls::with(move |tcx| {
|
ty::tls::with(move |tcx| {
|
||||||
let dcx = tcx.dcx();
|
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();
|
let message = self.diagnostic_message();
|
||||||
self.add_args(&mut diag);
|
self.add_args(&mut diag);
|
||||||
let s = dcx.eagerly_translate_to_string(message, diag.args.iter());
|
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> {
|
impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
|
||||||
fn diagnostic_message(&self) -> DiagnosticMessage {
|
fn diagnostic_message(&self) -> DiagMessage {
|
||||||
use crate::fluent_generated::*;
|
use crate::fluent_generated::*;
|
||||||
use UndefinedBehaviorInfo::*;
|
use UndefinedBehaviorInfo::*;
|
||||||
match self {
|
match self {
|
||||||
@ -595,7 +594,7 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
|
impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
|
||||||
fn diagnostic_message(&self) -> DiagnosticMessage {
|
fn diagnostic_message(&self) -> DiagMessage {
|
||||||
use crate::fluent_generated::*;
|
use crate::fluent_generated::*;
|
||||||
use rustc_middle::mir::interpret::ValidationErrorKind::*;
|
use rustc_middle::mir::interpret::ValidationErrorKind::*;
|
||||||
match self.kind {
|
match self.kind {
|
||||||
@ -783,7 +782,7 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ReportErrorExt for UnsupportedOpInfo {
|
impl ReportErrorExt for UnsupportedOpInfo {
|
||||||
fn diagnostic_message(&self) -> DiagnosticMessage {
|
fn diagnostic_message(&self) -> DiagMessage {
|
||||||
use crate::fluent_generated::*;
|
use crate::fluent_generated::*;
|
||||||
match self {
|
match self {
|
||||||
UnsupportedOpInfo::Unsupported(s) => s.clone().into(),
|
UnsupportedOpInfo::Unsupported(s) => s.clone().into(),
|
||||||
@ -819,7 +818,7 @@ impl ReportErrorExt for UnsupportedOpInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ReportErrorExt for InterpError<'tcx> {
|
impl<'tcx> ReportErrorExt for InterpError<'tcx> {
|
||||||
fn diagnostic_message(&self) -> DiagnosticMessage {
|
fn diagnostic_message(&self) -> DiagMessage {
|
||||||
match self {
|
match self {
|
||||||
InterpError::UndefinedBehavior(ub) => ub.diagnostic_message(),
|
InterpError::UndefinedBehavior(ub) => ub.diagnostic_message(),
|
||||||
InterpError::Unsupported(e) => e.diagnostic_message(),
|
InterpError::Unsupported(e) => e.diagnostic_message(),
|
||||||
@ -842,7 +841,7 @@ impl<'tcx> ReportErrorExt for InterpError<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> {
|
impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> {
|
||||||
fn diagnostic_message(&self) -> DiagnosticMessage {
|
fn diagnostic_message(&self) -> DiagMessage {
|
||||||
use crate::fluent_generated::*;
|
use crate::fluent_generated::*;
|
||||||
match self {
|
match self {
|
||||||
InvalidProgramInfo::TooGeneric => const_eval_too_generic,
|
InvalidProgramInfo::TooGeneric => const_eval_too_generic,
|
||||||
@ -877,7 +876,7 @@ impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ReportErrorExt for ResourceExhaustionInfo {
|
impl ReportErrorExt for ResourceExhaustionInfo {
|
||||||
fn diagnostic_message(&self) -> DiagnosticMessage {
|
fn diagnostic_message(&self) -> DiagMessage {
|
||||||
use crate::fluent_generated::*;
|
use crate::fluent_generated::*;
|
||||||
match self {
|
match self {
|
||||||
ResourceExhaustionInfo::StackFrameLimitReached => const_eval_stack_frame_limit_reached,
|
ResourceExhaustionInfo::StackFrameLimitReached => const_eval_stack_frame_limit_reached,
|
||||||
|
@ -253,8 +253,8 @@ type FluentId = Cow<'static, str>;
|
|||||||
/// translatable and non-translatable diagnostic messages.
|
/// translatable and non-translatable diagnostic messages.
|
||||||
///
|
///
|
||||||
/// Translatable messages for subdiagnostics are typically attributes attached to a larger Fluent
|
/// 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
|
/// message so messages of this type must be combined with a `DiagMessage` (using
|
||||||
/// `DiagnosticMessage::with_subdiagnostic_message`) before rendering. However, subdiagnostics from
|
/// `DiagMessage::with_subdiagnostic_message`) before rendering. However, subdiagnostics from
|
||||||
/// the `Subdiagnostic` derive refer to Fluent identifiers directly.
|
/// the `Subdiagnostic` derive refer to Fluent identifiers directly.
|
||||||
#[rustc_diagnostic_item = "SubdiagnosticMessage"]
|
#[rustc_diagnostic_item = "SubdiagnosticMessage"]
|
||||||
pub enum SubdiagnosticMessage {
|
pub enum SubdiagnosticMessage {
|
||||||
@ -265,7 +265,7 @@ pub enum SubdiagnosticMessage {
|
|||||||
/// Some diagnostics have repeated subdiagnostics where the same interpolated variables would
|
/// Some diagnostics have repeated subdiagnostics where the same interpolated variables would
|
||||||
/// be instantiated multiple times with different values. These subdiagnostics' messages
|
/// be instantiated multiple times with different values. These subdiagnostics' messages
|
||||||
/// are translated when they are added to the parent diagnostic, producing this variant of
|
/// are translated when they are added to the parent diagnostic, producing this variant of
|
||||||
/// `DiagnosticMessage`.
|
/// `DiagMessage`.
|
||||||
Translated(Cow<'static, str>),
|
Translated(Cow<'static, str>),
|
||||||
/// Identifier of a Fluent message. Instances of this variant are generated by the
|
/// Identifier of a Fluent message. Instances of this variant are generated by the
|
||||||
/// `Subdiagnostic` derive.
|
/// `Subdiagnostic` derive.
|
||||||
@ -299,8 +299,8 @@ impl From<Cow<'static, str>> for SubdiagnosticMessage {
|
|||||||
///
|
///
|
||||||
/// Intended to be removed once diagnostics are entirely translatable.
|
/// Intended to be removed once diagnostics are entirely translatable.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
|
||||||
#[rustc_diagnostic_item = "DiagnosticMessage"]
|
#[rustc_diagnostic_item = "DiagMessage"]
|
||||||
pub enum DiagnosticMessage {
|
pub enum DiagMessage {
|
||||||
/// Non-translatable diagnostic message.
|
/// Non-translatable diagnostic message.
|
||||||
Str(Cow<'static, str>),
|
Str(Cow<'static, str>),
|
||||||
/// Translatable message which has been already translated.
|
/// 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
|
/// Some diagnostics have repeated subdiagnostics where the same interpolated variables would
|
||||||
/// be instantiated multiple times with different values. These subdiagnostics' messages
|
/// be instantiated multiple times with different values. These subdiagnostics' messages
|
||||||
/// are translated when they are added to the parent diagnostic, producing this variant of
|
/// are translated when they are added to the parent diagnostic, producing this variant of
|
||||||
/// `DiagnosticMessage`.
|
/// `DiagMessage`.
|
||||||
Translated(Cow<'static, str>),
|
Translated(Cow<'static, str>),
|
||||||
/// Identifier for a Fluent message (with optional attribute) corresponding to the diagnostic
|
/// Identifier for a Fluent message (with optional attribute) corresponding to the diagnostic
|
||||||
/// message. Yet to be translated.
|
/// message. Yet to be translated.
|
||||||
@ -318,85 +318,81 @@ pub enum DiagnosticMessage {
|
|||||||
FluentIdentifier(FluentId, Option<FluentId>),
|
FluentIdentifier(FluentId, Option<FluentId>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DiagnosticMessage {
|
impl DiagMessage {
|
||||||
/// Given a `SubdiagnosticMessage` which may contain a Fluent attribute, create a new
|
/// 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
|
/// - If the `SubdiagnosticMessage` is non-translatable then return the message as a
|
||||||
/// `DiagnosticMessage`.
|
/// `DiagMessage`.
|
||||||
/// - If `self` is non-translatable then return `self`'s message.
|
/// - 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: SubdiagnosticMessage) -> Self {
|
||||||
let attr = match sub {
|
let attr = match sub {
|
||||||
SubdiagnosticMessage::Str(s) => return DiagnosticMessage::Str(s),
|
SubdiagnosticMessage::Str(s) => return DiagMessage::Str(s),
|
||||||
SubdiagnosticMessage::Translated(s) => return DiagnosticMessage::Translated(s),
|
SubdiagnosticMessage::Translated(s) => return DiagMessage::Translated(s),
|
||||||
SubdiagnosticMessage::FluentIdentifier(id) => {
|
SubdiagnosticMessage::FluentIdentifier(id) => {
|
||||||
return DiagnosticMessage::FluentIdentifier(id, None);
|
return DiagMessage::FluentIdentifier(id, None);
|
||||||
}
|
}
|
||||||
SubdiagnosticMessage::FluentAttr(attr) => attr,
|
SubdiagnosticMessage::FluentAttr(attr) => attr,
|
||||||
};
|
};
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
DiagnosticMessage::Str(s) => DiagnosticMessage::Str(s.clone()),
|
DiagMessage::Str(s) => DiagMessage::Str(s.clone()),
|
||||||
DiagnosticMessage::Translated(s) => DiagnosticMessage::Translated(s.clone()),
|
DiagMessage::Translated(s) => DiagMessage::Translated(s.clone()),
|
||||||
DiagnosticMessage::FluentIdentifier(id, _) => {
|
DiagMessage::FluentIdentifier(id, _) => {
|
||||||
DiagnosticMessage::FluentIdentifier(id.clone(), Some(attr))
|
DiagMessage::FluentIdentifier(id.clone(), Some(attr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_str(&self) -> Option<&str> {
|
pub fn as_str(&self) -> Option<&str> {
|
||||||
match self {
|
match self {
|
||||||
DiagnosticMessage::Translated(s) | DiagnosticMessage::Str(s) => Some(s),
|
DiagMessage::Translated(s) | DiagMessage::Str(s) => Some(s),
|
||||||
DiagnosticMessage::FluentIdentifier(_, _) => None,
|
DiagMessage::FluentIdentifier(_, _) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<String> for DiagnosticMessage {
|
impl From<String> for DiagMessage {
|
||||||
fn from(s: String) -> Self {
|
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 {
|
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 {
|
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.
|
/// 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);
|
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 {
|
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
|
/// 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 `SubdiagnosticMessage` and the
|
||||||
/// subdiagnostic derive refers to typed identifiers that are `DiagnosticMessage`s, so need to be
|
/// 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 `DiagnosticMessage`
|
/// 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.
|
/// 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 {
|
fn into(self) -> SubdiagnosticMessage {
|
||||||
match self {
|
match self {
|
||||||
DiagnosticMessage::Str(s) => SubdiagnosticMessage::Str(s),
|
DiagMessage::Str(s) => SubdiagnosticMessage::Str(s),
|
||||||
DiagnosticMessage::Translated(s) => SubdiagnosticMessage::Translated(s),
|
DiagMessage::Translated(s) => SubdiagnosticMessage::Translated(s),
|
||||||
DiagnosticMessage::FluentIdentifier(id, None) => {
|
DiagMessage::FluentIdentifier(id, None) => SubdiagnosticMessage::FluentIdentifier(id),
|
||||||
SubdiagnosticMessage::FluentIdentifier(id)
|
|
||||||
}
|
|
||||||
// There isn't really a sensible behaviour for this because it loses information but
|
// There isn't really a sensible behaviour for this because it loses information but
|
||||||
// this is the most sensible of the behaviours.
|
// this is the most sensible of the behaviours.
|
||||||
DiagnosticMessage::FluentIdentifier(_, Some(attr)) => {
|
DiagMessage::FluentIdentifier(_, Some(attr)) => SubdiagnosticMessage::FluentAttr(attr),
|
||||||
SubdiagnosticMessage::FluentAttr(attr)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -412,7 +408,7 @@ pub struct SpanLabel {
|
|||||||
pub is_primary: bool,
|
pub is_primary: bool,
|
||||||
|
|
||||||
/// What label should we attach to this span (if any)?
|
/// What label should we attach to this span (if any)?
|
||||||
pub label: Option<DiagnosticMessage>,
|
pub label: Option<DiagMessage>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A collection of `Span`s.
|
/// A collection of `Span`s.
|
||||||
@ -426,7 +422,7 @@ pub struct SpanLabel {
|
|||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq, Encodable, Decodable)]
|
#[derive(Clone, Debug, Hash, PartialEq, Eq, Encodable, Decodable)]
|
||||||
pub struct MultiSpan {
|
pub struct MultiSpan {
|
||||||
primary_spans: Vec<Span>,
|
primary_spans: Vec<Span>,
|
||||||
span_labels: Vec<(Span, DiagnosticMessage)>,
|
span_labels: Vec<(Span, DiagMessage)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MultiSpan {
|
impl MultiSpan {
|
||||||
@ -444,7 +440,7 @@ impl MultiSpan {
|
|||||||
MultiSpan { primary_spans: vec, span_labels: vec![] }
|
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()));
|
self.span_labels.push((span, label.into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,7 +483,7 @@ impl MultiSpan {
|
|||||||
replacements_occurred
|
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()
|
self.span_labels.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ use crate::emitter::FileWithAnnotatedLines;
|
|||||||
use crate::snippet::Line;
|
use crate::snippet::Line;
|
||||||
use crate::translation::{to_fluent_args, Translate};
|
use crate::translation::{to_fluent_args, Translate};
|
||||||
use crate::{
|
use crate::{
|
||||||
CodeSuggestion, DiagInner, DiagnosticMessage, Emitter, ErrCode, FluentBundle,
|
CodeSuggestion, DiagInner, DiagMessage, Emitter, ErrCode, FluentBundle, LazyFallbackBundle,
|
||||||
LazyFallbackBundle, Level, MultiSpan, Style, Subdiag,
|
Level, MultiSpan, Style, Subdiag,
|
||||||
};
|
};
|
||||||
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
|
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
@ -125,7 +125,7 @@ impl AnnotateSnippetEmitter {
|
|||||||
fn emit_messages_default(
|
fn emit_messages_default(
|
||||||
&mut self,
|
&mut self,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
messages: &[(DiagnosticMessage, Style)],
|
messages: &[(DiagMessage, Style)],
|
||||||
args: &FluentArgs<'_>,
|
args: &FluentArgs<'_>,
|
||||||
code: &Option<ErrCode>,
|
code: &Option<ErrCode>,
|
||||||
msp: &MultiSpan,
|
msp: &MultiSpan,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::snippet::Style;
|
use crate::snippet::Style;
|
||||||
use crate::{
|
use crate::{
|
||||||
CodeSuggestion, DiagCtxt, DiagnosticMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level,
|
CodeSuggestion, DiagCtxt, DiagMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level, MultiSpan,
|
||||||
MultiSpan, StashKey, SubdiagnosticMessage, Substitution, SubstitutionPart, SuggestionStyle,
|
StashKey, SubdiagnosticMessage, Substitution, SubstitutionPart, SuggestionStyle,
|
||||||
};
|
};
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_error_messages::fluent_value_from_str_list_sep_by_and;
|
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.
|
/// Decorate and emit a lint.
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>);
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>);
|
||||||
|
|
||||||
fn msg(&self) -> DiagnosticMessage;
|
fn msg(&self) -> DiagMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Encodable, Decodable)]
|
#[derive(Clone, Debug, Encodable, Decodable)]
|
||||||
@ -291,7 +291,7 @@ pub struct DiagInner {
|
|||||||
// outside of what methods in this crate themselves allow.
|
// outside of what methods in this crate themselves allow.
|
||||||
pub(crate) level: Level,
|
pub(crate) level: Level,
|
||||||
|
|
||||||
pub messages: Vec<(DiagnosticMessage, Style)>,
|
pub messages: Vec<(DiagMessage, Style)>,
|
||||||
pub code: Option<ErrCode>,
|
pub code: Option<ErrCode>,
|
||||||
pub span: MultiSpan,
|
pub span: MultiSpan,
|
||||||
pub children: Vec<Subdiag>,
|
pub children: Vec<Subdiag>,
|
||||||
@ -312,12 +312,12 @@ pub struct DiagInner {
|
|||||||
|
|
||||||
impl DiagInner {
|
impl DiagInner {
|
||||||
#[track_caller]
|
#[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)])
|
DiagInner::new_with_messages(level, vec![(message.into(), Style::NoStyle)])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[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 {
|
DiagInner {
|
||||||
level,
|
level,
|
||||||
messages,
|
messages,
|
||||||
@ -397,7 +397,7 @@ impl DiagInner {
|
|||||||
pub(crate) fn subdiagnostic_message_to_diagnostic_message(
|
pub(crate) fn subdiagnostic_message_to_diagnostic_message(
|
||||||
&self,
|
&self,
|
||||||
attr: impl Into<SubdiagnosticMessage>,
|
attr: impl Into<SubdiagnosticMessage>,
|
||||||
) -> DiagnosticMessage {
|
) -> DiagMessage {
|
||||||
let msg =
|
let msg =
|
||||||
self.messages.iter().map(|(msg, _)| msg).next().expect("diagnostic with no messages");
|
self.messages.iter().map(|(msg, _)| msg).next().expect("diagnostic with no messages");
|
||||||
msg.with_subdiagnostic_message(attr.into())
|
msg.with_subdiagnostic_message(attr.into())
|
||||||
@ -429,7 +429,7 @@ impl DiagInner {
|
|||||||
&self,
|
&self,
|
||||||
) -> (
|
) -> (
|
||||||
&Level,
|
&Level,
|
||||||
&[(DiagnosticMessage, Style)],
|
&[(DiagMessage, Style)],
|
||||||
&Option<ErrCode>,
|
&Option<ErrCode>,
|
||||||
&MultiSpan,
|
&MultiSpan,
|
||||||
&[Subdiag],
|
&[Subdiag],
|
||||||
@ -472,7 +472,7 @@ impl PartialEq for DiagInner {
|
|||||||
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
|
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
|
||||||
pub struct Subdiag {
|
pub struct Subdiag {
|
||||||
pub level: Level,
|
pub level: Level,
|
||||||
pub messages: Vec<(DiagnosticMessage, Style)>,
|
pub messages: Vec<(DiagMessage, Style)>,
|
||||||
pub span: MultiSpan,
|
pub span: MultiSpan,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,7 +578,7 @@ macro_rules! with_fn {
|
|||||||
impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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))
|
Self::new_diagnostic(dcx, DiagInner::new(level, message))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1203,7 +1203,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
|||||||
|
|
||||||
with_fn! { with_primary_message,
|
with_fn! { with_primary_message,
|
||||||
/// Add a 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.messages[0] = (msg.into(), Style::NoStyle);
|
||||||
self
|
self
|
||||||
} }
|
} }
|
||||||
@ -1219,13 +1219,13 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
|||||||
self
|
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
|
/// combining it with the primary message of the diagnostic (if translatable, otherwise it just
|
||||||
/// passes the user's string along).
|
/// passes the user's string along).
|
||||||
pub(crate) fn subdiagnostic_message_to_diagnostic_message(
|
pub(crate) fn subdiagnostic_message_to_diagnostic_message(
|
||||||
&self,
|
&self,
|
||||||
attr: impl Into<SubdiagnosticMessage>,
|
attr: impl Into<SubdiagnosticMessage>,
|
||||||
) -> DiagnosticMessage {
|
) -> DiagMessage {
|
||||||
self.deref().subdiagnostic_message_to_diagnostic_message(attr)
|
self.deref().subdiagnostic_message_to_diagnostic_message(attr)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1338,7 +1338,7 @@ impl<G: EmissionGuarantee> Drop for Diag<'_, G> {
|
|||||||
Some(diag) if !panicking() => {
|
Some(diag) if !panicking() => {
|
||||||
self.dcx.emit_diagnostic(DiagInner::new(
|
self.dcx.emit_diagnostic(DiagInner::new(
|
||||||
Level::Bug,
|
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);
|
self.dcx.emit_diagnostic(*diag);
|
||||||
panic!("error was constructed but not emitted");
|
panic!("error was constructed but not emitted");
|
||||||
|
@ -17,7 +17,7 @@ use crate::snippet::{
|
|||||||
use crate::styled_buffer::StyledBuffer;
|
use crate::styled_buffer::StyledBuffer;
|
||||||
use crate::translation::{to_fluent_args, Translate};
|
use crate::translation::{to_fluent_args, Translate};
|
||||||
use crate::{
|
use crate::{
|
||||||
diagnostic::DiagLocation, CodeSuggestion, DiagCtxt, DiagInner, DiagnosticMessage, ErrCode,
|
diagnostic::DiagLocation, CodeSuggestion, DiagCtxt, DiagInner, DiagMessage, ErrCode,
|
||||||
FluentBundle, LazyFallbackBundle, Level, MultiSpan, Subdiag, SubstitutionHighlight,
|
FluentBundle, LazyFallbackBundle, Level, MultiSpan, Subdiag, SubstitutionHighlight,
|
||||||
SuggestionStyle, TerminalUrl,
|
SuggestionStyle, TerminalUrl,
|
||||||
};
|
};
|
||||||
@ -339,7 +339,7 @@ pub trait Emitter: Translate {
|
|||||||
|
|
||||||
children.push(Subdiag {
|
children.push(Subdiag {
|
||||||
level: Level::Note,
|
level: Level::Note,
|
||||||
messages: vec![(DiagnosticMessage::from(msg), Style::NoStyle)],
|
messages: vec![(DiagMessage::from(msg), Style::NoStyle)],
|
||||||
span: MultiSpan::new(),
|
span: MultiSpan::new(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -543,12 +543,10 @@ pub struct SilentEmitter {
|
|||||||
pub fatal_note: String,
|
pub fatal_note: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn silent_translate<'a>(
|
pub fn silent_translate<'a>(message: &'a DiagMessage) -> Result<Cow<'_, str>, TranslateError<'_>> {
|
||||||
message: &'a DiagnosticMessage,
|
|
||||||
) -> Result<Cow<'_, str>, TranslateError<'_>> {
|
|
||||||
match message {
|
match message {
|
||||||
DiagnosticMessage::Str(msg) | DiagnosticMessage::Translated(msg) => Ok(Cow::Borrowed(msg)),
|
DiagMessage::Str(msg) | DiagMessage::Translated(msg) => Ok(Cow::Borrowed(msg)),
|
||||||
DiagnosticMessage::FluentIdentifier(identifier, _) => {
|
DiagMessage::FluentIdentifier(identifier, _) => {
|
||||||
// Any value works here.
|
// Any value works here.
|
||||||
Ok(identifier.clone())
|
Ok(identifier.clone())
|
||||||
}
|
}
|
||||||
@ -568,7 +566,7 @@ impl Translate for SilentEmitter {
|
|||||||
// subdiagnostics result in a call to this.
|
// subdiagnostics result in a call to this.
|
||||||
fn translate_message<'a>(
|
fn translate_message<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
message: &'a DiagnosticMessage,
|
message: &'a DiagMessage,
|
||||||
_: &'a FluentArgs<'_>,
|
_: &'a FluentArgs<'_>,
|
||||||
) -> Result<Cow<'_, str>, TranslateError<'_>> {
|
) -> Result<Cow<'_, str>, TranslateError<'_>> {
|
||||||
silent_translate(message)
|
silent_translate(message)
|
||||||
@ -1216,7 +1214,7 @@ impl HumanEmitter {
|
|||||||
fn msgs_to_buffer(
|
fn msgs_to_buffer(
|
||||||
&self,
|
&self,
|
||||||
buffer: &mut StyledBuffer,
|
buffer: &mut StyledBuffer,
|
||||||
msgs: &[(DiagnosticMessage, Style)],
|
msgs: &[(DiagMessage, Style)],
|
||||||
args: &FluentArgs<'_>,
|
args: &FluentArgs<'_>,
|
||||||
padding: usize,
|
padding: usize,
|
||||||
label: &str,
|
label: &str,
|
||||||
@ -1291,7 +1289,7 @@ impl HumanEmitter {
|
|||||||
fn emit_messages_default_inner(
|
fn emit_messages_default_inner(
|
||||||
&mut self,
|
&mut self,
|
||||||
msp: &MultiSpan,
|
msp: &MultiSpan,
|
||||||
msgs: &[(DiagnosticMessage, Style)],
|
msgs: &[(DiagMessage, Style)],
|
||||||
args: &FluentArgs<'_>,
|
args: &FluentArgs<'_>,
|
||||||
code: &Option<ErrCode>,
|
code: &Option<ErrCode>,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
@ -2060,7 +2058,7 @@ impl HumanEmitter {
|
|||||||
fn emit_messages_default(
|
fn emit_messages_default(
|
||||||
&mut self,
|
&mut self,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
messages: &[(DiagnosticMessage, Style)],
|
messages: &[(DiagMessage, Style)],
|
||||||
args: &FluentArgs<'_>,
|
args: &FluentArgs<'_>,
|
||||||
code: &Option<ErrCode>,
|
code: &Option<ErrCode>,
|
||||||
span: &MultiSpan,
|
span: &MultiSpan,
|
||||||
|
@ -47,8 +47,8 @@ pub use diagnostic_impls::{
|
|||||||
};
|
};
|
||||||
pub use emitter::ColorConfig;
|
pub use emitter::ColorConfig;
|
||||||
pub use rustc_error_messages::{
|
pub use rustc_error_messages::{
|
||||||
fallback_fluent_bundle, fluent_bundle, DelayDm, DiagnosticMessage, FluentBundle,
|
fallback_fluent_bundle, fluent_bundle, DelayDm, DiagMessage, FluentBundle, LanguageIdentifier,
|
||||||
LanguageIdentifier, LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagnosticMessage,
|
LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagnosticMessage,
|
||||||
};
|
};
|
||||||
pub use rustc_lint_defs::{pluralize, Applicability};
|
pub use rustc_lint_defs::{pluralize, Applicability};
|
||||||
pub use rustc_span::fatal_error::{FatalError, FatalErrorMarker};
|
pub use rustc_span::fatal_error::{FatalError, FatalErrorMarker};
|
||||||
@ -154,7 +154,7 @@ pub struct CodeSuggestion {
|
|||||||
/// ]
|
/// ]
|
||||||
/// ```
|
/// ```
|
||||||
pub substitutions: Vec<Substitution>,
|
pub substitutions: Vec<Substitution>,
|
||||||
pub msg: DiagnosticMessage,
|
pub msg: DiagMessage,
|
||||||
/// Visual representation of this suggestion.
|
/// Visual representation of this suggestion.
|
||||||
pub style: SuggestionStyle,
|
pub style: SuggestionStyle,
|
||||||
/// Whether or not the suggestion is approximate
|
/// Whether or not the suggestion is approximate
|
||||||
@ -634,7 +634,7 @@ impl DiagCtxt {
|
|||||||
/// Translate `message` eagerly with `args` to `SubdiagnosticMessage::Eager`.
|
/// Translate `message` eagerly with `args` to `SubdiagnosticMessage::Eager`.
|
||||||
pub fn eagerly_translate<'a>(
|
pub fn eagerly_translate<'a>(
|
||||||
&self,
|
&self,
|
||||||
message: DiagnosticMessage,
|
message: DiagMessage,
|
||||||
args: impl Iterator<Item = DiagArg<'a>>,
|
args: impl Iterator<Item = DiagArg<'a>>,
|
||||||
) -> SubdiagnosticMessage {
|
) -> SubdiagnosticMessage {
|
||||||
let inner = self.inner.borrow();
|
let inner = self.inner.borrow();
|
||||||
@ -644,7 +644,7 @@ impl DiagCtxt {
|
|||||||
/// Translate `message` eagerly with `args` to `String`.
|
/// Translate `message` eagerly with `args` to `String`.
|
||||||
pub fn eagerly_translate_to_string<'a>(
|
pub fn eagerly_translate_to_string<'a>(
|
||||||
&self,
|
&self,
|
||||||
message: DiagnosticMessage,
|
message: DiagMessage,
|
||||||
args: impl Iterator<Item = DiagArg<'a>>,
|
args: impl Iterator<Item = DiagArg<'a>>,
|
||||||
) -> String {
|
) -> String {
|
||||||
let inner = self.inner.borrow();
|
let inner = self.inner.borrow();
|
||||||
@ -904,7 +904,7 @@ impl DiagCtxt {
|
|||||||
// configuration like `--cap-lints allow --force-warn bare_trait_objects`.
|
// configuration like `--cap-lints allow --force-warn bare_trait_objects`.
|
||||||
inner.emit_diagnostic(DiagInner::new(
|
inner.emit_diagnostic(DiagInner::new(
|
||||||
ForceWarning(None),
|
ForceWarning(None),
|
||||||
DiagnosticMessage::Str(warnings),
|
DiagMessage::Str(warnings),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
(_, 0) => {
|
(_, 0) => {
|
||||||
@ -1078,13 +1078,13 @@ impl DiagCtxt {
|
|||||||
impl DiagCtxt {
|
impl DiagCtxt {
|
||||||
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
|
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
|
||||||
#[track_caller]
|
#[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)
|
Diag::new(self, Bug, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
|
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn bug(&self, msg: impl Into<DiagnosticMessage>) -> ! {
|
pub fn bug(&self, msg: impl Into<DiagMessage>) -> ! {
|
||||||
self.struct_bug(msg).emit()
|
self.struct_bug(msg).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1093,14 +1093,14 @@ impl DiagCtxt {
|
|||||||
pub fn struct_span_bug(
|
pub fn struct_span_bug(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
) -> Diag<'_, BugAbort> {
|
) -> Diag<'_, BugAbort> {
|
||||||
self.struct_bug(msg).with_span(span)
|
self.struct_bug(msg).with_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
|
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
|
||||||
#[track_caller]
|
#[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()
|
self.struct_span_bug(span, msg).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1116,13 +1116,13 @@ impl DiagCtxt {
|
|||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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)
|
Diag::new(self, Fatal, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
|
pub fn fatal(&self, msg: impl Into<DiagMessage>) -> ! {
|
||||||
self.struct_fatal(msg).emit()
|
self.struct_fatal(msg).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1131,14 +1131,14 @@ impl DiagCtxt {
|
|||||||
pub fn struct_span_fatal(
|
pub fn struct_span_fatal(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
) -> Diag<'_, FatalAbort> {
|
) -> Diag<'_, FatalAbort> {
|
||||||
self.struct_fatal(msg).with_span(span)
|
self.struct_fatal(msg).with_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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()
|
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).
|
// FIXME: This method should be removed (every error should have an associated error code).
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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)
|
Diag::new(self, Error, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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()
|
self.struct_err(msg).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1189,7 +1189,7 @@ impl DiagCtxt {
|
|||||||
pub fn struct_span_err(
|
pub fn struct_span_err(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
) -> Diag<'_> {
|
) -> Diag<'_> {
|
||||||
self.struct_err(msg).with_span(span)
|
self.struct_err(msg).with_span(span)
|
||||||
}
|
}
|
||||||
@ -1199,7 +1199,7 @@ impl DiagCtxt {
|
|||||||
pub fn span_err(
|
pub fn span_err(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
self.struct_span_err(span, msg).emit()
|
self.struct_span_err(span, msg).emit()
|
||||||
}
|
}
|
||||||
@ -1217,7 +1217,7 @@ impl DiagCtxt {
|
|||||||
/// Ensures that an error is printed. See `Level::DelayedBug`.
|
/// Ensures that an error is printed. See `Level::DelayedBug`.
|
||||||
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
|
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
|
||||||
#[track_caller]
|
#[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()
|
Diag::<ErrorGuaranteed>::new(self, DelayedBug, msg).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1230,20 +1230,20 @@ impl DiagCtxt {
|
|||||||
pub fn span_delayed_bug(
|
pub fn span_delayed_bug(
|
||||||
&self,
|
&self,
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
Diag::<ErrorGuaranteed>::new(self, DelayedBug, msg).with_span(sp).emit()
|
Diag::<ErrorGuaranteed>::new(self, DelayedBug, msg).with_span(sp).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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)
|
Diag::new(self, Warning, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn warn(&self, msg: impl Into<DiagnosticMessage>) {
|
pub fn warn(&self, msg: impl Into<DiagMessage>) {
|
||||||
self.struct_warn(msg).emit()
|
self.struct_warn(msg).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1252,14 +1252,14 @@ impl DiagCtxt {
|
|||||||
pub fn struct_span_warn(
|
pub fn struct_span_warn(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
) -> Diag<'_, ()> {
|
) -> Diag<'_, ()> {
|
||||||
self.struct_warn(msg).with_span(span)
|
self.struct_warn(msg).with_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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()
|
self.struct_span_warn(span, msg).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1275,13 +1275,13 @@ impl DiagCtxt {
|
|||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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)
|
Diag::new(self, Note, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn note(&self, msg: impl Into<DiagnosticMessage>) {
|
pub fn note(&self, msg: impl Into<DiagMessage>) {
|
||||||
self.struct_note(msg).emit()
|
self.struct_note(msg).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1290,14 +1290,14 @@ impl DiagCtxt {
|
|||||||
pub fn struct_span_note(
|
pub fn struct_span_note(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
) -> Diag<'_, ()> {
|
) -> Diag<'_, ()> {
|
||||||
self.struct_note(msg).with_span(span)
|
self.struct_note(msg).with_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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()
|
self.struct_span_note(span, msg).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1313,19 +1313,19 @@ impl DiagCtxt {
|
|||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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)
|
Diag::new(self, Help, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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)
|
Diag::new(self, FailureNote, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[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)
|
Diag::new(self, Allow, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1333,7 +1333,7 @@ impl DiagCtxt {
|
|||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn struct_expect(
|
pub fn struct_expect(
|
||||||
&self,
|
&self,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
id: LintExpectationId,
|
id: LintExpectationId,
|
||||||
) -> Diag<'_, ()> {
|
) -> Diag<'_, ()> {
|
||||||
Diag::new(self, Expect(id), msg)
|
Diag::new(self, Expect(id), msg)
|
||||||
@ -1556,7 +1556,7 @@ impl DiagCtxtInner {
|
|||||||
/// Translate `message` eagerly with `args` to `SubdiagnosticMessage::Eager`.
|
/// Translate `message` eagerly with `args` to `SubdiagnosticMessage::Eager`.
|
||||||
pub fn eagerly_translate<'a>(
|
pub fn eagerly_translate<'a>(
|
||||||
&self,
|
&self,
|
||||||
message: DiagnosticMessage,
|
message: DiagMessage,
|
||||||
args: impl Iterator<Item = DiagArg<'a>>,
|
args: impl Iterator<Item = DiagArg<'a>>,
|
||||||
) -> SubdiagnosticMessage {
|
) -> SubdiagnosticMessage {
|
||||||
SubdiagnosticMessage::Translated(Cow::from(self.eagerly_translate_to_string(message, args)))
|
SubdiagnosticMessage::Translated(Cow::from(self.eagerly_translate_to_string(message, args)))
|
||||||
@ -1565,7 +1565,7 @@ impl DiagCtxtInner {
|
|||||||
/// Translate `message` eagerly with `args` to `String`.
|
/// Translate `message` eagerly with `args` to `String`.
|
||||||
pub fn eagerly_translate_to_string<'a>(
|
pub fn eagerly_translate_to_string<'a>(
|
||||||
&self,
|
&self,
|
||||||
message: DiagnosticMessage,
|
message: DiagMessage,
|
||||||
args: impl Iterator<Item = DiagArg<'a>>,
|
args: impl Iterator<Item = DiagArg<'a>>,
|
||||||
) -> String {
|
) -> String {
|
||||||
let args = crate::translation::to_fluent_args(args);
|
let args = crate::translation::to_fluent_args(args);
|
||||||
|
@ -5,7 +5,7 @@ use crate::FluentBundle;
|
|||||||
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
|
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
|
||||||
use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError};
|
use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError};
|
||||||
use rustc_error_messages::langid;
|
use rustc_error_messages::langid;
|
||||||
use rustc_error_messages::DiagnosticMessage;
|
use rustc_error_messages::DiagMessage;
|
||||||
|
|
||||||
struct Dummy {
|
struct Dummy {
|
||||||
bundle: FluentBundle,
|
bundle: FluentBundle,
|
||||||
@ -53,7 +53,7 @@ fn wellformed_fluent() {
|
|||||||
args.set("name", "Foo");
|
args.set("name", "Foo");
|
||||||
args.set("ty", "std::string::String");
|
args.set("ty", "std::string::String");
|
||||||
{
|
{
|
||||||
let message = DiagnosticMessage::FluentIdentifier(
|
let message = DiagMessage::FluentIdentifier(
|
||||||
"mir_build_borrow_of_moved_value".into(),
|
"mir_build_borrow_of_moved_value".into(),
|
||||||
Some("suggestion".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(),
|
"mir_build_borrow_of_moved_value".into(),
|
||||||
Some("value_borrowed_label".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(),
|
"mir_build_borrow_of_moved_value".into(),
|
||||||
Some("occurs_because_label".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(),
|
"mir_build_borrow_of_moved_value".into(),
|
||||||
Some("label".into()),
|
Some("label".into()),
|
||||||
);
|
);
|
||||||
@ -112,7 +112,7 @@ fn misformed_fluent() {
|
|||||||
args.set("name", "Foo");
|
args.set("name", "Foo");
|
||||||
args.set("ty", "std::string::String");
|
args.set("ty", "std::string::String");
|
||||||
{
|
{
|
||||||
let message = DiagnosticMessage::FluentIdentifier(
|
let message = DiagMessage::FluentIdentifier(
|
||||||
"mir_build_borrow_of_moved_value".into(),
|
"mir_build_borrow_of_moved_value".into(),
|
||||||
Some("value_borrowed_label".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(),
|
"mir_build_borrow_of_moved_value".into(),
|
||||||
Some("label".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(),
|
"mir_build_borrow_of_moved_value".into(),
|
||||||
Some("occurs_because_label".into()),
|
Some("occurs_because_label".into()),
|
||||||
);
|
);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::error::{TranslateError, TranslateErrorKind};
|
use crate::error::{TranslateError, TranslateErrorKind};
|
||||||
use crate::snippet::Style;
|
use crate::snippet::Style;
|
||||||
use crate::{DiagArg, DiagnosticMessage, FluentBundle};
|
use crate::{DiagArg, DiagMessage, FluentBundle};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
pub use rustc_error_messages::FluentArgs;
|
pub use rustc_error_messages::FluentArgs;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
@ -37,10 +37,10 @@ pub trait Translate {
|
|||||||
/// unavailable for the requested locale.
|
/// unavailable for the requested locale.
|
||||||
fn fallback_fluent_bundle(&self) -> &FluentBundle;
|
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(
|
fn translate_messages(
|
||||||
&self,
|
&self,
|
||||||
messages: &[(DiagnosticMessage, Style)],
|
messages: &[(DiagMessage, Style)],
|
||||||
args: &FluentArgs<'_>,
|
args: &FluentArgs<'_>,
|
||||||
) -> Cow<'_, str> {
|
) -> Cow<'_, str> {
|
||||||
Cow::Owned(
|
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>(
|
fn translate_message<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
message: &'a DiagnosticMessage,
|
message: &'a DiagMessage,
|
||||||
args: &'a FluentArgs<'_>,
|
args: &'a FluentArgs<'_>,
|
||||||
) -> Result<Cow<'_, str>, TranslateError<'_>> {
|
) -> Result<Cow<'_, str>, TranslateError<'_>> {
|
||||||
trace!(?message, ?args);
|
trace!(?message, ?args);
|
||||||
let (identifier, attr) = match message {
|
let (identifier, attr) = match message {
|
||||||
DiagnosticMessage::Str(msg) | DiagnosticMessage::Translated(msg) => {
|
DiagMessage::Str(msg) | DiagMessage::Translated(msg) => {
|
||||||
return Ok(Cow::Borrowed(msg));
|
return Ok(Cow::Borrowed(msg));
|
||||||
}
|
}
|
||||||
DiagnosticMessage::FluentIdentifier(identifier, attr) => (identifier, attr),
|
DiagMessage::FluentIdentifier(identifier, attr) => (identifier, attr),
|
||||||
};
|
};
|
||||||
let translate_with_bundle =
|
let translate_with_bundle =
|
||||||
|bundle: &'a FluentBundle| -> Result<Cow<'_, str>, TranslateError<'_>> {
|
|bundle: &'a FluentBundle| -> Result<Cow<'_, str>, TranslateError<'_>> {
|
||||||
|
@ -7,7 +7,7 @@ use crate::mbe::{
|
|||||||
use rustc_ast::token::{self, Token, TokenKind};
|
use rustc_ast::token::{self, Token, TokenKind};
|
||||||
use rustc_ast::tokenstream::TokenStream;
|
use rustc_ast::tokenstream::TokenStream;
|
||||||
use rustc_ast_pretty::pprust;
|
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_parse::parser::{Parser, Recovery};
|
||||||
use rustc_span::source_map::SourceMap;
|
use rustc_span::source_map::SourceMap;
|
||||||
use rustc_span::symbol::Ident;
|
use rustc_span::symbol::Ident;
|
||||||
@ -227,12 +227,12 @@ pub(super) fn emit_frag_parse_err(
|
|||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
// FIXME(davidtwco): avoid depending on the error message text
|
// FIXME(davidtwco): avoid depending on the error message text
|
||||||
if parser.token == token::Eof
|
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>`")
|
&& message.ends_with(", found `<eof>`")
|
||||||
{
|
{
|
||||||
let msg = &e.messages[0];
|
let msg = &e.messages[0];
|
||||||
e.messages[0] = (
|
e.messages[0] = (
|
||||||
DiagnosticMessage::from(format!(
|
DiagMessage::from(format!(
|
||||||
"macro expansion ends with an incomplete expression: {}",
|
"macro expansion ends with an incomplete expression: {}",
|
||||||
message.replace(", found `<eof>`", ""),
|
message.replace(", found `<eof>`", ""),
|
||||||
)),
|
)),
|
||||||
|
@ -110,7 +110,7 @@ use crate::mbe::{KleeneToken, TokenTree};
|
|||||||
use rustc_ast::token::{Delimiter, IdentIsRaw, Token, TokenKind};
|
use rustc_ast::token::{Delimiter, IdentIsRaw, Token, TokenKind};
|
||||||
use rustc_ast::{NodeId, DUMMY_NODE_ID};
|
use rustc_ast::{NodeId, DUMMY_NODE_ID};
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
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::lint::builtin::{META_VARIABLE_MISUSE, MISSING_FRAGMENT_SPECIFIER};
|
||||||
use rustc_session::parse::ParseSess;
|
use rustc_session::parse::ParseSess;
|
||||||
use rustc_span::symbol::kw;
|
use rustc_span::symbol::kw;
|
||||||
@ -648,7 +648,7 @@ fn buffer_lint(
|
|||||||
psess: &ParseSess,
|
psess: &ParseSess,
|
||||||
span: MultiSpan,
|
span: MultiSpan,
|
||||||
node_id: NodeId,
|
node_id: NodeId,
|
||||||
message: impl Into<DiagnosticMessage>,
|
message: impl Into<DiagMessage>,
|
||||||
) {
|
) {
|
||||||
// Macros loaded from other crates have dummy node ids.
|
// Macros loaded from other crates have dummy node ids.
|
||||||
if node_id != DUMMY_NODE_ID {
|
if node_id != DUMMY_NODE_ID {
|
||||||
|
@ -512,7 +512,7 @@ impl server::FreeFunctions for Rustc<'_, '_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn emit_diagnostic(&mut self, diagnostic: Diagnostic<Self::Span>) {
|
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<'_, ()> =
|
let mut diag: Diag<'_, ()> =
|
||||||
Diag::new(&self.psess().dcx, diagnostic.level.to_internal(), message);
|
Diag::new(&self.psess().dcx, diagnostic.level.to_internal(), message);
|
||||||
diag.span(MultiSpan::from_spans(diagnostic.spans));
|
diag.span(MultiSpan::from_spans(diagnostic.spans));
|
||||||
|
@ -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}`");
|
format!("Constant referring to Fluent message `{name}` from `{crate_name}`");
|
||||||
constants.extend(quote! {
|
constants.extend(quote! {
|
||||||
#[doc = #docstr]
|
#[doc = #docstr]
|
||||||
pub const #snake_name: rustc_errors::DiagnosticMessage =
|
pub const #snake_name: rustc_errors::DiagMessage =
|
||||||
rustc_errors::DiagnosticMessage::FluentIdentifier(std::borrow::Cow::Borrowed(#name), None);
|
rustc_errors::DiagMessage::FluentIdentifier(
|
||||||
|
std::borrow::Cow::Borrowed(#name),
|
||||||
|
None
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
for Attribute { id: Identifier { name: attr_name }, .. } in attributes {
|
for Attribute { id: Identifier { name: attr_name }, .. } in attributes {
|
||||||
|
@ -35,10 +35,10 @@ mod fluent;
|
|||||||
///
|
///
|
||||||
/// mod fluent_generated {
|
/// mod fluent_generated {
|
||||||
/// mod typeck {
|
/// mod typeck {
|
||||||
/// pub const field_multiply_specified_in_initializer: DiagnosticMessage =
|
/// pub const field_multiply_specified_in_initializer: DiagMessage =
|
||||||
/// DiagnosticMessage::fluent("typeck_field_multiply_specified_in_initializer");
|
/// DiagMessage::fluent("typeck_field_multiply_specified_in_initializer");
|
||||||
/// pub const field_multiply_specified_in_initializer_label_previous_use: DiagnosticMessage =
|
/// pub const field_multiply_specified_in_initializer_label_previous_use: DiagMessage =
|
||||||
/// DiagnosticMessage::fluent_attr(
|
/// DiagMessage::fluent_attr(
|
||||||
/// "typeck_field_multiply_specified_in_initializer",
|
/// "typeck_field_multiply_specified_in_initializer",
|
||||||
/// "previous_use_label"
|
/// "previous_use_label"
|
||||||
/// );
|
/// );
|
||||||
|
@ -7,7 +7,7 @@ use crate::errors::{
|
|||||||
WrongNumberOfGenericArgumentsToIntrinsic,
|
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_hir as hir;
|
||||||
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
|
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
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 {
|
if has_safe_attr != is_in_list {
|
||||||
tcx.dcx().struct_span_err(
|
tcx.dcx().struct_span_err(
|
||||||
tcx.def_span(intrinsic_id),
|
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 `{}`",
|
"intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `{}`",
|
||||||
tcx.item_name(intrinsic_id.into())
|
tcx.item_name(intrinsic_id.into())
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use hir::GenericParamKind;
|
use hir::GenericParamKind;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagStyledString, DiagnosticMessage,
|
codes::*, AddToDiagnostic, Applicability, Diag, DiagMessage, DiagStyledString,
|
||||||
EmissionGuarantee, IntoDiagnosticArg, MultiSpan, SubdiagnosticMessageOp,
|
EmissionGuarantee, IntoDiagnosticArg, MultiSpan, SubdiagnosticMessageOp,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
@ -209,11 +209,11 @@ impl<'a> SourceKindMultiSuggestion<'a> {
|
|||||||
pub enum RegionOriginNote<'a> {
|
pub enum RegionOriginNote<'a> {
|
||||||
Plain {
|
Plain {
|
||||||
span: Span,
|
span: Span,
|
||||||
msg: DiagnosticMessage,
|
msg: DiagMessage,
|
||||||
},
|
},
|
||||||
WithName {
|
WithName {
|
||||||
span: Span,
|
span: Span,
|
||||||
msg: DiagnosticMessage,
|
msg: DiagMessage,
|
||||||
name: &'a str,
|
name: &'a str,
|
||||||
continues: bool,
|
continues: bool,
|
||||||
},
|
},
|
||||||
@ -230,7 +230,7 @@ impl AddToDiagnostic for RegionOriginNote<'_> {
|
|||||||
diag: &mut Diag<'_, G>,
|
diag: &mut Diag<'_, G>,
|
||||||
_f: F,
|
_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 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 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);
|
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();
|
let mut type_param_span: MultiSpan = self.spans.clone().into();
|
||||||
for &span in &self.spans {
|
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);
|
type_param_span.push_span_label(span, fluent::infer_tid_consider_borrowing);
|
||||||
}
|
}
|
||||||
let msg = f(diag, fluent::infer_tid_param_help.into());
|
let msg = f(diag, fluent::infer_tid_param_help.into());
|
||||||
|
@ -21,7 +21,7 @@ use crate::passes::{EarlyLintPassObject, LateLintPassObject};
|
|||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_data_structures::sync;
|
use rustc_data_structures::sync;
|
||||||
use rustc_data_structures::unord::UnordMap;
|
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_feature::Features;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::Res;
|
use rustc_hir::def::Res;
|
||||||
@ -536,7 +536,7 @@ pub trait LintContext {
|
|||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: Option<impl Into<MultiSpan>>,
|
span: Option<impl Into<MultiSpan>>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
diagnostic: BuiltinLintDiagnostics,
|
diagnostic: BuiltinLintDiagnostics,
|
||||||
) {
|
) {
|
||||||
@ -559,7 +559,7 @@ pub trait LintContext {
|
|||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: Option<S>,
|
span: Option<S>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -584,7 +584,7 @@ pub trait LintContext {
|
|||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: S,
|
span: S,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
self.opt_span_lint(lint, Some(span), msg, decorate);
|
self.opt_span_lint(lint, Some(span), msg, decorate);
|
||||||
@ -605,7 +605,7 @@ pub trait LintContext {
|
|||||||
fn lint(
|
fn lint(
|
||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
self.opt_span_lint(lint, None as Option<Span>, msg, decorate);
|
self.opt_span_lint(lint, None as Option<Span>, msg, decorate);
|
||||||
@ -670,7 +670,7 @@ impl<'tcx> LintContext for LateContext<'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: Option<S>,
|
span: Option<S>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
let hir_id = self.last_node_with_lint_attrs;
|
let hir_id = self.last_node_with_lint_attrs;
|
||||||
@ -697,7 +697,7 @@ impl LintContext for EarlyContext<'_> {
|
|||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: Option<S>,
|
span: Option<S>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
self.builder.opt_span_lint(lint, span.map(|s| s.into()), msg, decorate)
|
self.builder.opt_span_lint(lint, span.map(|s| s.into()), msg, decorate)
|
||||||
|
@ -403,7 +403,7 @@ impl LateLintPass<'_> for Diagnostics {
|
|||||||
debug!(?ty);
|
debug!(?ty);
|
||||||
if let Some(adt_def) = ty.ty_adt_def()
|
if let Some(adt_def) = ty.ty_adt_def()
|
||||||
&& let Some(name) = cx.tcx.get_diagnostic_name(adt_def.did())
|
&& 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;
|
found_diagnostic_message = true;
|
||||||
break;
|
break;
|
||||||
|
@ -16,7 +16,7 @@ use crate::{
|
|||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
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_feature::{Features, GateIssue};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::intravisit::{self, Visitor};
|
use rustc_hir::intravisit::{self, Visitor};
|
||||||
@ -1106,7 +1106,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
|||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: Option<MultiSpan>,
|
span: Option<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level(lint);
|
let (level, src) = self.lint_level(lint);
|
||||||
|
@ -5,8 +5,8 @@ use std::num::NonZero;
|
|||||||
use crate::errors::RequestedLevel;
|
use crate::errors::RequestedLevel;
|
||||||
use crate::fluent_generated as fluent;
|
use crate::fluent_generated as fluent;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, AddToDiagnostic, Applicability, DecorateLint, Diag, DiagStyledString,
|
codes::*, AddToDiagnostic, Applicability, DecorateLint, Diag, DiagMessage, DiagStyledString,
|
||||||
DiagnosticMessage, EmissionGuarantee, SubdiagnosticMessageOp, SuggestionStyle,
|
EmissionGuarantee, SubdiagnosticMessageOp, SuggestionStyle,
|
||||||
};
|
};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_macros::{LintDiagnostic, Subdiagnostic};
|
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));
|
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
|
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
|
fluent::lint_ungated_async_fn_track_caller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -416,7 +416,7 @@ pub struct BuiltinFeatureIssueNote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct BuiltinUnpermittedTypeInit<'a> {
|
pub struct BuiltinUnpermittedTypeInit<'a> {
|
||||||
pub msg: DiagnosticMessage,
|
pub msg: DiagMessage,
|
||||||
pub ty: Ty<'a>,
|
pub ty: Ty<'a>,
|
||||||
pub label: Span,
|
pub label: Span,
|
||||||
pub sub: BuiltinUnpermittedTypeInitSub,
|
pub sub: BuiltinUnpermittedTypeInitSub,
|
||||||
@ -437,7 +437,7 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
|
|||||||
self.sub.add_to_diagnostic(diag);
|
self.sub.add_to_diagnostic(diag);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagnosticMessage {
|
fn msg(&self) -> DiagMessage {
|
||||||
self.msg.clone()
|
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
|
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));
|
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
|
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));
|
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagnosticMessage {
|
fn msg(&self) -> DiagMessage {
|
||||||
fluent::lint_drop_glue
|
fluent::lint_drop_glue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1683,12 +1683,12 @@ pub struct ImproperCTypes<'a> {
|
|||||||
pub ty: Ty<'a>,
|
pub ty: Ty<'a>,
|
||||||
pub desc: &'a str,
|
pub desc: &'a str,
|
||||||
pub label: Span,
|
pub label: Span,
|
||||||
pub help: Option<DiagnosticMessage>,
|
pub help: Option<DiagMessage>,
|
||||||
pub note: DiagnosticMessage,
|
pub note: DiagMessage,
|
||||||
pub span_note: Option<Span>,
|
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<'_> {
|
impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
diag.arg("ty", self.ty);
|
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
|
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
|
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
|
fluent::lint_async_fn_in_trait
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ use crate::{LateContext, LateLintPass, LintContext};
|
|||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_attr as attr;
|
use rustc_attr as attr;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::DiagnosticMessage;
|
use rustc_errors::DiagMessage;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::{is_range_literal, Expr, ExprKind, Node};
|
use rustc_hir::{is_range_literal, Expr, ExprKind, Node};
|
||||||
use rustc_middle::ty::layout::{IntegerExt, LayoutOf, SizeSkeleton};
|
use rustc_middle::ty::layout::{IntegerExt, LayoutOf, SizeSkeleton};
|
||||||
@ -959,7 +959,7 @@ struct ImproperCTypesVisitor<'a, 'tcx> {
|
|||||||
enum FfiResult<'tcx> {
|
enum FfiResult<'tcx> {
|
||||||
FfiSafe,
|
FfiSafe,
|
||||||
FfiPhantom(Ty<'tcx>),
|
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>(
|
pub(crate) fn nonnull_optimization_guaranteed<'tcx>(
|
||||||
@ -1446,8 +1446,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
sp: Span,
|
sp: Span,
|
||||||
note: DiagnosticMessage,
|
note: DiagMessage,
|
||||||
help: Option<DiagnosticMessage>,
|
help: Option<DiagMessage>,
|
||||||
) {
|
) {
|
||||||
let lint = match self.mode {
|
let lint = match self.mode {
|
||||||
CItemKind::Declaration => IMPROPER_CTYPES,
|
CItemKind::Declaration => IMPROPER_CTYPES,
|
||||||
|
@ -8,7 +8,7 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
|||||||
use rustc_data_structures::stable_hasher::{
|
use rustc_data_structures::stable_hasher::{
|
||||||
HashStable, StableCompare, StableHasher, ToStableHashKey,
|
HashStable, StableCompare, StableHasher, ToStableHashKey,
|
||||||
};
|
};
|
||||||
use rustc_error_messages::{DiagnosticMessage, MultiSpan};
|
use rustc_error_messages::{DiagMessage, MultiSpan};
|
||||||
use rustc_hir::HashStableContext;
|
use rustc_hir::HashStableContext;
|
||||||
use rustc_hir::HirId;
|
use rustc_hir::HirId;
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
@ -674,7 +674,7 @@ pub struct BufferedEarlyLint {
|
|||||||
pub span: MultiSpan,
|
pub span: MultiSpan,
|
||||||
|
|
||||||
/// The lint message.
|
/// The lint message.
|
||||||
pub msg: DiagnosticMessage,
|
pub msg: DiagMessage,
|
||||||
|
|
||||||
/// The `NodeId` of the AST node that generated the lint.
|
/// The `NodeId` of the AST node that generated the lint.
|
||||||
pub node_id: NodeId,
|
pub node_id: NodeId,
|
||||||
@ -703,7 +703,7 @@ impl LintBuffer {
|
|||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
node_id: NodeId,
|
node_id: NodeId,
|
||||||
span: MultiSpan,
|
span: MultiSpan,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
diagnostic: BuiltinLintDiagnostics,
|
diagnostic: BuiltinLintDiagnostics,
|
||||||
) {
|
) {
|
||||||
let lint_id = LintId::of(lint);
|
let lint_id = LintId::of(lint);
|
||||||
@ -721,7 +721,7 @@ impl LintBuffer {
|
|||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
id: NodeId,
|
id: NodeId,
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
) {
|
) {
|
||||||
self.add_lint(lint, id, sp.into(), msg, BuiltinLintDiagnostics::Normal)
|
self.add_lint(lint, id, sp.into(), msg, BuiltinLintDiagnostics::Normal)
|
||||||
}
|
}
|
||||||
@ -731,7 +731,7 @@ impl LintBuffer {
|
|||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
id: NodeId,
|
id: NodeId,
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
diagnostic: BuiltinLintDiagnostics,
|
diagnostic: BuiltinLintDiagnostics,
|
||||||
) {
|
) {
|
||||||
self.add_lint(lint, id, sp.into(), msg, diagnostic)
|
self.add_lint(lint, id, sp.into(), msg, diagnostic)
|
||||||
|
@ -165,7 +165,7 @@ impl<'a> LintDiagnosticDerive<'a> {
|
|||||||
#implementation;
|
#implementation;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> rustc_errors::DiagnosticMessage {
|
fn msg(&self) -> rustc_errors::DiagMessage {
|
||||||
#msg
|
#msg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use rustc_errors::{codes::*, DiagArgName, DiagArgValue, DiagnosticMessage};
|
use rustc_errors::{codes::*, DiagArgName, DiagArgValue, DiagMessage};
|
||||||
use rustc_macros::Diagnostic;
|
use rustc_macros::Diagnostic;
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
|
|
||||||
@ -93,16 +93,16 @@ pub(super) struct ConstNotUsedTraitAlias {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct CustomSubdiagnostic<'a> {
|
pub struct CustomSubdiagnostic<'a> {
|
||||||
pub msg: fn() -> DiagnosticMessage,
|
pub msg: fn() -> DiagMessage,
|
||||||
pub add_args: Box<dyn FnOnce(&mut dyn FnMut(DiagArgName, DiagArgValue)) + 'a>,
|
pub add_args: Box<dyn FnOnce(&mut dyn FnMut(DiagArgName, DiagArgValue)) + 'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CustomSubdiagnostic<'a> {
|
impl<'a> CustomSubdiagnostic<'a> {
|
||||||
pub fn label(x: fn() -> DiagnosticMessage) -> Self {
|
pub fn label(x: fn() -> DiagMessage) -> Self {
|
||||||
Self::label_and_then(x, |_| {})
|
Self::label_and_then(x, |_| {})
|
||||||
}
|
}
|
||||||
pub fn label_and_then<F: FnOnce(&mut dyn FnMut(DiagArgName, DiagArgValue)) + 'a>(
|
pub fn label_and_then<F: FnOnce(&mut dyn FnMut(DiagArgName, DiagArgValue)) + 'a>(
|
||||||
msg: fn() -> DiagnosticMessage,
|
msg: fn() -> DiagMessage,
|
||||||
f: F,
|
f: F,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { msg, add_args: Box::new(move |x| f(x)) }
|
Self { msg, add_args: Box::new(move |x| f(x)) }
|
||||||
|
@ -2,7 +2,7 @@ use std::cmp;
|
|||||||
|
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_data_structures::sorted_map::SortedMap;
|
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_hir::{HirId, ItemLocalId};
|
||||||
use rustc_session::lint::{
|
use rustc_session::lint::{
|
||||||
builtin::{self, FORBIDDEN_LINT_GROUPS},
|
builtin::{self, FORBIDDEN_LINT_GROUPS},
|
||||||
@ -268,7 +268,7 @@ pub fn lint_level(
|
|||||||
level: Level,
|
level: Level,
|
||||||
src: LintLevelSource,
|
src: LintLevelSource,
|
||||||
span: Option<MultiSpan>,
|
span: Option<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
|
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
|
||||||
@ -280,7 +280,7 @@ pub fn lint_level(
|
|||||||
level: Level,
|
level: Level,
|
||||||
src: LintLevelSource,
|
src: LintLevelSource,
|
||||||
span: Option<MultiSpan>,
|
span: Option<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
decorate: Box<dyn '_ + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>)>,
|
decorate: Box<dyn '_ + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>)>,
|
||||||
) {
|
) {
|
||||||
// Check for future incompatibility lints and issue a stronger warning.
|
// Check for future incompatibility lints and issue a stronger warning.
|
||||||
|
@ -6,9 +6,7 @@ use crate::ty::{layout, tls, Ty, TyCtxt, ValTree};
|
|||||||
|
|
||||||
use rustc_ast_ir::Mutability;
|
use rustc_ast_ir::Mutability;
|
||||||
use rustc_data_structures::sync::Lock;
|
use rustc_data_structures::sync::Lock;
|
||||||
use rustc_errors::{
|
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg};
|
||||||
DiagArgName, DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg,
|
|
||||||
};
|
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use rustc_session::CtfeBacktrace;
|
use rustc_session::CtfeBacktrace;
|
||||||
use rustc_span::{def_id::DefId, Span, DUMMY_SP};
|
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).
|
/// A trait for machine-specific errors (or other "machine stop" conditions).
|
||||||
pub trait MachineStopType: Any + fmt::Debug + Send {
|
pub trait MachineStopType: Any + fmt::Debug + Send {
|
||||||
/// The diagnostic message for this error
|
/// 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
|
/// Add diagnostic arguments by passing name and value pairs to `adder`, which are passed to
|
||||||
/// fluent for formatting the translated diagnostic message.
|
/// fluent for formatting the translated diagnostic message.
|
||||||
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagArgName, DiagArgValue));
|
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagArgName, DiagArgValue));
|
||||||
|
@ -14,9 +14,7 @@ use crate::ty::{AdtDef, InstanceDef, UserTypeAnnotationIndex};
|
|||||||
use crate::ty::{GenericArg, GenericArgsRef};
|
use crate::ty::{GenericArg, GenericArgsRef};
|
||||||
|
|
||||||
use rustc_data_structures::captures::Captures;
|
use rustc_data_structures::captures::Captures;
|
||||||
use rustc_errors::{
|
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg};
|
||||||
DiagArgName, DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg,
|
|
||||||
};
|
|
||||||
use rustc_hir::def::{CtorKind, Namespace};
|
use rustc_hir::def::{CtorKind, Namespace};
|
||||||
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
|
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
|
||||||
use rustc_hir::{self, CoroutineDesugaring, CoroutineKind, ImplicitSelfKind};
|
use rustc_hir::{self, CoroutineDesugaring, CoroutineKind, ImplicitSelfKind};
|
||||||
|
@ -251,7 +251,7 @@ impl<O> AssertKind<O> {
|
|||||||
/// `AssertKind::description` and the lang items mentioned in its docs).
|
/// `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
|
/// 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.
|
/// 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 crate::fluent_generated::*;
|
||||||
use AssertKind::*;
|
use AssertKind::*;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, WorkerLocal};
|
|||||||
#[cfg(parallel_compiler)]
|
#[cfg(parallel_compiler)]
|
||||||
use rustc_data_structures::sync::{DynSend, DynSync};
|
use rustc_data_structures::sync::{DynSend, DynSync};
|
||||||
use rustc_data_structures::unord::UnordSet;
|
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 as hir;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||||
@ -2097,7 +2097,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
hir_id: HirId,
|
hir_id: HirId,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level_at_node(lint, hir_id);
|
let (level, src) = self.lint_level_at_node(lint, hir_id);
|
||||||
@ -2127,7 +2127,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self,
|
self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
id: HirId,
|
id: HirId,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level_at_node(lint, id);
|
let (level, src) = self.lint_level_at_node(lint, id);
|
||||||
|
@ -3,7 +3,7 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
|||||||
use crate::query::TyCtxtAt;
|
use crate::query::TyCtxtAt;
|
||||||
use crate::ty::normalize_erasing_regions::NormalizationError;
|
use crate::ty::normalize_erasing_regions::NormalizationError;
|
||||||
use crate::ty::{self, ConstKind, Ty, TyCtxt, TypeVisitableExt};
|
use crate::ty::{self, ConstKind, Ty, TyCtxt, TypeVisitableExt};
|
||||||
use rustc_error_messages::DiagnosticMessage;
|
use rustc_error_messages::DiagMessage;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
|
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
|
||||||
};
|
};
|
||||||
@ -205,7 +205,7 @@ pub enum LayoutError<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> LayoutError<'tcx> {
|
impl<'tcx> LayoutError<'tcx> {
|
||||||
pub fn diagnostic_message(&self) -> DiagnosticMessage {
|
pub fn diagnostic_message(&self) -> DiagMessage {
|
||||||
use crate::fluent_generated::*;
|
use crate::fluent_generated::*;
|
||||||
use LayoutError::*;
|
use LayoutError::*;
|
||||||
match self {
|
match self {
|
||||||
|
@ -13,9 +13,7 @@ use crate::ty::{GenericArg, GenericArgs, GenericArgsRef};
|
|||||||
use crate::ty::{List, ParamEnv};
|
use crate::ty::{List, ParamEnv};
|
||||||
use hir::def::DefKind;
|
use hir::def::DefKind;
|
||||||
use rustc_data_structures::captures::Captures;
|
use rustc_data_structures::captures::Captures;
|
||||||
use rustc_errors::{
|
use rustc_errors::{DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan};
|
||||||
DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan,
|
|
||||||
};
|
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::LangItem;
|
use rustc_hir::LangItem;
|
||||||
@ -1545,7 +1543,7 @@ impl<'tcx> Ty<'tcx> {
|
|||||||
pub fn new_error_with_message<S: Into<MultiSpan>>(
|
pub fn new_error_with_message<S: Into<MultiSpan>>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
span: S,
|
span: S,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
let reported = tcx.dcx().span_delayed_bug(span, msg);
|
let reported = tcx.dcx().span_delayed_bug(span, msg);
|
||||||
Ty::new(tcx, Error(reported))
|
Ty::new(tcx, Error(reported))
|
||||||
|
@ -36,7 +36,7 @@ pub(crate) macro throw_machine_stop_str($($tt:tt)*) {{
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl rustc_middle::mir::interpret::MachineStopType for Zst {
|
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()
|
self.to_string().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, Applicability, DecorateLint, Diag, DiagArgValue, DiagCtxt, DiagnosticMessage,
|
codes::*, Applicability, DecorateLint, Diag, DiagArgValue, DiagCtxt, DiagMessage,
|
||||||
EmissionGuarantee, IntoDiagnostic, Level,
|
EmissionGuarantee, IntoDiagnostic, Level,
|
||||||
};
|
};
|
||||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||||
@ -149,7 +149,7 @@ impl RequiresUnsafeDetail {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn label(&self) -> DiagnosticMessage {
|
fn label(&self) -> DiagMessage {
|
||||||
use UnsafetyViolationDetails::*;
|
use UnsafetyViolationDetails::*;
|
||||||
match self.violation {
|
match self.violation {
|
||||||
CallToUnsafeFunction => fluent::mir_transform_call_to_unsafe_label,
|
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
|
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);
|
diag.span_label(self.span, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagnosticMessage {
|
fn msg(&self) -> DiagMessage {
|
||||||
match self.lint_kind {
|
match self.lint_kind {
|
||||||
AssertLintKind::ArithmeticOverflow => fluent::mir_transform_arithmetic_overflow,
|
AssertLintKind::ArithmeticOverflow => fluent::mir_transform_arithmetic_overflow,
|
||||||
AssertLintKind::UnconditionalPanic => fluent::mir_transform_operation_will_panic,
|
AssertLintKind::UnconditionalPanic => fluent::mir_transform_operation_will_panic,
|
||||||
@ -281,7 +281,7 @@ impl<'a> DecorateLint<'a, ()> for MustNotSupend<'_, '_> {
|
|||||||
diag.arg("post", self.post);
|
diag.arg("post", self.post);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> rustc_errors::DiagnosticMessage {
|
fn msg(&self) -> rustc_errors::DiagMessage {
|
||||||
fluent::mir_transform_must_not_suspend
|
fluent::mir_transform_must_not_suspend
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ use std::num::NonZero;
|
|||||||
use rustc_ast::token;
|
use rustc_ast::token;
|
||||||
use rustc_ast::util::literal::LitError;
|
use rustc_ast::util::literal::LitError;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, Diag, DiagCtxt, DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed,
|
codes::*, Diag, DiagCtxt, DiagMessage, EmissionGuarantee, ErrorGuaranteed, IntoDiagnostic,
|
||||||
IntoDiagnostic, Level, MultiSpan,
|
Level, MultiSpan,
|
||||||
};
|
};
|
||||||
use rustc_macros::Diagnostic;
|
use rustc_macros::Diagnostic;
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
@ -14,7 +14,7 @@ use crate::parse::ParseSess;
|
|||||||
|
|
||||||
pub struct FeatureGateError {
|
pub struct FeatureGateError {
|
||||||
pub span: MultiSpan,
|
pub span: MultiSpan,
|
||||||
pub explain: DiagnosticMessage,
|
pub explain: DiagMessage,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for FeatureGateError {
|
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for FeatureGateError {
|
||||||
|
@ -15,8 +15,8 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
|
|||||||
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
|
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
|
||||||
use rustc_errors::emitter::{stderr_destination, HumanEmitter, SilentEmitter};
|
use rustc_errors::emitter::{stderr_destination, HumanEmitter, SilentEmitter};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
fallback_fluent_bundle, ColorConfig, Diag, DiagCtxt, DiagnosticMessage, EmissionGuarantee,
|
fallback_fluent_bundle, ColorConfig, Diag, DiagCtxt, DiagMessage, EmissionGuarantee, MultiSpan,
|
||||||
MultiSpan, StashKey,
|
StashKey,
|
||||||
};
|
};
|
||||||
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
|
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
@ -85,7 +85,7 @@ pub fn feature_err(
|
|||||||
sess: &Session,
|
sess: &Session,
|
||||||
feature: Symbol,
|
feature: Symbol,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
explain: impl Into<DiagnosticMessage>,
|
explain: impl Into<DiagMessage>,
|
||||||
) -> Diag<'_> {
|
) -> Diag<'_> {
|
||||||
feature_err_issue(sess, feature, span, GateIssue::Language, explain)
|
feature_err_issue(sess, feature, span, GateIssue::Language, explain)
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ pub fn feature_err_issue(
|
|||||||
feature: Symbol,
|
feature: Symbol,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
issue: GateIssue,
|
issue: GateIssue,
|
||||||
explain: impl Into<DiagnosticMessage>,
|
explain: impl Into<DiagMessage>,
|
||||||
) -> Diag<'_> {
|
) -> Diag<'_> {
|
||||||
let span = span.into();
|
let span = span.into();
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ impl ParseSess {
|
|||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
node_id: NodeId,
|
node_id: NodeId,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
) {
|
) {
|
||||||
self.buffered_lints.with_lock(|buffered_lints| {
|
self.buffered_lints.with_lock(|buffered_lints| {
|
||||||
buffered_lints.push(BufferedEarlyLint {
|
buffered_lints.push(BufferedEarlyLint {
|
||||||
@ -308,7 +308,7 @@ impl ParseSess {
|
|||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
node_id: NodeId,
|
node_id: NodeId,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
diagnostic: BuiltinLintDiagnostics,
|
diagnostic: BuiltinLintDiagnostics,
|
||||||
) {
|
) {
|
||||||
self.buffered_lints.with_lock(|buffered_lints| {
|
self.buffered_lints.with_lock(|buffered_lints| {
|
||||||
|
@ -22,8 +22,8 @@ use rustc_errors::emitter::{stderr_destination, DynEmitter, HumanEmitter, HumanR
|
|||||||
use rustc_errors::json::JsonEmitter;
|
use rustc_errors::json::JsonEmitter;
|
||||||
use rustc_errors::registry::Registry;
|
use rustc_errors::registry::Registry;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, fallback_fluent_bundle, Diag, DiagCtxt, DiagnosticMessage, ErrorGuaranteed,
|
codes::*, fallback_fluent_bundle, Diag, DiagCtxt, DiagMessage, ErrorGuaranteed, FatalAbort,
|
||||||
FatalAbort, FluentBundle, IntoDiagnostic, LazyFallbackBundle, TerminalUrl,
|
FluentBundle, IntoDiagnostic, LazyFallbackBundle, TerminalUrl,
|
||||||
};
|
};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
pub use rustc_span::def_id::StableCrateId;
|
pub use rustc_span::def_id::StableCrateId;
|
||||||
@ -1419,38 +1419,38 @@ impl EarlyDiagCtxt {
|
|||||||
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[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)
|
self.dcx.note(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[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()
|
self.dcx.struct_help(msg).emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[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"]
|
#[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)
|
self.dcx.err(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[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)
|
self.dcx.fatal(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[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)
|
self.dcx.struct_fatal(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[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)
|
self.dcx.warn(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ symbols! {
|
|||||||
DecorateLint,
|
DecorateLint,
|
||||||
Default,
|
Default,
|
||||||
Deref,
|
Deref,
|
||||||
DiagnosticMessage,
|
DiagMessage,
|
||||||
DirBuilder,
|
DirBuilder,
|
||||||
Display,
|
Display,
|
||||||
DoubleEndedIterator,
|
DoubleEndedIterator,
|
||||||
|
@ -1266,8 +1266,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
if has_custom_message {
|
if has_custom_message {
|
||||||
err.note(msg);
|
err.note(msg);
|
||||||
} else {
|
} else {
|
||||||
err.messages =
|
err.messages = vec![(rustc_errors::DiagMessage::from(msg), Style::NoStyle)];
|
||||||
vec![(rustc_errors::DiagnosticMessage::from(msg), Style::NoStyle)];
|
|
||||||
}
|
}
|
||||||
let mut file = None;
|
let mut file = None;
|
||||||
err.span_label(
|
err.span_label(
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::{Diag, DiagnosticMessage};
|
use rustc_errors::{Diag, DiagMessage};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
pub(crate) use rustc_resolve::rustdoc::main_body_opts;
|
pub(crate) use rustc_resolve::rustdoc::main_body_opts;
|
||||||
@ -828,7 +828,7 @@ impl<'tcx> ExtraInfo<'tcx> {
|
|||||||
ExtraInfo { def_id, sp, 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() {
|
if let Some(def_id) = self.def_id.as_local() {
|
||||||
self.tcx.node_span_lint(
|
self.tcx.node_span_lint(
|
||||||
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
|
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
|
||||||
@ -842,7 +842,7 @@ impl<'tcx> ExtraInfo<'tcx> {
|
|||||||
|
|
||||||
fn error_invalid_codeblock_attr_with_help(
|
fn error_invalid_codeblock_attr_with_help(
|
||||||
&self,
|
&self,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
f: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
f: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
if let Some(def_id) = self.def_id.as_local() {
|
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 }
|
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 {
|
if let Some(extra) = self.extra {
|
||||||
extra.error_invalid_codeblock_attr(err);
|
extra.error_invalid_codeblock_attr(err);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use rustc_data_structures::{
|
|||||||
fx::{FxHashMap, FxHashSet},
|
fx::{FxHashMap, FxHashSet},
|
||||||
intern::Interned,
|
intern::Interned,
|
||||||
};
|
};
|
||||||
use rustc_errors::{Applicability, Diag, DiagnosticMessage};
|
use rustc_errors::{Applicability, Diag, DiagMessage};
|
||||||
use rustc_hir::def::Namespace::*;
|
use rustc_hir::def::Namespace::*;
|
||||||
use rustc_hir::def::{DefKind, Namespace, PerNS};
|
use rustc_hir::def::{DefKind, Namespace, PerNS};
|
||||||
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
|
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
|
||||||
@ -1674,7 +1674,7 @@ impl Suggestion {
|
|||||||
fn report_diagnostic(
|
fn report_diagnostic(
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
msg: impl Into<DiagnosticMessage> + Display,
|
msg: impl Into<DiagMessage> + Display,
|
||||||
DiagnosticInfo { item, ori_link: _, dox, link_range }: &DiagnosticInfo<'_>,
|
DiagnosticInfo { item, ori_link: _, dox, link_range }: &DiagnosticInfo<'_>,
|
||||||
decorate: impl FnOnce(&mut Diag<'_, ()>, Option<rustc_span::Span>, MarkdownLinkRange),
|
decorate: impl FnOnce(&mut Diag<'_, ()>, Option<rustc_span::Span>, MarkdownLinkRange),
|
||||||
) {
|
) {
|
||||||
@ -2010,7 +2010,7 @@ fn disambiguator_error(
|
|||||||
cx: &DocContext<'_>,
|
cx: &DocContext<'_>,
|
||||||
mut diag_info: DiagnosticInfo<'_>,
|
mut diag_info: DiagnosticInfo<'_>,
|
||||||
disambiguator_range: MarkdownLinkRange,
|
disambiguator_range: MarkdownLinkRange,
|
||||||
msg: impl Into<DiagnosticMessage> + Display,
|
msg: impl Into<DiagMessage> + Display,
|
||||||
) {
|
) {
|
||||||
diag_info.link_range = disambiguator_range;
|
diag_info.link_range = disambiguator_range;
|
||||||
report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp, _link_range| {
|
report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp, _link_range| {
|
||||||
|
@ -5,12 +5,17 @@ extern crate rustc_hir;
|
|||||||
extern crate rustc_lint;
|
extern crate rustc_lint;
|
||||||
extern crate rustc_middle;
|
extern crate rustc_middle;
|
||||||
|
|
||||||
use rustc_errors::{DiagnosticMessage, MultiSpan};
|
use rustc_errors::{DiagMessage, MultiSpan};
|
||||||
use rustc_hir::hir_id::HirId;
|
use rustc_hir::hir_id::HirId;
|
||||||
use rustc_lint::{Lint, LintContext};
|
use rustc_lint::{Lint, LintContext};
|
||||||
use rustc_middle::ty::TyCtxt;
|
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, |_| {});
|
cx.span_lint(lint, span, msg, |_| {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,7 +24,7 @@ pub fn b(
|
|||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
hir_id: HirId,
|
hir_id: HirId,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagMessage>,
|
||||||
) {
|
) {
|
||||||
tcx.node_span_lint(lint, hir_id, span, msg, |_| {});
|
tcx.node_span_lint(lint, hir_id, span, msg, |_| {});
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use std::num::NonZero;
|
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_span::{SpanData, Symbol, DUMMY_SP};
|
||||||
use rustc_target::abi::{Align, Size};
|
use rustc_target::abi::{Align, Size};
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ impl fmt::Debug for TerminationInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MachineStopType for TerminationInfo {
|
impl MachineStopType for TerminationInfo {
|
||||||
fn diagnostic_message(&self) -> DiagnosticMessage {
|
fn diagnostic_message(&self) -> DiagMessage {
|
||||||
self.to_string().into()
|
self.to_string().into()
|
||||||
}
|
}
|
||||||
fn add_args(
|
fn add_args(
|
||||||
|
@ -44,7 +44,7 @@ impl Translate for SilentEmitter {
|
|||||||
// subdiagnostics result in a call to this.
|
// subdiagnostics result in a call to this.
|
||||||
fn translate_message<'a>(
|
fn translate_message<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
message: &'a rustc_errors::DiagnosticMessage,
|
message: &'a rustc_errors::DiagMessage,
|
||||||
_: &'a rustc_errors::translation::FluentArgs<'_>,
|
_: &'a rustc_errors::translation::FluentArgs<'_>,
|
||||||
) -> Result<Cow<'_, str>, rustc_errors::error::TranslateError<'_>> {
|
) -> Result<Cow<'_, str>, rustc_errors::error::TranslateError<'_>> {
|
||||||
rustc_errors::emitter::silent_translate(message)
|
rustc_errors::emitter::silent_translate(message)
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
extern crate rustc_errors;
|
extern crate rustc_errors;
|
||||||
extern crate rustc_fluent_macro;
|
extern crate rustc_fluent_macro;
|
||||||
|
|
||||||
/// Copy of the relevant `DiagnosticMessage` variant constructed by `fluent_messages` as it
|
/// Copy of the relevant `DiagMessage` variant constructed by `fluent_messages` as it
|
||||||
/// expects `crate::DiagnosticMessage` to exist.
|
/// expects `crate::DiagMessage` to exist.
|
||||||
pub enum DiagnosticMessage {
|
pub enum DiagMessage {
|
||||||
FluentIdentifier(std::borrow::Cow<'static, str>, Option<std::borrow::Cow<'static, str>>),
|
FluentIdentifier(std::borrow::Cow<'static, str>, Option<std::borrow::Cow<'static, str>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ extern crate rustc_macros;
|
|||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
extern crate rustc_span;
|
extern crate rustc_span;
|
||||||
|
|
||||||
use rustc_errors::{Applicability, DiagnosticMessage, SubdiagnosticMessage};
|
use rustc_errors::{Applicability, DiagMessage, SubdiagnosticMessage};
|
||||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ extern crate rustc_middle;
|
|||||||
use rustc_middle::ty::Ty;
|
use rustc_middle::ty::Ty;
|
||||||
|
|
||||||
extern crate rustc_errors;
|
extern crate rustc_errors;
|
||||||
use rustc_errors::{Applicability, DiagnosticMessage, ErrCode, MultiSpan, SubdiagnosticMessage};
|
use rustc_errors::{Applicability, DiagMessage, ErrCode, MultiSpan, SubdiagnosticMessage};
|
||||||
|
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ extern crate rustc_fluent_macro;
|
|||||||
extern crate rustc_macros;
|
extern crate rustc_macros;
|
||||||
extern crate rustc_errors;
|
extern crate rustc_errors;
|
||||||
use rustc_macros::Diagnostic;
|
use rustc_macros::Diagnostic;
|
||||||
use rustc_errors::{SubdiagnosticMessage, DiagnosticMessage};
|
use rustc_errors::{DiagMessage, SubdiagnosticMessage};
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
|
|
||||||
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
|
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
|
||||||
|
@ -17,7 +17,7 @@ extern crate rustc_macros;
|
|||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
extern crate rustc_span;
|
extern crate rustc_span;
|
||||||
|
|
||||||
use rustc_errors::{Applicability, DiagnosticMessage, SubdiagnosticMessage};
|
use rustc_errors::{Applicability, DiagMessage, SubdiagnosticMessage};
|
||||||
use rustc_macros::Subdiagnostic;
|
use rustc_macros::Subdiagnostic;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user