@@ -23,43 +23,36 @@ pub struct SuggestionsDisabled;
23
23
/// Simplified version of `FluentArg` that can implement `Encodable` and `Decodable`. Collection of
24
24
/// `DiagnosticArg` are converted to `FluentArgs` (consuming the collection) at the start of
25
25
/// diagnostic emission.
26
- pub type DiagnosticArg < ' iter , ' source > =
27
- ( & ' iter DiagnosticArgName < ' source > , & ' iter DiagnosticArgValue < ' source > ) ;
26
+ pub type DiagnosticArg < ' iter > = ( & ' iter DiagnosticArgName , & ' iter DiagnosticArgValue ) ;
28
27
29
28
/// Name of a diagnostic argument.
30
- pub type DiagnosticArgName < ' source > = Cow < ' source , str > ;
29
+ pub type DiagnosticArgName = Cow < ' static , str > ;
31
30
32
31
/// Simplified version of `FluentValue` that can implement `Encodable` and `Decodable`. Converted
33
32
/// to a `FluentValue` by the emitter to be used in diagnostic translation.
34
33
#[ 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 > ) ,
37
36
Number ( i128 ) ,
38
- StrListSepByAnd ( Vec < Cow < ' source , str > > ) ,
37
+ StrListSepByAnd ( Vec < Cow < ' static , str > > ) ,
39
38
}
40
39
41
40
/// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic`
42
41
/// struct). Implemented as a custom trait rather than `From` so that it is implemented on the type
43
42
/// being converted rather than on `DiagnosticArgValue`, which enables types from other `rustc_*`
44
43
/// crates to implement this.
45
44
pub trait IntoDiagnosticArg {
46
- fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > ;
45
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue ;
47
46
}
48
47
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
58
51
}
59
52
}
60
53
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 > {
63
56
match self {
64
57
DiagnosticArgValue :: Str ( s) => From :: from ( s) ,
65
58
DiagnosticArgValue :: Number ( n) => From :: from ( n) ,
@@ -109,7 +102,7 @@ pub struct Diagnostic {
109
102
pub span : MultiSpan ,
110
103
pub children : Vec < SubDiagnostic > ,
111
104
pub suggestions : Result < Vec < CodeSuggestion > , SuggestionsDisabled > ,
112
- args : FxHashMap < DiagnosticArgName < ' static > , DiagnosticArgValue < ' static > > ,
105
+ args : FxHashMap < DiagnosticArgName , DiagnosticArgValue > ,
113
106
114
107
/// This is not used for highlighting or rendering any error message. Rather, it can be used
115
108
/// as a sort key to sort a buffer of diagnostics. By default, it is the primary span of
@@ -916,7 +909,7 @@ impl Diagnostic {
916
909
// Exact iteration order of diagnostic arguments shouldn't make a difference to output because
917
910
// they're only used in interpolation.
918
911
#[ allow( rustc:: potential_query_instability) ]
919
- pub fn args ( & self ) -> impl Iterator < Item = DiagnosticArg < ' _ , ' static > > {
912
+ pub fn args ( & self ) -> impl Iterator < Item = DiagnosticArg < ' _ > > {
920
913
self . args . iter ( )
921
914
}
922
915
@@ -929,10 +922,7 @@ impl Diagnostic {
929
922
self
930
923
}
931
924
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 > ) {
936
926
self . args = args;
937
927
}
938
928
@@ -990,7 +980,7 @@ impl Diagnostic {
990
980
) -> (
991
981
& Level ,
992
982
& [ ( DiagnosticMessage , Style ) ] ,
993
- Vec < ( & Cow < ' static , str > , & DiagnosticArgValue < ' static > ) > ,
983
+ Vec < ( & Cow < ' static , str > , & DiagnosticArgValue ) > ,
994
984
& Option < ErrCode > ,
995
985
& Option < IsLint > ,
996
986
& MultiSpan ,
0 commit comments