Rename IntoDiagnosticArg
as IntoDiagArg
.
Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`.
This commit is contained in:
parent
256d802233
commit
a09b1d33a7
38 changed files with 218 additions and 219 deletions
|
@ -191,9 +191,9 @@ impl Display for RegionName {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rustc_errors::IntoDiagnosticArg for RegionName {
|
impl rustc_errors::IntoDiagArg for RegionName {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ use crate::errors;
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_data_structures::unord::UnordMap;
|
use rustc_data_structures::unord::UnordMap;
|
||||||
use rustc_data_structures::unord::UnordSet;
|
use rustc_data_structures::unord::UnordSet;
|
||||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||||
use rustc_hir::def_id::LOCAL_CRATE;
|
use rustc_hir::def_id::LOCAL_CRATE;
|
||||||
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
|
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
|
@ -205,8 +205,8 @@ impl fmt::Display for CguReuse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for CguReuse {
|
impl IntoDiagArg for CguReuse {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(self.to_string()))
|
DiagArgValue::Str(Cow::Owned(self.to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,7 @@ use crate::assert_module_sources::CguReuse;
|
||||||
use crate::back::command::Command;
|
use crate::back::command::Command;
|
||||||
use crate::fluent_generated as fluent;
|
use crate::fluent_generated as fluent;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg,
|
codes::*, Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagArg, IntoDiagnostic, Level,
|
||||||
Level,
|
|
||||||
};
|
};
|
||||||
use rustc_macros::Diagnostic;
|
use rustc_macros::Diagnostic;
|
||||||
use rustc_middle::ty::layout::LayoutError;
|
use rustc_middle::ty::layout::LayoutError;
|
||||||
|
@ -152,8 +151,8 @@ impl<'a> CopyPath<'a> {
|
||||||
|
|
||||||
struct DebugArgPath<'a>(pub &'a Path);
|
struct DebugArgPath<'a>(pub &'a Path);
|
||||||
|
|
||||||
impl IntoDiagnosticArg for DebugArgPath<'_> {
|
impl IntoDiagArg for DebugArgPath<'_> {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
|
DiagArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -974,8 +973,8 @@ pub enum ExpectedPointerMutability {
|
||||||
Not,
|
Not,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for ExpectedPointerMutability {
|
impl IntoDiagArg for ExpectedPointerMutability {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
match self {
|
match self {
|
||||||
ExpectedPointerMutability::Mut => DiagArgValue::Str(Cow::Borrowed("*mut")),
|
ExpectedPointerMutability::Mut => DiagArgValue::Str(Cow::Borrowed("*mut")),
|
||||||
ExpectedPointerMutability::Not => DiagArgValue::Str(Cow::Borrowed("*_")),
|
ExpectedPointerMutability::Not => DiagArgValue::Str(Cow::Borrowed("*_")),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, IntoDiagnostic, IntoDiagnosticArg};
|
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, IntoDiagArg, IntoDiagnostic};
|
||||||
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;
|
||||||
|
@ -40,10 +40,10 @@ impl MachineStopType for ConstEvalErrKind {
|
||||||
RecursiveStatic | ConstAccessesMutGlobal | ModifiedGlobal => {}
|
RecursiveStatic | ConstAccessesMutGlobal | ModifiedGlobal => {}
|
||||||
AssertFailure(kind) => kind.add_args(adder),
|
AssertFailure(kind) => kind.add_args(adder),
|
||||||
Panic { msg, line, col, file } => {
|
Panic { msg, line, col, file } => {
|
||||||
adder("msg".into(), msg.into_diagnostic_arg());
|
adder("msg".into(), msg.into_diag_arg());
|
||||||
adder("file".into(), file.into_diagnostic_arg());
|
adder("file".into(), file.into_diag_arg());
|
||||||
adder("line".into(), line.into_diagnostic_arg());
|
adder("line".into(), line.into_diag_arg());
|
||||||
adder("col".into(), col.into_diagnostic_arg());
|
adder("col".into(), col.into_diag_arg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -887,8 +887,8 @@ impl ReportErrorExt for ResourceExhaustionInfo {
|
||||||
fn add_args<G: EmissionGuarantee>(self, _: &mut Diag<'_, G>) {}
|
fn add_args<G: EmissionGuarantee>(self, _: &mut Diag<'_, G>) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rustc_errors::IntoDiagnosticArg for InternKind {
|
impl rustc_errors::IntoDiagArg for InternKind {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Borrowed(match self {
|
DiagArgValue::Str(Cow::Borrowed(match self {
|
||||||
InternKind::Static(Mutability::Not) => "static",
|
InternKind::Static(Mutability::Not) => "static",
|
||||||
InternKind::Static(Mutability::Mut) => "static_mut",
|
InternKind::Static(Mutability::Mut) => "static_mut",
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub enum DiagArgValue {
|
||||||
Str(Cow<'static, str>),
|
Str(Cow<'static, str>),
|
||||||
// This gets converted to a `FluentNumber`, which is an `f64`. An `i32`
|
// This gets converted to a `FluentNumber`, which is an `f64`. An `i32`
|
||||||
// safely fits in an `f64`. Any integers bigger than that will be converted
|
// safely fits in an `f64`. Any integers bigger than that will be converted
|
||||||
// to strings in `into_diagnostic_arg` and stored using the `Str` variant.
|
// to strings in `into_diag_arg` and stored using the `Str` variant.
|
||||||
Number(i32),
|
Number(i32),
|
||||||
StrListSepByAnd(Vec<Cow<'static, str>>),
|
StrListSepByAnd(Vec<Cow<'static, str>>),
|
||||||
}
|
}
|
||||||
|
@ -148,12 +148,12 @@ where
|
||||||
/// Implemented as a custom trait rather than `From` so that it is implemented on the type being
|
/// Implemented as a custom trait rather than `From` so that it is implemented on the type being
|
||||||
/// converted rather than on `DiagArgValue`, which enables types from other `rustc_*` crates to
|
/// converted rather than on `DiagArgValue`, which enables types from other `rustc_*` crates to
|
||||||
/// implement this.
|
/// implement this.
|
||||||
pub trait IntoDiagnosticArg {
|
pub trait IntoDiagArg {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue;
|
fn into_diag_arg(self) -> DiagArgValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for DiagArgValue {
|
impl IntoDiagArg for DiagArgValue {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,8 +419,8 @@ impl DiagInner {
|
||||||
self.children.push(sub);
|
self.children.push(sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn arg(&mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagnosticArg) {
|
pub(crate) fn arg(&mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagArg) {
|
||||||
self.args.insert(name.into(), arg.into_diagnostic_arg());
|
self.args.insert(name.into(), arg.into_diag_arg());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fields used for Hash, and PartialEq trait.
|
/// Fields used for Hash, and PartialEq trait.
|
||||||
|
@ -1243,7 +1243,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
|
||||||
pub fn arg(
|
pub fn arg(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: impl Into<DiagArgName>,
|
name: impl Into<DiagArgName>,
|
||||||
arg: impl IntoDiagnosticArg,
|
arg: impl IntoDiagArg,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.deref_mut().arg(name, arg);
|
self.deref_mut().arg(name, arg);
|
||||||
self
|
self
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::diagnostic::DiagLocation;
|
use crate::diagnostic::DiagLocation;
|
||||||
use crate::{fluent_generated as fluent, AddToDiagnostic};
|
use crate::{fluent_generated as fluent, AddToDiagnostic};
|
||||||
use crate::{
|
use crate::{
|
||||||
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, ErrCode, IntoDiagnostic, IntoDiagnosticArg,
|
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, ErrCode, IntoDiagArg, IntoDiagnostic, Level,
|
||||||
Level, SubdiagMessageOp,
|
SubdiagMessageOp,
|
||||||
};
|
};
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
|
@ -22,9 +22,9 @@ use std::process::ExitStatus;
|
||||||
|
|
||||||
pub struct DiagArgFromDisplay<'a>(pub &'a dyn fmt::Display);
|
pub struct DiagArgFromDisplay<'a>(pub &'a dyn fmt::Display);
|
||||||
|
|
||||||
impl IntoDiagnosticArg for DiagArgFromDisplay<'_> {
|
impl IntoDiagArg for DiagArgFromDisplay<'_> {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.0.to_string().into_diagnostic_arg()
|
self.0.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,34 +40,34 @@ impl<'a, T: fmt::Display> From<&'a T> for DiagArgFromDisplay<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Clone + IntoDiagnosticArg> IntoDiagnosticArg for &'a T {
|
impl<'a, T: Clone + IntoDiagArg> IntoDiagArg for &'a T {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.clone().into_diagnostic_arg()
|
self.clone().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! into_diagnostic_arg_using_display {
|
macro_rules! into_diag_arg_using_display {
|
||||||
($( $ty:ty ),+ $(,)?) => {
|
($( $ty:ty ),+ $(,)?) => {
|
||||||
$(
|
$(
|
||||||
impl IntoDiagnosticArg for $ty {
|
impl IntoDiagArg for $ty {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)+
|
)+
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! into_diagnostic_arg_for_number {
|
macro_rules! into_diag_arg_for_number {
|
||||||
($( $ty:ty ),+ $(,)?) => {
|
($( $ty:ty ),+ $(,)?) => {
|
||||||
$(
|
$(
|
||||||
impl IntoDiagnosticArg for $ty {
|
impl IntoDiagArg for $ty {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
// Convert to a string if it won't fit into `Number`.
|
// Convert to a string if it won't fit into `Number`.
|
||||||
if let Ok(n) = TryInto::<i32>::try_into(self) {
|
if let Ok(n) = TryInto::<i32>::try_into(self) {
|
||||||
DiagArgValue::Number(n)
|
DiagArgValue::Number(n)
|
||||||
} else {
|
} else {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ macro_rules! into_diagnostic_arg_for_number {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
into_diagnostic_arg_using_display!(
|
into_diag_arg_using_display!(
|
||||||
ast::ParamKindOrd,
|
ast::ParamKindOrd,
|
||||||
std::io::Error,
|
std::io::Error,
|
||||||
Box<dyn std::error::Error>,
|
Box<dyn std::error::Error>,
|
||||||
|
@ -92,10 +92,10 @@ into_diagnostic_arg_using_display!(
|
||||||
ErrCode,
|
ErrCode,
|
||||||
);
|
);
|
||||||
|
|
||||||
into_diagnostic_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
|
into_diag_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
|
||||||
|
|
||||||
impl IntoDiagnosticArg for bool {
|
impl IntoDiagArg for bool {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
if self {
|
if self {
|
||||||
DiagArgValue::Str(Cow::Borrowed("true"))
|
DiagArgValue::Str(Cow::Borrowed("true"))
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,64 +104,64 @@ impl IntoDiagnosticArg for bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for char {
|
impl IntoDiagArg for char {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(format!("{self:?}")))
|
DiagArgValue::Str(Cow::Owned(format!("{self:?}")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for Vec<char> {
|
impl IntoDiagArg for Vec<char> {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::StrListSepByAnd(
|
DiagArgValue::StrListSepByAnd(
|
||||||
self.into_iter().map(|c| Cow::Owned(format!("{c:?}"))).collect(),
|
self.into_iter().map(|c| Cow::Owned(format!("{c:?}"))).collect(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for Symbol {
|
impl IntoDiagArg for Symbol {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.to_ident_string().into_diagnostic_arg()
|
self.to_ident_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoDiagnosticArg for &'a str {
|
impl<'a> IntoDiagArg for &'a str {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for String {
|
impl IntoDiagArg for String {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(self))
|
DiagArgValue::Str(Cow::Owned(self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoDiagnosticArg for Cow<'a, str> {
|
impl<'a> IntoDiagArg for Cow<'a, str> {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(self.into_owned()))
|
DiagArgValue::Str(Cow::Owned(self.into_owned()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoDiagnosticArg for &'a Path {
|
impl<'a> IntoDiagArg for &'a Path {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(self.display().to_string()))
|
DiagArgValue::Str(Cow::Owned(self.display().to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for PathBuf {
|
impl IntoDiagArg for PathBuf {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(self.display().to_string()))
|
DiagArgValue::Str(Cow::Owned(self.display().to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for PanicStrategy {
|
impl IntoDiagArg for PanicStrategy {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(self.desc().to_string()))
|
DiagArgValue::Str(Cow::Owned(self.desc().to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for hir::ConstContext {
|
impl IntoDiagArg for hir::ConstContext {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Borrowed(match self {
|
DiagArgValue::Str(Cow::Borrowed(match self {
|
||||||
hir::ConstContext::ConstFn => "const_fn",
|
hir::ConstContext::ConstFn => "const_fn",
|
||||||
hir::ConstContext::Static(_) => "static",
|
hir::ConstContext::Static(_) => "static",
|
||||||
|
@ -170,58 +170,58 @@ impl IntoDiagnosticArg for hir::ConstContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for ast::Expr {
|
impl IntoDiagArg for ast::Expr {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(pprust::expr_to_string(&self)))
|
DiagArgValue::Str(Cow::Owned(pprust::expr_to_string(&self)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for ast::Path {
|
impl IntoDiagArg for ast::Path {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(pprust::path_to_string(&self)))
|
DiagArgValue::Str(Cow::Owned(pprust::path_to_string(&self)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for ast::token::Token {
|
impl IntoDiagArg for ast::token::Token {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(pprust::token_to_string(&self))
|
DiagArgValue::Str(pprust::token_to_string(&self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for ast::token::TokenKind {
|
impl IntoDiagArg for ast::token::TokenKind {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(pprust::token_kind_to_string(&self))
|
DiagArgValue::Str(pprust::token_kind_to_string(&self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for type_ir::FloatTy {
|
impl IntoDiagArg for type_ir::FloatTy {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Borrowed(self.name_str()))
|
DiagArgValue::Str(Cow::Borrowed(self.name_str()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for std::ffi::CString {
|
impl IntoDiagArg for std::ffi::CString {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
|
DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for rustc_data_structures::small_c_str::SmallCStr {
|
impl IntoDiagArg for rustc_data_structures::small_c_str::SmallCStr {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
|
DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for ast::Visibility {
|
impl IntoDiagArg for ast::Visibility {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
let s = pprust::vis_to_string(&self);
|
let s = pprust::vis_to_string(&self);
|
||||||
let s = s.trim_end().to_string();
|
let s = s.trim_end().to_string();
|
||||||
DiagArgValue::Str(Cow::Owned(s))
|
DiagArgValue::Str(Cow::Owned(s))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for rustc_lint_defs::Level {
|
impl IntoDiagArg for rustc_lint_defs::Level {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
|
DiagArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,16 +235,16 @@ impl From<Vec<Symbol>> for DiagSymbolList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for DiagSymbolList {
|
impl IntoDiagArg for DiagSymbolList {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::StrListSepByAnd(
|
DiagArgValue::StrListSepByAnd(
|
||||||
self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(),
|
self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Id> IntoDiagnosticArg for hir::def::Res<Id> {
|
impl<Id> IntoDiagArg for hir::def::Res<Id> {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Borrowed(self.descr()))
|
DiagArgValue::Str(Cow::Borrowed(self.descr()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,20 +315,20 @@ pub struct ExpectedLifetimeParameter {
|
||||||
pub count: usize,
|
pub count: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for DiagLocation {
|
impl IntoDiagArg for DiagLocation {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::from(self.to_string()))
|
DiagArgValue::Str(Cow::from(self.to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for Backtrace {
|
impl IntoDiagArg for Backtrace {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::from(self.to_string()))
|
DiagArgValue::Str(Cow::from(self.to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for Level {
|
impl IntoDiagArg for Level {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::from(self.to_string()))
|
DiagArgValue::Str(Cow::from(self.to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -342,8 +342,8 @@ pub struct IndicateAnonymousLifetime {
|
||||||
pub suggestion: String,
|
pub suggestion: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for type_ir::ClosureKind {
|
impl IntoDiagArg for type_ir::ClosureKind {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(self.as_str().into())
|
DiagArgValue::Str(self.as_str().into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ extern crate self as rustc_errors;
|
||||||
pub use codes::*;
|
pub use codes::*;
|
||||||
pub use diagnostic::{
|
pub use diagnostic::{
|
||||||
AddToDiagnostic, BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue,
|
AddToDiagnostic, BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue,
|
||||||
DiagInner, DiagStyledString, EmissionGuarantee, FatalAbort, IntoDiagnostic, IntoDiagnosticArg,
|
DiagInner, DiagStyledString, EmissionGuarantee, FatalAbort, IntoDiagArg, IntoDiagnostic,
|
||||||
StringPart, Subdiag, SubdiagMessageOp,
|
StringPart, Subdiag, SubdiagMessageOp,
|
||||||
};
|
};
|
||||||
pub use diagnostic_impls::{
|
pub use diagnostic_impls::{
|
||||||
|
|
|
@ -1510,7 +1510,7 @@ impl fmt::Display for ConstContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: `IntoDiagnosticArg` impl for `ConstContext` lives in `rustc_errors`
|
// NOTE: `IntoDiagArg` impl for `ConstContext` lives in `rustc_errors`
|
||||||
// due to a cyclical dependency between hir that crate.
|
// due to a cyclical dependency between hir that crate.
|
||||||
|
|
||||||
/// A literal.
|
/// A literal.
|
||||||
|
|
|
@ -3,8 +3,8 @@ use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::fluent_generated as fluent;
|
use crate::fluent_generated as fluent;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagArgValue, EmissionGuarantee,
|
codes::*, AddToDiagnostic, Applicability, Diag, DiagArgValue, EmissionGuarantee, IntoDiagArg,
|
||||||
IntoDiagnosticArg, MultiSpan, SubdiagMessageOp,
|
MultiSpan, SubdiagMessageOp,
|
||||||
};
|
};
|
||||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||||
use rustc_middle::ty::Ty;
|
use rustc_middle::ty::Ty;
|
||||||
|
@ -42,8 +42,8 @@ pub enum ReturnLikeStatementKind {
|
||||||
Become,
|
Become,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for ReturnLikeStatementKind {
|
impl IntoDiagArg for ReturnLikeStatementKind {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
let kind = match self {
|
let kind = match self {
|
||||||
Self::Return => "return",
|
Self::Return => "return",
|
||||||
Self::Become => "become",
|
Self::Become => "become",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use hir::GenericParamKind;
|
use hir::GenericParamKind;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagMessage, DiagStyledString,
|
codes::*, AddToDiagnostic, Applicability, Diag, DiagMessage, DiagStyledString,
|
||||||
EmissionGuarantee, IntoDiagnosticArg, MultiSpan, SubdiagMessageOp,
|
EmissionGuarantee, IntoDiagArg, MultiSpan, SubdiagMessageOp,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::FnRetTy;
|
use rustc_hir::FnRetTy;
|
||||||
|
@ -537,11 +537,11 @@ pub enum TyOrSig<'tcx> {
|
||||||
ClosureSig(Highlighted<'tcx, Binder<'tcx, FnSig<'tcx>>>),
|
ClosureSig(Highlighted<'tcx, Binder<'tcx, FnSig<'tcx>>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for TyOrSig<'_> {
|
impl IntoDiagArg for TyOrSig<'_> {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
match self {
|
match self {
|
||||||
TyOrSig::Ty(ty) => ty.into_diagnostic_arg(),
|
TyOrSig::Ty(ty) => ty.into_diag_arg(),
|
||||||
TyOrSig::ClosureSig(sig) => sig.into_diagnostic_arg(),
|
TyOrSig::ClosureSig(sig) => sig.into_diag_arg(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::fluent_generated as fluent;
|
use crate::fluent_generated as fluent;
|
||||||
use crate::infer::error_reporting::nice_region_error::find_anon_type;
|
use crate::infer::error_reporting::nice_region_error::find_anon_type;
|
||||||
use rustc_errors::{AddToDiagnostic, Diag, EmissionGuarantee, IntoDiagnosticArg, SubdiagMessageOp};
|
use rustc_errors::{AddToDiagnostic, Diag, EmissionGuarantee, IntoDiagArg, SubdiagMessageOp};
|
||||||
use rustc_middle::ty::{self, TyCtxt};
|
use rustc_middle::ty::{self, TyCtxt};
|
||||||
use rustc_span::{symbol::kw, Span};
|
use rustc_span::{symbol::kw, Span};
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ pub enum SuffixKind {
|
||||||
ReqByBinding,
|
ReqByBinding,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for PrefixKind {
|
impl IntoDiagArg for PrefixKind {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
let kind = match self {
|
let kind = match self {
|
||||||
Self::Empty => "empty",
|
Self::Empty => "empty",
|
||||||
Self::RefValidFor => "ref_valid_for",
|
Self::RefValidFor => "ref_valid_for",
|
||||||
|
@ -129,8 +129,8 @@ impl IntoDiagnosticArg for PrefixKind {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for SuffixKind {
|
impl IntoDiagArg for SuffixKind {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
let kind = match self {
|
let kind = match self {
|
||||||
Self::Empty => "empty",
|
Self::Empty => "empty",
|
||||||
Self::Continues => "continues",
|
Self::Continues => "continues",
|
||||||
|
|
|
@ -61,7 +61,7 @@ use crate::traits::{
|
||||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, pluralize, struct_span_code_err, Applicability, Diag, DiagCtxt, DiagStyledString,
|
codes::*, pluralize, struct_span_code_err, Applicability, Diag, DiagCtxt, DiagStyledString,
|
||||||
ErrorGuaranteed, IntoDiagnosticArg,
|
ErrorGuaranteed, IntoDiagArg,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
|
@ -2895,11 +2895,11 @@ impl<'tcx> ObligationCause<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Newtype to allow implementing IntoDiagnosticArg
|
/// Newtype to allow implementing IntoDiagArg
|
||||||
pub struct ObligationCauseAsDiagArg<'tcx>(pub ObligationCause<'tcx>);
|
pub struct ObligationCauseAsDiagArg<'tcx>(pub ObligationCause<'tcx>);
|
||||||
|
|
||||||
impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> {
|
impl IntoDiagArg for ObligationCauseAsDiagArg<'_> {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
use crate::traits::ObligationCauseCode::*;
|
use crate::traits::ObligationCauseCode::*;
|
||||||
let kind = match self.0.code() {
|
let kind = match self.0.code() {
|
||||||
CompareImplItemObligation { kind: ty::AssocKind::Fn, .. } => "method_compat",
|
CompareImplItemObligation { kind: ty::AssocKind::Fn, .. } => "method_compat",
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::errors::{
|
||||||
use crate::infer::error_reporting::TypeErrCtxt;
|
use crate::infer::error_reporting::TypeErrCtxt;
|
||||||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||||
use crate::infer::InferCtxt;
|
use crate::infer::InferCtxt;
|
||||||
use rustc_errors::{codes::*, Diag, IntoDiagnosticArg};
|
use rustc_errors::{codes::*, Diag, IntoDiagArg};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::Res;
|
use rustc_hir::def::Res;
|
||||||
use rustc_hir::def::{CtorOf, DefKind, Namespace};
|
use rustc_hir::def::{CtorOf, DefKind, Namespace};
|
||||||
|
@ -133,8 +133,8 @@ impl InferenceDiagnosticsParentData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for UnderspecifiedArgKind {
|
impl IntoDiagArg for UnderspecifiedArgKind {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
let kind = match self {
|
let kind = match self {
|
||||||
Self::Type { .. } => "type",
|
Self::Type { .. } => "type",
|
||||||
Self::Const { is_parameter: true } => "const_with_param",
|
Self::Const { is_parameter: true } => "const_with_param",
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::infer::ValuePairs;
|
||||||
use crate::infer::{SubregionOrigin, TypeTrace};
|
use crate::infer::{SubregionOrigin, TypeTrace};
|
||||||
use crate::traits::{ObligationCause, ObligationCauseCode};
|
use crate::traits::{ObligationCause, ObligationCauseCode};
|
||||||
use rustc_data_structures::intern::Interned;
|
use rustc_data_structures::intern::Interned;
|
||||||
use rustc_errors::{Diag, IntoDiagnosticArg};
|
use rustc_errors::{Diag, IntoDiagArg};
|
||||||
use rustc_hir::def::Namespace;
|
use rustc_hir::def::Namespace;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_middle::ty::error::ExpectedFound;
|
use rustc_middle::ty::error::ExpectedFound;
|
||||||
|
@ -26,11 +26,11 @@ pub struct Highlighted<'tcx, T> {
|
||||||
value: T,
|
value: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T> IntoDiagnosticArg for Highlighted<'tcx, T>
|
impl<'tcx, T> IntoDiagArg for Highlighted<'tcx, T>
|
||||||
where
|
where
|
||||||
T: for<'a> Print<'tcx, FmtPrinter<'a, 'tcx>>,
|
T: for<'a> Print<'tcx, FmtPrinter<'a, 'tcx>>,
|
||||||
{
|
{
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
rustc_errors::DiagArgValue::Str(self.to_string().into())
|
rustc_errors::DiagArgValue::Str(self.to_string().into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::memmap::Mmap;
|
use rustc_data_structures::memmap::Mmap;
|
||||||
use rustc_data_structures::owned_slice::slice_owned;
|
use rustc_data_structures::owned_slice::slice_owned;
|
||||||
use rustc_data_structures::svh::Svh;
|
use rustc_data_structures::svh::Svh;
|
||||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||||
use rustc_fs_util::try_canonicalize;
|
use rustc_fs_util::try_canonicalize;
|
||||||
use rustc_session::config;
|
use rustc_session::config;
|
||||||
use rustc_session::cstore::CrateSource;
|
use rustc_session::cstore::CrateSource;
|
||||||
|
@ -290,8 +290,8 @@ impl fmt::Display for CrateFlavor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for CrateFlavor {
|
impl IntoDiagArg for CrateFlavor {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
match self {
|
match self {
|
||||||
CrateFlavor::Rlib => DiagArgValue::Str(Cow::Borrowed("rlib")),
|
CrateFlavor::Rlib => DiagArgValue::Str(Cow::Borrowed("rlib")),
|
||||||
CrateFlavor::Rmeta => DiagArgValue::Str(Cow::Borrowed("rmeta")),
|
CrateFlavor::Rmeta => DiagArgValue::Str(Cow::Borrowed("rmeta")),
|
||||||
|
|
|
@ -6,7 +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::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg};
|
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg};
|
||||||
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};
|
||||||
|
@ -234,8 +234,8 @@ pub enum InvalidMetaKind {
|
||||||
TooBig,
|
TooBig,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for InvalidMetaKind {
|
impl IntoDiagArg for InvalidMetaKind {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Borrowed(match self {
|
DiagArgValue::Str(Cow::Borrowed(match self {
|
||||||
InvalidMetaKind::SliceTooBig => "slice_too_big",
|
InvalidMetaKind::SliceTooBig => "slice_too_big",
|
||||||
InvalidMetaKind::TooBig => "too_big",
|
InvalidMetaKind::TooBig => "too_big",
|
||||||
|
@ -266,10 +266,10 @@ pub struct Misalignment {
|
||||||
pub required: Align,
|
pub required: Align,
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! impl_into_diagnostic_arg_through_debug {
|
macro_rules! impl_into_diag_arg_through_debug {
|
||||||
($($ty:ty),*$(,)?) => {$(
|
($($ty:ty),*$(,)?) => {$(
|
||||||
impl IntoDiagnosticArg for $ty {
|
impl IntoDiagArg for $ty {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Owned(format!("{self:?}")))
|
DiagArgValue::Str(Cow::Owned(format!("{self:?}")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ macro_rules! impl_into_diagnostic_arg_through_debug {
|
||||||
}
|
}
|
||||||
|
|
||||||
// These types have nice `Debug` output so we can just use them in diagnostics.
|
// These types have nice `Debug` output so we can just use them in diagnostics.
|
||||||
impl_into_diagnostic_arg_through_debug! {
|
impl_into_diag_arg_through_debug! {
|
||||||
AllocId,
|
AllocId,
|
||||||
Pointer<AllocId>,
|
Pointer<AllocId>,
|
||||||
AllocRange,
|
AllocRange,
|
||||||
|
@ -370,8 +370,8 @@ pub enum PointerKind {
|
||||||
Box,
|
Box,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for PointerKind {
|
impl IntoDiagArg for PointerKind {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(
|
DiagArgValue::Str(
|
||||||
match self {
|
match self {
|
||||||
Self::Ref(_) => "ref",
|
Self::Ref(_) => "ref",
|
||||||
|
|
|
@ -100,7 +100,7 @@ macro_rules! err_ub_custom {
|
||||||
msg: || $msg,
|
msg: || $msg,
|
||||||
add_args: Box::new(move |mut set_arg| {
|
add_args: Box::new(move |mut set_arg| {
|
||||||
$($(
|
$($(
|
||||||
set_arg(stringify!($name).into(), rustc_errors::IntoDiagnosticArg::into_diagnostic_arg($name));
|
set_arg(stringify!($name).into(), rustc_errors::IntoDiagArg::into_diag_arg($name));
|
||||||
)*)?
|
)*)?
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +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::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagnosticArg};
|
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg};
|
||||||
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};
|
||||||
|
|
|
@ -311,7 +311,7 @@ impl<O> AssertKind<O> {
|
||||||
|
|
||||||
macro_rules! add {
|
macro_rules! add {
|
||||||
($name: expr, $value: expr) => {
|
($name: expr, $value: expr) => {
|
||||||
adder($name.into(), $value.into_diagnostic_arg());
|
adder($name.into(), $value.into_diag_arg());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/thir.html
|
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/thir.html
|
||||||
|
|
||||||
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
|
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
|
||||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||||
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::RangeEnd;
|
use rustc_hir::RangeEnd;
|
||||||
|
@ -676,9 +676,9 @@ impl<'tcx> Pat<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> IntoDiagnosticArg for Pat<'tcx> {
|
impl<'tcx> IntoDiagArg for Pat<'tcx> {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
format!("{self}").into_diagnostic_arg()
|
format!("{self}").into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use rustc_apfloat::ieee::{Double, Single};
|
use rustc_apfloat::ieee::{Double, Single};
|
||||||
use rustc_apfloat::Float;
|
use rustc_apfloat::Float;
|
||||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||||
use rustc_target::abi::Size;
|
use rustc_target::abi::Size;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -114,10 +114,10 @@ impl std::fmt::Debug for ConstInt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for ConstInt {
|
impl IntoDiagArg for ConstInt {
|
||||||
// FIXME this simply uses the Debug impl, but we could probably do better by converting both
|
// FIXME this simply uses the Debug impl, but we could probably do better by converting both
|
||||||
// to an inherent method that returns `Cow`.
|
// to an inherent method that returns `Cow`.
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(format!("{self:?}").into())
|
DiagArgValue::Str(format!("{self:?}").into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,9 @@ pub struct UnevaluatedConst<'tcx> {
|
||||||
pub args: GenericArgsRef<'tcx>,
|
pub args: GenericArgsRef<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rustc_errors::IntoDiagnosticArg for UnevaluatedConst<'_> {
|
impl rustc_errors::IntoDiagArg for UnevaluatedConst<'_> {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
format!("{self:?}").into_diagnostic_arg()
|
format!("{self:?}").into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::ty::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::{Applicability, Diag, DiagArgValue, IntoDiagnosticArg};
|
use rustc_errors::{Applicability, Diag, DiagArgValue, IntoDiagArg};
|
||||||
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::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
|
@ -19,9 +19,9 @@ use rustc_hir::{PredicateOrigin, WherePredicate};
|
||||||
use rustc_span::{BytePos, Span};
|
use rustc_span::{BytePos, Span};
|
||||||
use rustc_type_ir::TyKind::*;
|
use rustc_type_ir::TyKind::*;
|
||||||
|
|
||||||
impl<'tcx> IntoDiagnosticArg for Ty<'tcx> {
|
impl<'tcx> IntoDiagArg for Ty<'tcx> {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt};
|
||||||
use rustc_ast_ir::visit::VisitorResult;
|
use rustc_ast_ir::visit::VisitorResult;
|
||||||
use rustc_ast_ir::walk_visitable_list;
|
use rustc_ast_ir::walk_visitable_list;
|
||||||
use rustc_data_structures::intern::Interned;
|
use rustc_data_structures::intern::Interned;
|
||||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use rustc_serialize::{Decodable, Encodable};
|
use rustc_serialize::{Decodable, Encodable};
|
||||||
|
@ -57,9 +57,9 @@ unsafe impl<'tcx> Sync for GenericArg<'tcx> where
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> IntoDiagnosticArg for GenericArg<'tcx> {
|
impl<'tcx> IntoDiagArg for GenericArg<'tcx> {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ 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::DiagMessage;
|
use rustc_error_messages::DiagMessage;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
|
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagArg, IntoDiagnostic, Level,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
|
@ -254,9 +254,9 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> IntoDiagnosticArg for LayoutError<'tcx> {
|
impl<'tcx> IntoDiagArg for LayoutError<'tcx> {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use rustc_data_structures::captures::Captures;
|
use rustc_data_structures::captures::Captures;
|
||||||
use rustc_data_structures::intern::Interned;
|
use rustc_data_structures::intern::Interned;
|
||||||
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
|
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::LangItem;
|
use rustc_hir::LangItem;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
@ -120,14 +120,14 @@ impl<'tcx> Predicate<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
|
impl rustc_errors::IntoDiagArg for Predicate<'_> {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
|
rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rustc_errors::IntoDiagnosticArg for Clause<'_> {
|
impl rustc_errors::IntoDiagArg for Clause<'_> {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
|
rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,9 +407,9 @@ impl<'tcx> PolyTraitRef<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> IntoDiagnosticArg for TraitRef<'tcx> {
|
impl<'tcx> IntoDiagArg for TraitRef<'tcx> {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,9 +453,9 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> IntoDiagnosticArg for ExistentialTraitRef<'tcx> {
|
impl<'tcx> IntoDiagArg for ExistentialTraitRef<'tcx> {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2722,9 +2722,9 @@ where
|
||||||
#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
|
#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
|
||||||
pub struct TraitRefPrintOnlyTraitPath<'tcx>(ty::TraitRef<'tcx>);
|
pub struct TraitRefPrintOnlyTraitPath<'tcx>(ty::TraitRef<'tcx>);
|
||||||
|
|
||||||
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintOnlyTraitPath<'tcx> {
|
impl<'tcx> rustc_errors::IntoDiagArg for TraitRefPrintOnlyTraitPath<'tcx> {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2739,9 +2739,9 @@ impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitPath<'tcx> {
|
||||||
#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
|
#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
|
||||||
pub struct TraitRefPrintSugared<'tcx>(ty::TraitRef<'tcx>);
|
pub struct TraitRefPrintSugared<'tcx>(ty::TraitRef<'tcx>);
|
||||||
|
|
||||||
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintSugared<'tcx> {
|
impl<'tcx> rustc_errors::IntoDiagArg for TraitRefPrintSugared<'tcx> {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +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::{DiagArgValue, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan};
|
use rustc_errors::{DiagArgValue, ErrorGuaranteed, IntoDiagArg, 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;
|
||||||
|
@ -1094,12 +1094,12 @@ impl<'tcx, T: IntoIterator> Binder<'tcx, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T> IntoDiagnosticArg for Binder<'tcx, T>
|
impl<'tcx, T> IntoDiagArg for Binder<'tcx, T>
|
||||||
where
|
where
|
||||||
T: IntoDiagnosticArg,
|
T: IntoDiagArg,
|
||||||
{
|
{
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.value.into_diagnostic_arg()
|
self.value.into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1307,9 +1307,9 @@ impl<'tcx> FnSig<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> IntoDiagnosticArg for FnSig<'tcx> {
|
impl<'tcx> IntoDiagArg for FnSig<'tcx> {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,7 +298,7 @@ impl<'a> Parser<'a> {
|
||||||
{
|
{
|
||||||
recovered_ident = Some((ident, IdentIsRaw::Yes));
|
recovered_ident = Some((ident, IdentIsRaw::Yes));
|
||||||
|
|
||||||
// `Symbol::to_string()` is different from `Symbol::into_diagnostic_arg()`,
|
// `Symbol::to_string()` is different from `Symbol::into_diag_arg()`,
|
||||||
// which uses `Symbol::to_ident_string()` and "helpfully" adds an implicit `r#`
|
// which uses `Symbol::to_ident_string()` and "helpfully" adds an implicit `r#`
|
||||||
let ident_name = ident.name.to_string();
|
let ident_name = ident.name.to_string();
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use rustc_ast::{ast, AttrKind, AttrStyle, Attribute, LitKind};
|
||||||
use rustc_ast::{MetaItemKind, MetaItemLit, NestedMetaItem};
|
use rustc_ast::{MetaItemKind, MetaItemLit, NestedMetaItem};
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::StashKey;
|
use rustc_errors::StashKey;
|
||||||
use rustc_errors::{Applicability, DiagCtxt, IntoDiagnosticArg, MultiSpan};
|
use rustc_errors::{Applicability, DiagCtxt, IntoDiagArg, MultiSpan};
|
||||||
use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
|
use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::LocalModDefId;
|
use rustc_hir::def_id::LocalModDefId;
|
||||||
|
@ -79,14 +79,14 @@ pub(crate) enum ProcMacroKind {
|
||||||
Attribute,
|
Attribute,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for ProcMacroKind {
|
impl IntoDiagArg for ProcMacroKind {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
match self {
|
match self {
|
||||||
ProcMacroKind::Attribute => "attribute proc macro",
|
ProcMacroKind::Attribute => "attribute proc macro",
|
||||||
ProcMacroKind::Derive => "derive proc macro",
|
ProcMacroKind::Derive => "derive proc macro",
|
||||||
ProcMacroKind::FunctionLike => "function-like proc macro",
|
ProcMacroKind::FunctionLike => "function-like proc macro",
|
||||||
}
|
}
|
||||||
.into_diagnostic_arg()
|
.into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ use rustc_ast::visit::{walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}
|
||||||
use rustc_ast::*;
|
use rustc_ast::*;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, struct_span_code_err, Applicability, DiagArgValue, IntoDiagnosticArg, StashKey,
|
codes::*, struct_span_code_err, Applicability, DiagArgValue, IntoDiagArg, StashKey,
|
||||||
};
|
};
|
||||||
use rustc_hir::def::Namespace::{self, *};
|
use rustc_hir::def::Namespace::{self, *};
|
||||||
use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
|
use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
|
||||||
|
@ -89,8 +89,8 @@ impl PatternSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for PatternSource {
|
impl IntoDiagArg for PatternSource {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
DiagArgValue::Str(Cow::Borrowed(self.descr()))
|
DiagArgValue::Str(Cow::Borrowed(self.descr()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::{EarlyDiagCtxt, Session};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
|
||||||
use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
|
use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
|
||||||
use rustc_errors::emitter::HumanReadableErrorType;
|
use rustc_errors::emitter::HumanReadableErrorType;
|
||||||
use rustc_errors::{ColorConfig, DiagArgValue, DiagCtxtFlags, IntoDiagnosticArg};
|
use rustc_errors::{ColorConfig, DiagArgValue, DiagCtxtFlags, IntoDiagArg};
|
||||||
use rustc_feature::UnstableFeatures;
|
use rustc_feature::UnstableFeatures;
|
||||||
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
|
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
|
||||||
use rustc_span::source_map::FilePathMapping;
|
use rustc_span::source_map::FilePathMapping;
|
||||||
|
@ -3098,9 +3098,9 @@ impl fmt::Display for CrateType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnosticArg for CrateType {
|
impl IntoDiagArg for CrateType {
|
||||||
fn into_diagnostic_arg(self) -> DiagArgValue {
|
fn into_diag_arg(self) -> DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,9 +111,9 @@ impl Mul<usize> for Limit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rustc_errors::IntoDiagnosticArg for Limit {
|
impl rustc_errors::IntoDiagArg for Limit {
|
||||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
|
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
|
||||||
self.to_string().into_diagnostic_arg()
|
self.to_string().into_diag_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//@ check-fail
|
//@ check-fail
|
||||||
// Tests that a doc comment will not preclude a field from being considered a diagnostic argument
|
// Tests that a doc comment will not preclude a field from being considered a diagnostic argument
|
||||||
//@ normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
|
//@ normalize-stderr-test "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
|
||||||
//@ normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC"
|
//@ normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC"
|
||||||
|
|
||||||
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
|
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
|
||||||
|
@ -25,7 +25,7 @@ use rustc_span::Span;
|
||||||
|
|
||||||
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
|
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
|
||||||
|
|
||||||
struct NotIntoDiagnosticArg;
|
struct NotIntoDiagArg;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(no_crate_example)]
|
#[diag(no_crate_example)]
|
||||||
|
@ -33,8 +33,8 @@ struct Test {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
/// A doc comment
|
/// A doc comment
|
||||||
arg: NotIntoDiagnosticArg,
|
arg: NotIntoDiagArg,
|
||||||
//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
|
//~^ ERROR the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
|
@ -43,6 +43,6 @@ struct SubTest {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
/// A doc comment
|
/// A doc comment
|
||||||
arg: NotIntoDiagnosticArg,
|
arg: NotIntoDiagArg,
|
||||||
//~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
|
//~^ ERROR the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
|
error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
|
||||||
--> $DIR/diagnostic-derive-doc-comment-field.rs:36:10
|
--> $DIR/diagnostic-derive-doc-comment-field.rs:36:10
|
||||||
|
|
|
|
||||||
LL | #[derive(Diagnostic)]
|
LL | #[derive(Diagnostic)]
|
||||||
| ---------- required by a bound introduced by this call
|
| ---------- required by a bound introduced by this call
|
||||||
...
|
...
|
||||||
LL | arg: NotIntoDiagnosticArg,
|
LL | arg: NotIntoDiagArg,
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg`
|
| ^^^^^^^^^^^^^^ the trait `IntoDiagArg` is not implemented for `NotIntoDiagArg`
|
||||||
|
|
|
|
||||||
= help: normalized in stderr
|
= help: normalized in stderr
|
||||||
note: required by a bound in `Diag::<'a, G>::arg`
|
note: required by a bound in `Diag::<'a, G>::arg`
|
||||||
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
|
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
|
||||||
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied
|
error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
|
||||||
--> $DIR/diagnostic-derive-doc-comment-field.rs:46:10
|
--> $DIR/diagnostic-derive-doc-comment-field.rs:46:10
|
||||||
|
|
|
|
||||||
LL | #[derive(Subdiagnostic)]
|
LL | #[derive(Subdiagnostic)]
|
||||||
| ------------- required by a bound introduced by this call
|
| ------------- required by a bound introduced by this call
|
||||||
...
|
...
|
||||||
LL | arg: NotIntoDiagnosticArg,
|
LL | arg: NotIntoDiagArg,
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg`
|
| ^^^^^^^^^^^^^^ the trait `IntoDiagArg` is not implemented for `NotIntoDiagArg`
|
||||||
|
|
|
|
||||||
= help: normalized in stderr
|
= help: normalized in stderr
|
||||||
note: required by a bound in `Diag::<'a, G>::arg`
|
note: required by a bound in `Diag::<'a, G>::arg`
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//@ check-fail
|
//@ check-fail
|
||||||
// Tests error conditions for specifying diagnostics using #[derive(Diagnostic)]
|
// Tests error conditions for specifying diagnostics using #[derive(Diagnostic)]
|
||||||
//@ normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
|
//@ normalize-stderr-test "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
|
||||||
//@ normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC"
|
//@ normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC"
|
||||||
|
|
||||||
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
|
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
|
||||||
|
@ -347,7 +347,7 @@ struct ArgFieldWithoutSkip {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
other: Hello,
|
other: Hello,
|
||||||
//~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied
|
//~^ ERROR the trait bound `Hello: IntoDiagArg` is not satisfied
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
|
@ -355,7 +355,7 @@ struct ArgFieldWithoutSkip {
|
||||||
struct ArgFieldWithSkip {
|
struct ArgFieldWithSkip {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
// `Hello` does not implement `IntoDiagnosticArg` so this would result in an error if
|
// `Hello` does not implement `IntoDiagArg` so this would result in an error if
|
||||||
// not for `#[skip_arg]`.
|
// not for `#[skip_arg]`.
|
||||||
#[skip_arg]
|
#[skip_arg]
|
||||||
other: Hello,
|
other: Hello,
|
||||||
|
|
|
@ -618,14 +618,14 @@ LL | #[derive(Diagnostic)]
|
||||||
|
|
|
|
||||||
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied
|
error[E0277]: the trait bound `Hello: IntoDiagArg` is not satisfied
|
||||||
--> $DIR/diagnostic-derive.rs:349:12
|
--> $DIR/diagnostic-derive.rs:349:12
|
||||||
|
|
|
|
||||||
LL | #[derive(Diagnostic)]
|
LL | #[derive(Diagnostic)]
|
||||||
| ---------- required by a bound introduced by this call
|
| ---------- required by a bound introduced by this call
|
||||||
...
|
...
|
||||||
LL | other: Hello,
|
LL | other: Hello,
|
||||||
| ^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello`
|
| ^^^^^ the trait `IntoDiagArg` is not implemented for `Hello`
|
||||||
|
|
|
|
||||||
= help: normalized in stderr
|
= help: normalized in stderr
|
||||||
note: required by a bound in `Diag::<'a, G>::arg`
|
note: required by a bound in `Diag::<'a, G>::arg`
|
||||||
|
|
Loading…
Add table
Reference in a new issue