@@ -165,42 +165,51 @@ impl std::fmt::Display for ParserError {
165
165
impl < ' a > From < & ' a ParserError > for Diagnostic {
166
166
fn from ( error : & ' a ParserError ) -> Diagnostic {
167
167
match & error. reason {
168
- Some ( reason) => {
169
- match reason {
170
- ParserErrorReason :: ConstrainDeprecated => Diagnostic :: simple_error (
168
+ Some ( reason) => match reason {
169
+ ParserErrorReason :: ConstrainDeprecated => {
170
+ let mut diagnostic = Diagnostic :: simple_error (
171
171
"Use of deprecated keyword 'constrain'" . into ( ) ,
172
172
"The 'constrain' keyword is deprecated. Please use the 'assert' function instead." . into ( ) ,
173
173
error. span ,
174
- ) ,
175
- ParserErrorReason :: ComptimeDeprecated => Diagnostic :: simple_warning (
174
+ ) ;
175
+ diagnostic. deprecated = true ;
176
+ diagnostic
177
+ }
178
+ ParserErrorReason :: ComptimeDeprecated => {
179
+ let mut diagnostic = Diagnostic :: simple_warning (
176
180
"Use of deprecated keyword 'comptime'" . into ( ) ,
177
181
"The 'comptime' keyword has been deprecated. It can be removed without affecting your program" . into ( ) ,
178
182
error. span ,
183
+ ) ;
184
+ diagnostic. deprecated = true ;
185
+ diagnostic
186
+ }
187
+ ParserErrorReason :: InvalidBitSize ( bit_size) => Diagnostic :: simple_error (
188
+ format ! ( "Use of invalid bit size {}" , bit_size) ,
189
+ format ! (
190
+ "Allowed bit sizes for integers are {}" ,
191
+ IntegerBitSize :: allowed_sizes( )
192
+ . iter( )
193
+ . map( |n| n. to_string( ) )
194
+ . collect:: <Vec <_>>( )
195
+ . join( ", " )
179
196
) ,
180
- ParserErrorReason :: InvalidBitSize ( bit_size) => Diagnostic :: simple_error (
181
- format ! ( "Use of invalid bit size {}" , bit_size) ,
182
- format ! ( "Allowed bit sizes for integers are {}" , IntegerBitSize :: allowed_sizes( ) . iter( ) . map( |n| n. to_string( ) ) . collect:: <Vec <_>>( ) . join( ", " ) ) ,
183
- error. span ,
184
- ) ,
185
- ParserErrorReason :: ExperimentalFeature ( _) => Diagnostic :: simple_warning (
186
- reason. to_string ( ) ,
187
- "" . into ( ) ,
188
- error. span ,
189
- ) ,
190
- ParserErrorReason :: TraitImplFunctionModifiers => Diagnostic :: simple_warning (
191
- reason. to_string ( ) ,
192
- "" . into ( ) ,
193
- error. span ,
194
- ) ,
195
- ParserErrorReason :: ExpectedPatternButFoundType ( ty) => {
196
- Diagnostic :: simple_error ( "Expected a ; separating these two statements" . into ( ) , format ! ( "{ty} is a type and cannot be used as a variable name" ) , error. span )
197
- }
198
- ParserErrorReason :: Lexer ( error) => error. into ( ) ,
199
- other => {
200
- Diagnostic :: simple_error ( format ! ( "{other}" ) , String :: new ( ) , error. span )
201
- }
197
+ error. span ,
198
+ ) ,
199
+ ParserErrorReason :: ExperimentalFeature ( _) => {
200
+ Diagnostic :: simple_warning ( reason. to_string ( ) , "" . into ( ) , error. span )
202
201
}
203
- }
202
+ ParserErrorReason :: TraitImplFunctionModifiers => {
203
+ Diagnostic :: simple_warning ( reason. to_string ( ) , "" . into ( ) , error. span )
204
+ }
205
+ ParserErrorReason :: ExpectedPatternButFoundType ( ty) => Diagnostic :: simple_error (
206
+ "Expected a ; separating these two statements" . into ( ) ,
207
+ format ! ( "{ty} is a type and cannot be used as a variable name" ) ,
208
+ error. span ,
209
+ ) ,
210
+ ParserErrorReason :: Lexer ( error) => error. into ( ) ,
211
+ other => Diagnostic :: simple_error ( format ! ( "{other}" ) , String :: new ( ) , error. span ) ,
212
+ } ,
204
213
None => {
205
214
let primary = error. to_string ( ) ;
206
215
Diagnostic :: simple_error ( primary, String :: new ( ) , error. span )
0 commit comments