Rollup merge of #86838 - lambinoo:I-69630-rust_const_unstable_check_const, r=oli-obk

Checking that function is const if marked with rustc_const_unstable

Fixes #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!
This commit is contained in:
Guillaume Gomez 2021-07-08 18:30:34 +02:00 committed by GitHub
commit d85718ad01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 220 additions and 7 deletions

View file

@ -10,7 +10,7 @@ Erroneous code example:
fn _stable_fn() {}
#[rustc_const_stable(feature = "_stable_const_fn")] // invalid
fn _stable_const_fn() {}
const fn _stable_const_fn() {}
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
#[rustc_deprecated(
@ -29,7 +29,7 @@ To fix this issue, you need to provide the `since` field. Example:
fn _stable_fn() {}
#[rustc_const_stable(feature = "_stable_const_fn", since = "1.0.0")] // ok!
fn _stable_const_fn() {}
const fn _stable_const_fn() {}
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
#[rustc_deprecated(

View file

@ -10,7 +10,7 @@ Erroneous code example:
fn _unstable_fn() {}
#[rustc_const_unstable(feature = "_unstable_const_fn", issue = "0")] // invalid
fn _unstable_const_fn() {}
const fn _unstable_const_fn() {}
```
To fix this issue, you need to provide a correct value in the `issue` field.
@ -24,7 +24,7 @@ Example:
fn _unstable_fn() {}
#[rustc_const_unstable(feature = "_unstable_const_fn", issue = "1")] // ok!
fn _unstable_const_fn() {}
const fn _unstable_const_fn() {}
```
See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix

View file

@ -10,7 +10,7 @@ Erroneous code example:
fn _unstable_fn() {}
#[rustc_const_unstable(feature = "_unstable_const_fn")] // invalid
fn _unstable_const_fn() {}
const fn _unstable_const_fn() {}
```
To fix this issue, you need to provide the `issue` field. Example:
@ -26,7 +26,7 @@ fn _unstable_fn() {}
feature = "_unstable_const_fn",
issue = "none"
)] // ok!
fn _unstable_const_fn() {}
const fn _unstable_const_fn() {}
```
See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix