File tree 5 files changed +37
-23
lines changed
5 files changed +37
-23
lines changed Original file line number Diff line number Diff line change @@ -396,26 +396,31 @@ where
396
396
issue_num = match & * issue. unwrap ( ) . as_str ( ) {
397
397
"none" => None ,
398
398
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
+ } ;
399
413
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;
405
420
}
421
+ Ok ( num) => NonZeroU32 :: new ( num) ,
406
422
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 ( ) ) ;
419
424
continue ' outer;
420
425
}
421
426
}
Original file line number Diff line number Diff line change 4
4
#![ stable( feature = "stable_test_feature" , since = "1.0.0" ) ]
5
5
6
6
#[ 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"
8
8
9
9
#[ unstable( feature = "unstable_test_feature" , issue = "none" ) ]
10
10
fn unstable_issue_none ( ) { }
11
11
12
12
#[ 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"
2
10
--> $DIR/unstable-attribute-allow-issue-0.rs:12:47
3
11
|
4
12
LL | #[unstable(feature = "unstable_test_feature", issue = "something")]
5
13
| ^^^^^^^^-----------
6
14
| |
7
15
| invalid digit found in string
8
16
9
- error: aborting due to previous error
17
+ error: aborting due to 2 previous errors
10
18
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ fn f1() { }
10
10
#[ stable( feature = "a" , sinse = "1.0.0" ) ] //~ ERROR unknown meta item 'sinse'
11
11
fn f2 ( ) { }
12
12
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"
14
15
fn f3 ( ) { }
15
16
16
17
fn main ( ) { }
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ error[E0541]: unknown meta item 'sinse'
10
10
LL | #[stable(feature = "a", sinse = "1.0.0")]
11
11
| ^^^^^^^^^^^^^^^ expected one of `since`, `note`
12
12
13
- error[E0545]: `issue` must be a numeric string or "none"
13
+ error[E0545]: `issue` must be a non-zero numeric string or "none"
14
14
--> $DIR/stability-attribute-sanity-2.rs:13:27
15
15
|
16
16
LL | #[unstable(feature = "a", issue = "no")]
You can’t perform that action at this time.
0 commit comments