1
Fork 0

Remove the lifetime from DiagnosticArgName.

Because it's always 'static.
This commit is contained in:
Nicholas Nethercote 2024-01-30 16:04:03 +11:00
parent 06aa381adb
commit f0426b77fc
2 changed files with 5 additions and 9 deletions

View file

@ -1000,7 +1000,7 @@ pub struct CguMessage;
struct Diagnostic { struct Diagnostic {
msgs: Vec<(DiagnosticMessage, Style)>, msgs: Vec<(DiagnosticMessage, Style)>,
args: FxHashMap<DiagnosticArgName<'static>, DiagnosticArgValue>, args: FxHashMap<DiagnosticArgName, DiagnosticArgValue>,
code: Option<ErrCode>, code: Option<ErrCode>,
lvl: Level, lvl: Level,
} }

View file

@ -23,11 +23,10 @@ pub struct SuggestionsDisabled;
/// Simplified version of `FluentArg` that can implement `Encodable` and `Decodable`. Collection of /// Simplified version of `FluentArg` that can implement `Encodable` and `Decodable`. Collection of
/// `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, &'iter DiagnosticArgValue);
(&'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 = Cow<'static, 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.
@ -103,7 +102,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>, args: FxHashMap<DiagnosticArgName, 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
@ -923,10 +922,7 @@ impl Diagnostic {
self self
} }
pub fn replace_args( pub fn replace_args(&mut self, args: FxHashMap<DiagnosticArgName, DiagnosticArgValue>) {
&mut self,
args: FxHashMap<DiagnosticArgName<'static>, DiagnosticArgValue>,
) {
self.args = args; self.args = args;
} }