-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sanity checks for
reason
and soft
on unstable attributes
`reason` must appear at most once: it's the reason for the item being unstable, rather than a particular feature. This simplifies diagnostic formatting. `soft` must either be on all or no unstable attributes: it doesn't make sense for something to be partially soft, and allowing inconsistent softness markers would risk an item accidentally becoming properly unstable as its features stabilize.
- Loading branch information
Showing
6 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/ui/stability-attribute/multiple-stability-attribute-sanity.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//! Checks that multiple stability attributes are used correctly together | ||
|
||
#![feature(staged_api)] | ||
|
||
#![stable(feature = "stable_test_feature", since = "1.0.0")] | ||
|
||
#[unstable(feature = "a", issue = "none", reason = "reason 1")] | ||
#[unstable(feature = "b", issue = "none", reason = "reason 2")] //~ ERROR multiple reasons provided for unstability | ||
fn f1() { } | ||
|
||
#[unstable(feature = "a", issue = "none", reason = "reason 1")] | ||
#[unstable(feature = "b", issue = "none", reason = "reason 2")] //~ ERROR multiple reasons provided for unstability | ||
#[unstable(feature = "c", issue = "none", reason = "reason 3")] //~ ERROR multiple reasons provided for unstability | ||
fn f2() { } | ||
|
||
#[unstable(feature = "a", issue = "none")] //~ ERROR `soft` must be present on either none or all of an item's `unstable` attributes | ||
#[unstable(feature = "b", issue = "none", soft)] | ||
fn f3() { } | ||
|
||
#[unstable(feature = "a", issue = "none", soft)] //~ ERROR `soft` must be present on either none or all of an item's `unstable` attributes | ||
#[unstable(feature = "b", issue = "none")] | ||
fn f4() { } | ||
|
||
fn main() { } |
36 changes: 36 additions & 0 deletions
36
tests/ui/stability-attribute/multiple-stability-attribute-sanity.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
error: multiple reasons provided for unstability | ||
--> $DIR/multiple-stability-attribute-sanity.rs:8:1 | ||
| | ||
LL | #[unstable(feature = "b", issue = "none", reason = "reason 2")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: multiple reasons provided for unstability | ||
--> $DIR/multiple-stability-attribute-sanity.rs:12:1 | ||
| | ||
LL | #[unstable(feature = "b", issue = "none", reason = "reason 2")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: multiple reasons provided for unstability | ||
--> $DIR/multiple-stability-attribute-sanity.rs:13:1 | ||
| | ||
LL | #[unstable(feature = "c", issue = "none", reason = "reason 3")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: `soft` must be present on either none or all of an item's `unstable` attributes | ||
--> $DIR/multiple-stability-attribute-sanity.rs:16:1 | ||
| | ||
LL | #[unstable(feature = "a", issue = "none")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[unstable(feature = "b", issue = "none", soft)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: `soft` must be present on either none or all of an item's `unstable` attributes | ||
--> $DIR/multiple-stability-attribute-sanity.rs:20:1 | ||
| | ||
LL | #[unstable(feature = "a", issue = "none", soft)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[unstable(feature = "b", issue = "none")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|