rust/tests/ui/intrinsics
Ralf Jung a0215d8e46 Re-do recursive const stability checks
Fundamentally, we have *three* disjoint categories of functions:
1. const-stable functions
2. private/unstable functions that are meant to be callable from const-stable functions
3. functions that can make use of unstable const features

This PR implements the following system:
- `#[rustc_const_stable]` puts functions in the first category. It may only be applied to `#[stable]` functions.
- `#[rustc_const_unstable]` by default puts functions in the third category. The new attribute `#[rustc_const_stable_indirect]` can be added to such a function to move it into the second category.
- `const fn` without a const stability marker are in the second category if they are still unstable. They automatically inherit the feature gate for regular calls, it can now also be used for const-calls.

Also, several holes in recursive const stability checking are being closed.
There's still one potential hole that is hard to avoid, which is when MIR
building automatically inserts calls to a particular function in stable
functions -- which happens in the panic machinery. Those need to *not* be
`rustc_const_unstable` (or manually get a `rustc_const_stable_indirect`) to be
sure they follow recursive const stability. But that's a fairly rare and special
case so IMO it's fine.

The net effect of this is that a `#[unstable]` or unmarked function can be
constified simply by marking it as `const fn`, and it will then be
const-callable from stable `const fn` and subject to recursive const stability
requirements. If it is publicly reachable (which implies it cannot be unmarked),
it will be const-unstable under the same feature gate. Only if the function ever
becomes `#[stable]` does it need a `#[rustc_const_unstable]` or
`#[rustc_const_stable]` marker to decide if this should also imply
const-stability.

Adding `#[rustc_const_unstable]` is only needed for (a) functions that need to
use unstable const lang features (including intrinsics), or (b) `#[stable]`
functions that are not yet intended to be const-stable. Adding
`#[rustc_const_stable]` is only needed for functions that are actually meant to
be directly callable from stable const code. `#[rustc_const_stable_indirect]` is
used to mark intrinsics as const-callable and for `#[rustc_const_unstable]`
functions that are actually called from other, exposed-on-stable `const fn`. No
other attributes are required.
2024-10-25 20:31:40 +02:00
..
auxiliary Move /src/test to /tests 2023-01-11 09:32:08 +00:00
always-extern.rs Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
always-extern.stderr Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
always-gets-overridden.rs Add a scheme for moving away from extern "rust-intrinsic" entirely 2024-03-04 16:13:50 +00:00
bad-intrinsic-monomorphization.rs Fixup 2 ui tests using changed intrinsics 2024-04-16 12:39:53 +00:00
bad-intrinsic-monomorphization.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-eval-select-backtrace-std.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
const-eval-select-backtrace-std.run.stderr Improve spans for indexing expressions 2023-08-04 13:17:39 +02:00
const-eval-select-backtrace.rs const_eval_select: make it safe but be careful with what we expose on stable for now 2024-03-02 16:09:31 +01:00
const-eval-select-backtrace.run.stderr const_eval_select: make it safe but be careful with what we expose on stable for now 2024-03-02 16:09:31 +01:00
const-eval-select-bad.rs Pretty print Fn traits in rustc_on_unimplemented 2023-11-02 20:57:05 +00:00
const-eval-select-bad.stderr Use parenthetical notation for Fn traits 2024-05-29 22:26:54 +00:00
const-eval-select-stability.rs Re-do recursive const stability checks 2024-10-25 20:31:40 +02:00
const-eval-select-stability.stderr Re-do recursive const stability checks 2024-10-25 20:31:40 +02:00
const-eval-select-x86_64.rs const_eval_select: make it safe but be careful with what we expose on stable for now 2024-03-02 16:09:31 +01:00
const-eval-select.rs const_eval_select: make it safe but be careful with what we expose on stable for now 2024-03-02 16:09:31 +01:00
feature-gate-safe-intrinsic.rs Gate and validate #[rustc_safe_intrinsic] 2023-09-25 22:33:15 +02:00
feature-gate-safe-intrinsic.stderr Bless tests 2024-01-13 12:46:58 -05:00
incorrect-read_via_copy-defn.rs Don't even parse an intrinsic unless the feature gate is enabled 2024-04-07 13:30:12 -04:00
incorrect-read_via_copy-defn.stderr Don't even parse an intrinsic unless the feature gate is enabled 2024-04-07 13:30:12 -04:00
incorrect-transmute.rs Don't even parse an intrinsic unless the feature gate is enabled 2024-04-07 13:30:12 -04:00
incorrect-transmute.stderr Don't even parse an intrinsic unless the feature gate is enabled 2024-04-07 13:30:12 -04:00
intrinsic-alignment.rs Fix most ui tests on emscripten target 2024-10-15 14:25:55 +02:00
intrinsic-assume.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
intrinsic-atomics-cc.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
intrinsic-atomics.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
intrinsic-fmuladd.rs intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semantics 2024-10-11 15:32:56 -06:00
intrinsic-nearby.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
intrinsic-raw_eq-const-bad.rs interpret: add missing alignment check in raw_eq 2024-08-27 19:29:52 +02:00
intrinsic-raw_eq-const-bad.stderr interpret: add missing alignment check in raw_eq 2024-08-27 19:29:52 +02:00
intrinsic-raw_eq-const.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
intrinsic-unreachable.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
intrinsic-volatile.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
intrinsics-integer.rs Fixup 2 ui tests using changed intrinsics 2024-04-16 12:39:53 +00:00
intrinsics-math.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-28575.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
issue-28575.stderr Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
issue-84297-reifying-copy.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
non-integer-atomic.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
non-integer-atomic.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
not-overridden.rs Always use a colon in //@ normalize-*: headers 2024-07-11 12:23:44 +10:00
not-overridden.stderr Add a scheme for moving away from extern "rust-intrinsic" entirely 2024-03-04 16:13:50 +00:00
panic-uninitialized-zeroed.rs Stabilize generic NonZero. 2024-04-22 18:48:47 +02:00
reify-intrinsic.rs Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
reify-intrinsic.stderr document & impl the transmutation modeled by BikeshedIntrinsicFrom 2024-08-23 14:37:36 +00:00
safe-intrinsic-mismatch.effects.stderr Use FnSig instead of raw FnDecl for ForeignItemKind::Fn 2024-08-16 14:10:06 -04:00
safe-intrinsic-mismatch.rs Fix intrinsic const parameter counting with effects 2024-07-07 11:30:03 +00:00
safe-intrinsic-mismatch.stock.stderr Use FnSig instead of raw FnDecl for ForeignItemKind::Fn 2024-08-16 14:10:06 -04:00
unchecked_math_unsafe.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
unchecked_math_unsafe.stderr Stabilize THIR unsafeck 2024-01-05 10:00:59 +00:00
unchecked_math_unstable.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unchecked_math_unstable.stderr Bless tests 2024-01-13 12:46:58 -05:00