Commit Graph

14646 Commits

Author SHA1 Message Date
Michael Goulet 9dfd527c6f
Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxu
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`

In the stabilization [attempt](https://github.com/rust-lang/rust/pull/120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](https://github.com/rust-lang/rust/pull/120832#issuecomment-2007394609) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward.

So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature.

Another point was [also raised](https://github.com/rust-lang/rust/pull/120832#issuecomment-1987023484), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization.

Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-05-03 23:34:22 -04:00
Matthias Krüger 1ff247c404
Rollup merge of #124593 - GKFX:cstr-literals-in-api-docs, r=workingjubilee
Describe and use CStr literals in CStr and CString docs

Mention CStr literals in the description of both types, and use them in some of the code samples for CStr. This is intended to make C string literals more discoverable.

Additionally, I don't think the orange "This example is not tested" warnings are very encouraging, so I have made the examples on `CStr` build.
2024-05-03 20:33:46 +02:00
Matthias Krüger 8e3f61b9f9
Rollup merge of #124059 - RalfJung:default_alloc_error_hook, r=workingjubilee
default_alloc_error_hook: explain difference to default __rdl_oom in alloc

Though I'm not sure if that is really the reason that this code is duplicated. On no_std it may already be possible to call user-defined code on allocation failure.
2024-05-03 20:33:45 +02:00
Matthias Krüger 4b913a2330
Rollup merge of #123815 - trueb2:patch-1, r=workingjubilee
Fix cannot usage in time.rs

Fix a small grammar error in usage of cannot in time.rs errors
2024-05-03 20:33:44 +02:00
Matthias Krüger a296693376
Rollup merge of #122492 - GrigorenkoPV:ptr_as_ref_unchecked, r=workingjubilee
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-03 20:33:44 +02:00
Ralf Jung 3f6703bbd8 default_alloc_error_hook: explain difference to default __rdl_oom in alloc 2024-05-03 19:12:33 +02:00
Matthias Krüger a7f4a2edc6
Rollup merge of #124649 - Meziu:master, r=ChrisDenton
Fix HorizonOS build broken by #124210

HorizonOS (for the Tier-3 target `armv6k-nintendo-3ds`) does not support `dirfd()`, as many other similar targets.
2024-05-03 15:26:11 +02:00
Andrea Ciliberti bdf1eae360 Horizon OS: dirfd unavailable 2024-05-03 10:09:28 +02:00
Matthias Krüger e2a53441b9
Rollup merge of #124626 - RalfJung:const_eval_select, r=joboet
const_eval_select: add tracking issue
2024-05-03 06:04:23 +02:00
Matthias Krüger c412751d19
Rollup merge of #124609 - RalfJung:float-precision, r=cuviper
variable-precision float operations can differ depending on optimization levels

Follow-up to https://github.com/rust-lang/rust/pull/121793 and https://github.com/rust-lang/rust/pull/118217 that accounts for optimizations changing the precision of these functions.

Fixes https://github.com/rust-lang/rust/issues/109118
Fixes https://github.com/rust-lang/rust/issues/71355
2024-05-03 06:04:22 +02:00
Matthias Krüger bd6276c95e
Rollup merge of #124604 - Enselic:std-gimli-symbolize, r=workingjubilee
library/std: Remove unused `gimli-symbolize` feature

library/backtrace also declares a feature called `gimli-symbolize` which appear used, but the feature in std with the same name is unused, so remove it.
2024-05-03 06:04:21 +02:00
Matthias Krüger d7a8936b78
Rollup merge of #124441 - bravequickcleverfibreyarn:string.rs, r=Amanieu
String.truncate comment microfix (greater or equal)

String.truncate calls Vec.truncate, in turn, and that states "is greater or equal to". Beside common sense.
2024-05-03 06:04:20 +02:00
Matthias Krüger 9ab5cfd91e
Rollup merge of #124412 - RalfJung:io-safety, r=Amanieu
io safety: update Unix explanation to use `Arc`

Fixes https://github.com/rust-lang/rust/issues/124384

Cc ```@jsgf```
2024-05-03 06:04:19 +02:00
Matthias Krüger e17a222a0a
Rollup merge of #123480 - Nadrieril:impl-all-derefpures, r=compiler-errors
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-03 06:04:19 +02:00
George Bateman 0e0042f16e
Update based on review 2024-05-02 21:29:13 +01:00
Martin Nordholts cde0cde151 Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern
was raised related to using a language attribute for the feature: Long
term, we want `fn lang_start()` to be definable by any crate, not just
libstd. Having a special language attribute in that case becomes
awkward.

So as a first step towards towards the next stabilization attempt, this
PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag
`-Zon-broken-pipe=...` to remove that concern, since now the language
is not "contaminated" by this feature.

Another point was also raised, namely that the ui should not leak
**how** it does things, but rather what the **end effect** is. The new
flag uses the proposed naming. This is of course something that can be
iterated on further before stabilization.
2024-05-02 19:48:29 +02:00
Ralf Jung ff2ff97904 variable-precision float operations behave non-deterministically 2024-05-02 18:57:30 +02:00
Ralf Jung dbe2f51d62 const_eval_select: add tracking issue 2024-05-02 18:39:27 +02:00
bors 80451a485b Auto merge of #124419 - WaffleLapkin:never-type-fallback-docs, r=workingjubilee
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-02 11:54:53 +00:00
Martin Nordholts 9af3b1eff4 library/std: Remove unused `gimli-symbolize` feature
library/backtrace also declares a feature called `gimli-symbolize` which
appear used, but the feature in std with the same name is unused, so
remove it.
2024-05-02 06:51:17 +02:00
Waffle Maybe e18b6e819e
fixup links in never type docs
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2024-05-02 06:04:16 +02:00
Mark Rousskov 44988e2577 Workaround rustfmt bug replacing type ascription 2024-05-01 23:23:00 -04:00
Waffle Lapkin e2eb053bba Slightly reformat !'s docs after applying github suggestions 2024-05-02 04:19:43 +02:00
Mark Rousskov a64f941611 Step bootstrap cfgs 2024-05-01 22:19:11 -04:00
Waffle Maybe 3a40e838bf
Apply suggestions from code review
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-02 04:13:57 +02:00
Mark Rousskov bd7d328807 Replace version placeholders for 1.79 2024-05-01 21:01:51 -04:00
George Bateman e610a52a62
Describe and use CStr literals in CStr and CString docs 2024-05-01 19:59:00 +01:00
Matthias Krüger 38cbad9d26
Rollup merge of #124542 - CBSpeir:diagnostic-item-enumerate-method, r=scottmcm
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-01 20:05:26 +02:00
bors 2e88e9e7d0 Auto merge of #124491 - madsmtm:target_vendor-apple, r=workingjubilee
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-05-01 02:11:29 +00:00
Christopher B. Speir c8079e9390 Add diagnostic item for std::iter::Iterator::enumerate 2024-04-29 17:36:31 -05:00
Matthias Krüger d94eabaf9b
Rollup merge of #124530 - djkoloski:fuchsia_dirfd, r=tmandry
Fix Fuchsia build broken by #124210

Fuchsia doesn't support dirfd although we have a symbol stubbed for it.
2024-04-29 22:37:51 +02:00
许杰友 Jieyou Xu (Joe) 0580588ec6
Rollup merge of #124484 - GKFX:offset_of_must_use, r=jieyouxu
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-29 18:03:24 +01:00
David Koloski 982a58e900 Fix Fuchsia build broken by #124210
Fuchsia doesn't support dirfd although we have a symbol stubbed for it.
2024-04-29 17:00:03 +00:00
ivmarkov fa6db4c428 Fix ESP IDF build broken by #124210 2024-04-29 06:17:02 +00:00
bors 5b1d58c9e2 Auto merge of #124502 - NCGThompson:statically-known-docs, r=jhpratt
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-29 03:00:12 +00:00
Nicholas Thompson 5969ad4cae 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.
2024-04-28 21:00:53 -04:00
Trevor Gross e0f8202ed5 Stabilize `non_null_convenience`
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-28 16:19:53 -05:00
Mads Marquart f9f3573b62 Fix posix_spawn not being used on iOS and visionOS
`man posix_spawn` documents it to be able to return `ENOENT`, and there
should be nothing preventing this. Tested in the iOS simulator and on
Mac Catalyst.
2024-04-28 22:34:51 +02:00
Mads Marquart 214d588a5b Fix va_list on watchOS and visionOS 2024-04-28 21:30:40 +02:00
Mads Marquart a6d9da6b2a Fix SIGEMT and SIGINFO parsing on watchOS and visionOS 2024-04-28 21:10:32 +02:00
Mads Marquart 79c6d91966 Fix available_parallelism on watchOS and visionOS
Both `sysconf` and `_SC_NPROCESSORS_ONLN` is available on all Apple platforms.
2024-04-28 21:10:32 +02:00
George Bateman ca79086c87
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.
2024-04-28 18:36:08 +01:00
Mads Marquart d9c0eb8084 Use `target_vendor = "apple"` instead of `target_os = "..."` 2024-04-28 18:22:37 +02:00
bors cb49406457 Auto merge of #124210 - the8472:consign-ebadf-to-the-fire, r=Mark-Simulacrum
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-28 06:20:28 +00:00
The 8472 1ba00d9cb2 put FD validity behind late debug_asserts checking
uses the same machinery as assert_unsafe_precondition
2024-04-28 01:44:25 +02:00
Matthias Krüger be8976022e
Rollup merge of #124447 - workingjubilee:set-argv-twice-on-gnu, r=ChrisDenton
Unconditionally call `really_init` on GNU/Linux

This makes miri not diverge in behavior, it fixes running Rust linux-gnu binaries on musl with gcompat, it fixes dlopen edge-cases that cranelift somehow hits, etc.

Fixes #124126

thou hast gazed into this abyss with me:
r? ``@ChrisDenton``
2024-04-28 01:25:02 +02:00
Jubilee Young fa73ebb303 Unconditionally call really_init
This makes miri not diverge in behavior, it fixes running Rust linux-gnu
binaries on musl with gcompat, it fixes dlopen edge-cases that cranelift
somehow hits, etc.
2024-04-27 11:33:15 -07:00
Tobias Bucher adebad1dce Elaborate in comment about `statx` probe
As requested by @workingjubilee in
https://github.com/rust-lang/rust/pull/123928#discussion_r1564916743.
2024-04-27 18:36:29 +02:00
JirCep f840da757f WS fix. 2024-04-27 17:18:25 +02:00
JirCep 825a3b1f09 String.truncate calls Vec.truncate, in turn, and that states
"is greater or equal to". Beside common sense.
2024-04-27 16:57:20 +02:00