Commit Graph

14707 Commits

Author SHA1 Message Date
Oli Scherer 821d23b329 Ensure miri only uses fallback bodies that have manually been vetted to preserve all UB that the native intrinsic would have 2024-05-03 09:16:57 +00: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
Ross Smyth 6967d1c0fc Stabilize exclusive_range 2024-05-02 19:42:31 -04: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
Trevor Spiteri 30d787ae9b add constants in std::f128::consts 2024-05-02 15:13:30 +02:00
Trevor Spiteri 5ea4873fbe add constants in std::f16::consts 2024-05-02 15:13:30 +02:00
Trevor Spiteri 96f6b0be57 add f128 associated constants
NaN and infinity are not included as they require arithmetic.
2024-05-02 15:13:30 +02:00
Trevor Spiteri f679a9e79c add f16 associated constants
NaN and infinity are not included as they require arithmetic.
2024-05-02 15:13:30 +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
joboet a56fd370fc
std: move thread parking to `sys::sync` 2024-05-02 12:38:26 +02: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
Tobias Bucher a0f8ada69e Document that `create_dir_all` calls `mkdir`/`CreateDirW` multiple times
Also mention that there might be leftover directories in the error case.
2024-04-29 21:22:34 +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
Ryan Lowe 419924d878 Run tidy on tests 2024-04-28 18:04:25 -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
Ryan Lowe ed9d6e0c03 Move various stdlib tests to library/std/tests 2024-04-28 16:10:12 -04: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
David Carlier a25b0946a7
std::net: Socket::new_raw set to SO_NOSIGPIPE on freebsd/netbsd/dragonfly. 2024-04-28 17:44:42 +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
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
Ralf Jung 6b6bc9805d io safety: update Unix explanation 2024-04-27 09:40:55 +02: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
Jacob Trueb 3ad0618076 Fix cannot usage in time.rs 2024-04-24 17:37:44 +00:00
Chris Denton f56afa0477
Stabilize `std::path::absolute` 2024-04-24 14:35:02 +00:00
Gary Guo f8a1cad07c Add `cfg_attr(bootstrap)` to doc tests 2024-04-24 13:12:33 +01:00
Gary Guo 94c1920497 Stabilise `inline_const` 2024-04-24 13:12:25 +01:00
León Orell Valerian Liehr eaeaeb92a5
Rollup merge of #124308 - CBSpeir:diagnostic-item-enumerate, r=compiler-errors
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-24 14:00:58 +02:00
León Orell Valerian Liehr 388dc0d0b7
Rollup merge of #124282 - RalfJung:fill_utf16_buf, r=ChrisDenton
windows fill_utf16_buf: explain the expected return value

The comment just says "return what the syscall returns", but that doesn't work for all syscalls as the Windows API is not consistent in how buffer size is negotiated. For instance, GetUserProfileDirectoryW works a bit differently, and so home_dir_crt has to translate this to the usual protocol itself. So it's worth describing that protocol.

r? ``@ChrisDenton``
2024-04-24 14:00:57 +02:00
León Orell Valerian Liehr 4eda87603d
Rollup merge of #124281 - RalfJung:win-tls, r=joboet
fix weak memory bug in TLS on Windows

We need to store the `key` *after* we register the dtor.

Now I hope there isn't also some other reason why we have to actually register the dtor last... `@joboet` is there a reason you picked this particular order in https://github.com/rust-lang/rust/pull/102655?

Fixes https://github.com/rust-lang/rust/issues/123583
2024-04-24 14:00:57 +02:00
Oli Scherer aef0f4024a Error on using `yield` without also using `#[coroutine]` on the closure
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +00:00
whosehang 65d7c1d2d6 chore: fix some typos in comments
Signed-off-by: whosehang <whosehang@outlook.com>
2024-04-24 13:58:51 +08:00
Christopher B. Speir bcc4469c2b Add diagnostic item for std::iter::Enumerate 2024-04-23 16:50:10 -05:00
bors 40dcd796d0 Auto merge of #124302 - matthiaskrgr:rollup-2aya8n8, r=matthiaskrgr
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-23 18:23:46 +00:00
Matthias Krüger 918304b190
Rollup merge of #124003 - WaffleLapkin:dellvmization, r=scottmcm,RalfJung,antoyo
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-23 20:17:51 +02:00
León Orell Valerian Liehr 2d7d480054
Rollup merge of #123048 - RalfJung:layout, r=dtolnay
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-23 17:25:16 +02:00
Matthias Krüger 72e8fb4268
Rollup merge of #123050 - RalfJung:panic_str, r=m-ou-se
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-23 12:10:25 +02:00
Ralf Jung d5d714bb34 fix weak memory bug in TLS on Windows 2024-04-23 10:42:45 +02:00
Ralf Jung a21c2d8704 windows fill_utf16_buf: explain the expected return value 2024-04-23 09:32:35 +02:00
Matthias Krüger 819b4d5e5b
Rollup merge of #124266 - RalfJung:no-answer, r=joboet
remove an unused type from the reentrant lock tests

At least it seems unused. This was added back in 45aa6c8d1b together with a test related to poisoning; when the test got removed, it seems like it was forgotten to also remove this type.
2024-04-23 06:24:58 +02:00
bors aca749eefc Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obk
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-23 02:10:23 +00:00
Guillaume Gomez 6a326d889a
Rollup merge of #124230 - reitermarkus:generic-nonzero-stable, r=dtolnay
Stabilize generic `NonZero`.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

r? `@dtolnay`
2024-04-22 20:26:00 +02:00
Guillaume Gomez 206e0df78d
Rollup merge of #115913 - FedericoStra:checked_ilog, r=the8472
checked_ilog: improve performance

Addresses #115874.

(This PR replicates the original #115875, which I accidentally closed by deleting my forked repository...)
2024-04-22 20:25:58 +02:00
Ralf Jung df437a2af4 remove an unused type from the reentrant lock tests 2024-04-22 19:36:21 +02:00
The 8472 25babe9a79 export assert_unsafe_precondition macro for std-internal use 2024-04-22 19:02:37 +02:00
Markus Reiter 33e68aadc9
Stabilize generic `NonZero`. 2024-04-22 18:48:47 +02:00
Matthias Krüger c597ccf3f1
Rollup merge of #124246 - gurry:add-comma-in-abs-doc, r=jhpratt
Add comma at one place in `abs()` documentation

As suggested  by ``@RalfJung`` here: https://github.com/rust-lang/rust/pull/124184#discussion_r1573670533
2024-04-22 10:02:56 +02:00