forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#86838 - lambinoo:I-69630-rust_const_unstabl…
…e_check_const, r=oli-obk Checking that function is const if marked with rustc_const_unstable Fixes rust-lang#69630 This one is still missing tests to check the behavior but I checked by hand and it seemed to work. I would not mind some direction for writing those unit tests!
- Loading branch information
Showing
7 changed files
with
239 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#![crate_type = "lib"] | ||
#![feature(staged_api)] | ||
#![stable(feature = "foo", since = "1.0.0")] | ||
|
||
#[stable(feature = "foo", since = "1.0.0")] | ||
#[rustc_const_unstable(feature = "const_foo", issue = "none")] | ||
pub fn foo() {} | ||
//~^ ERROR attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
|
||
#[stable(feature = "bar", since = "1.0.0")] | ||
#[rustc_const_stable(feature = "const_bar", since = "1.0.0")] | ||
pub fn bar() {} | ||
//~^ ERROR attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
|
||
#[stable(feature = "potato", since = "1.0.0")] | ||
pub struct Potato; | ||
|
||
impl Potato { | ||
#[stable(feature = "salad", since = "1.0.0")] | ||
#[rustc_const_unstable(feature = "const_salad", issue = "none")] | ||
pub fn salad(&self) -> &'static str { "mmmmmm" } | ||
//~^ ERROR attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
|
||
#[stable(feature = "roasted", since = "1.0.0")] | ||
#[rustc_const_unstable(feature = "const_roasted", issue = "none")] | ||
pub fn roasted(&self) -> &'static str { "mmmmmmmmmm" } | ||
//~^ ERROR attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
} | ||
|
||
#[stable(feature = "bar", since = "1.0.0")] | ||
#[rustc_const_stable(feature = "const_bar", since = "1.0.0")] | ||
pub extern "C" fn bar_c() {} | ||
//~^ ERROR attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
|
||
#[stable(feature = "foo", since = "1.0.0")] | ||
#[rustc_const_unstable(feature = "const_foo", issue = "none")] | ||
pub extern "C" fn foo_c() {} | ||
//~^ ERROR attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
|
||
|
||
#[stable(feature = "foo", since = "1.0.0")] | ||
#[rustc_const_unstable(feature = "const_foo", issue = "none")] | ||
pub extern "stdcall" fn foo_stdcall() {} | ||
//~^ ERROR attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
|
||
#[stable(feature = "foobar", since = "1.0.0")] | ||
#[rustc_const_unstable(feature = "foobar_const", issue = "none")] | ||
pub const fn foobar() {} | ||
|
||
#[stable(feature = "barfoo", since = "1.0.0")] | ||
#[rustc_const_stable(feature = "barfoo_const", since = "1.0.0")] | ||
pub const fn barfoo() {} |
100 changes: 100 additions & 0 deletions
100
src/test/ui/consts/rustc-const-stability-require-const.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,100 @@ | ||
error: attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
--> $DIR/rustc-const-stability-require-const.rs:7:1 | ||
| | ||
LL | #[rustc_const_unstable(feature = "const_foo", issue = "none")] | ||
| -------------------------------------------------------------- attribute specified here | ||
LL | pub fn foo() {} | ||
| ^^^^^^^^^^^^ | ||
| | ||
help: make the function or method const | ||
--> $DIR/rustc-const-stability-require-const.rs:7:1 | ||
| | ||
LL | pub fn foo() {} | ||
| ^^^^^^^^^^^^ | ||
|
||
error: attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
--> $DIR/rustc-const-stability-require-const.rs:12:1 | ||
| | ||
LL | #[rustc_const_stable(feature = "const_bar", since = "1.0.0")] | ||
| ------------------------------------------------------------- attribute specified here | ||
LL | pub fn bar() {} | ||
| ^^^^^^^^^^^^ | ||
| | ||
help: make the function or method const | ||
--> $DIR/rustc-const-stability-require-const.rs:12:1 | ||
| | ||
LL | pub fn bar() {} | ||
| ^^^^^^^^^^^^ | ||
|
||
error: attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
--> $DIR/rustc-const-stability-require-const.rs:21:5 | ||
| | ||
LL | #[rustc_const_unstable(feature = "const_salad", issue = "none")] | ||
| ---------------------------------------------------------------- attribute specified here | ||
LL | pub fn salad(&self) -> &'static str { "mmmmmm" } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: make the function or method const | ||
--> $DIR/rustc-const-stability-require-const.rs:21:5 | ||
| | ||
LL | pub fn salad(&self) -> &'static str { "mmmmmm" } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
--> $DIR/rustc-const-stability-require-const.rs:26:5 | ||
| | ||
LL | #[rustc_const_unstable(feature = "const_roasted", issue = "none")] | ||
| ------------------------------------------------------------------ attribute specified here | ||
LL | pub fn roasted(&self) -> &'static str { "mmmmmmmmmm" } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: make the function or method const | ||
--> $DIR/rustc-const-stability-require-const.rs:26:5 | ||
| | ||
LL | pub fn roasted(&self) -> &'static str { "mmmmmmmmmm" } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
--> $DIR/rustc-const-stability-require-const.rs:32:1 | ||
| | ||
LL | #[rustc_const_stable(feature = "const_bar", since = "1.0.0")] | ||
| ------------------------------------------------------------- attribute specified here | ||
LL | pub extern "C" fn bar_c() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: make the function or method const | ||
--> $DIR/rustc-const-stability-require-const.rs:32:1 | ||
| | ||
LL | pub extern "C" fn bar_c() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
--> $DIR/rustc-const-stability-require-const.rs:37:1 | ||
| | ||
LL | #[rustc_const_unstable(feature = "const_foo", issue = "none")] | ||
| -------------------------------------------------------------- attribute specified here | ||
LL | pub extern "C" fn foo_c() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: make the function or method const | ||
--> $DIR/rustc-const-stability-require-const.rs:37:1 | ||
| | ||
LL | pub extern "C" fn foo_c() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const` | ||
--> $DIR/rustc-const-stability-require-const.rs:43:1 | ||
| | ||
LL | #[rustc_const_unstable(feature = "const_foo", issue = "none")] | ||
| -------------------------------------------------------------- attribute specified here | ||
LL | pub extern "stdcall" fn foo_stdcall() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: make the function or method const | ||
--> $DIR/rustc-const-stability-require-const.rs:43:1 | ||
| | ||
LL | pub extern "stdcall" fn foo_stdcall() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 7 previous errors | ||
|
Oops, something went wrong.