Commit Graph

14620 Commits

Author SHA1 Message Date
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
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
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
bors 61a1dbd751 Auto merge of #124432 - zetanumbers:non_copy_into_raw_with_alloc, r=Nilstrieb
Relax `A: Clone` bound for `rc::Weak::into_raw_and_alloc`

Makes this method to behave the same way as [`Box::into_raw_with_allocator`](https://doc.rust-lang.org/1.77.2/alloc/boxed/struct.Box.html#method.into_raw_with_allocator) and [`Vec::into_raw_parts_with_alloc`](https://doc.rust-lang.org/1.77.2/alloc/vec/struct.Vec.html#method.into_raw_parts_with_alloc).

I have also noticed the inconsistent presence and naming, should probably be addressed in the future.
2024-04-27 13:41:45 +00:00
Daria Sukhonina 255a1e9554 Relax `A: Clone` bound for `rc::Weak::into_raw_and_alloc` 2024-04-27 12:21:23 +03:00
Matthias Krüger 7c5213cf0a
Rollup merge of #124387 - workingjubilee:use-raw-pointers-in-thread-locals, r=joboet
thread_local: be excruciatingly explicit in dtor code

Use raw pointers to accomplish internal mutability, and clearly split references where applicable. This reduces the likelihood that any of these parts are misunderstood, either by humans or the compiler's optimizations.

Fixes #124317

r? ``@joboet``
2024-04-27 07:55:38 +02:00
Jubilee c63b0ceb94
thread_local: refine LazyKeyInner::take safety doc
Co-authored-by: joboet <jonasboettiger@icloud.com>
2024-04-26 18:28:46 -07:00
Jacob Pratt 7cbba53396
Rollup merge of #124410 - RalfJung:path-buf-transmute, r=Nilstrieb
PathBuf: replace transmuting by accessor functions

The existing `repr(transparent)` was anyway insufficient as `OsString` was not `repr(transparent)`. And furthermore, on Windows it was blatantly wrong as `OsString` wraps `Wtf8Buf` which is a `repr(Rust)` type with 2 fields:

51a7396ad3/library/std/src/sys_common/wtf8.rs (L131-L146)

So let's just be honest about what happens and add accessor methods that make this abstraction-breaking act of PathBuf visible on the APIs that it pierces through.

Fixes https://github.com/rust-lang/rust/issues/124409
2024-04-26 19:25:57 -04:00
Waffle Maybe b73bfd26e4
Apply suggestions from code review
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2024-04-27 00:47:23 +02:00
Waffle Lapkin 23b67de151 Document never type fallback in `!`'s docs 2024-04-26 20:49:34 +02:00
bors 4d570eea02 Auto merge of #123909 - dtolnay:utf8chunks, r=joboet
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-26 17:41:24 +00:00
Ralf Jung c47978a241 PathBuf: replace transmuting by accessor functions 2024-04-26 18:09:09 +02:00
bors 5ff8fbb2d8 Auto merge of #124393 - scottmcm:do-the-macros-still-matter, r=joboet
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-26 11:16:05 +00:00
Scott McMurray cd47a0ed08 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.
2024-04-25 22:16:02 -07:00
Michael Goulet 6f5c69e65f
Rollup merge of #124076 - NobodyXu:patch-1, r=dtolnay
Stablise io_error_downcast

Tracking issue #99262
Closes #99262

FCP completed in https://github.com/rust-lang/rust/issues/99262#issuecomment-2077374397
2024-04-25 20:07:40 -04:00
Jubilee Young 43f21a6871 thread_local: split refs to fields of Key 2024-04-25 12:45:21 -07:00
Jubilee Young 538ddb0ac2 thread_local: use less &mut T in LazyKeyInner::take
Instead, use raw pointers to accomplish internal mutability throughout.
2024-04-25 12:33:09 -07:00
lcnr ce70584753 remove trivial bounds 2024-04-25 17:31:00 +00:00
David Tolnay 61cf00464e
Stabilize Utf8Chunks 2024-04-24 15:27:47 -07:00
Matthias Krüger 62bc38dd65
Rollup merge of #124351 - Treeniks:master, r=workingjubilee
fix typo in binary_heap docs

There was an extra "the" that should not be there.
2024-04-25 00:19:56 +02:00
Matthias Krüger ecf794bc69
Rollup merge of #124335 - ChrisDenton:stabilize-absolute, r=dtolnay
Stabilize `std::path::absolute`

FCP complete in https://github.com/rust-lang/rust/issues/92750#issuecomment-2075046985
2024-04-25 00:19:56 +02:00
Matthias Krüger 177139032a
Rollup merge of #124322 - whosehang:master, r=Nilstrieb
chore: fix some typos in comments
2024-04-25 00:19:54 +02:00
Thomas Lindae d3bbdcf26c fix typo in binary_heap docs 2024-04-24 22:59:39 +02:00
bors ef8b9dcf23 Auto merge of #124330 - fmease:rollup-a98y7jf, r=fmease
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-24 19:26:50 +00:00
Chris Denton f56afa0477
Stabilize `std::path::absolute` 2024-04-24 14:35:02 +00:00