@@ -8,7 +8,7 @@ use rustc_error_messages::FluentValue;
8
8
use rustc_lint_defs:: { Applicability , LintExpectationId } ;
9
9
use rustc_span:: edition:: LATEST_STABLE_EDITION ;
10
10
use rustc_span:: symbol:: { Ident , Symbol } ;
11
- use rustc_span:: { Span , DUMMY_SP } ;
11
+ use rustc_span:: { edition :: Edition , Span , DUMMY_SP } ;
12
12
use std:: borrow:: Cow ;
13
13
use std:: fmt;
14
14
use std:: hash:: { Hash , Hasher } ;
@@ -39,12 +39,94 @@ pub trait IntoDiagnosticArg {
39
39
fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > ;
40
40
}
41
41
42
+ impl IntoDiagnosticArg for bool {
43
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
44
+ if self {
45
+ DiagnosticArgValue :: Str ( Cow :: Borrowed ( "true" ) )
46
+ } else {
47
+ DiagnosticArgValue :: Str ( Cow :: Borrowed ( "false" ) )
48
+ }
49
+ }
50
+ }
51
+
52
+ impl IntoDiagnosticArg for i8 {
53
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
54
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
55
+ }
56
+ }
57
+
58
+ impl IntoDiagnosticArg for u8 {
59
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
60
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
61
+ }
62
+ }
63
+
64
+ impl IntoDiagnosticArg for i16 {
65
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
66
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
67
+ }
68
+ }
69
+
70
+ impl IntoDiagnosticArg for u16 {
71
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
72
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
73
+ }
74
+ }
75
+
76
+ impl IntoDiagnosticArg for i32 {
77
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
78
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
79
+ }
80
+ }
81
+
82
+ impl IntoDiagnosticArg for u32 {
83
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
84
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
85
+ }
86
+ }
87
+
88
+ impl IntoDiagnosticArg for i64 {
89
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
90
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
91
+ }
92
+ }
93
+
94
+ impl IntoDiagnosticArg for u64 {
95
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
96
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
97
+ }
98
+ }
99
+
100
+ impl IntoDiagnosticArg for i128 {
101
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
102
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
103
+ }
104
+ }
105
+
106
+ impl IntoDiagnosticArg for u128 {
107
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
108
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
109
+ }
110
+ }
111
+
42
112
impl IntoDiagnosticArg for String {
43
113
fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
44
114
DiagnosticArgValue :: Str ( Cow :: Owned ( self ) )
45
115
}
46
116
}
47
117
118
+ impl IntoDiagnosticArg for std:: num:: NonZeroU32 {
119
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
120
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
121
+ }
122
+ }
123
+
124
+ impl IntoDiagnosticArg for Edition {
125
+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
126
+ DiagnosticArgValue :: Str ( Cow :: Owned ( self . to_string ( ) ) )
127
+ }
128
+ }
129
+
48
130
impl IntoDiagnosticArg for Symbol {
49
131
fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
50
132
self . to_ident_string ( ) . into_diagnostic_arg ( )
0 commit comments