-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Checking that function is const if marked with rustc_const_unstable #86838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,47 @@ | ||||||||||||||||
#![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` | ||||||||||||||||
|
||||||||||||||||
lambinoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
#[stable(feature = "potato", since = "1.0.0")] | ||||||||||||||||
pub struct Potato; | ||||||||||||||||
|
||||||||||||||||
impl Potato { | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please also add a test for the unstable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's what is being tested on this one, no? rust/src/test/ui/consts/rustc-impl-const-stability.rs Lines 15 to 21 in aadad14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. apologies, I completely overlooked that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to apologies! Thank you for giving me some of your time to check up on that MR! On a side note, I'd like to get more involved as I've been a very happy user for a while. Any part of the compiler/libraries I should look at to be useful? |
||||||||||||||||
#[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 = "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() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
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: aborting due to 6 previous errors | ||
|
Uh oh!
There was an error while loading. Please reload this page.