about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2024-05-03Rollup merge of #123815 - trueb2:patch-1, r=workingjubileeMatthias Krüger-2/+2
Fix cannot usage in time.rs Fix a small grammar error in usage of cannot in time.rs errors
2024-05-03Rollup merge of #122492 - GrigorenkoPV:ptr_as_ref_unchecked, r=workingjubileeMatthias Krüger-0/+151
Implement ptr_as_ref_unchecked Implementation of #122034. Prefixed the feature name with `ptr_` for clarity. Linked const-unstability to #91822, so the post there should probably be updated to mentions the 3 new methods when/if this PR is merged.
2024-05-03Use `CURRENT_RUSTC_VERSION`Артём Павлов [Artyom Pavlov]-2/+2
2024-05-03Stabilize `div_duration`Артём Павлов [Artyom Pavlov]-5/+2
2024-05-03Ensure miri only uses fallback bodies that have manually been vetted to ↵Oli Scherer-0/+3
preserve all UB that the native intrinsic would have
2024-05-03Rollup merge of #124626 - RalfJung:const_eval_select, r=joboetMatthias Krüger-2/+1
const_eval_select: add tracking issue
2024-05-03Rollup merge of #123480 - Nadrieril:impl-all-derefpures, r=compiler-errorsMatthias Krüger-3/+15
deref patterns: impl `DerefPure` for more std types Context: [deref patterns](https://github.com/rust-lang/rust/issues/87121). The requirements of `DerefPure` aren't precise yet, but these types unambiguously satisfy them. Interestingly, a hypothetical `impl DerefMut for Cow` that does a `Clone` would *not* be eligible for `DerefPure` if we allow mixing deref patterns with normal patterns. If the following is exhaustive then the `DerefMut` would cause UB: ```rust match &mut Cow::Borrowed(&()) { Cow::Owned(_) => ..., // Doesn't match deref!(_x) if false => ..., // Causes the variant to switch to `Owned` Cow::Borrowed(_) => ..., // Doesn't match // We reach unreachable } ```
2024-05-02Update based on reviewGeorge Bateman-7/+7
2024-05-02const_eval_select: add tracking issueRalf Jung-2/+1
2024-05-02add constants in std::f128::constsTrevor Spiteri-1/+110
2024-05-02add constants in std::f16::constsTrevor Spiteri-1/+106
2024-05-02add f128 associated constantsTrevor Spiteri-1/+83
NaN and infinity are not included as they require arithmetic.
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-251/+29
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-01Add benchmarks for `impl Debug for str`Arpad Borsos-0/+80
In order to inform future perf improvements and prevent regressions, lets add some benchmarks that stress `impl Debug for str`.
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-30/+53
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-30/+53
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-5/+5
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>