update const stability docs (#2111)

This commit is contained in:
Ralf Jung 2024-11-05 10:26:56 +01:00 committed by GitHub
parent 6ef78e3691
commit 9532ff1e18
1 changed files with 2 additions and 3 deletions

View File

@ -58,9 +58,6 @@ ipsum")]` has the same interface as the `unstable` attribute. It is used to mark
(The compiler will tell you to add the attribute if you run into this.) (The compiler will tell you to add the attribute if you run into this.)
- If a `const fn` is `#[stable]` but not yet intended to be const-stable. - If a `const fn` is `#[stable]` but not yet intended to be const-stable.
Furthermore, this attribute is needed to mark an intrinsic as an *unstable* `const fn`, because
there's no way to add `const` to functions in `extern` blocks for now.
Const-stability differs from regular stability in that it is *recursive*: a Const-stability differs from regular stability in that it is *recursive*: a
`#[rustc_const_unstable(...)]` function cannot even be indirectly called from stable code. This is `#[rustc_const_unstable(...)]` function cannot even be indirectly called from stable code. This is
to avoid accidentally leaking unstable compiler implementation artifacts to stable code or locking to avoid accidentally leaking unstable compiler implementation artifacts to stable code or locking
@ -82,6 +79,8 @@ compiler features); the only reason it is not const-stable yet are API concerns.
This should also be added to lang items for which const-calls are synthesized in the compiler, to This should also be added to lang items for which const-calls are synthesized in the compiler, to
ensure those calls do not bypass recursive const stability rules. ensure those calls do not bypass recursive const stability rules.
## rustc_const_stable_intrinsic
On an intrinsic, this attribute marks the intrinsic as "ready to be used by public stable functions". On an intrinsic, this attribute marks the intrinsic as "ready to be used by public stable functions".
The `rustc_const_unstable` can be removed when this attribute is added. The `rustc_const_unstable` can be removed when this attribute is added.
**Adding this attribute to an intrinsic requires t-lang and wg-const-eval approval!** **Adding this attribute to an intrinsic requires t-lang and wg-const-eval approval!**