Commit Graph

14985 Commits

Author SHA1 Message Date
bors
eda9d7f987 Auto merge of #125577 - devnexen:netbsd_stack_min, r=joboet
std::pal::unix::thread fetching min stack size on netbsd.

PTHREAD_STACK_MIN is not defined however sysconf/_SC_THREAD_STACK_MIN returns it as it can vary from arch to another.
2024-06-02 15:42:33 +00:00
bors
12b5d3c29c Auto merge of #124294 - tspiteri:ilog-first-iter, r=the8472
Unroll first iteration of checked_ilog loop

This follows the optimization of #115913. As shown in https://github.com/rust-lang/rust/pull/115913#issuecomment-2066788006, the performance was improved in all important cases, but some regressions were introduced for the benchmarks `u32_log_random_small`, `u8_log_random` and `u8_log_random_small`.

Basically, #115913 changed the implementation from one division per iteration to one multiplication per iteration plus one division. When there are zero iterations, this is a regression from zero divisions to one division.

This PR avoids this by avoiding the division if we need zero iterations by returning `Some(0)` early. It also reduces the number of multiplications by one in all other cases.
2024-06-02 00:05:32 +00:00
coekjan
7cee7c664b
stablize const_binary_heap_constructor & create an unstable feature const_binary_heap_new_in for BinaryHeap::new_in 2024-06-01 12:44:19 +08:00
Matthias Krüger
e9046602c5
Rollup merge of #125730 - mu001999-contrib:clippy-fix, r=oli-obk
Apply `x clippy --fix` and `x fmt` on Rustc

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->

Just run `x clippy --fix` and `x fmt`, and remove some changes like `impl Default`.
2024-05-31 17:05:24 +02:00
bors
99cb42c296 Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk
Implement `needs_async_drop` in rustc and optimize async drop glue

This PR expands on #121801 and implements `Ty::needs_async_drop` which works almost exactly the same as `Ty::needs_drop`, which is needed for #123948.

Also made compiler's async drop code to look more like compiler's regular drop code, which enabled me to write an optimization where types which do not use `AsyncDrop` can simply forward async drop glue to `drop_in_place`. This made size of the async block from the [async_drop test](67980dd6fb/tests/ui/async-await/async-drop.rs) to decrease by 12%.
2024-05-31 10:12:24 +00:00
bors
91c0823ee6 Auto merge of #124636 - tbu-:pr_env_unsafe, r=petrochenkov
Make `std::env::{set_var, remove_var}` unsafe in edition 2024

Allow calling these functions without `unsafe` blocks in editions up until 2021, but don't trigger the `unused_unsafe` lint for `unsafe` blocks containing these functions.

Fixes #27970.
Fixes #90308.
CC #124866.
2024-05-30 12:17:06 +00:00
Matthias Krüger
a4d00ff8e4
Rollup merge of #125746 - jmillikin:duration-from-weeks-typo, r=lqd
Fix copy-paste error in `Duration::from_weeks` panic message.
2024-05-30 10:23:08 +02:00
Matthias Krüger
60c2d80482
Rollup merge of #125739 - RalfJung:drop-in-place-docs, r=workingjubilee
drop_in_place: weaken the claim of equivalence with drop(ptr.read())

The two are *not* semantically equivalent in all cases, so let's not be so definite about this.

Fixes https://github.com/rust-lang/rust/issues/112015
2024-05-30 10:23:07 +02:00
Matthias Krüger
70e7b49cf2
Rollup merge of #125342 - tbu-:pr_doc_write, r=ChrisDenton
Document platform-specifics for `Read` and `Write` of `File`
2024-05-30 10:23:06 +02:00
Ralf Jung
5c68a15e41 explain what the open questions are, and add a Miri test for that 2024-05-30 09:07:06 +02:00
r0cky
dabd05bbab Apply x clippy --fix and x fmt 2024-05-30 09:51:27 +08:00
John Millikin
a8234d5f87 Fix copy-paste error in Duration::from_weeks panic message. 2024-05-30 08:40:48 +09:00
León Orell Valerian Liehr
1ae1388d2a
Rollup merge of #125733 - compiler-errors:async-fn-assoc-item, r=fmease
Add lang items for `AsyncFn*`, `Future`, `AsyncFnKindHelper`'s associated types

Adds lang items for `AsyncFnOnce::Output`, `AsyncFnOnce::CallOnceFuture`, `AsyncFnMut::CallRefFuture`, and uses them in the new solver. I'm mostly interested in doing this to help accelerate uplifting the new trait solver into a separate crate.

The old solver is kind of spaghetti, so I haven't moved that to use these lang items (i.e. it still uses `item_name`-based comparisons).

update: Also adds lang items for `Future::Output` and `AsyncFnKindHelper::Upvars`.

cc ``@lcnr``
2024-05-30 01:12:37 +02:00
Tobias Bucher
d7680e3556 Elaborate about modifying env vars in multi-threaded programs 2024-05-29 23:42:27 +02:00
Tobias Bucher
8cf4980648 Add note about safety of std::env::set_var on Windows 2024-05-29 23:42:27 +02:00
Tobias Bucher
5d8f9b4dc1 Make std::env::{set_var, remove_var} unsafe in edition 2024
Allow calling these functions without `unsafe` blocks in editions up
until 2021, but don't trigger the `unused_unsafe` lint for `unsafe`
blocks containing these functions.

Fixes #27970.
Fixes #90308.
CC #124866.
2024-05-29 23:42:27 +02:00
Ralf Jung
5c497cb3f0 drop_in_place: weaken the claim of equivalence with drop(ptr.read()) 2024-05-29 21:53:44 +02:00
Michael Goulet
a03ba7fd2d Add lang item for AsyncFnKindHelper::Upvars 2024-05-29 14:28:53 -04:00
Michael Goulet
a9c7e024c0 Add lang item for Future::Output 2024-05-29 14:22:56 -04:00
Michael Goulet
7f11d6f4bf Add lang items for AsyncFn's associated types 2024-05-29 14:09:19 -04:00
Scott McMurray
0d63e6b608 [ACP 362] genericize ptr::from_raw_parts 2024-05-29 09:34:16 -07:00
Daria Sukhonina
2892302aef Add safety comment to fix tidy 2024-05-29 12:57:01 +03:00
Daria Sukhonina
7cdd95e1a6 Optimize async drop glue for some old types 2024-05-29 12:56:59 +03:00
许杰友 Jieyou Xu (Joe)
3cc59aeaae
Rollup merge of #125226 - madsmtm:fix-mac-catalyst-tests, r=workingjubilee
Make more of the test suite run on Mac Catalyst

Combined with https://github.com/rust-lang/rust/pull/125225, the only failing parts of the test suite are in `tests/rustdoc-js`, `tests/rustdoc-js-std` and `tests/debuginfo`. Tested with:
```console
./x test --target=aarch64-apple-ios-macabi library/std
./x test --target=aarch64-apple-ios-macabi --skip=tests/rustdoc-js --skip=tests/rustdoc-js-std --skip=tests/debuginfo tests
```

Will probably put up a PR later to enable _running_ on (not just compiling for) Mac Catalyst in CI, though not sure where exactly I should do so? `src/ci/github-actions/jobs.yml`?

Note that I've deliberately _not_ enabled stack overflow handlers on iOS/tvOS/watchOS/visionOS (see https://github.com/rust-lang/rust/issues/25872), but rather just skipped those tests, as it uses quite a few APIs that I'd be weary about getting rejected by the App Store (note that Swift doesn't do it on those platforms either).

r? ``@workingjubilee``

CC ``@thomcc``

``@rustbot`` label O-ios O-apple
2024-05-29 03:25:08 +01:00
许杰友 Jieyou Xu (Joe)
2d3b1e014b
Rollup merge of #124251 - scottmcm:unop-ptr-metadata, r=oli-obk
Add an intrinsic for `ptr::metadata`

The follow-up to #123840, so we can remove `PtrComponents` and `PtrRepr` from libcore entirely (well, after a bootstrap update).

As discussed in <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/.60ptr_metadata.60.20in.20MIR/near/435637808>, this introduces `UnOp::PtrMetadata` taking a raw pointer and returning the associated metadata value.

By no longer going through a `union`, this should also help future PRs better optimize pointer operations.

r? ``@oli-obk``
2024-05-29 03:25:07 +01:00
Scott McMurray
7150839552 Add custom mir support for PtrMetadata 2024-05-28 09:28:51 -07:00
Scott McMurray
459ce3f6bb Add an intrinsic for ptr::metadata 2024-05-28 09:28:51 -07:00
Matthias Krüger
faabc74625
Rollup merge of #125637 - nnethercote:rustfmt-fixes, r=GuillaumeGomez
rustfmt fixes

The `rmake.rs` entries in `rustfmt.toml` are causing major problems for `x fmt`. This PR removes them and does some minor related cleanups.

r? ``@GuillaumeGomez``
2024-05-28 18:04:33 +02:00
Mads Marquart
e6b9bb7b72 Make more of the test suite run on Mac Catalyst
This adds the `only-apple`/`ignore-apple` compiletest directive, and
uses that basically everywhere instead of `only-macos`/`ignore-macos`.

Some of the updates in `run-make` are a bit redundant, as they use
`ignore-cross-compile` and won't run on iOS - but using Apple in these
is still more correct, so I've made that change anyhow.
2024-05-28 12:31:33 +02:00
Mads Marquart
37ae2b68b1 Disable stack overflow handler tests on iOS-like platforms 2024-05-28 12:31:12 +02:00
Nicholas Nethercote
f1b0ca08a4 Don't format tests/run-make/*/rmake.rs.
It's reasonable to want to, but in the current implementation this
causes multiple problems.

- All the `rmake.rs` files are formatted every time even when they
  haven't changed. This is because they get whitelisted unconditionally
  in the `OverrideBuilder`, before the changed files get added.

- The way `OverrideBuilder` works, if any files gets whitelisted then no
  unmentioned files will get traversed. This is surprising, and means
  that the `rmake.rs` entries broke the use of explicit paths to `x
  fmt`, and also broke `GITHUB_ACTIONS=true git check --fmt`.

The commit removes the `rmake.rs` entries, fixes the formatting of a
couple of files that were misformatted (not previously caught due to the
`GITHUB_ACTIONS` breakage), and bans `!`-prefixed entries in
`rustfmt.toml` because they cause all these problems.
2024-05-28 19:28:46 +10:00
Jubilee
4aaf9f645e
Rollup merge of #125647 - tspiteri:track-lazy_cell_consume, r=workingjubilee
update tracking issue for lazy_cell_consume

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
2024-05-28 02:07:49 -07:00
Jubilee
941bf8bee1
Rollup merge of #125551 - clarfonthey:ip-bits, r=jhpratt
Stabilise `IpvNAddr::{BITS, to_bits, from_bits}` (`ip_bits`)

This completed FCP in #113744. (Closes #113744.)

Stabilises the following APIs:

```rust
impl Ipv4Addr {
    pub const BITS: u32 = 32;
    pub const fn from_bits(bits: u32) -> Ipv4Addr;
    pub const fn to_bits(self) -> u32;
}

impl Ipv6Addr {
    pub const BITS: u32 = 128;
    pub const fn from_bits(bits: u128) -> Ipv4Addr;
    pub const fn to_bits(self) -> u128;
}
```
2024-05-28 02:07:48 -07:00
Trevor Spiteri
402a649e75 update tracking issue for lazy_cell_consume 2024-05-28 11:02:03 +02:00
bors
c0d600385b Auto merge of #125636 - workingjubilee:bump-backtrace-0.3.72, r=workingjubilee
Bump backtrace to 0.3.72

This removes a bunch of dead code, contains critical aarch64-windows fixes, some less-critical windows-in-general improvements, adds visionOS support (and probably improves support for a bunch of Apple platforms...), and harmonizes backtrace's dependencies with rustc/std's.

See https://github.com/rust-lang/backtrace-rs/compare/0.3.71...0.3.72

r? `@ghost`
2024-05-28 04:58:04 +00:00
Jubilee Young
3ec9d8db27 Sync libstd deps with backtrace 2024-05-27 19:53:41 -07:00
Jubilee Young
00b759530e Bump backtrace to 0.3.72 2024-05-27 19:53:31 -07:00
bors
d86e122941 Auto merge of #125609 - diondokter:opt-size-char-count, r=thomcc
Always use the general case char count with `optimize_for_size`

The faster algo is really expensive, over a kilobyte if the full algo is present in a binary.
With this PR the general case algo is picked always instead of only for small strings.

In a test of mine this change makes the total binary go from 3116 bytes to 2032 bytes in opt-level 3 and from 1652 bytes to 1428 bytes in opt-level z. I've seen it much worse in real application, so the savings (especially on 'z') will be higher in many cases.

This is the second pr of this kind after #125606
2024-05-28 02:47:32 +00:00
Guillaume Gomez
6dddc888fc
Rollup merge of #124870 - Lokathor:update-result-docs, r=dtolnay
Update Result docs to the new guarantees

The `Option` docs already explain the guarantees given in [RFC 3391](https://github.com/rust-lang/rfcs/blob/master/text/3391-result_ffi_guarantees.md), so all that we need is a paragraph saying that some `Result` type combinations will also qualify.

Part of https://github.com/rust-lang/rust/issues/110503
2024-05-27 13:10:33 +02:00
Dion Dokter
05fa647dc7 Always use the general case char count 2024-05-27 12:05:00 +02:00
Jubilee
25b079a1cf
Rollup merge of #125559 - scottmcm:simplify-shift-ubcheck, r=workingjubilee
Simplify the `unchecked_sh[lr]` ub-checks a bit

It can use the constant in the check, rather than passing it as a parameter.
2024-05-26 15:28:28 -07:00
bors
b0925697fd Auto merge of #122079 - tbu-:pr_copy_file_range_probe, r=the8472
Less syscalls for the `copy_file_range` probe

If it's obvious from the actual syscall results themselves that the syscall is supported or unsupported, don't do an extra syscall with an invalid file descriptor.

CC #122052
2024-05-26 15:48:29 +00:00
David Carlier
073e5d4a2a std::pal::unix::thread fetching min stack size on netbsd.
PTHREAD_STACK_MIN is not defined however sysconf/_SC_THREAD_STACK_MIN
returns it as it can vary from arch to another.
2024-05-26 14:35:26 +00:00
bors
785eb65377 Auto merge of #125574 - matthiaskrgr:rollup-1oljoup, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #125307 (tidy: stop special-casing tests/ui entry limit)
 - #125375 (Create a triagebot ping group for Rust for Linux)
 - #125473 (fix(opt-dist): respect existing config.toml)
 - #125508 (Stop SRoA'ing `DynMetadata` in MIR)
 - #125561 (Stabilize `slice_flatten`)
 - #125571 (f32: use constants instead of reassigning a dummy value as PI)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-26 13:09:58 +00:00
Matthias Krüger
27cdb36ec5
Rollup merge of #125571 - tesuji:dummy-pi, r=Nilstrieb
f32: use constants instead of reassigning a dummy value as PI
2024-05-26 13:43:08 +02:00
Matthias Krüger
f775fffac5
Rollup merge of #125561 - Cyborus04:stabilize-slice-flatten, r=scottmcm
Stabilize `slice_flatten`
2024-05-26 13:43:07 +02:00
bors
a6a017d3f3 Auto merge of #125570 - tesuji:stdout-handle, r=Nilstrieb
Use STD_OUTPUT_HANDLE instead of magic number
2024-05-26 10:57:58 +00:00
Lzu Tao
96a731e5b8 f32: use constants instead of reassigning a dummy value as PI 2024-05-26 09:32:39 +00:00
Lzu Tao
b06b122d8c use proper name instead of magic number 2024-05-26 09:19:18 +00:00
Cyborus
824ffd29ee
Stabilize slice_flatten 2024-05-26 01:26:24 -04:00