@@ -237,8 +237,6 @@ where
237
237
let mut promotable = false ;
238
238
let mut allowed_through_unstable_modules = false ;
239
239
240
- let diagnostic = & sess. parse_sess . span_diagnostic ;
241
-
242
240
' outer: for attr in attrs_iter {
243
241
if ![
244
242
sym:: rustc_const_unstable,
@@ -278,7 +276,7 @@ where
278
276
* item = Some ( v) ;
279
277
true
280
278
} else {
281
- struct_span_err ! ( diagnostic , meta . span, E0539 , "incorrect meta item" ) . emit ( ) ;
279
+ sess . emit_err ( session_diagnostics :: InvalidMetaItem { span : meta. span } ) ;
282
280
false
283
281
}
284
282
} ;
@@ -344,39 +342,28 @@ where
344
342
// is a name/value pair string literal.
345
343
issue_num = match issue. unwrap ( ) . as_str ( ) {
346
344
"none" => None ,
347
- issue => {
348
- let emit_diag = |msg : & str | {
349
- struct_span_err ! (
350
- diagnostic,
351
- mi. span,
352
- E0545 ,
353
- "`issue` must be a non-zero numeric string \
354
- or \" none\" ",
355
- )
356
- . span_label ( mi. name_value_literal_span ( ) . unwrap ( ) , msg)
357
- . emit ( ) ;
358
- } ;
359
- match issue. parse ( ) {
360
- Ok ( 0 ) => {
361
- emit_diag (
362
- "`issue` must not be \" 0\" , \
363
- use \" none\" instead",
364
- ) ;
365
- continue ' outer;
366
- }
367
- Ok ( num) => NonZeroU32 :: new ( num) ,
368
- Err ( err) => {
369
- emit_diag ( & err. to_string ( ) ) ;
370
- continue ' outer;
371
- }
345
+ issue => match issue. parse :: < NonZeroU32 > ( ) {
346
+ Ok ( num) => Some ( num) ,
347
+ Err ( err) => {
348
+ sess. emit_err (
349
+ session_diagnostics:: InvalidIssueString {
350
+ span : mi. span ,
351
+ cause : session_diagnostics:: InvalidIssueStringCause :: from_int_error_kind (
352
+ mi. name_value_literal_span ( ) . unwrap ( ) ,
353
+ err. kind ( ) ,
354
+ ) ,
355
+ } ,
356
+ ) ;
357
+ continue ' outer;
372
358
}
373
- }
359
+ } ,
374
360
} ;
375
361
}
376
362
sym:: soft => {
377
363
if !mi. is_word ( ) {
378
- let msg = "`soft` should not have any arguments" ;
379
- sess. parse_sess . span_diagnostic . span_err ( mi. span , msg) ;
364
+ sess. emit_err ( session_diagnostics:: SoftNoArgs {
365
+ span : mi. span ,
366
+ } ) ;
380
367
}
381
368
is_soft = true ;
382
369
}
@@ -434,8 +421,7 @@ where
434
421
continue ;
435
422
}
436
423
_ => {
437
- struct_span_err ! ( diagnostic, attr. span, E0547 , "missing 'issue'" )
438
- . emit ( ) ;
424
+ sess. emit_err ( session_diagnostics:: MissingIssue { span : attr. span } ) ;
439
425
continue ;
440
426
}
441
427
}
@@ -530,14 +516,7 @@ where
530
516
if let Some ( ( ref mut stab, _) ) = const_stab {
531
517
stab. promotable = promotable;
532
518
} else {
533
- struct_span_err ! (
534
- diagnostic,
535
- item_sp,
536
- E0717 ,
537
- "`rustc_promotable` attribute must be paired with either a `rustc_const_unstable` \
538
- or a `rustc_const_stable` attribute"
539
- )
540
- . emit ( ) ;
519
+ sess. emit_err ( session_diagnostics:: RustcPromotablePairing { span : item_sp } ) ;
541
520
}
542
521
}
543
522
@@ -552,13 +531,7 @@ where
552
531
{
553
532
* allowed_through_unstable_modules = true ;
554
533
} else {
555
- struct_span_err ! (
556
- diagnostic,
557
- item_sp,
558
- E0789 ,
559
- "`rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute"
560
- )
561
- . emit ( ) ;
534
+ sess. emit_err ( session_diagnostics:: RustcAllowedUnstablePairing { span : item_sp } ) ;
562
535
}
563
536
}
564
537
0 commit comments