File tree Expand file tree Collapse file tree 5 files changed +37
-23
lines changed Expand file tree Collapse file tree 5 files changed +37
-23
lines changed Original file line number Diff line number Diff line change @@ -396,26 +396,31 @@ where
396396 issue_num = match & * issue. unwrap ( ) . as_str ( ) {
397397 "none" => None ,
398398 issue => {
399+ let emit_diag = |msg : & str | {
400+ struct_span_err ! (
401+ diagnostic,
402+ mi. span,
403+ E0545 ,
404+ "`issue` must be a non-zero numeric string \
405+ or \" none\" ",
406+ )
407+ . span_label (
408+ mi. name_value_literal ( ) . unwrap ( ) . span ,
409+ msg,
410+ )
411+ . emit ( ) ;
412+ } ;
399413 match issue. parse ( ) {
400- Ok ( num) => {
401- // FIXME(rossmacarthur): disallow 0
402- // Disallowing this requires updates to
403- // some submodules
404- NonZeroU32 :: new ( num)
414+ Ok ( num) if num == 0 => {
415+ emit_diag (
416+ "`issue` must not be \" 0\" , \
417+ use \" none\" instead",
418+ ) ;
419+ continue ' outer;
405420 }
421+ Ok ( num) => NonZeroU32 :: new ( num) ,
406422 Err ( err) => {
407- struct_span_err ! (
408- diagnostic,
409- mi. span,
410- E0545 ,
411- "`issue` must be a numeric string \
412- or \" none\" ",
413- )
414- . span_label (
415- mi. name_value_literal ( ) . unwrap ( ) . span ,
416- & err. to_string ( ) ,
417- )
418- . emit ( ) ;
423+ emit_diag ( & err. to_string ( ) ) ;
419424 continue ' outer;
420425 }
421426 }
Original file line number Diff line number Diff line change 44#![ stable( feature = "stable_test_feature" , since = "1.0.0" ) ]
55
66#[ unstable( feature = "unstable_test_feature" , issue = "0" ) ]
7- fn unstable_issue_0 ( ) { }
7+ fn unstable_issue_0 ( ) { } //~^ ERROR `issue` must be a non-zero numeric string or "none"
88
99#[ unstable( feature = "unstable_test_feature" , issue = "none" ) ]
1010fn unstable_issue_none ( ) { }
1111
1212#[ unstable( feature = "unstable_test_feature" , issue = "something" ) ]
13- fn unstable_issue_not_allowed ( ) { } //~^ ERROR `issue` must be a numeric string or "none"
13+ fn unstable_issue_not_allowed ( ) { } //~^ ERROR `issue` must be a non-zero numeric string or "none"
Original file line number Diff line number Diff line change 1- error[E0545]: `issue` must be a numeric string or "none"
1+ error[E0545]: `issue` must be a non-zero numeric string or "none"
2+ --> $DIR/unstable-attribute-allow-issue-0.rs:6:47
3+ |
4+ LL | #[unstable(feature = "unstable_test_feature", issue = "0")]
5+ | ^^^^^^^^---
6+ | |
7+ | `issue` must not be "0", use "none" instead
8+
9+ error[E0545]: `issue` must be a non-zero numeric string or "none"
210 --> $DIR/unstable-attribute-allow-issue-0.rs:12:47
311 |
412LL | #[unstable(feature = "unstable_test_feature", issue = "something")]
513 | ^^^^^^^^-----------
614 | |
715 | invalid digit found in string
816
9- error: aborting due to previous error
17+ error: aborting due to 2 previous errors
1018
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ fn f1() { }
1010#[ stable( feature = "a" , sinse = "1.0.0" ) ] //~ ERROR unknown meta item 'sinse'
1111fn f2 ( ) { }
1212
13- #[ unstable( feature = "a" , issue = "no" ) ] //~ ERROR `issue` must be a numeric string or "none"
13+ #[ unstable( feature = "a" , issue = "no" ) ]
14+ //~^ ERROR `issue` must be a non-zero numeric string or "none"
1415fn f3 ( ) { }
1516
1617fn main ( ) { }
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ error[E0541]: unknown meta item 'sinse'
1010LL | #[stable(feature = "a", sinse = "1.0.0")]
1111 | ^^^^^^^^^^^^^^^ expected one of `since`, `note`
1212
13- error[E0545]: `issue` must be a numeric string or "none"
13+ error[E0545]: `issue` must be a non-zero numeric string or "none"
1414 --> $DIR/stability-attribute-sanity-2.rs:13:27
1515 |
1616LL | #[unstable(feature = "a", issue = "no")]
You can’t perform that action at this time.
0 commit comments