-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #107801 - davidtwco:stability-implies-const, r=Nilstrieb
const_eval: `implies_by` in `rustc_const_unstable` Fixes #107605. Extend support for `implies_by` (from `#[stable]` and `#[unstable]`) to `#[rustc_const_stable]` and `#[rustc_const_unstable]`. cc ``@steffahn``
- Loading branch information
Showing
12 changed files
with
177 additions
and
7 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
12 changes: 12 additions & 0 deletions
12
tests/ui/stability-attribute/auxiliary/const-stability-attribute-implies.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,12 @@ | ||
#![crate_type = "lib"] | ||
#![feature(staged_api)] | ||
#![stable(feature = "stability_attribute_implies", since = "1.0.0")] | ||
#![rustc_const_stable(feature = "stability_attribute_implies", since = "1.0.0")] | ||
|
||
#[stable(feature = "stability_attribute_implies", since = "1.0.0")] | ||
#[rustc_const_stable(feature = "const_foo", since = "1.62.0")] | ||
pub const fn foo() {} | ||
|
||
#[stable(feature = "stability_attribute_implies", since = "1.0.0")] | ||
#[rustc_const_unstable(feature = "const_foobar", issue = "1", implied_by = "const_foo")] | ||
pub const fn foobar() {} |
16 changes: 16 additions & 0 deletions
16
tests/ui/stability-attribute/const-stability-attribute-implies-missing.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,16 @@ | ||
#![crate_type = "lib"] | ||
#![feature(staged_api)] | ||
#![stable(feature = "stability_attribute_implies", since = "1.0.0")] | ||
#![rustc_const_stable(feature = "stability_attribute_implies", since = "1.0.0")] | ||
|
||
// Tests that `implied_by = "const_bar"` results in an error being emitted if `const_bar` does not | ||
// exist. | ||
|
||
#[stable(feature = "stability_attribute_implies", since = "1.0.0")] | ||
#[rustc_const_unstable(feature = "const_foobar", issue = "1", implied_by = "const_bar")] | ||
//~^ ERROR feature `const_bar` implying `const_foobar` does not exist | ||
pub const fn foobar() -> u32 { | ||
0 | ||
} | ||
|
||
const VAR: u32 = foobar(); |
8 changes: 8 additions & 0 deletions
8
tests/ui/stability-attribute/const-stability-attribute-implies-missing.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,8 @@ | ||
error: feature `const_bar` implying `const_foobar` does not exist | ||
--> $DIR/const-stability-attribute-implies-missing.rs:10:1 | ||
| | ||
LL | #[rustc_const_unstable(feature = "const_foobar", issue = "1", implied_by = "const_bar")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
16 changes: 16 additions & 0 deletions
16
tests/ui/stability-attribute/const-stability-attribute-implies-no-feature.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,16 @@ | ||
// aux-build:const-stability-attribute-implies.rs | ||
#![crate_type = "lib"] | ||
|
||
// Tests that despite the `const_foobar` feature being implied by now-stable feature `const_foo`, | ||
// if `const_foobar` isn't allowed in this crate then an error will be emitted. | ||
|
||
extern crate const_stability_attribute_implies; | ||
use const_stability_attribute_implies::{foo, foobar}; | ||
|
||
pub const fn bar() -> u32 { | ||
foo(); // no error - stable | ||
foobar(); //~ ERROR `foobar` is not yet stable as a const fn | ||
0 | ||
} | ||
|
||
pub const VAR: u32 = bar(); |
10 changes: 10 additions & 0 deletions
10
tests/ui/stability-attribute/const-stability-attribute-implies-no-feature.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,10 @@ | ||
error: `foobar` is not yet stable as a const fn | ||
--> $DIR/const-stability-attribute-implies-no-feature.rs:12:5 | ||
| | ||
LL | foobar(); | ||
| ^^^^^^^^ | ||
| | ||
= help: add `#![feature(const_foobar)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
19 changes: 19 additions & 0 deletions
19
tests/ui/stability-attribute/const-stability-attribute-implies-using-stable.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,19 @@ | ||
// aux-build:const-stability-attribute-implies.rs | ||
#![crate_type = "lib"] | ||
#![deny(stable_features)] | ||
#![feature(const_foo)] | ||
//~^ ERROR the feature `const_foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `const_foobar` | ||
|
||
// Tests that the use of `implied_by` in the `#[rustc_const_unstable]` attribute results in a | ||
// diagnostic mentioning partial stabilization, and that given the implied unstable feature is | ||
// unused (there is no `foobar` call), that the compiler suggests removing the flag. | ||
|
||
extern crate const_stability_attribute_implies; | ||
use const_stability_attribute_implies::foo; | ||
|
||
pub const fn bar() -> u32 { | ||
foo(); | ||
0 | ||
} | ||
|
||
pub const VAR: u32 = bar(); |
22 changes: 22 additions & 0 deletions
22
tests/ui/stability-attribute/const-stability-attribute-implies-using-stable.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,22 @@ | ||
error: the feature `const_foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `const_foobar` | ||
--> $DIR/const-stability-attribute-implies-using-stable.rs:4:12 | ||
| | ||
LL | #![feature(const_foo)] | ||
| ^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/const-stability-attribute-implies-using-stable.rs:3:9 | ||
| | ||
LL | #![deny(stable_features)] | ||
| ^^^^^^^^^^^^^^^ | ||
help: if you are using features which are still unstable, change to using `const_foobar` | ||
| | ||
LL | #![feature(const_foobar)] | ||
| ~~~~~~~~~~~~ | ||
help: if you are using features which are now stable, remove this line | ||
| | ||
LL - #![feature(const_foo)] | ||
| | ||
|
||
error: aborting due to previous error | ||
|
21 changes: 21 additions & 0 deletions
21
tests/ui/stability-attribute/const-stability-attribute-implies-using-unstable.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,21 @@ | ||
// aux-build:const-stability-attribute-implies.rs | ||
#![crate_type = "lib"] | ||
#![deny(stable_features)] | ||
#![feature(const_foo)] | ||
//~^ ERROR the feature `const_foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `const_foobar` | ||
|
||
// Tests that the use of `implied_by` in the `#[rustc_const_unstable]` attribute results in a | ||
// diagnostic mentioning partial stabilization and that given the implied unstable feature is | ||
// used (there is a `const_foobar` call), that the compiler suggests changing to that feature and | ||
// doesn't error about its use. | ||
|
||
extern crate const_stability_attribute_implies; | ||
use const_stability_attribute_implies::{foo, foobar}; | ||
|
||
pub const fn bar() -> u32 { | ||
foo(); | ||
foobar(); // no error! | ||
0 | ||
} | ||
|
||
pub const VAR: u32 = bar(); |
22 changes: 22 additions & 0 deletions
22
tests/ui/stability-attribute/const-stability-attribute-implies-using-unstable.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,22 @@ | ||
error: the feature `const_foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `const_foobar` | ||
--> $DIR/const-stability-attribute-implies-using-unstable.rs:4:12 | ||
| | ||
LL | #![feature(const_foo)] | ||
| ^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/const-stability-attribute-implies-using-unstable.rs:3:9 | ||
| | ||
LL | #![deny(stable_features)] | ||
| ^^^^^^^^^^^^^^^ | ||
help: if you are using features which are still unstable, change to using `const_foobar` | ||
| | ||
LL | #![feature(const_foobar)] | ||
| ~~~~~~~~~~~~ | ||
help: if you are using features which are now stable, remove this line | ||
| | ||
LL - #![feature(const_foo)] | ||
| | ||
|
||
error: aborting due to previous error | ||
|