about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2024-05-02add f16 associated constantsTrevor Spiteri-1/+83
NaN and infinity are not included as they require arithmetic.
2024-05-02Auto merge of #124419 - WaffleLapkin:never-type-fallback-docs, r=workingjubileebors-0/+47
Document never type fallback in `!`'s docs Pulled the documentation I've written for #123939. I want a single place where never type fallback is explained, which can be referred in all the lints and migration materials.
2024-05-02fixup links in never type docsWaffle Maybe-3/+3
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2024-05-01Workaround rustfmt bug replacing type ascriptionMark Rousskov-0/+1
2024-05-02Slightly reformat !'s docs after applying github suggestionsWaffle Lapkin-5/+7
2024-05-01Step bootstrap cfgsMark Rousskov-248/+28
2024-05-02Apply suggestions from code reviewWaffle Maybe-8/+7
Co-authored-by: Kevin Reid <kpreid@switchb.org> Co-authored-by: Herman Skogseth <herman.skogseth@me.com> Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2024-05-01Replace version placeholders for 1.79Mark Rousskov-56/+53
2024-05-01Describe and use CStr literals in CStr and CString docsGeorge Bateman-12/+23
2024-05-01Rollup merge of #124542 - CBSpeir:diagnostic-item-enumerate-method, r=scottmcmMatthias Krüger-0/+1
Add diagnostic item for `std::iter::Iterator::enumerate` Adds a diagnostic item for the `std::iter:Iterator::enumerate` trait method. This change, along with PR https://github.com/rust-lang/rust/pull/124308, will be used by the clippy `unused_enumerate_index` lint to move away from paths to using diagnostic items. see: https://github.com/rust-lang/rust-clippy/issues/5393
2024-05-01Auto merge of #124491 - madsmtm:target_vendor-apple, r=workingjubileebors-16/+7
Use `target_vendor = "apple"` instead of `target_os = "..."` Use `target_vendor = "apple"` instead of `all(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos")`. The apple targets are quite close to being identical, with iOS, tvOS, watchOS and visionOS being even closer, so using `target_vendor` when possible makes it clearer when something is actually OS-specific, or just Apple-specific. Note that `target_vendor` will [be deprecated in the future](https://github.com/rust-lang/rust/issues/100343), but not before an alternative (like `target_family = "apple"`) is available. While doing this, I found various inconsistencies and small mistakes in the standard library, see the commits for details. Will follow-up with an extra PR for a similar issue that need a bit more discussion. EDIT: https://github.com/rust-lang/rust/pull/124494 Since you've talked about using `target_vendor = "apple"` in the past: r? workingjubilee CC `@simlay,` `@thomcc` `@rustbot` label O-macos O-ios O-tvos O-watchos O-visionos
2024-04-29Add diagnostic item for std::iter::Iterator::enumerateChristopher B. Speir-0/+1
2024-04-29Rollup merge of #124484 - GKFX:offset_of_must_use, r=jieyouxu许杰友 Jieyou Xu (Joe)-2/+2
Fix #124478 - offset_of! returns a temporary This was due to the must_use() call. Adding HIR's `OffsetOf` to the must_use checking within the compiler avoids this issue while maintaining the lint output. Fixes #124478. `@tgross35`
2024-04-29Auto merge of #124502 - NCGThompson:statically-known-docs, r=jhprattbors-4/+39
Update `is_val_statically_known` Docs * Add `Type Requirements` section, listing the allowed inputs, as requested by #121115 * Add `Pointers` subsection, explaining is_val_statically_known handles pointers. * Add `Stability concerns` section, referring to other documentation relating to consistency in `const` functions. Fixes #121115 Sorry this took so long.
2024-04-28Update is_val_statically_known docsNicholas Thompson-4/+39
* Add `Type Requirements` section, listing the allowed inputs, as requested by #121115 * Add `Pointers` subsection, explaining is_val_statically_known handles pointers. * Add `Stability concerns` section, referring to other documentation relating to consistency in `const` functions.
2024-04-28Stabilize `non_null_convenience`Trevor Gross-78/+63
Fully stabilize the following API, including const where applicable: impl <T> NonNull<T> { pub const unsafe fn offset(self, count: isize) -> Self; pub const unsafe fn add(self, count: usize) -> Self; pub const unsafe fn sub(self, count: usize) -> Self; pub const unsafe fn offset_from(self, origin: NonNull<T>) -> isize; pub const unsafe fn read(self) -> T; pub unsafe fn read_volatile(self) -> T; pub const unsafe fn read_unaligned(self) -> T; pub unsafe fn write_volatile(self, val: T); pub unsafe fn replace(self, src: T) -> T; } impl<T: ?Sized> NonNull<T> { pub const unsafe fn byte_offset(self, count: isize) -> Self; pub const unsafe fn byte_add(self, count: usize) -> Self; pub const unsafe fn byte_sub(self, count: usize) -> Self; pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: NonNull<U>) -> isize; pub unsafe fn drop_in_place(self); } Stabilize the following without const: impl <T> NonNull<T> { // const under `const_intrinsic_copy` pub const unsafe fn copy_to(self, dest: NonNull<T>, count: usize); pub const unsafe fn copy_to_nonoverlapping(self, dest: NonNull<T>, count: usize); pub const unsafe fn copy_from(self, src: NonNull<T>, count: usize); pub const unsafe fn copy_from_nonoverlapping(self, src: NonNull<T>, count: usize); // const under `const_ptr_write` pub const unsafe fn write(self, val: T); pub const unsafe fn write_bytes(self, val: u8, count: usize); pub const unsafe fn write_unaligned(self, val: T); // const under `const_swap` pub const unsafe fn swap(self, with: NonNull<T>); // const under `const_align_offset` pub const fn align_offset(self, align: usize) -> usize; // const under `const_pointer_is_aligned` pub const fn is_aligned(self) -> bool; } Left the following unstable: impl <T> NonNull<T> { // moved gate to `ptr_sub_ptr` pub const unsafe fn sub_ptr(self, subtracted: NonNull<T>) -> usize; } impl <T: ?Sized> NonNull<T> { // moved gate to `pointer_is_aligned_to` pub const fn is_aligned_to(self, align: usize) -> bool; } Fixes: https://github.com/rust-lang/rust/issues/117691
2024-04-28Fix va_list on watchOS and visionOSMads Marquart-16/+7
2024-04-28Fix #124478 - offset_of! returns a temporaryGeorge Bateman-2/+2
This was due to the must_use() call. Adding HIR's OffsetOf to the must_use checking within the compiler avoids this issue.
2024-04-28Auto merge of #124210 - the8472:consign-ebadf-to-the-fire, r=Mark-Simulacrumbors-4/+10
Abort a process when FD ownership is violated When an owned FD has already been closed before it's dropped that means something else touched an FD in ways it is not allowed to. At that point things can already be arbitrarily bad, e.g. clobbered mmaps. Recovery is not possible. All we can do is hasten the fire. Unlike the previous attempt in #124130 this shouldn't suffer from the possibility that FUSE filesystems can return arbitrary errors.
2024-04-27Apply suggestions from code reviewWaffle Maybe-4/+9
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2024-04-26Add missing .into_iter()Matthias Geier-1/+1
2024-04-26Extend the example code and assert the resultMatthias Geier-3/+10
2024-04-26Document never type fallback in `!`'s docsWaffle Lapkin-0/+41
2024-04-26Add "safety" commentMatthias Geier-0/+5
2024-04-26Auto merge of #123909 - dtolnay:utf8chunks, r=joboetbors-25/+51
Stabilize `Utf8Chunks` Pending FCP in https://github.com/rust-lang/rust/issues/99543. This PR includes the proposed modification in https://github.com/rust-lang/libs-team/issues/190 as agreed in https://github.com/rust-lang/rust/issues/99543#issuecomment-2050406568.
2024-04-26Auto merge of #124393 - scottmcm:do-the-macros-still-matter, r=joboetbors-21/+20
Convert some iter macros to normal functions With all the MIR optimization changes that have happened since these were written, let's see if they still actually matter. \*perf comes back\* Well, it looks like it's not longer relevant for instruction, cycle, nor wall-time perf. Looks like a bunch of things are maybe 10kb bigger in debug, but some are also 50k *smaller* in debug. So I think they should switch to being normal functions as the "greatly improves performance" justification for them being macros seems to no longer be true -- probably thanks to us always building `core` with `-Z inline-mir` so the difference is negligible.
2024-04-25Convert some iter macros to normal functionsScott McMurray-21/+20
With all the MIR optimization changes that have happened since these were written, let's see if they still actually matter.
2024-04-25remove trivial boundslcnr-13/+7
2024-04-24Stabilize Utf8ChunksDavid Tolnay-25/+51
2024-04-25Rollup merge of #124322 - whosehang:master, r=NilstriebMatthias Krüger-1/+1
chore: fix some typos in comments
2024-04-24Auto merge of #124330 - fmease:rollup-a98y7jf, r=fmeasebors-0/+1
Rollup of 6 pull requests Successful merges: - #123316 (Test `#[unix_sigpipe = "inherit"]` with both `SIG_DFL` and `SIG_IGN`) - #123794 (More DefineOpaqueTypes::Yes) - #123881 (Bump Fuchsia versions) - #124281 (fix weak memory bug in TLS on Windows) - #124282 (windows fill_utf16_buf: explain the expected return value) - #124308 (Add diagnostic item for `std::iter::Enumerate`) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-24Fix cannot usage in time.rsJacob Trueb-2/+2
2024-04-24Add `cfg_attr(bootstrap)` to doc testsGary Guo-0/+3
2024-04-24Stabilise `inline_const`Gary Guo-4/+4
2024-04-24Rollup merge of #124308 - CBSpeir:diagnostic-item-enumerate, r=compiler-errorsLeón Orell Valerian Liehr-0/+1
Add diagnostic item for `std::iter::Enumerate` This adds a diagnostic item for `std::iter::Enumerate`. The change will be used by the clippy `unused_enumerate_index` lint to move away from type paths to using diagnostic items. see: https://github.com/rust-lang/rust-clippy/issues/5393
2024-04-24Error on using `yield` without also using `#[coroutine]` on the closureOli Scherer-3/+4
And suggest adding the `#[coroutine]` to the closure
2024-04-24chore: fix some typos in commentswhosehang-1/+1
Signed-off-by: whosehang <whosehang@outlook.com>
2024-04-23Add diagnostic item for std::iter::EnumerateChristopher B. Speir-0/+1
2024-04-23Auto merge of #124302 - matthiaskrgr:rollup-2aya8n8, r=matthiaskrgrbors-7/+79
Rollup of 3 pull requests Successful merges: - #124003 (Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics)) - #124169 (Don't fatal when calling `expect_one_of` when recovering arg in `parse_seq`) - #124286 (Subtree sync for rustc_codegen_cranelift) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-23Rollup merge of #124003 - WaffleLapkin:dellvmization, r=scottmcm,RalfJung,antoyoMatthias Krüger-7/+79
Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics) This implements https://github.com/rust-lang/compiler-team/issues/693 minus what was implemented in #123226. Note: I decided to _not_ change `shl`/... builder methods, as it just doesn't seem worth it. r? ``@scottmcm``
2024-04-23Rollup merge of #123048 - RalfJung:layout, r=dtolnayLeón Orell Valerian Liehr-1/+3
alloc::Layout: explicitly document size invariant on the type level https://github.com/rust-lang/rust/pull/95295 added this to the constructor, but it seems worth documenting the type invariant at the type level.
2024-04-23unroll first iter of checked_ilog loop to save one multiplicationTrevor Spiteri-2/+5
2024-04-23Rollup merge of #123050 - RalfJung:panic_str, r=m-ou-seMatthias Krüger-14/+21
panic_str only exists for the migration to 2021 panic macros The only caller is `expect_failed`, which is already a cold inline(never) function, so inlining into that function should be fine. (And indeed `panic_str` was `#[inline]` anyway.) The existence of panic_str risks someone calling it when they should call `panic` instead, and I can't see a reason why this footgun should exist. I also extended the comment in `panic` to explain why it needs a `'static` string -- I know I've wondered about this in the past and it took me quite a while to understand.
2024-04-23Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obkbors-0/+288
Add simple async drop glue generation This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work). This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit). Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html). This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work. Feature completeness: - [x] `AsyncDrop` trait - [ ] `async_drop_in_place_raw`/async drop glue generation support for - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.) - [x] Arrays and slices (array pointer is unsized into slice pointer) - [x] ADTs (enums, structs, unions) - [x] tuple-like types (tuples, closures) - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait)) - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948) - [x] Async drop glue includes sync drop glue code - [x] Cleanup branch generation for `async_drop_in_place_raw` - [ ] Union rejects non-trivially async destructible fields - [ ] `AsyncDrop` implementation requires same bounds as type definition - [ ] Skip trivially destructible fields (optimization) - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop) - [ ] Automatic async drop at the end of the scope in async context
2024-04-22Rollup merge of #124230 - reitermarkus:generic-nonzero-stable, r=dtolnayGuillaume Gomez-13/+19
Stabilize generic `NonZero`. Tracking issue: https://github.com/rust-lang/rust/issues/120257 r? `@dtolnay`
2024-04-22Rollup merge of #115913 - FedericoStra:checked_ilog, r=the8472Guillaume Gomez-21/+16
checked_ilog: improve performance Addresses #115874. (This PR replicates the original #115875, which I accidentally closed by deleting my forked repository...)
2024-04-22export assert_unsafe_precondition macro for std-internal useThe 8472-4/+10
2024-04-22Stabilize generic `NonZero`.Markus Reiter-13/+19
2024-04-22Add comma at one place in `abs()` documentationGurinder Singh-1/+1
2024-04-21Address more PR feedbackScott McMurray-1/+2