Remove the lifetime from DiagnosticArgValue.

Because it's almost always static.

This makes `impl IntoDiagnosticArg for DiagnosticArgValue` trivial,
which is nice.

There are a few diagnostics constructed in
`compiler/rustc_mir_build/src/check_unsafety.rs` and
`compiler/rustc_mir_transform/src/errors.rs` that now need symbols
converted to `String` with `to_string` instead of `&str` with `as_str`,
but that' no big deal, and worth it for the simplifications elsewhere.
This commit is contained in:
Nicholas Nethercote 2024-01-30 15:27:16 +11:00
parent fb4bca04fa
commit 5350edb9e8
38 changed files with 113 additions and 116 deletions

View File

@ -188,7 +188,7 @@ impl Display for RegionName {
} }
impl rustc_errors::IntoDiagnosticArg for RegionName { impl rustc_errors::IntoDiagnosticArg for RegionName {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }

View File

@ -35,7 +35,7 @@ pub(crate) enum PossibleFeature<'a> {
struct ExitCode(Option<i32>); struct ExitCode(Option<i32>);
impl IntoDiagnosticArg for ExitCode { impl IntoDiagnosticArg for ExitCode {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
let ExitCode(exit_code) = self; let ExitCode(exit_code) = self;
match exit_code { match exit_code {
Some(t) => t.into_diagnostic_arg(), Some(t) => t.into_diagnostic_arg(),

View File

@ -206,7 +206,7 @@ impl fmt::Display for CguReuse {
} }
impl IntoDiagnosticArg for CguReuse { impl IntoDiagnosticArg for CguReuse {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.to_string())) DiagnosticArgValue::Str(Cow::Owned(self.to_string()))
} }
} }

View File

@ -999,7 +999,7 @@ type DiagnosticArgName<'source> = Cow<'source, str>;
struct Diagnostic { struct Diagnostic {
msgs: Vec<(DiagnosticMessage, Style)>, msgs: Vec<(DiagnosticMessage, Style)>,
args: FxHashMap<DiagnosticArgName<'static>, rustc_errors::DiagnosticArgValue<'static>>, args: FxHashMap<DiagnosticArgName<'static>, rustc_errors::DiagnosticArgValue>,
code: Option<ErrCode>, code: Option<ErrCode>,
lvl: Level, lvl: Level,
} }
@ -1811,7 +1811,7 @@ impl Translate for SharedEmitter {
impl Emitter for SharedEmitter { impl Emitter for SharedEmitter {
fn emit_diagnostic(&mut self, diag: &rustc_errors::Diagnostic) { fn emit_diagnostic(&mut self, diag: &rustc_errors::Diagnostic) {
let args: FxHashMap<Cow<'_, str>, rustc_errors::DiagnosticArgValue<'_>> = let args: FxHashMap<Cow<'_, str>, rustc_errors::DiagnosticArgValue> =
diag.args().map(|(name, arg)| (name.clone(), arg.clone())).collect(); diag.args().map(|(name, arg)| (name.clone(), arg.clone())).collect();
drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic { drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
msgs: diag.messages.clone(), msgs: diag.messages.clone(),

View File

@ -147,7 +147,7 @@ impl<'a> CopyPath<'a> {
struct DebugArgPath<'a>(pub &'a Path); struct DebugArgPath<'a>(pub &'a Path);
impl IntoDiagnosticArg for DebugArgPath<'_> { impl IntoDiagnosticArg for DebugArgPath<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(format!("{:?}", self.0))) DiagnosticArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
} }
} }
@ -974,7 +974,7 @@ pub enum ExpectedPointerMutability {
} }
impl IntoDiagnosticArg for ExpectedPointerMutability { impl IntoDiagnosticArg for ExpectedPointerMutability {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
match self { match self {
ExpectedPointerMutability::Mut => DiagnosticArgValue::Str(Cow::Borrowed("*mut")), ExpectedPointerMutability::Mut => DiagnosticArgValue::Str(Cow::Borrowed("*mut")),
ExpectedPointerMutability::Not => DiagnosticArgValue::Str(Cow::Borrowed("*_")), ExpectedPointerMutability::Not => DiagnosticArgValue::Str(Cow::Borrowed("*_")),

View File

@ -34,7 +34,7 @@ impl MachineStopType for ConstEvalErrKind {
} }
fn add_args( fn add_args(
self: Box<Self>, self: Box<Self>,
adder: &mut dyn FnMut(std::borrow::Cow<'static, str>, DiagnosticArgValue<'static>), adder: &mut dyn FnMut(std::borrow::Cow<'static, str>, DiagnosticArgValue),
) { ) {
use ConstEvalErrKind::*; use ConstEvalErrKind::*;
match *self { match *self {

View File

@ -906,7 +906,7 @@ impl ReportErrorExt for ResourceExhaustionInfo {
} }
impl rustc_errors::IntoDiagnosticArg for InternKind { impl rustc_errors::IntoDiagnosticArg for InternKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(match self { DiagnosticArgValue::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",

View File

@ -24,7 +24,7 @@ pub struct SuggestionsDisabled;
/// `DiagnosticArg` are converted to `FluentArgs` (consuming the collection) at the start of /// `DiagnosticArg` are converted to `FluentArgs` (consuming the collection) at the start of
/// diagnostic emission. /// diagnostic emission.
pub type DiagnosticArg<'iter, 'source> = pub type DiagnosticArg<'iter, 'source> =
(&'iter DiagnosticArgName<'source>, &'iter DiagnosticArgValue<'source>); (&'iter DiagnosticArgName<'source>, &'iter DiagnosticArgValue);
/// Name of a diagnostic argument. /// Name of a diagnostic argument.
pub type DiagnosticArgName<'source> = Cow<'source, str>; pub type DiagnosticArgName<'source> = Cow<'source, str>;
@ -32,10 +32,10 @@ pub type DiagnosticArgName<'source> = Cow<'source, str>;
/// Simplified version of `FluentValue` that can implement `Encodable` and `Decodable`. Converted /// Simplified version of `FluentValue` that can implement `Encodable` and `Decodable`. Converted
/// to a `FluentValue` by the emitter to be used in diagnostic translation. /// to a `FluentValue` by the emitter to be used in diagnostic translation.
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
pub enum DiagnosticArgValue<'source> { pub enum DiagnosticArgValue {
Str(Cow<'source, str>), Str(Cow<'static, str>),
Number(i128), Number(i128),
StrListSepByAnd(Vec<Cow<'source, str>>), StrListSepByAnd(Vec<Cow<'static, str>>),
} }
/// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic` /// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic`
@ -43,23 +43,17 @@ pub enum DiagnosticArgValue<'source> {
/// being converted rather than on `DiagnosticArgValue`, which enables types from other `rustc_*` /// being converted rather than on `DiagnosticArgValue`, which enables types from other `rustc_*`
/// crates to implement this. /// crates to implement this.
pub trait IntoDiagnosticArg { pub trait IntoDiagnosticArg {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static>; fn into_diagnostic_arg(self) -> DiagnosticArgValue;
} }
impl<'source> IntoDiagnosticArg for DiagnosticArgValue<'source> { impl IntoDiagnosticArg for DiagnosticArgValue {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
match self { self
DiagnosticArgValue::Str(s) => DiagnosticArgValue::Str(Cow::Owned(s.into_owned())),
DiagnosticArgValue::Number(n) => DiagnosticArgValue::Number(n),
DiagnosticArgValue::StrListSepByAnd(l) => DiagnosticArgValue::StrListSepByAnd(
l.into_iter().map(|s| Cow::Owned(s.into_owned())).collect(),
),
}
} }
} }
impl<'source> Into<FluentValue<'source>> for DiagnosticArgValue<'source> { impl Into<FluentValue<'static>> for DiagnosticArgValue {
fn into(self) -> FluentValue<'source> { fn into(self) -> FluentValue<'static> {
match self { match self {
DiagnosticArgValue::Str(s) => From::from(s), DiagnosticArgValue::Str(s) => From::from(s),
DiagnosticArgValue::Number(n) => From::from(n), DiagnosticArgValue::Number(n) => From::from(n),
@ -109,7 +103,7 @@ pub struct Diagnostic {
pub span: MultiSpan, pub span: MultiSpan,
pub children: Vec<SubDiagnostic>, pub children: Vec<SubDiagnostic>,
pub suggestions: Result<Vec<CodeSuggestion>, SuggestionsDisabled>, pub suggestions: Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
args: FxHashMap<DiagnosticArgName<'static>, DiagnosticArgValue<'static>>, args: FxHashMap<DiagnosticArgName<'static>, DiagnosticArgValue>,
/// This is not used for highlighting or rendering any error message. Rather, it can be used /// 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 /// as a sort key to sort a buffer of diagnostics. By default, it is the primary span of
@ -931,7 +925,7 @@ impl Diagnostic {
pub fn replace_args( pub fn replace_args(
&mut self, &mut self,
args: FxHashMap<DiagnosticArgName<'static>, DiagnosticArgValue<'static>>, args: FxHashMap<DiagnosticArgName<'static>, DiagnosticArgValue>,
) { ) {
self.args = args; self.args = args;
} }
@ -990,7 +984,7 @@ impl Diagnostic {
) -> ( ) -> (
&Level, &Level,
&[(DiagnosticMessage, Style)], &[(DiagnosticMessage, Style)],
Vec<(&Cow<'static, str>, &DiagnosticArgValue<'static>)>, Vec<(&Cow<'static, str>, &DiagnosticArgValue)>,
&Option<ErrCode>, &Option<ErrCode>,
&Option<IsLint>, &Option<IsLint>,
&MultiSpan, &MultiSpan,

View File

@ -23,7 +23,7 @@ use std::process::ExitStatus;
pub struct DiagnosticArgFromDisplay<'a>(pub &'a dyn fmt::Display); pub struct DiagnosticArgFromDisplay<'a>(pub &'a dyn fmt::Display);
impl IntoDiagnosticArg for DiagnosticArgFromDisplay<'_> { impl IntoDiagnosticArg for DiagnosticArgFromDisplay<'_> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.0.to_string().into_diagnostic_arg() 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 { impl<'a, T: Clone + IntoDiagnosticArg> IntoDiagnosticArg for &'a T {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.clone().into_diagnostic_arg() self.clone().into_diagnostic_arg()
} }
} }
@ -50,7 +50,7 @@ macro_rules! into_diagnostic_arg_using_display {
($( $ty:ty ),+ $(,)?) => { ($( $ty:ty ),+ $(,)?) => {
$( $(
impl IntoDiagnosticArg for $ty { impl IntoDiagnosticArg for $ty {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }
@ -62,7 +62,7 @@ macro_rules! into_diagnostic_arg_for_number {
($( $ty:ty ),+ $(,)?) => { ($( $ty:ty ),+ $(,)?) => {
$( $(
impl IntoDiagnosticArg for $ty { impl IntoDiagnosticArg for $ty {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
// HACK: `FluentNumber` the underline backing struct represent // HACK: `FluentNumber` the underline backing struct represent
// numbers using a f64 which can't represent all the i128 numbers // numbers using a f64 which can't represent all the i128 numbers
// So in order to be able to use fluent selectors and still // So in order to be able to use fluent selectors and still
@ -99,7 +99,7 @@ into_diagnostic_arg_using_display!(
into_diagnostic_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize); into_diagnostic_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize);
impl IntoDiagnosticArg for bool { impl IntoDiagnosticArg for bool {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
if self { if self {
DiagnosticArgValue::Str(Cow::Borrowed("true")) DiagnosticArgValue::Str(Cow::Borrowed("true"))
} else { } else {
@ -109,13 +109,13 @@ impl IntoDiagnosticArg for bool {
} }
impl IntoDiagnosticArg for char { impl IntoDiagnosticArg for char {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}"))) DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}")))
} }
} }
impl IntoDiagnosticArg for Vec<char> { impl IntoDiagnosticArg for Vec<char> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::StrListSepByAnd( DiagnosticArgValue::StrListSepByAnd(
self.into_iter().map(|c| Cow::Owned(format!("{c:?}"))).collect(), self.into_iter().map(|c| Cow::Owned(format!("{c:?}"))).collect(),
) )
@ -123,49 +123,49 @@ impl IntoDiagnosticArg for Vec<char> {
} }
impl IntoDiagnosticArg for Symbol { impl IntoDiagnosticArg for Symbol {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.to_ident_string().into_diagnostic_arg() self.to_ident_string().into_diagnostic_arg()
} }
} }
impl<'a> IntoDiagnosticArg for &'a str { impl<'a> IntoDiagnosticArg for &'a str {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }
impl IntoDiagnosticArg for String { impl IntoDiagnosticArg for String {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self)) DiagnosticArgValue::Str(Cow::Owned(self))
} }
} }
impl<'a> IntoDiagnosticArg for Cow<'a, str> { impl<'a> IntoDiagnosticArg for Cow<'a, str> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.into_owned())) DiagnosticArgValue::Str(Cow::Owned(self.into_owned()))
} }
} }
impl<'a> IntoDiagnosticArg for &'a Path { impl<'a> IntoDiagnosticArg for &'a Path {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.display().to_string())) DiagnosticArgValue::Str(Cow::Owned(self.display().to_string()))
} }
} }
impl IntoDiagnosticArg for PathBuf { impl IntoDiagnosticArg for PathBuf {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.display().to_string())) DiagnosticArgValue::Str(Cow::Owned(self.display().to_string()))
} }
} }
impl IntoDiagnosticArg for PanicStrategy { impl IntoDiagnosticArg for PanicStrategy {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.desc().to_string())) DiagnosticArgValue::Str(Cow::Owned(self.desc().to_string()))
} }
} }
impl IntoDiagnosticArg for hir::ConstContext { impl IntoDiagnosticArg for hir::ConstContext {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(match self { DiagnosticArgValue::Str(Cow::Borrowed(match self {
hir::ConstContext::ConstFn => "const_fn", hir::ConstContext::ConstFn => "const_fn",
hir::ConstContext::Static(_) => "static", hir::ConstContext::Static(_) => "static",
@ -175,49 +175,49 @@ impl IntoDiagnosticArg for hir::ConstContext {
} }
impl IntoDiagnosticArg for ast::Expr { impl IntoDiagnosticArg for ast::Expr {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(pprust::expr_to_string(&self))) DiagnosticArgValue::Str(Cow::Owned(pprust::expr_to_string(&self)))
} }
} }
impl IntoDiagnosticArg for ast::Path { impl IntoDiagnosticArg for ast::Path {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(pprust::path_to_string(&self))) DiagnosticArgValue::Str(Cow::Owned(pprust::path_to_string(&self)))
} }
} }
impl IntoDiagnosticArg for ast::token::Token { impl IntoDiagnosticArg for ast::token::Token {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(pprust::token_to_string(&self)) DiagnosticArgValue::Str(pprust::token_to_string(&self))
} }
} }
impl IntoDiagnosticArg for ast::token::TokenKind { impl IntoDiagnosticArg for ast::token::TokenKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(pprust::token_kind_to_string(&self)) DiagnosticArgValue::Str(pprust::token_kind_to_string(&self))
} }
} }
impl IntoDiagnosticArg for type_ir::FloatTy { impl IntoDiagnosticArg for type_ir::FloatTy {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(self.name_str())) DiagnosticArgValue::Str(Cow::Borrowed(self.name_str()))
} }
} }
impl IntoDiagnosticArg for std::ffi::CString { impl IntoDiagnosticArg for std::ffi::CString {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned())) DiagnosticArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
} }
} }
impl IntoDiagnosticArg for rustc_data_structures::small_c_str::SmallCStr { impl IntoDiagnosticArg for rustc_data_structures::small_c_str::SmallCStr {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned())) DiagnosticArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
} }
} }
impl IntoDiagnosticArg for ast::Visibility { impl IntoDiagnosticArg for ast::Visibility {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
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();
DiagnosticArgValue::Str(Cow::Owned(s)) DiagnosticArgValue::Str(Cow::Owned(s))
@ -225,7 +225,7 @@ impl IntoDiagnosticArg for ast::Visibility {
} }
impl IntoDiagnosticArg for rustc_lint_defs::Level { impl IntoDiagnosticArg for rustc_lint_defs::Level {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(self.to_cmd_flag())) DiagnosticArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
} }
} }
@ -240,7 +240,7 @@ impl From<Vec<Symbol>> for DiagnosticSymbolList {
} }
impl IntoDiagnosticArg for DiagnosticSymbolList { impl IntoDiagnosticArg for DiagnosticSymbolList {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::StrListSepByAnd( DiagnosticArgValue::StrListSepByAnd(
self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(), self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(),
) )
@ -248,7 +248,7 @@ impl IntoDiagnosticArg for DiagnosticSymbolList {
} }
impl<Id> IntoDiagnosticArg for hir::def::Res<Id> { impl<Id> IntoDiagnosticArg for hir::def::Res<Id> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(self.descr())) DiagnosticArgValue::Str(Cow::Borrowed(self.descr()))
} }
} }
@ -334,13 +334,13 @@ pub struct DelayedAtWithoutNewline {
} }
impl IntoDiagnosticArg for DiagnosticLocation { impl IntoDiagnosticArg for DiagnosticLocation {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::from(self.to_string())) DiagnosticArgValue::Str(Cow::from(self.to_string()))
} }
} }
impl IntoDiagnosticArg for Backtrace { impl IntoDiagnosticArg for Backtrace {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::from(self.to_string())) DiagnosticArgValue::Str(Cow::from(self.to_string()))
} }
} }
@ -353,7 +353,7 @@ pub struct InvalidFlushedDelayedDiagnosticLevel {
pub level: Level, pub level: Level,
} }
impl IntoDiagnosticArg for Level { impl IntoDiagnosticArg for Level {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::from(self.to_string())) DiagnosticArgValue::Str(Cow::from(self.to_string()))
} }
} }
@ -368,7 +368,7 @@ pub struct IndicateAnonymousLifetime {
} }
impl IntoDiagnosticArg for type_ir::ClosureKind { impl IntoDiagnosticArg for type_ir::ClosureKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(self.as_str().into()) DiagnosticArgValue::Str(self.as_str().into())
} }
} }

View File

@ -12,9 +12,9 @@ use std::error::Report;
/// ///
/// Typically performed once for each diagnostic at the start of `emit_diagnostic` and then /// Typically performed once for each diagnostic at the start of `emit_diagnostic` and then
/// passed around as a reference thereafter. /// passed around as a reference thereafter.
pub fn to_fluent_args<'iter, 'arg: 'iter>( pub fn to_fluent_args<'iter>(
iter: impl Iterator<Item = DiagnosticArg<'iter, 'arg>>, iter: impl Iterator<Item = DiagnosticArg<'iter, 'static>>,
) -> FluentArgs<'arg> { ) -> FluentArgs<'static> {
let mut args = if let Some(size) = iter.size_hint().1 { let mut args = if let Some(size) = iter.size_hint().1 {
FluentArgs::with_capacity(size) FluentArgs::with_capacity(size)
} else { } else {

View File

@ -43,7 +43,7 @@ pub enum ReturnLikeStatementKind {
} }
impl IntoDiagnosticArg for ReturnLikeStatementKind { impl IntoDiagnosticArg for ReturnLikeStatementKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
let kind = match self { let kind = match self {
Self::Return => "return", Self::Return => "return",
Self::Become => "become", Self::Become => "become",

View File

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

View File

@ -108,7 +108,7 @@ pub enum SuffixKind {
} }
impl IntoDiagnosticArg for PrefixKind { impl IntoDiagnosticArg for PrefixKind {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
let kind = match self { let kind = match self {
Self::Empty => "empty", Self::Empty => "empty",
Self::RefValidFor => "ref_valid_for", Self::RefValidFor => "ref_valid_for",
@ -130,7 +130,7 @@ impl IntoDiagnosticArg for PrefixKind {
} }
impl IntoDiagnosticArg for SuffixKind { impl IntoDiagnosticArg for SuffixKind {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
let kind = match self { let kind = match self {
Self::Empty => "empty", Self::Empty => "empty",
Self::Continues => "continues", Self::Continues => "continues",

View File

@ -2914,7 +2914,7 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
pub struct ObligationCauseAsDiagArg<'tcx>(pub ObligationCause<'tcx>); pub struct ObligationCauseAsDiagArg<'tcx>(pub ObligationCause<'tcx>);
impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> { impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
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",

View File

@ -134,7 +134,7 @@ impl InferenceDiagnosticsParentData {
} }
impl IntoDiagnosticArg for UnderspecifiedArgKind { impl IntoDiagnosticArg for UnderspecifiedArgKind {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
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",

View File

@ -30,7 +30,7 @@ impl<'tcx, T> IntoDiagnosticArg 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::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
rustc_errors::DiagnosticArgValue::Str(self.to_string().into()) rustc_errors::DiagnosticArgValue::Str(self.to_string().into())
} }
} }

View File

@ -291,7 +291,7 @@ impl fmt::Display for CrateFlavor {
} }
impl IntoDiagnosticArg for CrateFlavor { impl IntoDiagnosticArg for CrateFlavor {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
match self { match self {
CrateFlavor::Rlib => DiagnosticArgValue::Str(Cow::Borrowed("rlib")), CrateFlavor::Rlib => DiagnosticArgValue::Str(Cow::Borrowed("rlib")),
CrateFlavor::Rmeta => DiagnosticArgValue::Str(Cow::Borrowed("rmeta")), CrateFlavor::Rmeta => DiagnosticArgValue::Str(Cow::Borrowed("rmeta")),

View File

@ -95,17 +95,14 @@ pub(super) struct ConstNotUsedTraitAlias {
pub struct CustomSubdiagnostic<'a> { pub struct CustomSubdiagnostic<'a> {
pub msg: fn() -> DiagnosticMessage, pub msg: fn() -> DiagnosticMessage,
pub add_args: pub add_args: Box<dyn FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue)) + 'a>,
Box<dyn FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue<'static>)) + 'a>,
} }
impl<'a> CustomSubdiagnostic<'a> { impl<'a> CustomSubdiagnostic<'a> {
pub fn label(x: fn() -> DiagnosticMessage) -> Self { pub fn label(x: fn() -> DiagnosticMessage) -> Self {
Self::label_and_then(x, |_| {}) Self::label_and_then(x, |_| {})
} }
pub fn label_and_then< pub fn label_and_then<F: FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue)) + 'a>(
F: FnOnce(&mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue<'static>)) + 'a,
>(
msg: fn() -> DiagnosticMessage, msg: fn() -> DiagnosticMessage,
f: F, f: F,
) -> Self { ) -> Self {

View File

@ -233,7 +233,7 @@ pub enum InvalidMetaKind {
} }
impl IntoDiagnosticArg for InvalidMetaKind { impl IntoDiagnosticArg for InvalidMetaKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(match self { DiagnosticArgValue::Str(Cow::Borrowed(match self {
InvalidMetaKind::SliceTooBig => "slice_too_big", InvalidMetaKind::SliceTooBig => "slice_too_big",
InvalidMetaKind::TooBig => "too_big", InvalidMetaKind::TooBig => "too_big",
@ -267,7 +267,7 @@ pub struct Misalignment {
macro_rules! impl_into_diagnostic_arg_through_debug { macro_rules! impl_into_diagnostic_arg_through_debug {
($($ty:ty),*$(,)?) => {$( ($($ty:ty),*$(,)?) => {$(
impl IntoDiagnosticArg for $ty { impl IntoDiagnosticArg for $ty {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}"))) DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}")))
} }
} }
@ -367,7 +367,7 @@ pub enum PointerKind {
} }
impl IntoDiagnosticArg for PointerKind { impl IntoDiagnosticArg for PointerKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str( DiagnosticArgValue::Str(
match self { match self {
Self::Ref => "ref", Self::Ref => "ref",
@ -485,10 +485,7 @@ pub trait MachineStopType: Any + fmt::Debug + Send {
fn diagnostic_message(&self) -> DiagnosticMessage; fn diagnostic_message(&self) -> DiagnosticMessage;
/// Add diagnostic arguments by passing name and value pairs to `adder`, which are passed to /// Add diagnostic arguments by passing name and value pairs to `adder`, which are passed to
/// fluent for formatting the translated diagnostic message. /// fluent for formatting the translated diagnostic message.
fn add_args( fn add_args(self: Box<Self>, adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue));
self: Box<Self>,
adder: &mut dyn FnMut(Cow<'static, str>, DiagnosticArgValue<'static>),
);
} }
impl dyn MachineStopType { impl dyn MachineStopType {

View File

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

View File

@ -674,7 +674,7 @@ impl<'tcx> Pat<'tcx> {
} }
impl<'tcx> IntoDiagnosticArg for Pat<'tcx> { impl<'tcx> IntoDiagnosticArg for Pat<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
format!("{self}").into_diagnostic_arg() format!("{self}").into_diagnostic_arg()
} }
} }

View File

@ -117,7 +117,7 @@ impl std::fmt::Debug for ConstInt {
impl IntoDiagnosticArg for ConstInt { impl IntoDiagnosticArg 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) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(format!("{self:?}").into()) DiagnosticArgValue::Str(format!("{self:?}").into())
} }
} }

View File

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

View File

@ -20,7 +20,7 @@ use rustc_span::{BytePos, Span};
use rustc_type_ir::TyKind::*; use rustc_type_ir::TyKind::*;
impl<'tcx> IntoDiagnosticArg for Ty<'tcx> { impl<'tcx> IntoDiagnosticArg for Ty<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }

View File

@ -56,7 +56,7 @@ unsafe impl<'tcx> Sync for GenericArg<'tcx> where
} }
impl<'tcx> IntoDiagnosticArg for GenericArg<'tcx> { impl<'tcx> IntoDiagnosticArg for GenericArg<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }

View File

@ -269,7 +269,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
} }
impl<'tcx> IntoDiagnosticArg for LayoutError<'tcx> { impl<'tcx> IntoDiagnosticArg for LayoutError<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }

View File

@ -583,13 +583,13 @@ impl<'tcx> Predicate<'tcx> {
} }
impl rustc_errors::IntoDiagnosticArg for Predicate<'_> { impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string())) rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
} }
} }
impl rustc_errors::IntoDiagnosticArg for Clause<'_> { impl rustc_errors::IntoDiagnosticArg for Clause<'_> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string())) rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
} }
} }

View File

@ -2632,7 +2632,7 @@ where
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::IntoDiagnosticArg for TraitRefPrintOnlyTraitPath<'tcx> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }
@ -2649,7 +2649,7 @@ impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitPath<'tcx> {
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::IntoDiagnosticArg for TraitRefPrintSugared<'tcx> {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }

View File

@ -862,7 +862,7 @@ impl<'tcx> PolyTraitRef<'tcx> {
} }
impl<'tcx> IntoDiagnosticArg for TraitRef<'tcx> { impl<'tcx> IntoDiagnosticArg for TraitRef<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }
@ -908,7 +908,7 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
} }
impl<'tcx> IntoDiagnosticArg for ExistentialTraitRef<'tcx> { impl<'tcx> IntoDiagnosticArg for ExistentialTraitRef<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }
@ -1149,7 +1149,7 @@ impl<'tcx, T> IntoDiagnosticArg for Binder<'tcx, T>
where where
T: IntoDiagnosticArg, T: IntoDiagnosticArg,
{ {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.value.into_diagnostic_arg() self.value.into_diagnostic_arg()
} }
} }
@ -1359,7 +1359,7 @@ impl<'tcx> FnSig<'tcx> {
} }
impl<'tcx> IntoDiagnosticArg for FnSig<'tcx> { impl<'tcx> IntoDiagnosticArg for FnSig<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }

View File

@ -698,12 +698,15 @@ impl UnsafeOpKind {
span, span,
function: &with_no_trimmed_paths!(tcx.def_path_str(*function)), function: &with_no_trimmed_paths!(tcx.def_path_str(*function)),
missing_target_features: DiagnosticArgValue::StrListSepByAnd( missing_target_features: DiagnosticArgValue::StrListSepByAnd(
missing.iter().map(|feature| Cow::from(feature.as_str())).collect(), missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
), ),
missing_target_features_count: missing.len(), missing_target_features_count: missing.len(),
note: if build_enabled.is_empty() { None } else { Some(()) }, note: if build_enabled.is_empty() { None } else { Some(()) },
build_target_features: DiagnosticArgValue::StrListSepByAnd( build_target_features: DiagnosticArgValue::StrListSepByAnd(
build_enabled.iter().map(|feature| Cow::from(feature.as_str())).collect(), build_enabled
.iter()
.map(|feature| Cow::from(feature.to_string()))
.collect(),
), ),
build_target_features_count: build_enabled.len(), build_target_features_count: build_enabled.len(),
unsafe_not_inherited_note, unsafe_not_inherited_note,
@ -860,12 +863,15 @@ impl UnsafeOpKind {
dcx.emit_err(CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed { dcx.emit_err(CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span, span,
missing_target_features: DiagnosticArgValue::StrListSepByAnd( missing_target_features: DiagnosticArgValue::StrListSepByAnd(
missing.iter().map(|feature| Cow::from(feature.as_str())).collect(), missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
), ),
missing_target_features_count: missing.len(), missing_target_features_count: missing.len(),
note: if build_enabled.is_empty() { None } else { Some(()) }, note: if build_enabled.is_empty() { None } else { Some(()) },
build_target_features: DiagnosticArgValue::StrListSepByAnd( build_target_features: DiagnosticArgValue::StrListSepByAnd(
build_enabled.iter().map(|feature| Cow::from(feature.as_str())).collect(), build_enabled
.iter()
.map(|feature| Cow::from(feature.to_string()))
.collect(),
), ),
build_target_features_count: build_enabled.len(), build_target_features_count: build_enabled.len(),
unsafe_not_inherited_note, unsafe_not_inherited_note,
@ -876,12 +882,15 @@ impl UnsafeOpKind {
dcx.emit_err(CallToFunctionWithRequiresUnsafe { dcx.emit_err(CallToFunctionWithRequiresUnsafe {
span, span,
missing_target_features: DiagnosticArgValue::StrListSepByAnd( missing_target_features: DiagnosticArgValue::StrListSepByAnd(
missing.iter().map(|feature| Cow::from(feature.as_str())).collect(), missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
), ),
missing_target_features_count: missing.len(), missing_target_features_count: missing.len(),
note: if build_enabled.is_empty() { None } else { Some(()) }, note: if build_enabled.is_empty() { None } else { Some(()) },
build_target_features: DiagnosticArgValue::StrListSepByAnd( build_target_features: DiagnosticArgValue::StrListSepByAnd(
build_enabled.iter().map(|feature| Cow::from(feature.as_str())).collect(), build_enabled
.iter()
.map(|feature| Cow::from(feature.to_string()))
.collect(),
), ),
build_target_features_count: build_enabled.len(), build_target_features_count: build_enabled.len(),
unsafe_not_inherited_note, unsafe_not_inherited_note,

View File

@ -127,11 +127,11 @@ pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe<'a> {
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: &'a str,
pub missing_target_features: DiagnosticArgValue<'a>, pub missing_target_features: DiagnosticArgValue,
pub missing_target_features_count: usize, pub missing_target_features_count: usize,
#[note] #[note]
pub note: Option<()>, pub note: Option<()>,
pub build_target_features: DiagnosticArgValue<'a>, pub build_target_features: DiagnosticArgValue,
pub build_target_features_count: usize, pub build_target_features_count: usize,
#[subdiagnostic] #[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>, pub unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>,
@ -379,11 +379,11 @@ pub struct CallToFunctionWithRequiresUnsafe<'a> {
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: &'a str,
pub missing_target_features: DiagnosticArgValue<'a>, pub missing_target_features: DiagnosticArgValue,
pub missing_target_features_count: usize, pub missing_target_features_count: usize,
#[note] #[note]
pub note: Option<()>, pub note: Option<()>,
pub build_target_features: DiagnosticArgValue<'a>, pub build_target_features: DiagnosticArgValue,
pub build_target_features_count: usize, pub build_target_features_count: usize,
#[subdiagnostic] #[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>, pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
@ -397,11 +397,11 @@ pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: &'a str,
pub missing_target_features: DiagnosticArgValue<'a>, pub missing_target_features: DiagnosticArgValue,
pub missing_target_features_count: usize, pub missing_target_features_count: usize,
#[note] #[note]
pub note: Option<()>, pub note: Option<()>,
pub build_target_features: DiagnosticArgValue<'a>, pub build_target_features: DiagnosticArgValue,
pub build_target_features_count: usize, pub build_target_features_count: usize,
#[subdiagnostic] #[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>, pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,

View File

@ -34,7 +34,7 @@ pub(crate) macro throw_machine_stop_str($($tt:tt)*) {{
fn add_args( fn add_args(
self: Box<Self>, self: Box<Self>,
_: &mut dyn FnMut(std::borrow::Cow<'static, str>, rustc_errors::DiagnosticArgValue<'static>), _: &mut dyn FnMut(std::borrow::Cow<'static, str>, rustc_errors::DiagnosticArgValue),
) {} ) {}
} }
throw_machine_stop!(Zst) throw_machine_stop!(Zst)

View File

@ -125,7 +125,7 @@ impl RequiresUnsafeDetail {
diag.arg( diag.arg(
"missing_target_features", "missing_target_features",
DiagnosticArgValue::StrListSepByAnd( DiagnosticArgValue::StrListSepByAnd(
missing.iter().map(|feature| Cow::from(feature.as_str())).collect(), missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
), ),
); );
diag.arg("missing_target_features_count", missing.len()); diag.arg("missing_target_features_count", missing.len());
@ -136,7 +136,7 @@ impl RequiresUnsafeDetail {
DiagnosticArgValue::StrListSepByAnd( DiagnosticArgValue::StrListSepByAnd(
build_enabled build_enabled
.iter() .iter()
.map(|feature| Cow::from(feature.as_str())) .map(|feature| Cow::from(feature.to_string()))
.collect(), .collect(),
), ),
); );

View File

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

View File

@ -90,7 +90,7 @@ impl PatternSource {
} }
impl IntoDiagnosticArg for PatternSource { impl IntoDiagnosticArg for PatternSource {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(Cow::Borrowed(self.descr())) DiagnosticArgValue::Str(Cow::Borrowed(self.descr()))
} }
} }

View File

@ -3092,7 +3092,7 @@ impl fmt::Display for CrateType {
} }
impl IntoDiagnosticArg for CrateType { impl IntoDiagnosticArg for CrateType {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
self.to_string().into_diagnostic_arg() self.to_string().into_diagnostic_arg()
} }
} }

View File

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

View File

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