Rename `DiagnosticArg{,Map,Name,Value}` as `DiagArg{,Map,Name,Value}`.

This commit is contained in:
Nicholas Nethercote 2024-02-23 14:37:48 +11:00
parent 899cb40809
commit 8199632aa8
40 changed files with 196 additions and 198 deletions

View File

@ -192,7 +192,7 @@ impl Display for RegionName {
}
impl rustc_errors::IntoDiagnosticArg for RegionName {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}

View File

@ -1,5 +1,5 @@
use rustc_errors::{
DiagCtxt, DiagnosticArgValue, Diag, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
DiagCtxt, DiagArgValue, Diag, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::Span;
@ -34,11 +34,11 @@ pub(crate) enum PossibleFeature<'a> {
struct ExitCode(Option<i32>);
impl IntoDiagnosticArg for ExitCode {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
let ExitCode(exit_code) = self;
match exit_code {
Some(t) => t.into_diagnostic_arg(),
None => DiagnosticArgValue::Str(Cow::Borrowed("<signal>")),
None => DiagArgValue::Str(Cow::Borrowed("<signal>")),
}
}
}

View File

@ -27,7 +27,7 @@ use crate::errors;
use rustc_ast as ast;
use rustc_data_structures::unord::UnordMap;
use rustc_data_structures::unord::UnordSet;
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
use rustc_middle::ty::TyCtxt;
@ -206,8 +206,8 @@ impl fmt::Display for CguReuse {
}
impl IntoDiagnosticArg for CguReuse {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.to_string()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.to_string()))
}
}

View File

@ -16,7 +16,7 @@ use rustc_data_structures::sync::Lrc;
use rustc_errors::emitter::Emitter;
use rustc_errors::translation::Translate;
use rustc_errors::{
Diag, DiagCtxt, DiagnosticArgMap, DiagnosticMessage, ErrCode, FatalError, FluentBundle, Level,
Diag, DiagArgMap, DiagCtxt, DiagnosticMessage, ErrCode, FatalError, FluentBundle, Level,
MultiSpan, Style,
};
use rustc_fs_util::link_or_copy;
@ -1013,7 +1013,7 @@ struct Diagnostic {
messages: Vec<(DiagnosticMessage, Style)>,
code: Option<ErrCode>,
children: Vec<Subdiagnostic>,
args: DiagnosticArgMap,
args: DiagArgMap,
}
// A cut-down version of `rustc_errors::SubDiagnostic` that impls `Send`. It's
@ -1838,7 +1838,7 @@ impl Emitter for SharedEmitter {
assert_eq!(diag.is_lint, None);
// No sensible check for `diag.emitted_at`.
let args = mem::replace(&mut diag.args, DiagnosticArgMap::default());
let args = mem::replace(&mut diag.args, DiagArgMap::default());
drop(
self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
level: diag.level(),

View File

@ -4,8 +4,8 @@ use crate::assert_module_sources::CguReuse;
use crate::back::command::Command;
use crate::fluent_generated as fluent;
use rustc_errors::{
codes::*, Diag, DiagCtxt, DiagnosticArgValue, EmissionGuarantee, IntoDiagnostic,
IntoDiagnosticArg, Level,
codes::*, Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg,
Level,
};
use rustc_macros::Diagnostic;
use rustc_middle::ty::layout::LayoutError;
@ -153,8 +153,8 @@ impl<'a> CopyPath<'a> {
struct DebugArgPath<'a>(pub &'a Path);
impl IntoDiagnosticArg for DebugArgPath<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
DiagArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
}
}
@ -975,10 +975,10 @@ pub enum ExpectedPointerMutability {
}
impl IntoDiagnosticArg for ExpectedPointerMutability {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
match self {
ExpectedPointerMutability::Mut => DiagnosticArgValue::Str(Cow::Borrowed("*mut")),
ExpectedPointerMutability::Not => DiagnosticArgValue::Str(Cow::Borrowed("*_")),
ExpectedPointerMutability::Mut => DiagArgValue::Str(Cow::Borrowed("*mut")),
ExpectedPointerMutability::Not => DiagArgValue::Str(Cow::Borrowed("*_")),
}
}
}

View File

@ -1,7 +1,7 @@
use std::mem;
use rustc_errors::{
DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage, IntoDiagnostic, IntoDiagnosticArg,
DiagArgName, DiagArgValue, DiagnosticMessage, IntoDiagnostic, IntoDiagnosticArg,
};
use rustc_hir::CRATE_HIR_ID;
use rustc_middle::mir::AssertKind;
@ -36,7 +36,7 @@ impl MachineStopType for ConstEvalErrKind {
AssertFailure(x) => x.diagnostic_message(),
}
}
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue)) {
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagArgName, DiagArgValue)) {
use ConstEvalErrKind::*;
match *self {
RecursiveStatic | ConstAccessesMutGlobal | ModifiedGlobal => {}

View File

@ -1,8 +1,8 @@
use std::borrow::Cow;
use rustc_errors::{
codes::*, Diag, DiagCtxt, DiagnosticArgValue, DiagnosticMessage, EmissionGuarantee,
IntoDiagnostic, Level,
codes::*, Diag, DiagArgValue, DiagCtxt, DiagnosticMessage, EmissionGuarantee, IntoDiagnostic,
Level,
};
use rustc_hir::ConstContext;
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
@ -683,7 +683,7 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
let message = if let Some(path) = self.path {
err.dcx.eagerly_translate_to_string(
fluent::const_eval_validation_front_matter_invalid_value_with_path,
[("path".into(), DiagnosticArgValue::Str(path.into()))].iter().map(|(a, b)| (a, b)),
[("path".into(), DiagArgValue::Str(path.into()))].iter().map(|(a, b)| (a, b)),
)
} else {
err.dcx.eagerly_translate_to_string(
@ -716,8 +716,8 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
};
let args = [
("lo".into(), DiagnosticArgValue::Str(lo.to_string().into())),
("hi".into(), DiagnosticArgValue::Str(hi.to_string().into())),
("lo".into(), DiagArgValue::Str(lo.to_string().into())),
("hi".into(), DiagArgValue::Str(hi.to_string().into())),
];
let args = args.iter().map(|(a, b)| (a, b));
let message = err.dcx.eagerly_translate_to_string(msg, args);
@ -892,8 +892,8 @@ impl ReportErrorExt for ResourceExhaustionInfo {
}
impl rustc_errors::IntoDiagnosticArg for InternKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(match self {
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(match self {
InternKind::Static(Mutability::Not) => "static",
InternKind::Static(Mutability::Mut) => "static_mut",
InternKind::Constant => "const",

View File

@ -24,17 +24,17 @@ use std::thread::panicking;
pub struct SuggestionsDisabled;
/// Simplified version of `FluentArg` that can implement `Encodable` and `Decodable`. Collection of
/// `DiagnosticArg` are converted to `FluentArgs` (consuming the collection) at the start of
/// diagnostic emission.
pub type DiagnosticArg<'iter> = (&'iter DiagnosticArgName, &'iter DiagnosticArgValue);
/// `DiagArg` are converted to `FluentArgs` (consuming the collection) at the start of diagnostic
/// emission.
pub type DiagArg<'iter> = (&'iter DiagArgName, &'iter DiagArgValue);
/// Name of a diagnostic argument.
pub type DiagnosticArgName = Cow<'static, str>;
pub type DiagArgName = Cow<'static, str>;
/// Simplified version of `FluentValue` that can implement `Encodable` and `Decodable`. Converted
/// to a `FluentValue` by the emitter to be used in diagnostic translation.
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
pub enum DiagnosticArgValue {
pub enum DiagArgValue {
Str(Cow<'static, str>),
// 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
@ -43,7 +43,7 @@ pub enum DiagnosticArgValue {
StrListSepByAnd(Vec<Cow<'static, str>>),
}
pub type DiagnosticArgMap = FxIndexMap<DiagnosticArgName, DiagnosticArgValue>;
pub type DiagArgMap = FxIndexMap<DiagArgName, DiagArgValue>;
/// Trait for types that `Diag::emit` can return as a "guarantee" (or "proof")
/// token that the emission happened.
@ -125,26 +125,26 @@ where
}
}
/// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic`
/// struct). Implemented as a custom trait rather than `From` so that it is implemented on the type
/// being converted rather than on `DiagnosticArgValue`, which enables types from other `rustc_*`
/// crates to implement this.
/// Converts a value of a type into a `DiagArg` (typically a field of an `IntoDiagnostic` struct).
/// 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
/// implement this.
pub trait IntoDiagnosticArg {
fn into_diagnostic_arg(self) -> DiagnosticArgValue;
fn into_diagnostic_arg(self) -> DiagArgValue;
}
impl IntoDiagnosticArg for DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
impl IntoDiagnosticArg for DiagArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self
}
}
impl Into<FluentValue<'static>> for DiagnosticArgValue {
impl Into<FluentValue<'static>> for DiagArgValue {
fn into(self) -> FluentValue<'static> {
match self {
DiagnosticArgValue::Str(s) => From::from(s),
DiagnosticArgValue::Number(n) => From::from(n),
DiagnosticArgValue::StrListSepByAnd(l) => fluent_value_from_str_list_sep_by_and(l),
DiagArgValue::Str(s) => From::from(s),
DiagArgValue::Number(n) => From::from(n),
DiagArgValue::StrListSepByAnd(l) => fluent_value_from_str_list_sep_by_and(l),
}
}
}
@ -277,7 +277,7 @@ pub struct DiagInner {
pub span: MultiSpan,
pub children: Vec<Subdiag>,
pub suggestions: Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
pub args: DiagnosticArgMap,
pub args: DiagArgMap,
/// This is not used for highlighting or rendering any error message. Rather, it can be used
/// as a sort key to sort a buffer of diagnostics. By default, it is the primary span of
@ -401,7 +401,7 @@ impl DiagInner {
self.children.push(sub);
}
pub(crate) fn arg(&mut self, name: impl Into<DiagnosticArgName>, arg: impl IntoDiagnosticArg) {
pub(crate) fn arg(&mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagnosticArg) {
self.args.insert(name.into(), arg.into_diagnostic_arg());
}
@ -415,7 +415,7 @@ impl DiagInner {
&MultiSpan,
&[Subdiag],
&Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
Vec<(&DiagnosticArgName, &DiagnosticArgValue)>,
Vec<(&DiagArgName, &DiagArgValue)>,
&Option<IsLint>,
) {
(
@ -1193,7 +1193,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// Add an argument.
pub fn arg(
&mut self,
name: impl Into<DiagnosticArgName>,
name: impl Into<DiagArgName>,
arg: impl IntoDiagnosticArg,
) -> &mut Self {
self.deref_mut().arg(name, arg);

View File

@ -1,8 +1,8 @@
use crate::diagnostic::DiagnosticLocation;
use crate::{fluent_generated as fluent, AddToDiagnostic};
use crate::{
Diag, DiagCtxt, DiagnosticArgValue, EmissionGuarantee, ErrCode, IntoDiagnostic,
IntoDiagnosticArg, Level, SubdiagnosticMessageOp,
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, ErrCode, IntoDiagnostic, IntoDiagnosticArg,
Level, SubdiagnosticMessageOp,
};
use rustc_ast as ast;
use rustc_ast_pretty::pprust;
@ -23,7 +23,7 @@ use std::process::ExitStatus;
pub struct DiagnosticArgFromDisplay<'a>(pub &'a dyn fmt::Display);
impl IntoDiagnosticArg for DiagnosticArgFromDisplay<'_> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.0.to_string().into_diagnostic_arg()
}
}
@ -41,7 +41,7 @@ impl<'a, T: fmt::Display> From<&'a T> for DiagnosticArgFromDisplay<'a> {
}
impl<'a, T: Clone + IntoDiagnosticArg> IntoDiagnosticArg for &'a T {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.clone().into_diagnostic_arg()
}
}
@ -50,7 +50,7 @@ macro_rules! into_diagnostic_arg_using_display {
($( $ty:ty ),+ $(,)?) => {
$(
impl IntoDiagnosticArg for $ty {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}
@ -62,10 +62,10 @@ macro_rules! into_diagnostic_arg_for_number {
($( $ty:ty ),+ $(,)?) => {
$(
impl IntoDiagnosticArg for $ty {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
// Convert to a string if it won't fit into `Number`.
if let Ok(n) = TryInto::<i32>::try_into(self) {
DiagnosticArgValue::Number(n)
DiagArgValue::Number(n)
} else {
self.to_string().into_diagnostic_arg()
}
@ -95,74 +95,74 @@ into_diagnostic_arg_using_display!(
into_diagnostic_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
impl IntoDiagnosticArg for bool {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
if self {
DiagnosticArgValue::Str(Cow::Borrowed("true"))
DiagArgValue::Str(Cow::Borrowed("true"))
} else {
DiagnosticArgValue::Str(Cow::Borrowed("false"))
DiagArgValue::Str(Cow::Borrowed("false"))
}
}
}
impl IntoDiagnosticArg for char {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}")))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(format!("{self:?}")))
}
}
impl IntoDiagnosticArg for Vec<char> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::StrListSepByAnd(
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::StrListSepByAnd(
self.into_iter().map(|c| Cow::Owned(format!("{c:?}"))).collect(),
)
}
}
impl IntoDiagnosticArg for Symbol {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_ident_string().into_diagnostic_arg()
}
}
impl<'a> IntoDiagnosticArg for &'a str {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}
impl IntoDiagnosticArg for String {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self))
}
}
impl<'a> IntoDiagnosticArg for Cow<'a, str> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.into_owned()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.into_owned()))
}
}
impl<'a> IntoDiagnosticArg for &'a Path {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.display().to_string()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.display().to_string()))
}
}
impl IntoDiagnosticArg for PathBuf {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.display().to_string()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.display().to_string()))
}
}
impl IntoDiagnosticArg for PanicStrategy {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.desc().to_string()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.desc().to_string()))
}
}
impl IntoDiagnosticArg for hir::ConstContext {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(match self {
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(match self {
hir::ConstContext::ConstFn => "const_fn",
hir::ConstContext::Static(_) => "static",
hir::ConstContext::Const { .. } => "const",
@ -171,58 +171,58 @@ impl IntoDiagnosticArg for hir::ConstContext {
}
impl IntoDiagnosticArg for ast::Expr {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(pprust::expr_to_string(&self)))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(pprust::expr_to_string(&self)))
}
}
impl IntoDiagnosticArg for ast::Path {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(pprust::path_to_string(&self)))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(pprust::path_to_string(&self)))
}
}
impl IntoDiagnosticArg for ast::token::Token {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(pprust::token_to_string(&self))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(pprust::token_to_string(&self))
}
}
impl IntoDiagnosticArg for ast::token::TokenKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(pprust::token_kind_to_string(&self))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(pprust::token_kind_to_string(&self))
}
}
impl IntoDiagnosticArg for type_ir::FloatTy {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(self.name_str()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(self.name_str()))
}
}
impl IntoDiagnosticArg for std::ffi::CString {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
}
}
impl IntoDiagnosticArg for rustc_data_structures::small_c_str::SmallCStr {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
}
}
impl IntoDiagnosticArg for ast::Visibility {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
let s = pprust::vis_to_string(&self);
let s = s.trim_end().to_string();
DiagnosticArgValue::Str(Cow::Owned(s))
DiagArgValue::Str(Cow::Owned(s))
}
}
impl IntoDiagnosticArg for rustc_lint_defs::Level {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
}
}
@ -236,16 +236,16 @@ impl From<Vec<Symbol>> for DiagnosticSymbolList {
}
impl IntoDiagnosticArg for DiagnosticSymbolList {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::StrListSepByAnd(
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::StrListSepByAnd(
self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(),
)
}
}
impl<Id> IntoDiagnosticArg for hir::def::Res<Id> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(self.descr()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(self.descr()))
}
}
@ -316,20 +316,20 @@ pub struct ExpectedLifetimeParameter {
}
impl IntoDiagnosticArg for DiagnosticLocation {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::from(self.to_string()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::from(self.to_string()))
}
}
impl IntoDiagnosticArg for Backtrace {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::from(self.to_string()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::from(self.to_string()))
}
}
impl IntoDiagnosticArg for Level {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::from(self.to_string()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::from(self.to_string()))
}
}
@ -343,7 +343,7 @@ pub struct IndicateAnonymousLifetime {
}
impl IntoDiagnosticArg for type_ir::ClosureKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(self.as_str().into())
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(self.as_str().into())
}
}

View File

@ -37,9 +37,9 @@ extern crate self as rustc_errors;
pub use codes::*;
pub use diagnostic::{
AddToDiagnostic, BugAbort, DecorateLint, Diag, DiagInner, DiagnosticArg, DiagnosticArgMap,
DiagnosticArgName, DiagnosticArgValue, DiagnosticStyledString, EmissionGuarantee, FatalAbort,
IntoDiagnostic, IntoDiagnosticArg, StringPart, Subdiag, SubdiagnosticMessageOp,
AddToDiagnostic, BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue,
DiagInner, DiagnosticStyledString, EmissionGuarantee, FatalAbort, IntoDiagnostic,
IntoDiagnosticArg, StringPart, Subdiag, SubdiagnosticMessageOp,
};
pub use diagnostic_impls::{
DiagnosticArgFromDisplay, DiagnosticSymbolList, ExpectedLifetimeParameter,
@ -639,7 +639,7 @@ impl DiagCtxt {
pub fn eagerly_translate<'a>(
&self,
message: DiagnosticMessage,
args: impl Iterator<Item = DiagnosticArg<'a>>,
args: impl Iterator<Item = DiagArg<'a>>,
) -> SubdiagnosticMessage {
let inner = self.inner.borrow();
inner.eagerly_translate(message, args)
@ -649,7 +649,7 @@ impl DiagCtxt {
pub fn eagerly_translate_to_string<'a>(
&self,
message: DiagnosticMessage,
args: impl Iterator<Item = DiagnosticArg<'a>>,
args: impl Iterator<Item = DiagArg<'a>>,
) -> String {
let inner = self.inner.borrow();
inner.eagerly_translate_to_string(message, args)
@ -1461,7 +1461,7 @@ impl DiagCtxtInner {
pub fn eagerly_translate<'a>(
&self,
message: DiagnosticMessage,
args: impl Iterator<Item = DiagnosticArg<'a>>,
args: impl Iterator<Item = DiagArg<'a>>,
) -> SubdiagnosticMessage {
SubdiagnosticMessage::Translated(Cow::from(self.eagerly_translate_to_string(message, args)))
}
@ -1470,7 +1470,7 @@ impl DiagCtxtInner {
pub fn eagerly_translate_to_string<'a>(
&self,
message: DiagnosticMessage,
args: impl Iterator<Item = DiagnosticArg<'a>>,
args: impl Iterator<Item = DiagArg<'a>>,
) -> String {
let args = crate::translation::to_fluent_args(args);
self.emitter.translate_message(&message, &args).map_err(Report::new).unwrap().to_string()

View File

@ -1,6 +1,6 @@
use crate::error::{TranslateError, TranslateErrorKind};
use crate::snippet::Style;
use crate::{DiagnosticArg, DiagnosticMessage, FluentBundle};
use crate::{DiagArg, DiagnosticMessage, FluentBundle};
use rustc_data_structures::sync::Lrc;
pub use rustc_error_messages::FluentArgs;
use std::borrow::Cow;
@ -12,9 +12,7 @@ use std::error::Report;
///
/// Typically performed once for each diagnostic at the start of `emit_diagnostic` and then
/// passed around as a reference thereafter.
pub fn to_fluent_args<'iter>(
iter: impl Iterator<Item = DiagnosticArg<'iter>>,
) -> FluentArgs<'static> {
pub fn to_fluent_args<'iter>(iter: impl Iterator<Item = DiagArg<'iter>>) -> FluentArgs<'static> {
let mut args = if let Some(size) = iter.size_hint().1 {
FluentArgs::with_capacity(size)
} else {

View File

@ -3,7 +3,7 @@ use std::borrow::Cow;
use crate::fluent_generated as fluent;
use rustc_errors::{
codes::*, AddToDiagnostic, Applicability, Diag, DiagnosticArgValue, EmissionGuarantee,
codes::*, AddToDiagnostic, Applicability, Diag, DiagArgValue, EmissionGuarantee,
IntoDiagnosticArg, MultiSpan, SubdiagnosticMessageOp,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
@ -43,14 +43,14 @@ pub enum ReturnLikeStatementKind {
}
impl IntoDiagnosticArg for ReturnLikeStatementKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
let kind = match self {
Self::Return => "return",
Self::Become => "become",
}
.into();
DiagnosticArgValue::Str(kind)
DiagArgValue::Str(kind)
}
}

View File

@ -538,7 +538,7 @@ pub enum TyOrSig<'tcx> {
}
impl IntoDiagnosticArg for TyOrSig<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
match self {
TyOrSig::Ty(ty) => ty.into_diagnostic_arg(),
TyOrSig::ClosureSig(sig) => sig.into_diagnostic_arg(),

View File

@ -110,7 +110,7 @@ pub enum SuffixKind {
}
impl IntoDiagnosticArg for PrefixKind {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
let kind = match self {
Self::Empty => "empty",
Self::RefValidFor => "ref_valid_for",
@ -127,19 +127,19 @@ impl IntoDiagnosticArg for PrefixKind {
Self::DataValidFor => "data_valid_for",
}
.into();
rustc_errors::DiagnosticArgValue::Str(kind)
rustc_errors::DiagArgValue::Str(kind)
}
}
impl IntoDiagnosticArg for SuffixKind {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
let kind = match self {
Self::Empty => "empty",
Self::Continues => "continues",
Self::ReqByBinding => "req_by_binding",
}
.into();
rustc_errors::DiagnosticArgValue::Str(kind)
rustc_errors::DiagArgValue::Str(kind)
}
}

View File

@ -2899,7 +2899,7 @@ impl<'tcx> ObligationCause<'tcx> {
pub struct ObligationCauseAsDiagArg<'tcx>(pub ObligationCause<'tcx>);
impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
use crate::traits::ObligationCauseCode::*;
let kind = match self.0.code() {
CompareImplItemObligation { kind: ty::AssocKind::Fn, .. } => "method_compat",
@ -2913,7 +2913,7 @@ impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> {
_ => "other",
}
.into();
rustc_errors::DiagnosticArgValue::Str(kind)
rustc_errors::DiagArgValue::Str(kind)
}
}

View File

@ -134,13 +134,13 @@ impl InferenceDiagnosticsParentData {
}
impl IntoDiagnosticArg for UnderspecifiedArgKind {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
let kind = match self {
Self::Type { .. } => "type",
Self::Const { is_parameter: true } => "const_with_param",
Self::Const { is_parameter: false } => "const",
};
rustc_errors::DiagnosticArgValue::Str(kind.into())
rustc_errors::DiagArgValue::Str(kind.into())
}
}

View File

@ -30,8 +30,8 @@ impl<'tcx, T> IntoDiagnosticArg for Highlighted<'tcx, T>
where
T: for<'a> Print<'tcx, FmtPrinter<'a, 'tcx>>,
{
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
rustc_errors::DiagnosticArgValue::Str(self.to_string().into())
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
rustc_errors::DiagArgValue::Str(self.to_string().into())
}
}

View File

@ -220,7 +220,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::owned_slice::slice_owned;
use rustc_data_structures::svh::Svh;
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_fs_util::try_canonicalize;
use rustc_session::config;
use rustc_session::cstore::CrateSource;
@ -291,11 +291,11 @@ impl fmt::Display for CrateFlavor {
}
impl IntoDiagnosticArg for CrateFlavor {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
match self {
CrateFlavor::Rlib => DiagnosticArgValue::Str(Cow::Borrowed("rlib")),
CrateFlavor::Rmeta => DiagnosticArgValue::Str(Cow::Borrowed("rmeta")),
CrateFlavor::Dylib => DiagnosticArgValue::Str(Cow::Borrowed("dylib")),
CrateFlavor::Rlib => DiagArgValue::Str(Cow::Borrowed("rlib")),
CrateFlavor::Rmeta => DiagArgValue::Str(Cow::Borrowed("rmeta")),
CrateFlavor::Dylib => DiagArgValue::Str(Cow::Borrowed("dylib")),
}
}
}

View File

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

View File

@ -6,7 +6,7 @@ use crate::ty::{layout, tls, Ty, TyCtxt, ValTree};
use rustc_data_structures::sync::Lock;
use rustc_errors::{
DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg,
DiagArgName, DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg,
};
use rustc_macros::HashStable;
use rustc_session::CtfeBacktrace;
@ -237,8 +237,8 @@ pub enum InvalidMetaKind {
}
impl IntoDiagnosticArg for InvalidMetaKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(match self {
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(match self {
InvalidMetaKind::SliceTooBig => "slice_too_big",
InvalidMetaKind::TooBig => "too_big",
}))
@ -271,8 +271,8 @@ pub struct Misalignment {
macro_rules! impl_into_diagnostic_arg_through_debug {
($($ty:ty),*$(,)?) => {$(
impl IntoDiagnosticArg for $ty {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}")))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(format!("{self:?}")))
}
}
)*}
@ -373,8 +373,8 @@ pub enum PointerKind {
}
impl IntoDiagnosticArg for PointerKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(
match self {
Self::Ref(_) => "ref",
Self::Box => "box",
@ -493,7 +493,7 @@ pub trait MachineStopType: Any + fmt::Debug + Send {
fn diagnostic_message(&self) -> DiagnosticMessage;
/// Add diagnostic arguments by passing name and value pairs to `adder`, which are passed to
/// fluent for formatting the translated diagnostic message.
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue));
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagArgName, DiagArgValue));
}
impl dyn MachineStopType {

View File

@ -15,7 +15,7 @@ use crate::ty::{GenericArg, GenericArgsRef};
use rustc_data_structures::captures::Captures;
use rustc_errors::{
DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg,
DiagArgName, DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg,
};
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};

View File

@ -292,7 +292,7 @@ impl<O> AssertKind<O> {
}
}
pub fn add_args(self, adder: &mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue))
pub fn add_args(self, adder: &mut dyn FnMut(DiagArgName, DiagArgValue))
where
O: fmt::Debug,
{

View File

@ -9,7 +9,7 @@
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/thir.html
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::RangeEnd;
@ -674,7 +674,7 @@ impl<'tcx> Pat<'tcx> {
}
impl<'tcx> IntoDiagnosticArg for Pat<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
format!("{self}").into_diagnostic_arg()
}
}

View File

@ -1,6 +1,6 @@
use rustc_apfloat::ieee::{Double, Single};
use rustc_apfloat::Float;
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_target::abi::Size;
use std::fmt;
@ -117,8 +117,8 @@ impl std::fmt::Debug for ConstInt {
impl IntoDiagnosticArg for ConstInt {
// FIXME this simply uses the Debug impl, but we could probably do better by converting both
// to an inherent method that returns `Cow`.
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(format!("{self:?}").into())
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(format!("{self:?}").into())
}
}

View File

@ -15,7 +15,7 @@ pub struct UnevaluatedConst<'tcx> {
}
impl rustc_errors::IntoDiagnosticArg for UnevaluatedConst<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
format!("{self:?}").into_diagnostic_arg()
}
}

View File

@ -11,7 +11,7 @@ use crate::ty::{
};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{Applicability, Diag, DiagnosticArgValue, IntoDiagnosticArg};
use rustc_errors::{Applicability, Diag, DiagArgValue, IntoDiagnosticArg};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
@ -20,7 +20,7 @@ use rustc_span::{BytePos, Span};
use rustc_type_ir::TyKind::*;
impl<'tcx> IntoDiagnosticArg for Ty<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}

View File

@ -7,7 +7,7 @@ use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor};
use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt};
use rustc_data_structures::intern::Interned;
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_hir::def_id::DefId;
use rustc_macros::HashStable;
use rustc_serialize::{Decodable, Encodable};
@ -56,7 +56,7 @@ unsafe impl<'tcx> Sync for GenericArg<'tcx> where
}
impl<'tcx> IntoDiagnosticArg for GenericArg<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}

View File

@ -5,7 +5,7 @@ use crate::ty::normalize_erasing_regions::NormalizationError;
use crate::ty::{self, ConstKind, Ty, TyCtxt, TypeVisitableExt};
use rustc_error_messages::DiagnosticMessage;
use rustc_errors::{
Diag, DiagCtxt, DiagnosticArgValue, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
@ -252,7 +252,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
}
impl<'tcx> IntoDiagnosticArg for LayoutError<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}

View File

@ -1,6 +1,6 @@
use rustc_data_structures::captures::Captures;
use rustc_data_structures::intern::Interned;
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
use rustc_errors::{DiagArgValue, IntoDiagnosticArg};
use rustc_hir::def_id::DefId;
use rustc_hir::LangItem;
use rustc_span::Span;
@ -121,14 +121,14 @@ impl<'tcx> Predicate<'tcx> {
}
impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
}
}
impl rustc_errors::IntoDiagnosticArg for Clause<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
}
}
@ -408,7 +408,7 @@ impl<'tcx> PolyTraitRef<'tcx> {
}
impl<'tcx> IntoDiagnosticArg for TraitRef<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}
@ -454,7 +454,7 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
}
impl<'tcx> IntoDiagnosticArg for ExistentialTraitRef<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}

View File

@ -2725,7 +2725,7 @@ where
pub struct TraitRefPrintOnlyTraitPath<'tcx>(ty::TraitRef<'tcx>);
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintOnlyTraitPath<'tcx> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}
@ -2742,7 +2742,7 @@ impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitPath<'tcx> {
pub struct TraitRefPrintSugared<'tcx>(ty::TraitRef<'tcx>);
impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintSugared<'tcx> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}

View File

@ -14,7 +14,7 @@ use crate::ty::{List, ParamEnv};
use hir::def::DefKind;
use rustc_data_structures::captures::Captures;
use rustc_errors::{
DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan,
DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan,
};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
@ -1100,7 +1100,7 @@ impl<'tcx, T> IntoDiagnosticArg for Binder<'tcx, T>
where
T: IntoDiagnosticArg,
{
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.value.into_diagnostic_arg()
}
}
@ -1310,7 +1310,7 @@ impl<'tcx> FnSig<'tcx> {
}
impl<'tcx> IntoDiagnosticArg for FnSig<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}

View File

@ -4,7 +4,7 @@ use crate::build::ExprCategory;
use crate::errors::*;
use rustc_middle::thir::visit::Visitor;
use rustc_errors::DiagnosticArgValue;
use rustc_errors::DiagArgValue;
use rustc_hir as hir;
use rustc_middle::mir::BorrowKind;
use rustc_middle::thir::*;
@ -703,12 +703,12 @@ impl UnsafeOpKind {
UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
span,
function: with_no_trimmed_paths!(tcx.def_path_str(*function)),
missing_target_features: DiagnosticArgValue::StrListSepByAnd(
missing_target_features: DiagArgValue::StrListSepByAnd(
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
),
missing_target_features_count: missing.len(),
note: if build_enabled.is_empty() { None } else { Some(()) },
build_target_features: DiagnosticArgValue::StrListSepByAnd(
build_target_features: DiagArgValue::StrListSepByAnd(
build_enabled
.iter()
.map(|feature| Cow::from(feature.to_string()))
@ -868,12 +868,12 @@ impl UnsafeOpKind {
{
dcx.emit_err(CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span,
missing_target_features: DiagnosticArgValue::StrListSepByAnd(
missing_target_features: DiagArgValue::StrListSepByAnd(
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
),
missing_target_features_count: missing.len(),
note: if build_enabled.is_empty() { None } else { Some(()) },
build_target_features: DiagnosticArgValue::StrListSepByAnd(
build_target_features: DiagArgValue::StrListSepByAnd(
build_enabled
.iter()
.map(|feature| Cow::from(feature.to_string()))
@ -887,12 +887,12 @@ impl UnsafeOpKind {
CallToFunctionWith { function, missing, build_enabled } => {
dcx.emit_err(CallToFunctionWithRequiresUnsafe {
span,
missing_target_features: DiagnosticArgValue::StrListSepByAnd(
missing_target_features: DiagArgValue::StrListSepByAnd(
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
),
missing_target_features_count: missing.len(),
note: if build_enabled.is_empty() { None } else { Some(()) },
build_target_features: DiagnosticArgValue::StrListSepByAnd(
build_target_features: DiagArgValue::StrListSepByAnd(
build_enabled
.iter()
.map(|feature| Cow::from(feature.to_string()))

View File

@ -1,5 +1,5 @@
use crate::fluent_generated as fluent;
use rustc_errors::DiagnosticArgValue;
use rustc_errors::DiagArgValue;
use rustc_errors::{
codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic,
Level, MultiSpan, SubdiagnosticMessageOp,
@ -127,11 +127,11 @@ pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
#[label]
pub span: Span,
pub function: String,
pub missing_target_features: DiagnosticArgValue,
pub missing_target_features: DiagArgValue,
pub missing_target_features_count: usize,
#[note]
pub note: Option<()>,
pub build_target_features: DiagnosticArgValue,
pub build_target_features: DiagArgValue,
pub build_target_features_count: usize,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
@ -379,11 +379,11 @@ pub struct CallToFunctionWithRequiresUnsafe {
#[label]
pub span: Span,
pub function: String,
pub missing_target_features: DiagnosticArgValue,
pub missing_target_features: DiagArgValue,
pub missing_target_features_count: usize,
#[note]
pub note: Option<()>,
pub build_target_features: DiagnosticArgValue,
pub build_target_features: DiagArgValue,
pub build_target_features_count: usize,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
@ -397,11 +397,11 @@ pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
#[label]
pub span: Span,
pub function: String,
pub missing_target_features: DiagnosticArgValue,
pub missing_target_features: DiagArgValue,
pub missing_target_features_count: usize,
#[note]
pub note: Option<()>,
pub build_target_features: DiagnosticArgValue,
pub build_target_features: DiagArgValue,
pub build_target_features_count: usize,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,

View File

@ -42,7 +42,7 @@ pub(crate) macro throw_machine_stop_str($($tt:tt)*) {{
fn add_args(
self: Box<Self>,
_: &mut dyn FnMut(rustc_errors::DiagnosticArgName, rustc_errors::DiagnosticArgValue),
_: &mut dyn FnMut(rustc_errors::DiagArgName, rustc_errors::DiagArgValue),
) {}
}
throw_machine_stop!(Zst)

View File

@ -1,7 +1,7 @@
use std::borrow::Cow;
use rustc_errors::{
codes::*, Applicability, DecorateLint, Diag, DiagCtxt, DiagnosticArgValue, DiagnosticMessage,
codes::*, Applicability, DecorateLint, Diag, DiagArgValue, DiagCtxt, DiagnosticMessage,
EmissionGuarantee, IntoDiagnostic, Level,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
@ -127,7 +127,7 @@ impl RequiresUnsafeDetail {
diag.help(fluent::mir_transform_target_feature_call_help);
diag.arg(
"missing_target_features",
DiagnosticArgValue::StrListSepByAnd(
DiagArgValue::StrListSepByAnd(
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
),
);
@ -136,7 +136,7 @@ impl RequiresUnsafeDetail {
diag.note(fluent::mir_transform_target_feature_call_note);
diag.arg(
"build_target_features",
DiagnosticArgValue::StrListSepByAnd(
DiagArgValue::StrListSepByAnd(
build_enabled
.iter()
.map(|feature| Cow::from(feature.to_string()))

View File

@ -80,7 +80,7 @@ pub(crate) enum ProcMacroKind {
}
impl IntoDiagnosticArg for ProcMacroKind {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
match self {
ProcMacroKind::Attribute => "attribute proc macro",
ProcMacroKind::Derive => "derive proc macro",

View File

@ -17,7 +17,7 @@ use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor};
use rustc_ast::*;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_errors::{
codes::*, struct_span_code_err, Applicability, DiagnosticArgValue, IntoDiagnosticArg, StashKey,
codes::*, struct_span_code_err, Applicability, DiagArgValue, IntoDiagnosticArg, StashKey,
};
use rustc_hir::def::Namespace::{self, *};
use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
@ -90,8 +90,8 @@ impl PatternSource {
}
impl IntoDiagnosticArg for PatternSource {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(self.descr()))
fn into_diagnostic_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(self.descr()))
}
}

View File

@ -11,7 +11,7 @@ use crate::{EarlyDiagCtxt, Session};
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
use rustc_errors::emitter::HumanReadableErrorType;
use rustc_errors::{ColorConfig, DiagCtxtFlags, DiagnosticArgValue, IntoDiagnosticArg};
use rustc_errors::{ColorConfig, DiagArgValue, DiagCtxtFlags, IntoDiagnosticArg};
use rustc_feature::UnstableFeatures;
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
use rustc_span::source_map::FilePathMapping;
@ -3099,7 +3099,7 @@ impl fmt::Display for CrateType {
}
impl IntoDiagnosticArg for CrateType {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}

View File

@ -111,7 +111,7 @@ impl Mul<usize> for Limit {
}
impl rustc_errors::IntoDiagnosticArg for Limit {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue {
self.to_string().into_diagnostic_arg()
}
}

View File

@ -100,7 +100,7 @@ impl MachineStopType for TerminationInfo {
}
fn add_args(
self: Box<Self>,
_: &mut dyn FnMut(std::borrow::Cow<'static, str>, rustc_errors::DiagnosticArgValue),
_: &mut dyn FnMut(std::borrow::Cow<'static, str>, rustc_errors::DiagArgValue),
) {
}
}