Forbid using 0
as issue number
This commit is contained in:
parent
ed853b8619
commit
bf269335d0
@ -396,26 +396,31 @@ where
|
||||
issue_num = match &*issue.unwrap().as_str() {
|
||||
"none" => None,
|
||||
issue => {
|
||||
let emit_diag = |msg: &str| {
|
||||
struct_span_err!(
|
||||
diagnostic,
|
||||
mi.span,
|
||||
E0545,
|
||||
"`issue` must be a non-zero numeric string \
|
||||
or \"none\"",
|
||||
)
|
||||
.span_label(
|
||||
mi.name_value_literal().unwrap().span,
|
||||
msg,
|
||||
)
|
||||
.emit();
|
||||
};
|
||||
match issue.parse() {
|
||||
Ok(num) => {
|
||||
// FIXME(rossmacarthur): disallow 0
|
||||
// Disallowing this requires updates to
|
||||
// some submodules
|
||||
NonZeroU32::new(num)
|
||||
Ok(num) if num == 0 => {
|
||||
emit_diag(
|
||||
"`issue` must not be \"0\", \
|
||||
use \"none\" instead",
|
||||
);
|
||||
continue 'outer;
|
||||
}
|
||||
Ok(num) => NonZeroU32::new(num),
|
||||
Err(err) => {
|
||||
struct_span_err!(
|
||||
diagnostic,
|
||||
mi.span,
|
||||
E0545,
|
||||
"`issue` must be a numeric string \
|
||||
or \"none\"",
|
||||
)
|
||||
.span_label(
|
||||
mi.name_value_literal().unwrap().span,
|
||||
&err.to_string(),
|
||||
)
|
||||
.emit();
|
||||
emit_diag(&err.to_string());
|
||||
continue 'outer;
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,10 @@
|
||||
#![stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||
|
||||
#[unstable(feature = "unstable_test_feature", issue = "0")]
|
||||
fn unstable_issue_0() {}
|
||||
fn unstable_issue_0() {} //~^ ERROR `issue` must be a non-zero numeric string or "none"
|
||||
|
||||
#[unstable(feature = "unstable_test_feature", issue = "none")]
|
||||
fn unstable_issue_none() {}
|
||||
|
||||
#[unstable(feature = "unstable_test_feature", issue = "something")]
|
||||
fn unstable_issue_not_allowed() {} //~^ ERROR `issue` must be a numeric string or "none"
|
||||
fn unstable_issue_not_allowed() {} //~^ ERROR `issue` must be a non-zero numeric string or "none"
|
||||
|
@ -1,4 +1,12 @@
|
||||
error[E0545]: `issue` must be a numeric string or "none"
|
||||
error[E0545]: `issue` must be a non-zero numeric string or "none"
|
||||
--> $DIR/unstable-attribute-allow-issue-0.rs:6:47
|
||||
|
|
||||
LL | #[unstable(feature = "unstable_test_feature", issue = "0")]
|
||||
| ^^^^^^^^---
|
||||
| |
|
||||
| `issue` must not be "0", use "none" instead
|
||||
|
||||
error[E0545]: `issue` must be a non-zero numeric string or "none"
|
||||
--> $DIR/unstable-attribute-allow-issue-0.rs:12:47
|
||||
|
|
||||
LL | #[unstable(feature = "unstable_test_feature", issue = "something")]
|
||||
@ -6,5 +14,5 @@ LL | #[unstable(feature = "unstable_test_feature", issue = "something")]
|
||||
| |
|
||||
| invalid digit found in string
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -10,7 +10,8 @@ fn f1() { }
|
||||
#[stable(feature = "a", sinse = "1.0.0")] //~ ERROR unknown meta item 'sinse'
|
||||
fn f2() { }
|
||||
|
||||
#[unstable(feature = "a", issue = "no")] //~ ERROR `issue` must be a numeric string or "none"
|
||||
#[unstable(feature = "a", issue = "no")]
|
||||
//~^ ERROR `issue` must be a non-zero numeric string or "none"
|
||||
fn f3() { }
|
||||
|
||||
fn main() { }
|
||||
|
@ -10,7 +10,7 @@ error[E0541]: unknown meta item 'sinse'
|
||||
LL | #[stable(feature = "a", sinse = "1.0.0")]
|
||||
| ^^^^^^^^^^^^^^^ expected one of `since`, `note`
|
||||
|
||||
error[E0545]: `issue` must be a numeric string or "none"
|
||||
error[E0545]: `issue` must be a non-zero numeric string or "none"
|
||||
--> $DIR/stability-attribute-sanity-2.rs:13:27
|
||||
|
|
||||
LL | #[unstable(feature = "a", issue = "no")]
|
||||
|
Loading…
Reference in New Issue
Block a user