@@ -237,8 +237,6 @@ where
237237 let mut promotable = false ;
238238 let mut allowed_through_unstable_modules = false ;
239239
240- let diagnostic = & sess. parse_sess . span_diagnostic ;
241-
242240 ' outer: for attr in attrs_iter {
243241 if ![
244242 sym:: rustc_const_unstable,
@@ -278,7 +276,7 @@ where
278276 * item = Some ( v) ;
279277 true
280278 } else {
281- struct_span_err ! ( diagnostic , meta . span, E0539 , "incorrect meta item" ) . emit ( ) ;
279+ sess . emit_err ( session_diagnostics :: InvalidMetaItem { span : meta. span } ) ;
282280 false
283281 }
284282 } ;
@@ -344,39 +342,28 @@ where
344342 // is a name/value pair string literal.
345343 issue_num = match issue. unwrap ( ) . as_str ( ) {
346344 "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;
372358 }
373- }
359+ } ,
374360 } ;
375361 }
376362 sym:: soft => {
377363 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+ } ) ;
380367 }
381368 is_soft = true ;
382369 }
@@ -434,8 +421,7 @@ where
434421 continue ;
435422 }
436423 _ => {
437- struct_span_err ! ( diagnostic, attr. span, E0547 , "missing 'issue'" )
438- . emit ( ) ;
424+ sess. emit_err ( session_diagnostics:: MissingIssue { span : attr. span } ) ;
439425 continue ;
440426 }
441427 }
@@ -530,14 +516,7 @@ where
530516 if let Some ( ( ref mut stab, _) ) = const_stab {
531517 stab. promotable = promotable;
532518 } 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 } ) ;
541520 }
542521 }
543522
@@ -552,13 +531,7 @@ where
552531 {
553532 * allowed_through_unstable_modules = true ;
554533 } 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 } ) ;
562535 }
563536 }
564537
0 commit comments