@@ -23,43 +23,36 @@ pub struct SuggestionsDisabled;
2323/// Simplified version of `FluentArg` that can implement `Encodable` and `Decodable`. Collection of
2424/// `DiagnosticArg` are converted to `FluentArgs` (consuming the collection) at the start of
2525/// diagnostic emission.
26- pub type DiagnosticArg < ' iter , ' source > =
27- ( & ' iter DiagnosticArgName < ' source > , & ' iter DiagnosticArgValue < ' source > ) ;
26+ pub type DiagnosticArg < ' iter > = ( & ' iter DiagnosticArgName , & ' iter DiagnosticArgValue ) ;
2827
2928/// Name of a diagnostic argument.
30- pub type DiagnosticArgName < ' source > = Cow < ' source , str > ;
29+ pub type DiagnosticArgName = Cow < ' static , str > ;
3130
3231/// Simplified version of `FluentValue` that can implement `Encodable` and `Decodable`. Converted
3332/// to a `FluentValue` by the emitter to be used in diagnostic translation.
3433#[ derive( Clone , Debug , PartialEq , Eq , Hash , Encodable , Decodable ) ]
35- pub enum DiagnosticArgValue < ' source > {
36- Str ( Cow < ' source , str > ) ,
34+ pub enum DiagnosticArgValue {
35+ Str ( Cow < ' static , str > ) ,
3736 Number ( i128 ) ,
38- StrListSepByAnd ( Vec < Cow < ' source , str > > ) ,
37+ StrListSepByAnd ( Vec < Cow < ' static , str > > ) ,
3938}
4039
4140/// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic`
4241/// struct). Implemented as a custom trait rather than `From` so that it is implemented on the type
4342/// being converted rather than on `DiagnosticArgValue`, which enables types from other `rustc_*`
4443/// crates to implement this.
4544pub trait IntoDiagnosticArg {
46- fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > ;
45+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue ;
4746}
4847
49- impl < ' source > IntoDiagnosticArg for DiagnosticArgValue < ' source > {
50- fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
51- match self {
52- DiagnosticArgValue :: Str ( s) => DiagnosticArgValue :: Str ( Cow :: Owned ( s. into_owned ( ) ) ) ,
53- DiagnosticArgValue :: Number ( n) => DiagnosticArgValue :: Number ( n) ,
54- DiagnosticArgValue :: StrListSepByAnd ( l) => DiagnosticArgValue :: StrListSepByAnd (
55- l. into_iter ( ) . map ( |s| Cow :: Owned ( s. into_owned ( ) ) ) . collect ( ) ,
56- ) ,
57- }
48+ impl IntoDiagnosticArg for DiagnosticArgValue {
49+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue {
50+ self
5851 }
5952}
6053
61- impl < ' source > Into < FluentValue < ' source > > for DiagnosticArgValue < ' source > {
62- fn into ( self ) -> FluentValue < ' source > {
54+ impl Into < FluentValue < ' static > > for DiagnosticArgValue {
55+ fn into ( self ) -> FluentValue < ' static > {
6356 match self {
6457 DiagnosticArgValue :: Str ( s) => From :: from ( s) ,
6558 DiagnosticArgValue :: Number ( n) => From :: from ( n) ,
@@ -109,7 +102,7 @@ pub struct Diagnostic {
109102 pub span : MultiSpan ,
110103 pub children : Vec < SubDiagnostic > ,
111104 pub suggestions : Result < Vec < CodeSuggestion > , SuggestionsDisabled > ,
112- args : FxHashMap < DiagnosticArgName < ' static > , DiagnosticArgValue < ' static > > ,
105+ args : FxHashMap < DiagnosticArgName , DiagnosticArgValue > ,
113106
114107 /// This is not used for highlighting or rendering any error message. Rather, it can be used
115108 /// as a sort key to sort a buffer of diagnostics. By default, it is the primary span of
@@ -916,7 +909,7 @@ impl Diagnostic {
916909 // Exact iteration order of diagnostic arguments shouldn't make a difference to output because
917910 // they're only used in interpolation.
918911 #[ allow( rustc:: potential_query_instability) ]
919- pub fn args ( & self ) -> impl Iterator < Item = DiagnosticArg < ' _ , ' static > > {
912+ pub fn args ( & self ) -> impl Iterator < Item = DiagnosticArg < ' _ > > {
920913 self . args . iter ( )
921914 }
922915
@@ -929,10 +922,7 @@ impl Diagnostic {
929922 self
930923 }
931924
932- pub fn replace_args (
933- & mut self ,
934- args : FxHashMap < DiagnosticArgName < ' static > , DiagnosticArgValue < ' static > > ,
935- ) {
925+ pub fn replace_args ( & mut self , args : FxHashMap < DiagnosticArgName , DiagnosticArgValue > ) {
936926 self . args = args;
937927 }
938928
@@ -990,7 +980,7 @@ impl Diagnostic {
990980 ) -> (
991981 & Level ,
992982 & [ ( DiagnosticMessage , Style ) ] ,
993- Vec < ( & Cow < ' static , str > , & DiagnosticArgValue < ' static > ) > ,
983+ Vec < ( & Cow < ' static , str > , & DiagnosticArgValue ) > ,
994984 & Option < ErrCode > ,
995985 & Option < IsLint > ,
996986 & MultiSpan ,
0 commit comments