os-rust/library/core/tests
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
..
async_iter Remove unnecessary lets and borrowing from Waker::noop() usage. 2024-01-17 12:00:27 -08:00
ffi CStr: derive PartialEq, Eq; add test for Ord 2024-07-25 14:18:40 +03:00
fmt Implement debug_more_non_exhaustive 2024-07-21 12:05:02 -05:00
hash Library: Rename "object safe" to "dyn compatible" 2024-10-09 18:48:29 +02:00
io Make io::BorrowedCursor::advance safe 2024-02-07 16:46:28 +01:00
iter Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
net core/net: add Ipv[46]Addr::from_octets, Ipv6Addr::from_segments 2024-10-13 20:26:23 +02:00
num Run most core::num tests in const context too 2024-10-14 16:37:57 -04:00
ops Explicitly specify type parameter on FromResidual impls in stdlib. 2024-08-12 12:54:18 -05:00
panic Fix test (location_const_file) 2022-10-08 11:48:53 +00:00
alloc.rs rename ptr::invalid -> ptr::without_provenance 2024-02-21 20:15:52 +01:00
any.rs Adjust library tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
array.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
ascii.rs Optimize escape_ascii 2024-10-09 17:17:50 -04:00
ascii_char.rs core: optimise Debug impl for ascii::Char 2024-08-09 22:50:57 +02:00
asserting.rs Spelling library/ 2023-04-26 02:10:22 -04:00
atomic.rs update bootstrap configs 2024-10-15 20:30:23 -07:00
bool.rs fix library and rustdoc tests 2023-04-16 11:38:52 +00:00
cell.rs apply fmt 2024-01-11 15:04:48 +03:00
char.rs remove redundant imports 2023-12-10 10:56:22 +08:00
clone.rs impl CloneToUninit for str and CStr 2024-07-29 20:33:11 +03:00
cmp.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
const_ptr.rs cleanup code w/ pointers in std a little 2022-08-05 16:47:49 +04:00
convert.rs fix library and rustdoc tests 2023-04-16 11:38:52 +00:00
error.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
ffi.rs CStr: derive PartialEq, Eq; add test for Ord 2024-07-25 14:18:40 +03:00
future.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
intrinsics.rs Step bootstrap cfgs 2024-05-01 22:19:11 -04:00
lazy.rs Do not run test where it cannot run 2024-10-17 09:33:39 -04:00
lib.rs Re-do recursive const stability checks 2024-10-25 20:31:40 +02:00
macros.rs Rustfmt 2024-09-13 15:18:30 -03:00
manually_drop.rs Flip cfg's for bootstrap bump 2023-07-12 21:38:55 -04:00
mem.rs fix UB in a test 2024-09-09 16:17:34 +02:00
nonzero.rs Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
ops.rs Explicitly specify type parameter on FromResidual impls in stdlib. 2024-08-12 12:54:18 -05:00
option.rs Make Option::as_[mut_]slice const 2024-06-19 21:44:47 +01:00
panic.rs Add newlines 2022-09-27 19:23:52 +00:00
pattern.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
pin.rs Partially stabilize const_pin 2024-10-16 21:24:38 +01:00
pin_macro.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
ptr.rs ignore some vtable/fn ptr equality tests in Miri, their result is not fully predictable 2024-08-12 10:39:11 +02:00
result.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
simd.rs Fix library tests 2023-11-26 08:50:39 -05:00
slice.rs Port sort-research-rs test suite Rust stdlib tests 2024-09-30 15:05:30 +02:00
str.rs Update paths in comments. 2022-12-30 14:00:42 +01:00
str_lossy.rs Stabilize Utf8Chunks 2024-04-24 15:27:47 -07:00
task.rs Remove test of static Context 2023-01-02 10:33:23 -08:00
time.rs core: add Duration constructors 2024-01-24 14:24:57 +01:00
tuple.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
unicode.rs revert changes to unicode stability 2022-07-08 21:18:15 +00:00
waker.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00