about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2019-11-12 16:36:16 +0900
committerGitHub <noreply@github.com>2019-11-12 16:36:16 +0900
commit4134a4acf555bad45c83b0379df5fb86402499ec (patch)
treea6e77a1a987f9cc3edb8edcdeead9ffb4e358876 /src/test
parent6bdd1beca6d310f0baaffa0835a16a968061ccfb (diff)
parent3ba825725390fe103a057e59100c7c8cafc22404 (diff)
Rollup merge of #66299 - rossmacarthur:fix-41260-avoid-issue-0, r=varkor
support issue = "none" in unstable attributes

This works towards fixing #41260.

This PR allows the use of `issue = "none"` in unstable attributes and makes changes to internally store the issue number as an `Option<NonZeroU32>`. For example:

```rust
#[unstable(feature = "unstable_test_feature", issue = "none")]
fn unstable_issue_none() {}
```

It was not made optional because feedback seen here #60860 suggested that people might forget the issue field if it was optional.

I could not remove the current uses of `issue = "0"` (of which there are a lot) because the stage 0 compiler expects the old syntax. Once this is available in the stage 0 compiler we can replace all uses of `"0"` with `"none"` and no longer allow `"0"`. This is my first time contributing, so I'm not sure what the protocol is with two-part things like this, so some guidance would be appreciated.

r? @varkor
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/feature-gate/unstable-attribute-allow-issue-none.rs13
-rw-r--r--src/test/ui/feature-gate/unstable-attribute-allow-issue-none.stderr8
2 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/feature-gate/unstable-attribute-allow-issue-none.rs b/src/test/ui/feature-gate/unstable-attribute-allow-issue-none.rs
new file mode 100644
index 00000000000..3ce9de3fb1b
--- /dev/null
+++ b/src/test/ui/feature-gate/unstable-attribute-allow-issue-none.rs
@@ -0,0 +1,13 @@
+// Check that an issue value can be explicitly set to "none" instead of "0"
+#![crate_type = "lib"]
+#![feature(staged_api)]
+#![stable(feature = "stable_test_feature", since = "1.0.0")]
+
+#[unstable(feature = "unstable_test_feature", issue = "0")]
+fn unstable_issue_0() {}
+
+#[unstable(feature = "unstable_test_feature", issue = "none")]
+fn unstable_issue_none() {}
+
+#[unstable(feature = "unstable_test_feature", issue = "something")] //~ ERROR incorrect 'issue'
+fn unstable_issue_not_allowed() {}
diff --git a/src/test/ui/feature-gate/unstable-attribute-allow-issue-none.stderr b/src/test/ui/feature-gate/unstable-attribute-allow-issue-none.stderr
new file mode 100644
index 00000000000..fc031f5f8c5
--- /dev/null
+++ b/src/test/ui/feature-gate/unstable-attribute-allow-issue-none.stderr
@@ -0,0 +1,8 @@
+error[E0545]: incorrect 'issue'
+  --> $DIR/unstable-attribute-allow-issue-none.rs:12:1
+   |
+LL | #[unstable(feature = "unstable_test_feature", issue = "something")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+