rust/library/core/src
Stuart Cook 380ad1b5d4
Rollup merge of #138374 - celinval:issue-136925-const-contract, r=compiler-errors,oli-obk,RalfJung
Enable contracts for const functions

Use `const_eval_select!()` macro to enable contract checking only at runtime. The existing contract logic relies on closures, which are not supported in constant functions.

This commit also removes one level of indirection for ensures clauses since we no longer build a closure around the ensures predicate.

Resolves #136925

**Call-out:** This is still a draft PR since CI is broken due to a new warning message for unreachable code when the bottom of the function is indeed unreachable. It's not clear to me why the warning wasn't triggered before.

r? ```@compiler-errors```
2025-04-15 15:47:24 +10:00
..
alloc Pass Alignment for RawVecInner::new_in 2025-03-26 21:41:11 +00:00
array Auto merge of #139430 - scottmcm:polymorphic-array-into-iter, r=cuviper 2025-04-11 23:21:31 +00:00
ascii Add more precondition check tests 2024-10-09 19:34:27 -04:00
async_iter Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
bstr Implement SliceIndex for ByteStr 2025-03-11 20:26:10 -07:00
cell OnceCell & OnceLock docs: Using (un)initialized consistently 2025-02-03 17:48:39 +05:30
char Auto merge of #139279 - BoxyUwU:bump-boostrap, r=jieyouxu 2025-04-10 00:43:25 +00:00
clone CloneToUninit: use a private specialization trait 2024-07-29 20:44:43 +03:00
cmp Use generic NonZero everywhere in core. 2024-02-22 15:17:33 +01:00
convert Auto merge of #138363 - beetrees:f16-f128-integer-convert, r=Amanieu 2025-03-17 00:33:36 +00:00
ffi Use cfg_match in core 2025-03-26 14:32:35 -04:00
fmt update cfgs 2025-04-09 12:29:59 +01:00
future tidying up tidy 2025-02-15 13:34:01 +06:00
hash library: Use size_of from the prelude instead of imported 2025-03-06 20:20:38 -08:00
intrinsics Rollup merge of #138374 - celinval:issue-136925-const-contract, r=compiler-errors,oli-obk,RalfJung 2025-04-15 15:47:24 +10:00
io Add inherent versions of MaybeUninit methods for slices 2025-01-11 23:57:00 -05:00
iter doc changes 2025-04-06 15:09:59 +05:30
macros Auto merge of #139279 - BoxyUwU:bump-boostrap, r=jieyouxu 2025-04-10 00:43:25 +00:00
marker Make phantom variance markers transparent 2025-02-15 00:47:49 +00:00
mem Rollup merge of #135394 - clarfonthey:uninit-slices-part-2, r=tgross35 2025-03-19 16:52:52 +01:00
net replace version placeholder 2025-04-09 12:29:59 +01:00
num docs: clarify uint exponent for is_power_of_two 2025-04-12 02:18:40 -04:00
ops Polymorphize array::IntoIter's iterator impl 2025-04-05 17:55:24 -07:00
panic Remove #[cfg(not(test))] gates in core 2025-03-06 13:21:59 -08:00
pin Initial UnsafePinned/UnsafeUnpin impl [Part 1: Libs] 2025-04-13 01:11:04 -04:00
prelude update cfgs 2025-04-09 12:29:59 +01:00
ptr ptr docs: add missing backtics around 'usize' 2025-04-14 13:56:51 +02:00
range Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
slice Auto merge of #139746 - ChrisDenton:rollup-eq08b2e, r=ChrisDenton 2025-04-13 14:56:44 +00:00
str replace version placeholder 2025-04-09 12:29:59 +01:00
sync Allow inlining for Atomic*::from_ptr 2025-03-21 20:51:06 +00:00
task Remove #[cfg(not(test))] gates in core 2025-03-06 13:21:59 -08:00
unicode Remove unneeded parentheses. 2025-03-08 12:56:00 +01:00
any.rs Remove #[cfg(not(test))] gates in core 2025-03-06 13:21:59 -08:00
arch.rs core: #[allow(unreachable_pub)] on unreachable pub use 2025-01-20 18:35:32 +01:00
ascii.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
asserting.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
bool.rs Move select_unpredictable to the hint module 2025-04-13 01:34:25 +01:00
borrow.rs Suggest borrowing on fn argument that is impl AsRef 2024-05-09 23:25:31 +00:00
cell.rs Rollup merge of #139164 - xizheyin:issue-139034, r=joboet 2025-04-09 20:23:09 +02:00
clone.rs Auto merge of #139279 - BoxyUwU:bump-boostrap, r=jieyouxu 2025-04-10 00:43:25 +00:00
cmp.rs Extend the chaining logic to slices too 2025-04-12 22:10:17 -07:00
contracts.rs Apply suggestions from code review 2025-04-10 16:32:56 -07:00
default.rs Remove #[cfg(not(test))] gates in core 2025-03-06 13:21:59 -08:00
error.md Mention core's PanicInfo in error.md. 2024-06-11 15:47:00 +02:00
error.rs Remove #[cfg(not(test))] gates in core 2025-03-06 13:21:59 -08:00
escape.rs core: add #![warn(unreachable_pub)] 2025-01-20 18:35:32 +01:00
hint.rs Move select_unpredictable to the hint module 2025-04-13 01:34:25 +01:00
internal_macros.rs Use cfg_match in core 2025-03-26 14:32:35 -04:00
lib.miri.rs add 'x.py miri', and make it work for 'library/{core,alloc,std}' 2024-04-03 20:27:20 +02:00
lib.rs Rollup merge of #138374 - celinval:issue-136925-const-contract, r=compiler-errors,oli-obk,RalfJung 2025-04-15 15:47:24 +10:00
marker.rs Initial UnsafePinned/UnsafeUnpin impl [Part 1: Libs] 2025-04-13 01:11:04 -04:00
option.rs Rollup merge of #138082 - thaliaarchi:slice-cfg-not-test, r=thomcc 2025-03-16 09:40:05 +08:00
panic.rs update cfgs 2024-11-27 15:14:54 +00:00
panicking.rs update cfg(bootstrap) 2025-02-18 09:32:44 -08:00
pat.rs update cfgs 2025-04-09 12:29:59 +01:00
pin.rs Initial UnsafePinned/UnsafeUnpin impl [Part 1: Libs] 2025-04-13 01:11:04 -04:00
primitive.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
primitive_docs.rs Rollup merge of #136457 - calder:master, r=tgross35 2025-04-05 13:18:12 +11:00
random.rs random: add tracking issue, address other comments 2024-09-23 10:36:16 +02:00
range.rs update cfg(bootstrap) 2025-02-18 09:32:44 -08:00
result.rs Rollup merge of #138082 - thaliaarchi:slice-cfg-not-test, r=thomcc 2025-03-16 09:40:05 +08:00
time.rs Rollup merge of #138082 - thaliaarchi:slice-cfg-not-test, r=thomcc 2025-03-16 09:40:05 +08:00
tuple.rs Extend the chaining logic to slices too 2025-04-12 22:10:17 -07:00
ub_checks.rs Make ub_check message clear that it's not an assert 2025-02-16 00:56:09 +00:00
unit.rs core: Make Debug impl of raw pointers print metadata if present 2025-02-15 17:27:55 +01:00
unsafe_binder.rs Add unwrap_unsafe_binder and wrap_unsafe_binder macro operators 2024-12-12 16:29:40 +00:00