rust/library/core/src
Matthias Krüger bb7291e71b
Rollup merge of #141222 - mathisbot:ptr_trycastaligned, r=tgross35
Implement `ptr::try_cast_aligned` and `NonNull::try_cast_aligned`.

Implement three common methods on raw pointers and `NonNull`s: `try_cast_aligned`.

## Related links

- Tracking Issue: https://github.com/rust-lang/rust/issues/141221

## About `#[inline]`

Since the result of a call to `align_of` is a power of two known at compile time, the compiler is able to reduce a call to `try_cast_aligned` to only test and sete (or test and jne if followed by `unwrap`), at least on every tier 1 target's arch. This seemed like a good reason to `#[inline]` the function.

- https://godbolt.org/z/ocehvPWMx (raw inlining)
- https://godbolt.org/z/3qa4j4Yrn (comparison with no inlining)
2025-05-21 08:05:21 +02:00
..
alloc Fix some grammar errors and hyperlinks in doc for trait Allocator 2025-04-14 22:26:43 +09:00
array Add #[must_use] to Array::map 2025-05-13 12:34:53 +09: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 Replace colon with parentheses, add missing period 2025-04-21 10:48:46 -04:00
cell Rollup merge of #129334 - ChayimFriedman2:more-lazy-methods, r=Amanieu 2025-05-10 16:26:01 +02:00
char Add assert_unsafe_precondition!()s to as_ascii_unchecked() methods 2025-05-16 13:54:02 +01: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 std: Explain prefer TryInto over TryFrom when specifying traits bounds on generic function 2025-05-08 18:12:05 +08:00
ffi update version placeholders 2025-05-12 15:33:30 +02:00
fmt float: Add f16 parsing and printing 2025-05-18 16:43:13 +00:00
future update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
hash library: Use size_of from the prelude instead of imported 2025-03-06 20:20:38 -08:00
intrinsics make std::intrinsic functions actually be intrinsics 2025-05-20 08:09:16 +02:00
io Add inherent versions of MaybeUninit methods for slices 2025-01-11 23:57:00 -05:00
iter Rollup merge of #136183 - hkBst:patch-25, r=Amanieu 2025-05-06 19:27:38 +02:00
macros Rollup merge of #134273 - RalfJung:de-stabilize-bench, r=ibraheemdev,traviscross 2025-05-07 00:29:20 +00:00
marker Make phantom variance markers transparent 2025-02-15 00:47:49 +00:00
mem make std::intrinsic functions actually be intrinsics 2025-05-20 08:09:16 +02:00
net Add Ipv4Addr and Ipv6Addr diagnostic items 2025-05-14 09:34:25 +02:00
num core_float_math: Move functions to math folder 2025-05-20 16:41:43 +01:00
ops update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
panic Remove #[cfg(not(test))] gates in core 2025-03-06 13:21:59 -08:00
pin update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
prelude update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
ptr Implement ptr::try_cast_aligned and NonNull::try_cast_aligned. 2025-05-20 22:51:31 +02:00
range Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
slice [std] fix the presentation of split_off_mut and split_off documentation 2025-05-18 23:22:08 +08:00
str Add assert_unsafe_precondition!()s to as_ascii_unchecked() methods 2025-05-16 13:54:02 +01:00
sync Remove #[doc(hidden)] from AtomicPrimitive::AtomicInner 2025-04-27 02:18:08 +03: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 fix missing word in comment 2025-04-16 18:53:40 -07:00
arch.rs update version placeholders 2025-05-12 15:33:30 +02: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 update version placeholders 2025-05-12 15:33:30 +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 update version placeholders 2025-05-12 15:33:30 +02: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 Auto merge of #127013 - tgross35:f16-format-parse, r=Mark-Simulacrum 2025-05-18 20:38:01 +00:00
marker.rs update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
option.rs add examples using .as_ref() for is_some_and and is_none_or 2025-04-24 10:22:49 +08:00
panic.rs update cfgs 2024-11-27 15:14:54 +00:00
panicking.rs update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
pat.rs update cfgs 2025-04-09 12:29:59 +01:00
pin.rs Rollup merge of #141289 - compiler-errors:more-self, r=jhpratt 2025-05-20 20:57:28 +02: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 #138870 - beetrees:tier-2-nans, r=RalfJung 2025-04-20 14:05:33 +00: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 Solved suggestions 2025-04-25 11:06:53 +08:00
time.rs Split duration_constructors to get non-controversial bits out faster. 2025-05-09 22:52:39 -04: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