Commit Graph

16252 Commits

Author SHA1 Message Date
Matthias Krüger b9dfb4d6f8
Rollup merge of #129592 - saethlin:core-cfg-test, r=tgross35
Remove cfg(test) from library/core

The diff here is very small with the ignore whitespace option.

`core` doesn't/can't have unit tests. All of its tests are just modules under `tests/`, so it has no use for `cfg(test)`, because the entire contents of `library/core/src` are only ever compiled with that cfg off, and the entire contents of `library/core/tests` are only ever compiled with that cfg on.

You can tell this is what's happening because we had `#[cfg(test)]` on a module declaration that has no source file.

I also deleted the extra `mod tests {` layer of nesting; there's no need to mention again in the module path that this is a module of tests. This exposes a name collision between the `u128` module of tests and `core::u128`. Fixed that by using `<u128>::MAX` like is done in the `check!` macro, which is what avoids this name ambiguity for the other types.
2024-08-26 17:25:33 +02:00
Matthias Krüger d0b3c3a110
Rollup merge of #129588 - hermit-os:sleep-micros, r=workingjubilee
pal/hermit: correctly round up microseconds in `Thread::sleep`

This fixes the Hermit-related part of https://github.com/rust-lang/rust/issues/129212 and thus the whole issue, since ESP-IDF is already fixed, as far as I understand.

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

r? `@workingjubilee`

CC: `@stlankes`
2024-08-26 17:25:32 +02:00
Matthias Krüger b1c9064071
Rollup merge of #129539 - oconnor663:poll_link, r=tgross35
link to Future::poll from the Poll docs

The most important thing about Poll is that Future::poll returns it, but previously the docs didn't emphasize this.
2024-08-26 17:25:32 +02:00
Matthias Krüger 68aff290fd
Rollup merge of #129377 - chorman0773:unbounded-shifts-impl, r=scottmcm
Add implementations for `unbounded_shl`/`unbounded_shr`

Tracking Issue: https://github.com/rust-lang/rust/issues/129375

This implements `unbounded_shl` and `unbounded_shr` under the feature gate `unbounded_shifts`
2024-08-26 17:25:31 +02:00
Ralf Jung 0c7d6c45e6 also update copysign docs 2024-08-26 17:25:24 +02:00
Ralf Jung 53d4544628 move per-target NaN info into a table 2024-08-26 17:20:40 +02:00
Ralf Jung fe2975076f float types: document NaN bit pattern guarantees 2024-08-26 17:20:40 +02:00
bors f48062e7d0 Auto merge of #129595 - matthiaskrgr:rollup-4udn7nn, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #129288 (Use subtyping for `UnsafeFnPointer` coercion, too)
 - #129405 (Fixing span manipulation and indentation of the suggestion introduced by #126187)
 - #129518 (gitignore: ignore ICE reports regardless of directory)
 - #129519 (Remove redundant flags from `lower_ty_common` that can be inferred from the HIR)
 - #129525 (rustdoc: clean up tuple <-> primitive conversion docs)
 - #129526 (Use `FxHasher` on new solver unconditionally)
 - #129544 (Removes dead code from the compiler)
 - #129553 (add back test for stable-const-can-only-call-stable-const)
 - #129590 (Avoid taking reference of &TyKind)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-26 05:45:40 +00:00
Ben Kimock 4f3ef2ac90 Remove cfg(test) from library/core 2024-08-25 20:04:26 -04:00
Matthias Krüger c6e00680ac
Rollup merge of #129544 - mu001999-contrib:dead-code/clean, r=compiler-errors
Removes dead code from the compiler

Detected by #128637
2024-08-26 01:49:03 +02:00
Matthias Krüger aa26e1ad97
Rollup merge of #129525 - notriddle:notriddle/fake-variadic-tuple-array, r=GuillaumeGomez
rustdoc: clean up tuple <-> primitive conversion docs

This adds a minor missing feature to `fake_variadic`, so that it can render `impl From<(T,)> for [T; 1]` correctly.
2024-08-26 01:49:02 +02:00
bors 3f121b9461 Auto merge of #129488 - saethlin:alignment-precondition, r=workingjubilee
Enable Alignment::new_unchecked precondition check

Similar to what happened with https://github.com/rust-lang/rust/pull/126556, I think this has become palatable since https://github.com/rust-lang/rust/pull/126793.
2024-08-25 23:45:25 +00:00
Martin Kröning edeefc532f
pal/hermit: saturate `usleep` microseconds at `u64::MAX`
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-26 00:04:00 +02:00
bors c6db1ca3c9 Auto merge of #129563 - matthiaskrgr:rollup-t6bai2d, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #129091 (add Box::as_ptr and Box::as_mut_ptr methods)
 - #129134 (bootstrap: improve error recovery flags to curl)
 - #129416 (library: Move unstable API of new_uninit to new features)
 - #129459 (handle stage0 `cargo` and `rustc` separately)
 - #129487 (repr_transparent_external_private_fields: special-case some std types)
 - #129511 (Update minifier to 0.3.1)
 - #129523 (Make `rustc_type_ir` build on stable)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-25 20:29:33 +00:00
Ben Kimock b1c2c78d29 Tweak some attributes to improve panic_immediate_abort 2024-08-25 14:52:53 -04:00
Martin Kröning 687c8a1eab
pal/hermit: correctly round up microseconds in `Thread::sleep`
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-25 20:49:23 +02:00
Ralf Jung 21dd88f963 exit: explain our expectations for the exit handlers registered in a Rust program 2024-08-25 17:46:26 +02:00
Jack O'Connor 3153b7d7b4 link to Future::poll from the Poll docs
The most important thing about Poll is that Future::poll returns it, but
previously the docs didn't emphasize this.
2024-08-25 08:35:06 -07:00
Matthias Krüger 9c59e97ded
Rollup merge of #129487 - GrigorenkoPV:repr_transparent_external_private_fields, r=compiler-errors
repr_transparent_external_private_fields: special-case some std types

Fixes #129470

```@rustbot``` label +A-lint +L-repr_transparent_external_private_fields
2024-08-25 16:51:05 +02:00
Matthias Krüger 0e2523eaf8
Rollup merge of #129416 - workingjubilee:partial-move-from-stabilization, r=dtolnay
library: Move unstable API of new_uninit to new features

- `new_zeroed` variants move to `new_zeroed_alloc`
- the `write` fn moves to `box_uninit_write`

The remainder will be stabilized in upcoming patches, as it was decided to only stabilize `uninit*` and `assume_init`.
2024-08-25 16:51:04 +02:00
Matthias Krüger 7edbd6353b
Rollup merge of #129091 - RalfJung:box_as_ptr, r=Amanieu
add Box::as_ptr and Box::as_mut_ptr methods

Unstably implements https://github.com/rust-lang/libs-team/issues/355. Tracking issue: https://github.com/rust-lang/rust/issues/129090.

r? libs-api
2024-08-25 16:51:03 +02:00
bors 1a94d839be Auto merge of #129295 - Zalathar:profiler-builtins, r=Kobzol
Build `library/profiler_builtins` from `ci-llvm` if appropriate

Running all of `tests/coverage` requires the LLVM profiler runtime, which requires setting `build.profiler = true`.

Historically, doing that has required checking out the entire `src/llvm-project` submodule. For compiler contributors who otherwise don't need that submodule (thanks to `download-ci-vm`), that's quite inconvenient.

However, thanks to #129116, the downloaded CI LLVM tarball now contains a copy of LLVM's `compiler-rt` directory, which includes all the files needed to build the profiler runtime. So with a little bit of extra logic in bootstrap, we can have `library/profiler_builtins` look for the `compiler-rt` files in `ci-llvm` instead of the `src/llvm-project` submodule.
2024-08-25 14:44:55 +00:00
Ralf Jung a772db4206 ub_checks intrinsics: fall back to cfg(ub_checks) 2024-08-25 13:15:48 +02:00
bors 717aec0f8e Auto merge of #129521 - matthiaskrgr:rollup-uigv77m, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #128596 (stabilize const_fn_floating_point_arithmetic)
 - #129199 (make writes_through_immutable_pointer a hard error)
 - #129246 (Retroactively feature gate `ConstArgKind::Path`)
 - #129290 (Pin `cc` to 1.0.105)
 - #129323 (Implement `ptr::fn_addr_eq`)
 - #129500 (remove invalid `TyCompat` relation for effects)
 - #129501 (panicking: improve hint for Miri's RUST_BACKTRACE behavior)
 - #129505 (interpret: ImmTy: tighten sanity checks in offset logic)
 - #129510 (Fix `elided_named_lifetimes` in code)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-25 08:12:16 +00:00
mu001999 e7f11b6913 Removes dead code from the compiler 2024-08-25 13:41:39 +08:00
Trevor Gross 678193f7d1
Rollup merge of #129481 - scottmcm:update-cb, r=tgross35
Update `compiler_builtins` to `0.1.121`

To pick up https://github.com/rust-lang/compiler-builtins/pull/673 and unblock https://github.com/rust-lang/rust/pull/129403

r? tgross35
2024-08-24 21:03:33 -05:00
Trevor Gross e96faab70b
Rollup merge of #129449 - coolreader18:pin-as_deref_mut-signature, r=dtolnay
Put Pin::as_deref_mut in impl Pin<Ptr> / rearrange Pin methods

Tracking issue: #86918

Based on the suggestion in https://github.com/rust-lang/rust/issues/86918#issuecomment-2189367582

> Some advantages:
>
>  * Synergy with the existing `as_ref` and `as_mut` signatures (stable since Rust 1.33)
>
>  * Lifetime elision reduces noise in the signature
>
>  * Turbofish less verbose: `Pin::<&mut T>::as_deref_mut` vs `Pin::<&mut Pin<&mut T>>::as_deref_mut`

The comment seemed to imply that `Pin::as_ref` and `Pin::as_mut` already share an impl block, which they don't. So, I rearranged it so that they do, and we can see which looks better in the docs.

<details><summary><b>Docs screenshots</b></summary>

Current nightly:
![image](https://github.com/user-attachments/assets/b432cb82-8f4b-48ae-bafc-2fe49d0ad48c)

`Pin::as_deref_mut` moved into the same block as `as_mut`:
![image](https://github.com/user-attachments/assets/f9b35722-6a88-4465-ad1c-28d8e91902ac)

`Pin::as_ref`, `as_mut`, and `as_deref_mut` all in the same block:
![image](https://github.com/user-attachments/assets/9a1b2bf0-70a6-4751-b13f-390f1d575244)

</details>

I think I like the last one the most; obviously I'm biased since I'm the one who rearranged it, but it doesn't make sense to me to have `as_ref` methods split up by an `into_inner` method.

r? dtolnay
2024-08-24 21:03:33 -05:00
Trevor Gross 198a68df1c
Rollup merge of #128735 - jieyouxu:pr-120176-revive, r=cjgillot
Add a special case for `CStr`/`CString` in the `improper_ctypes` lint

Revives #120176. Just needed to bless a test and fix an argument, but seemed reasonable to me otherwise.

Instead of saying to "consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct", we now tell users to "Use `*const ffi::c_char` instead, and pass the value from `CStr::as_ptr()`" when the type involved is a `CStr` or a `CString`.

The suggestion is not made for `&mut CString` or `*mut CString`.

r? ``````@cjgillot`````` (since you were the reviewer of the original PR #120176, but feel free to reroll)
2024-08-24 21:03:31 -05:00
Michael Howell 6df0ccf49e rustdoc: clean up tuple <-> primitive conversion docs
This adds a minor missing feature to `fake_variadic`,
so that it can render `impl From<(T,)> for [T; 1]` correctly.
2024-08-24 14:06:57 -07:00
Matthias Krüger 5611b3714f
Rollup merge of #129501 - RalfJung:miri-rust-backtrace, r=Noratrieb
panicking: improve hint for Miri's RUST_BACKTRACE behavior

Should help with https://github.com/rust-lang/miri/issues/3838
2024-08-24 22:14:14 +02:00
Matthias Krüger 3f5d6b2e40
Rollup merge of #129500 - fee1-dead-contrib:fxrel, r=compiler-errors
remove invalid `TyCompat` relation for effects

if the current impl uses `Maybe` (`impl const`), the parent impl must use `Maybe` (`impl const`) as well.

I'd like to rename `TyCompat` to `Sub` which is probably clearer. But it would conflict with my other PR.

r? ``@rust-lang/project-const-traits``
2024-08-24 22:14:14 +02:00
Matthias Krüger 2c4338802a
Rollup merge of #129323 - Urgau:ptr_fn_addr_eq, r=Mark-Simulacrum
Implement `ptr::fn_addr_eq`

This PR implements https://github.com/rust-lang/libs-team/issues/323: `ptr::fn_addr_eq`.

r? libs
2024-08-24 22:14:13 +02:00
Matthias Krüger 0dfdea1c45
Rollup merge of #128596 - RalfJung:const_fn_floating_point_arithmetic, r=nnethercote
stabilize const_fn_floating_point_arithmetic

Part of https://github.com/rust-lang/rust/issues/128288
Fixes https://github.com/rust-lang/rust/issues/57241

The existing test `tests/ui/consts/const_let_eq_float.rs`  ([link](https://github.com/RalfJung/rust/blob/const_fn_floating_point_arithmetic/tests/ui/consts/const_let_eq_float.rs)) covers the basics, and also Miri has extensive tests covering the interpreter's float machinery. Also, that machinery can already be used on stable inside `const`/`static` initializers, just not inside `const fn`.

This was explicitly called out in https://github.com/rust-lang/rfcs/pull/3514 so in a sense t-lang just recently already FCP'd this, but let's hear from them whether they want another FCP for the stabilization here or whether that was covered by the FCP for the RFC.
Cc ``@rust-lang/lang``

### Open items

- [x] Update the Reference: https://github.com/rust-lang/reference/pull/1566
2024-08-24 22:14:11 +02:00
Pavel Grigorenko b9033bdd92 New `#[rustc_pub_transparent]` attribute 2024-08-24 23:05:37 +03:00
Ralf Jung ec0e16a665 panicking: improve hint for Miri's RUST_BACKTRACE behavior 2024-08-24 14:38:50 +02:00
Zalathar 94aadf0f62 Build `library/profiler_builtins` from `ci-llvm` if appropriate 2024-08-24 21:21:34 +10:00
Deadbeef 378902e325 remove invalid `TyCompat` relation for effects 2024-08-24 14:24:21 +08:00
Jubilee Young 9ccd7abefe library: Move unstable API of new_uninit to new features
- `new_zeroed` variants move to `new_zeroed_alloc`
- the `write` fn moves to `box_uninit_write`

The remainder will be stabilized in upcoming patches, as
it was decided to only stabilize `uninit*` and `assume_init`.
2024-08-23 20:52:02 -07:00
Ben Kimock 5d98d20529 Enable Alignment::new_unchecked precondition check 2024-08-23 18:26:45 -04:00
Trevor Gross e76b7d029c Change `f16` doctests in core to run on x86-64 linux
Since `f16` now works on x86 and x86-64, change doctests to use this
instead of aarch64. This is to make sure any changes get run in PR CI.
2024-08-23 14:21:57 -05:00
Scott McMurray 62f7d5305e Update `compiler_builtins` to `0.1.121` 2024-08-23 12:02:26 -07:00
Trevor Gross 402ce53bfe Enable `f16` tests on x86 and x86-64
Since the `compiler_builtins` update [1], ABI bugs on x86 should be
resolved. Enable tests for f16 on these platforms now.

`f16` math functions (`reliable_f16_math`) are still excluded because
there is an LLVM crash for powi [2].

[1]: https://github.com/rust-lang/rust/pull/125016
[2]: https://github.com/llvm/llvm-project/issues/105747
2024-08-23 13:54:50 -05:00
binarycat d7e7886b3c docs: correct panic conditions for rem_euclid and similar functions
fixes https://github.com/rust-lang/rust/issues/128857
2024-08-23 14:47:21 -04:00
Noa c65ef3d37c
Move into_inner_unchecked back to the bottom of the impl block 2024-08-23 13:06:26 -05:00
Noa b968b26c03
Put Pin::as_deref_mut in impl Pin<Ptr> 2024-08-23 12:45:05 -05:00
Jack Wrenn 2540070fd4 document & impl the transmutation modeled by `BikeshedIntrinsicFrom`
Documents that `BikeshedIntrinsicFrom` models transmute-via-union,
which is slightly more expressive than the transmute-via-cast
implemented by `transmute_copy`. Additionally, we provide an
implementation of transmute-via-union as a method on the
`BikeshedIntrinsicFrom` trait with additional documentation on
the boundary between trait invariants and caller obligations.

Whether or not transmute-via-union is the right kind of transmute
to model remains up for discussion [1]. Regardless, it seems wise
to document the present behavior.

[1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20'kind'.20of.20transmute.20to.20model.3F/near/426331967
2024-08-23 14:37:36 +00:00
bors a60a9e567a Auto merge of #129464 - GuillaumeGomez:rollup-ckfqd7h, r=GuillaumeGomez
Rollup of 9 pull requests

Successful merges:

 - #128511 (Document WebAssembly target feature expectations)
 - #129243 (do not build `cargo-miri` by default on stable channel)
 - #129263 (Add a missing compatibility note in the 1.80.0 release notes)
 - #129276 (Stabilize feature `char_indices_offset`)
 - #129350 (adapt integer comparison tests for LLVM 20 IR changes)
 - #129408 (Fix handling of macro arguments within the `dropping_copy_types` lint)
 - #129426 (rustdoc-search: use tighter json for names and parents)
 - #129437 (Fix typo in a help diagnostic)
 - #129457 (kobzol vacation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-23 10:56:34 +00:00
Guillaume Gomez 26672c93d5
Rollup merge of #129276 - eduardosm:stabilize-char_indices_offset, r=Amanieu
Stabilize feature `char_indices_offset`

Stabilized API:

```rust
impl CharIndices<'_> {
    pub fn offset(&self) -> usize;
}
```

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

Closes https://github.com/rust-lang/rust/issues/83871

I also attempted to improved the documentation to make it more clear that it returns the offset of the character that will be returned by the next call to `next()`.
2024-08-23 12:32:15 +02:00
Matthias Krüger 79d36669b5
Rollup merge of #129400 - Amjad50:update-compiler-builtins, r=tgross35
Update `compiler_builtins` to `0.1.120`

Includes https://github.com/rust-lang/compiler-builtins/pull/672 which fixes regression issue with Apple and Windows compilers.

try-job: aarch64-apple
try-job: x86_64-apple-1
try-job: x86_64-msvc
2024-08-23 06:26:53 +02:00
Matthias Krüger 370b3265ff
Rollup merge of #127623 - lolbinarycat:fix_remove_dir_all, r=Amanieu
fix: fs::remove_dir_all: treat internal ENOENT as success

fixes #127576

try-job: test-various
2024-08-23 06:26:51 +02:00
Zalathar 585804fcee Check that `library/profiler_builtins` actually found some source files
The current `build.rs` will automatically skip source files that don't exist.
An unfortunate side-effect is that if _no_ files could be found (e.g. because
the directory was wrong), the build fails with a mysterious linker error.

We can reduce the awkwardness of this by explicitly checking that at least one
source file was found.
2024-08-23 10:10:34 +10:00
binarycat 988bc1c654 fix typos in new pointer conversion docs 2024-08-22 14:25:54 -04:00
binarycat 736f773844 fix: fs::remove_dir_all: treat ENOENT as success
fixes #127576

windows implementation still needs some work
2024-08-22 14:18:42 -04:00
Connor Horman f4dc7830ed feat(core): Make `unbounded_shl{l,r}` unstably const and remove `rustc_allow_const_fn_unstable` 2024-08-22 10:28:48 +00:00
bors 8269be147b Auto merge of #129398 - matthiaskrgr:rollup-50l01ry, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #128432 (WASI: forbid `unsafe_op_in_unsafe_fn` for `std::{os, sys}`)
 - #129373 (Add missing module flags for CFI and KCFI sanitizers)
 - #129374 (Use `assert_unsafe_precondition!` in `AsciiChar::digit_unchecked`)
 - #129376 (Change `assert_unsafe_precondition` docs to refer to `check_language_ub`)
 - #129382 (Add `const_cell_into_inner` to `OnceCell`)
 - #129387 (Advise against removing the remaining Python scripts from `tests/run-make`)
 - #129388 (Do not rely on names to find lifetimes.)
 - #129395 (Pretty-print own args of existential projections (dyn-Trait w/ GAT constraints))

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-22 08:20:49 +00:00
Amjad Alsharafi 57b164a9d2
Update `compiler_builtins` to `0.1.120`
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
2024-08-22 14:26:31 +08:00
Ralf Jung ebfa3e3f62 stabilize const_fn_floating_point_arithmetic 2024-08-22 08:25:54 +02:00
Matthias Krüger 28d4b8248e
Rollup merge of #129382 - tgross35:once-cell-const-into-inner, r=Noratrieb
Add `const_cell_into_inner` to `OnceCell`

`Cell` and `RefCell` have their `into_inner` methods const unstable. `OnceCell` has the same logic, so add it under the same gate.

Tracking issue: https://github.com/rust-lang/rust/issues/78729
2024-08-22 08:17:22 +02:00
Matthias Krüger ae58bbfbce
Rollup merge of #129376 - ChaiTRex:assert_unsafe_precondition_check_language_ub, r=workingjubilee,the8472
Change `assert_unsafe_precondition` docs to refer to `check_language_ub`
2024-08-22 08:17:21 +02:00
Matthias Krüger e7df7ba1e4
Rollup merge of #129374 - ChaiTRex:digit_unchecked_assert_unsafe_precondition, r=scottmcm
Use `assert_unsafe_precondition!` in `AsciiChar::digit_unchecked`
2024-08-22 08:17:20 +02:00
Matthias Krüger a8d5c6d151
Rollup merge of #128432 - g0djan:godjan/wasi_prohibit_implicit_unsafe, r=tgross35
WASI: forbid `unsafe_op_in_unsafe_fn` for `std::{os, sys}`

Part of https://github.com/rust-lang/rust/issues/127747 for WASI

try-job: test-various
2024-08-22 08:17:19 +02:00
bors 739b1fdb15 Auto merge of #129365 - matthiaskrgr:rollup-ebwx6ya, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #127279 (use old ctx if has same expand environment during decode span)
 - #127945 (Implement `debug_more_non_exhaustive`)
 - #128941 ( Improve diagnostic-related lints: `untranslatable_diagnostic` & `diagnostic_outside_of_impl`)
 - #129070 (Point at explicit `'static` obligations on a trait)
 - #129187 (bootstrap: fix clean's remove_dir_all implementation)
 - #129231 (improve submodule updates)
 - #129264 (Update `library/Cargo.toml` in weekly job)
 - #129284 (rustdoc: animate the `:target` highlight)
 - #129302 (compiletest: use `std::fs::remove_dir_all` now that it is available)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-22 05:17:27 +00:00
Connor Horman 2cf48eaebc fix(core): Use correct operations/values in `unbounded_shr` doctests 2024-08-22 00:08:03 +00:00
Connor Horman 27b63b85ec chore: `x fmt` 2024-08-21 23:38:04 +00:00
Connor Horman 9907f617ab fix(core): Add `#![feature(unbounded_shifts)]` to doctests for `unbounded_shr`/`unbounded_shl` 2024-08-21 23:22:07 +00:00
Trevor Gross 81c00dde2b Add `const_cell_into_inner` to `OnceCell`
`Cell` and `RefCell` have their `into_inner` methods const unstable.
`OnceCell` has the same logic, so add it under the same gate.

Tracking issue: https://github.com/rust-lang/rust/issues/78729
2024-08-21 17:36:05 -05:00
Geoffry Song 40481fc70a
format 2024-08-21 15:34:51 -07:00
Connor Horman 79cbb878c7 chore: `x fmt` and hopefully fix the tidy issue 2024-08-21 21:37:50 +00:00
Geoffry Song d7b2fd4213
Clean up cfg-gating of ProcessPrng extern 2024-08-21 14:37:39 -07:00
Chai T. Rex c836739529 Change `assert_unsafe_precondition` docs to refer to `check_language_ub` 2024-08-21 17:35:54 -04:00
Connor Horman 38b5a2a67e chore: Also format the control flow 2024-08-21 21:23:25 +00:00
Connor Horman c89bae0ea8 Manually format functions and use `rhs` instead of `v` from my CE testing 2024-08-21 21:16:18 +00:00
Connor Horman 9b5a004bf8 feat(core): Add implementations for `unbounded_shl`/`unbounded_shr` 2024-08-21 20:57:50 +00:00
Chai T. Rex 191862d701 Use `assert_unsafe_precondition!` in `AsciiChar::digit_unchecked` 2024-08-21 16:26:35 -04:00
Matthias Krüger 3fb8faa653
Rollup merge of #129321 - krtab:float_sum, r=workingjubilee
Change neutral element of <fNN as iter::Sum> to neg_zero

The neutral element used to be positive zero, but +0 + -0 = +0 so -0 seems better indicated.
2024-08-21 21:58:28 +02:00
Matthias Krüger 94b3953853
Rollup merge of #129232 - ivmarkov:master, r=workingjubilee
Fix `thread::sleep` Duration-handling for ESP-IDF

Addresses the ESP-IDF specific aspect of https://github.com/rust-lang/rust/issues/129212

#### A short summary of the problems addressed by this PR:
================================================

1. **Problem 1** - the current implementation of `std:🧵:sleep` does not properly round up the passed `Duration`

As per the documentation of `std:🧵:sleep`, the implementation should sleep _at least_ for the provided duration, but not less. Since the minimum supported resolution of the `usleep` syscall which is used with ESP-IDF is one microsecond, this means that we need to round-up any sub-microsecond nanos to one microsecond. Moreover, in the edge case where the user had passed a duration of < 1000 nanos (i.e. less than one microsecond), the current implementation will _not_ sleep _at all_.

This is addressed by this PR.

2. **Problem 2** - the implementation of `usleep` on the ESP-IDF can overflow if the passed number of microseconds is >= `u32::MAX - 1_000_000`

This is also addressed by this PR.

Extra details for Problem 2:

`u32::MAX - 1_000_000` is chosen to accommodate for the longest possible systick on the ESP IDF which is 1000ms.

The systick duration is selected when compiling the ESP IDF FreeRTOS task scheduler itself, so we can't know it from within `STD`. The default systick duration is 10ms, and might be lowered down to 1ms. (Making it longer I have never seen, but in theory it can go up to a 1000ms max, even if obviously a one second systick is unrealistic - but we are paranoid in the PR.)

While the overflow is reported upstream in the ESP IDF repo[^1], I still believe we should workaround it in the Rust wrappers as well, because it might take time until it is fixed, and they might not fix it for all released ESP IDF versions.

For big durations, rather than calling `usleep` repeatedly on the ESP-IDF in chunks of `u32::MAX - 1_000_000`us, it might make sense to call instead with 1_000_000us (one second) as this is the max period that seems to be agreed upon as a safe max period in the `usleep` POSIX spec. On the other hand, that might introduce less precision (as we need to call more times `usleep` in a loop) and, we would be fighting a theoretical problem only, as I have big doubts the ESP IDF will stop supporting durations higher than 1_000_000us - ever - because of backwards compatibility with code which already calls `usleep` on the ESP IDF with bigger durations.

[^1]: https://github.com/espressif/esp-idf/issues/14390
2024-08-21 21:58:28 +02:00
Matthias Krüger 65386c045e
Rollup merge of #127945 - tgross35:debug-more-non-exhaustive, r=Noratrieb
Implement `debug_more_non_exhaustive`

This implements the ACP at https://github.com/rust-lang/libs-team/issues/248, adding `.finish_non_exhaustive()` for `DebugTuple`, `DebugSet`, `DebugList`, and `DebugMap`.

Also used this as an opportunity to make some documentation and tests more readable by using raw strings instead of escaped quotes.

Tracking issue: https://github.com/rust-lang/rust/issues/127942
2024-08-21 19:35:10 +02:00
Matthias Krüger e961d6b204
Rollup merge of #129332 - cuviper:cstr-cast, r=compiler-errors
Avoid extra `cast()`s after `CStr::as_ptr()`

These used to be `&str` literals that did need a pointer cast, but that
became a no-op after switching to `c""` literals in #118566.
2024-08-21 18:15:04 +02:00
Matthias Krüger 349f29992b
Rollup merge of #129312 - tbu-:pr_str_not_impl_error, r=Noratrieb
Fix stability attribute of `impl !Error for &str`

It was introduced in bf7611d55e (#99917), which was included in Rust 1.65.0.
2024-08-21 18:15:03 +02:00
Tobias Bucher 123bb585f8 Fix stability attribute of `impl !Error for &str`
It was introduced in bf7611d55e (#99917),
which was included in Rust 1.65.0.
2024-08-21 16:21:40 +02:00
bors 982c6f8721 Auto merge of #126556 - saethlin:layout-precondition, r=joboet
Add a precondition check for Layout::from_size_align_unchecked

Ran into this while looking into https://github.com/rust-lang/miri/issues/3679. This is of course not the cause of the ICE, but the reproducer doesn't encounter a precondition check and it ought to.
2024-08-21 12:50:05 +00:00
bors 59a74db37d Auto merge of #128866 - scottmcm:update-stdarch, r=tgross35
Update stdarch submodule

To pick up https://github.com/rust-lang/stdarch/pull/1624 and unblock removing support for non-array-based-simd (https://github.com/rust-lang/compiler-team/issues/621).
2024-08-21 08:18:36 +00:00
Scott McMurray 210f603651 Update stdarch submodule 2024-08-21 00:20:27 -07:00
Ben Kimock e6b0f27e00 Try to golf down the amount of code in Layout 2024-08-20 18:41:07 -04:00
Josh Stone e424e7fcaa Avoid extra `cast()`s after `CStr::as_ptr()`
These used to be `&str` literals that did need a pointer cast, but that
became a no-op after switching to `c""` literals in #118566.
2024-08-20 14:04:48 -07:00
Matthias Krüger aced570e53
Rollup merge of #129294 - scottmcm:stabilize-repeat-n, r=Noratrieb
Stabilize `iter::repeat_n`

ACP completed in https://github.com/rust-lang/rust/issues/104434#issuecomment-2296993685
2024-08-20 22:21:58 +02:00
Urgau 4325ac9652 Implement `ptr::fn_addr_eq` 2024-08-20 19:27:29 +02:00
Arthur Carcano 4908188518 Change neutral element of <fNN as iter::Sum> to neg_zero
The neutral element used to be positive zero, but +0 + -0 = +0 so
-0 seems better indicated.
2024-08-20 18:45:53 +02:00
Scott McMurray dfea11d620 Stabilize `iter::repeat_n` 2024-08-19 22:39:04 -07:00
bors fdf61d499c Auto merge of #129226 - RalfJung:libc, r=Mark-Simulacrum
library: bump libc dependency

This pulls in https://github.com/rust-lang/libc/pull/3723, which hopefully unblocks https://github.com/rust-lang/miri/pull/3748.
2024-08-20 01:40:21 +00:00
Ben Kimock 7f5d282185 Add a precondition check for Layout::from_size_align_unchecked 2024-08-19 17:18:17 -04:00
Eduardo Sánchez Muñoz dbad758134 Stabilize feature `char_indices_offset` 2024-08-19 20:31:48 +02:00
Ralf Jung 5365b05fc9 library: bump libc dependency 2024-08-19 09:26:25 +02:00
Trevor Gross 332ab61d29
Rollup merge of #128902 - evanj:evan.jones/env-var-doc, r=workingjubilee
doc: std::env::var: Returns None for names with '=' or NUL byte

The documentation incorrectly stated that std::env::var could return an error for variable names containing '=' or the NUL byte. Copy the correct documentation from var_os.

var_os was fixed in Commit 8a7a665, Pull Request #109894, which closed Issue #109893.

This documentation was incorrectly added in commit f2c0f292, which replaced a panic in var_os by returning None, but documented the change as "May error if ...".

Reference the specific error values and link to them.
2024-08-18 23:41:47 -05:00
Ralf Jung b8464961a2 soft-deprecate the addr_of macros 2024-08-18 19:46:53 +02:00
Evan Jones b0023f5a41 code review improvements 2024-08-18 10:43:36 -04:00
ivmarkov 1faccbaadc Fix for issue #129212 for the ESP-IDF 2024-08-18 11:33:30 +00:00
bors c6f81a452e Auto merge of #126877 - GrigorenkoPV:clone_to_uninit, r=dtolnay
CloneToUninit impls

As per #126799.

Also implements it for `Wtf8` and both versions of `os_str::Slice`.

Maybe it is worth to slap `#[inline]` on some of those impls.

r? `@dtolnay`
2024-08-17 11:39:08 +00:00
bors 426a60abc2 Auto merge of #128598 - RalfJung:float-comments, r=workingjubilee
float to/from bits and classify: update for float semantics RFC

With https://github.com/rust-lang/rfcs/pull/3514 having been accepted, it is clear that hardware which e.g. flushes subnormal to zero is just non-conformant from a Rust perspective -- this is a hardware bug, or maybe an LLVM backend bug (where LLVM doesn't lower floating-point ops in a way that they have the standardized behavior). So update the comments here to make it clear that we don't have to do any of this, we're just being nice.

Also remove the subnormal/NaN checks from the (unstable) const-version of to/from-bits; they are not needed since we decided with the aforementioned RFC that it is okay to get a different result at const-time and at run-time.

r? `@workingjubilee` since I think you wrote many of the comments I am editing here.
2024-08-17 09:13:13 +00:00
bors f24a6ba06f Auto merge of #106943 - mina86:exact_size_take_repeat, r=dtolnay
Implement DoubleEnded and ExactSize for Take<Repeat> and Take<RepeatWith>

Repeat iterator always returns the same element and behaves the same way
backwards and forwards.  Take iterator can trivially implement backwards
iteration over Repeat inner iterator by simply doing forwards iteration.

DoubleEndedIterator is not currently implemented for Take<Repeat<T>>
because Repeat doesn’t implement ExactSizeIterator which is a required
bound on DEI implementation for Take.

Similarly, since Repeat is an infinite iterator which never stops, Take
can trivially know how many elements it’s going to return.  This allows
implementing ExactSizeIterator on Take<Repeat<T>>.

While at it, observe that ExactSizeIterator can also be implemented for
Take<RepeatWhile<F>> so add that implementation too.  Since in contrast
to Repeat, RepeatWhile doesn’t guarante to always return the same value,
DoubleEndedIterator isn’t implemented.

Those changes render core::iter::repeat_n somewhat redundant.

Issue: https://github.com/rust-lang/rust/issues/104434
Issue: https://github.com/rust-lang/rust/issues/104729

- [ ] ACP: https://github.com/rust-lang/libs-team/issues/120 (this is actually ACP for repeat_n but this is nearly the same functionality so hijacking it so both approaches can be discussed in one place)
2024-08-17 01:46:24 +00:00
bors 67d09736ea Auto merge of #116528 - daxpedda:stabilize-ready-into-inner, r=dtolnay
Stabilize `Ready::into_inner()`

This PR stabilizes `Ready::into_inner()`.

Tracking issue: #101196.
Implementation PR: #101189.

Closes #101196.
2024-08-16 23:20:38 +00:00
Matthias Krüger a9bf86a5f2
Rollup merge of #129161 - dtolnay:spawnunck, r=Noratrieb
Stabilize std:🧵:Builder::spawn_unchecked

Closes #55132.
2024-08-16 19:59:00 +02:00
Matthias Krüger 9d57e46f81
Rollup merge of #129086 - slanterns:is_none_or, r=dtolnay
Stabilize `is_none_or`

Closes: https://github.com/rust-lang/rust/issues/126383.

`@rustbot` label: +T-libs-api

r? libs-api
2024-08-16 19:58:58 +02:00
David Tolnay e6ac503ec1
Stabilize std:🧵:Builder::spawn_unchecked 2024-08-16 10:43:47 -07:00
Ralf Jung 368a4c6808 float to/from bits and classify: update comments regarding non-conformant hardware 2024-08-16 10:11:36 +02:00
Jubilee f624f2d3f9
Rollup merge of #128064 - ijackson:noop-waker-doc, r=workingjubilee
Improve docs for Waker::noop and LocalWaker::noop

 * Add a warning about a likely misuse.  (See my commit message for longer rationale.)
 * Apply some probably-accidentally-omitted changes to `LocalWaker`'s docs
 * Add a comment about the clone-and-hack of the docs

I have used [semantic linefeeds](https://rhodesmill.org/brandon/2012/one-sentence-per-line/) for the docs formatting.
2024-08-15 18:44:15 -07:00
Ian Jackson 9a95573c2b Add cautionary paragraph about noop wakers.
Based on a suggestion from @kpreid, with some further editing.
2024-08-15 16:18:49 +01:00
Matthias Krüger cd1b42c3e9
Rollup merge of #128946 - orlp:faster-ip-hash, r=joboet
Hash Ipv*Addr as an integer

The `Ipv4Addr` and `Ipv6Addr` structs always have a fixed size, but directly derive `Hash`. This causes them to call the bytestring hasher implementation, which adds extra work for most hashers. This PR converts the internal representation to a fixed-width integer before passing to the hasher to prevent this.
2024-08-15 00:02:25 +02:00
Matthias Krüger 9938349c71
Rollup merge of #128925 - dingxiangfei2009:smart-ptr-helper-attr, r=compiler-errors
derive(SmartPointer): register helper attributes

Fix #128888

This PR enables built-in macros to register helper attributes, if any, to support correct name resolution in the correct lexical scope under the macros.

Also, `#[pointee]` is moved into the scope under `derive(SmartPointer)`.

cc `@Darksonn` `@davidtwco`
2024-08-15 00:02:25 +02:00
Matthias Krüger 0bed4d1f1c
Rollup merge of #125970 - RalfJung:before_exec, r=m-ou-se
CommandExt::before_exec: deprecate safety in edition 2024

Similar to `set_var`, we had to find out after 1.0 was released that `before_exec` should have been unsafe. We partially rectified this by deprecating that function a long time ago, but since https://github.com/rust-lang/rust/pull/124636 we have the ability to also deprecate the safety of the old function and make it a *hard error* to call the old function outside `unsafe` in the next edition. So just in case anyone still uses the old function, let's ensure this can't be ignored when moving code to the new edition.

Cc `@rust-lang/libs-api`

Tracking:

- https://github.com/rust-lang/rust/issues/124866
2024-08-15 00:02:24 +02:00
The 8472 79b5cfdf83 size-optimize some of the panic dependencies 2024-08-14 20:50:04 +02:00
The 8472 6d8f0bd930 apply #[optimize(size)] to #[cold] ones and part of the panick machinery 2024-08-14 20:50:04 +02:00
许杰友 Jieyou Xu (Joe) 049b3e549e
Rollup merge of #128954 - zachs18:fromresidual-no-default, r=scottmcm
Explicitly specify type parameter on FromResidual for Option and ControlFlow.

~~Remove type parameter default `R = <Self as Try>::Residual` from `FromResidual`~~ _Specify default type parameter on `FromResidual` impls in the stdlib_ to work around https://github.com/rust-lang/rust/issues/99940 / https://github.com/rust-lang/rust/issues/87350 ~~as mentioned in https://github.com/rust-lang/rust/issues/84277#issuecomment-1773259264~~.

This does not completely fix the issue, but works around it for `Option` and `ControlFlow` specifically (`Result` does not have the issue since it already did not use the default parameter of `FromResidual`).

~~(Does this need an ACP or similar?)~~ ~~This probably needs at least an FCP since it changes the API described in [the RFC](https://github.com/rust-lang/rfcs/pull/3058). Not sure if T-lang, T-libs-api, T-libs, or some combination (The tracking issue is tagged T-lang, T-libs-api).~~ This probably doesn't need T-lang input, since it is not changing the API of `FromResidual` from the RFC? Maybe needs T-libs-api FCP?
2024-08-14 21:43:08 +08:00
许杰友 Jieyou Xu (Joe) 196d256b20
Rollup merge of #128570 - folkertdev:stabilize-asm-const, r=Amanieu
Stabilize `asm_const`

tracking issue: https://github.com/rust-lang/rust/issues/93332

reference PR: https://github.com/rust-lang/reference/pull/1556

this will probably require some CI wrangling (and a rebase), so let's get that over with even though the final required PR is not merged yet.

r? `@ghost`
2024-08-14 21:43:07 +08:00
Ralf Jung 6eaf531432 add Box::as_ptr and Box::as_mut_ptr methods 2024-08-14 14:30:31 +02:00
Ralf Jung 5ae03863de CommandExt::before_exec: deprecate safety in edition 2024 2024-08-14 14:04:11 +02:00
Slanterns e2ec11502d
stabilize `is_none_or` 2024-08-14 18:28:40 +08:00
bors fbce03b195 Auto merge of #129060 - matthiaskrgr:rollup-s72gpif, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #122884 (Optimize integer `pow` by removing the exit branch)
 - #127857 (Allow to customize `// TODO:` comment for deprecated safe autofix)
 - #129034 (Add `#[must_use]` attribute to `Coroutine` trait)
 - #129049 (compiletest: Don't panic on unknown JSON-like output lines)
 - #129050 (Emit a warning instead of an error if `--generate-link-to-definition` is used with other output formats than HTML)
 - #129056 (Fix one usage of target triple in bootstrap)
 - #129058 (Add mw back to review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-14 06:43:26 +00:00
Matthias Krüger a4261a0bc0
Rollup merge of #129001 - cblh:fix/128713, r=Noratrieb
chore(lib): Enhance documentation for core::fmt::Formatter's write_fm…

fix: #128713
2024-08-14 05:05:52 +02:00
Matthias Krüger f4c860a996
Rollup merge of #128873 - ChrisDenton:windows-targets, r=Mark-Simulacrum
Add windows-targets crate to std's sysroot

With this PR, when backtrace is used as a crate from crates.io it will (once updated) use the real [windows-targets](https://crates.io/crates/windows-targets) crate. But when used from std it'll use std's replacement version.

This allows sharing our customized `windows_tagets::link!` macro between std proper and the backtrace crate when used as part of std, ensuring a consistent linking story. This will be especially important once we move to using [`raw-dylib`](https://doc.rust-lang.org/reference/items/external-blocks.html#dylib-versus-raw-dylib) by default.
2024-08-14 05:05:51 +02:00
Matthias Krüger 85180cd365
Rollup merge of #128759 - notriddle:notriddle/spec-to-string, r=workingjubilee,compiler-errors
alloc: add ToString specialization for `&&str`

Fixes #128690
2024-08-14 05:05:51 +02:00
Folkert 8419c0956e stabilize `asm_const` 2024-08-13 23:18:31 +02:00
Matthias Krüger d4f5a89f6e
Rollup merge of #129034 - henryksloan:coroutine-must-use, r=joboet
Add `#[must_use]` attribute to `Coroutine` trait

[Coroutines tracking issue](https://github.com/rust-lang/rust/issues/43122)

Like closures (`FnOnce`, `AsyncFn`, etc.), coroutines are lazy and do nothing unless called (resumed). Closure traits like `FnOnce` have `#[must_use = "closures are lazy and do nothing unless called"]` to catch likely bugs for users of APIs that produce them. This PR adds such a `#[must_use]` attribute to `trait Coroutine`.
2024-08-13 21:11:13 +02:00
Matthias Krüger f68a28d95c
Rollup merge of #127857 - tbu-:pr_deprecated_safe_todo, r=petrochenkov
Allow to customize `// TODO:` comment for deprecated safe autofix

Relevant for the deprecation of `CommandExt::before_exit` in #125970.

Tracking:
- #124866
2024-08-13 21:11:12 +02:00
Matthias Krüger bc9c31df69
Rollup merge of #122884 - mzabaluev:pow-remove-exit-branch, r=Amanieu
Optimize integer `pow` by removing the exit branch

The branch at the end of the `pow` implementations is redundant with multiplication code already present in the loop. By rotating the exit check, this branch can be largely removed, improving code size and reducing instruction cache misses.

Testing on my machine (`x86_64`, 11th Gen Intel Core i5-1135G7 @ 2.40GHz), the `num::int_pow` benchmarks improve by some 40% for the unchecked operations and show some slight improvement for the checked operations as well.
2024-08-13 21:11:12 +02:00
Guillaume Gomez 1e1743a379 Reduce merged doctest source code size 2024-08-13 20:14:56 +02:00
Guillaume Gomez 475824d811 Mark location doctest as standalone since file information will not work in merged doctest file 2024-08-13 20:14:55 +02:00
bors 80eb5a8e91 Auto merge of #129046 - matthiaskrgr:rollup-9x4xgak, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #128643 (Refactor `powerpc64` call ABI handling)
 - #128655 (std: refactor UNIX random data generation)
 - #128745 (Remove unused lifetime parameter from spawn_unchecked)
 - #128841 (bootstrap: don't use rustflags for `--rustc-args`)
 - #128983 (Slightly refactor `TargetSelection` in bootstrap)
 - #129026 (CFI: Move CFI ui tests to cfi directory)
 - #129040 (Fix blessing of rmake tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-13 11:43:20 +00:00
Matthias Krüger 37b956787a
Rollup merge of #128745 - dtolnay:spawnunchecked, r=workingjubilee
Remove unused lifetime parameter from spawn_unchecked

Amanieu caught this when reviewing the stabilization proposal in https://github.com/rust-lang/rust/issues/55132.

The `'a` lifetime here is useless. The signature is asking the caller of `spawn_unchecked` to "give me any lifetime that is shorter than your F's and T's lifetime", which they can always to with no effect, because arbitrarily short lifetimes exist.
2024-08-13 12:12:23 +02:00
Matthias Krüger c977deb24b
Rollup merge of #128655 - joboet:play_with_the_dice, r=ChrisDenton
std: refactor UNIX random data generation

This PR makes a number of changes to the UNIX randomness implementation:
* Use `io::Error` for centralized error handling
* Move the file-fallback logic out of the `getrandom`-specific module
* Stop redefining the syscalls on macOS and DragonFly, they have appeared in `libc`
* Add a `OnceLock` to cache the random device file descriptor
2024-08-13 12:12:22 +02:00
Tobias Bucher 811d7dd113 `#[deprecated_safe_2024]`: Also use the `// TODO:` hint in the compiler error
This doesn't work for translated compiler error messages.
2024-08-13 11:32:47 +02:00
Tobias Bucher 399ef23d2b Allow to customize `// TODO:` comment for deprecated safe autofix
Relevant for the deprecation of `CommandExt::before_exit` in #125970.
2024-08-13 11:32:24 +02:00
bors a2e1d154d5 Auto merge of #128962 - devnexen:fs_get_mode_haiku, r=workingjubilee
std::fs: get_mode implementation for all unix
2024-08-13 09:10:32 +00:00
Ralf Jung 194baa820d simd_shuffle intrinsic: allow argument to be passed as vector (not just as array) 2024-08-13 07:51:17 +02:00
Mikhail Zabaluev ac88b330b8 Revert to original loop for const pow exponents
Give LLVM the for original, optimizable loop in pow and wrapped_pow
functions in the case when the exponent is statically known.
2024-08-13 08:32:36 +03:00
bors 591ecb88df Auto merge of #128742 - RalfJung:miri-vtable-uniqueness, r=saethlin
miri: make vtable addresses not globally unique

Miri currently gives vtables a unique global address. That's not actually matching reality though. So this PR enables Miri to generate different addresses for the same type-trait pair.

To avoid generating an unbounded number of `AllocId` (and consuming unbounded amounts of memory), we use the "salt" technique that we also already use for giving constants non-unique addresses: the cache is keyed on a "salt" value n top of the actually relevant key, and Miri picks a random salt (currently in the range `0..16`) each time it needs to choose an `AllocId` for one of these globals -- that means we'll get up to 16 different addresses for each vtable. The salt scheme is integrated into the global allocation deduplication logic in `tcx`, and also used for functions and string literals. (So this also fixes the problem that casting the same function to a fn ptr over and over will consume unbounded memory.)

r? `@saethlin`
Fixes https://github.com/rust-lang/miri/issues/3737
2024-08-13 04:32:34 +00:00
Henry Sloan 1e445f48d4 Add must_use attribute to Coroutine trait 2024-08-12 19:27:57 -07:00
burlinchen c4333026a0 chore(lib): fmt core::fmt::Formatter's write_fmt method 2024-08-13 08:40:08 +08:00
David Carlier 70e0f69632
trying common codepath for every unixes 2024-08-12 23:44:42 +01:00
David Carlier a7be5bf683
std::fs: get_mode implementation for haiku. 2024-08-12 23:44:00 +01:00
Matthias Krüger 522d43673a
Rollup merge of #129017 - its-the-shrimp:core_fmt_from_fn, r=Noratrieb
Replace `std::fmt:FormatterFn` with `std::fmt::from_fn`

Modelled after the suggestion made in [this](https://github.com/rust-lang/rust/issues/117729#issuecomment-1837628559) comment, this should bring this functionality in line with the existing `array::from_fn` & `iter::from_fn`
2024-08-12 23:10:52 +02:00
Ding Xiang Fei 5534cb0a4a
derive(SmartPointer): register helper attributes 2024-08-13 04:26:48 +08:00
Zachary S 1b6df71192 Explicitly specify type parameter on FromResidual impls in stdlib.
To work around coherence issue. Also adds regression test.
2024-08-12 12:54:18 -05:00
schvv31n 027b19fa9b std::fmt::FormatterFn -> std::fmt::FromFn 2024-08-12 18:33:30 +01:00
Guillaume Gomez aa6f240972
Rollup merge of #128632 - joboet:dont_overwrite_style, r=Amanieu
std: do not overwrite style in `get_backtrace_style`

If another thread calls `set_backtrace_style` while a `get_backtrace_style` is reading the environment variables, `get_backtrace_style` will overwrite the value. Use an atomic CAS to avoid this.
2024-08-12 17:09:16 +02:00
Guillaume Gomez 095ca33bb6
Rollup merge of #128149 - RalfJung:nontemporal_store, r=jieyouxu,Amanieu,Jubilee
nontemporal_store: make sure that the intrinsic is truly just a hint

The `!nontemporal` flag for stores in LLVM *sounds* like it is just a hint, but actually, it is not -- at least on x86, non-temporal stores need very special treatment by the programmer or else the Rust memory model breaks down. LLVM still treats these stores as-if they were normal stores for optimizations, which is [highly dubious](https://github.com/llvm/llvm-project/issues/64521). Let's avoid all that dubiousness by making our own non-temporal stores be truly just a hint, which is possible on some targets (e.g. ARM). On all other targets, non-temporal stores become regular stores.

~~Blocked on https://github.com/rust-lang/stdarch/pull/1541 propagating to the rustc repo, to make sure the `_mm_stream` intrinsics are unaffected by this change.~~

Fixes https://github.com/rust-lang/rust/issues/114582
Cc `@Amanieu` `@workingjubilee`
2024-08-12 17:09:14 +02:00
burlinchen 72ef357ea3 chore(lib): Enhance documentation for core::fmt::Formatter's write_fmt method 2024-08-12 17:37:30 +08:00
Ralf Jung 4763d12207 ignore some vtable/fn ptr equality tests in Miri, their result is not fully predictable 2024-08-12 10:39:11 +02:00
joboet 99c0d768b0
std: use `/scheme/rand` on Redox 2024-08-12 10:23:26 +02:00
joboet 8301dd4767
core: make documentation clearer, rename slice comparison specialization trait 2024-08-12 10:20:32 +02:00
joboet 8542cd67f0
std: do not overwrite style in `get_backtrace_style`
If another thread calls `set_backtrace_style` while a `get_backtrace_style` is reading the environment variables, `get_backtrace_style` will overwrite the value. Use an atomic CAS to avoid this.
2024-08-12 10:08:56 +02:00
bors 1d8f135b20 Auto merge of #128862 - cblh:fix/128855, r=scottmcm
fix:  #128855 Ensure `Guard`'s `drop` method is removed at `opt-level=s` for `…

fix: #128855

…Copy` types

Added `#[inline]` to the `drop` method in the `Guard` implementation to ensure that the method is removed by the compiler at optimization level `opt-level=s` for `Copy` types. This change aims to align the method's behavior with optimization expectations and ensure it does not affect performance.

r​? `@scottmcm`
2024-08-12 05:22:03 +00:00
bors 13f8a57cfb Auto merge of #126793 - saethlin:mono-rawvec, r=scottmcm
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered https://github.com/rust-lang/rust-clippy/issues/12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
2024-08-12 01:47:06 +00:00
Orson Peters fce1decc3c Do not use unnecessary endian conversion. 2024-08-11 14:55:29 +02:00
Matthias Krüger 2c88eb9805
Rollup merge of #128882 - RalfJung:local-waker-will-wake, r=cuviper
make LocalWaker::will_wake consistent with Waker::will_wake

This mirrors https://github.com/rust-lang/rust/pull/119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (https://github.com/rust-lang/rust/pull/118960).
2024-08-11 07:51:52 +02:00
Matthias Krüger e8f6819db7
Rollup merge of #120314 - mina86:i, r=Mark-Simulacrum
core: optimise Debug impl for ascii::Char

Rather than writing character at a time, optimise Debug implementation
for core::ascii::Char such that it writes the entire representation
with a single write_str call.

With that, add tests for Display and Debug.

Issue: https://github.com/rust-lang/rust/issues/110998
2024-08-11 07:51:49 +02:00
Orson Peters a04a1e464f Fix stability annotation and expand comment 2024-08-11 01:28:30 +02:00
Orson Peters ba62034430 Hash Ipv*Addr as an integer 2024-08-10 23:52:35 +02:00
bors 04ba50e823 Auto merge of #128927 - GuillaumeGomez:rollup-ei2lr0f, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #128273 (Improve `Ord` violation help)
 - #128807 (run-make: explaing why fmt-write-bloat is ignore-windows)
 - #128903 (rustdoc-json-types `Discriminant`: fix typo)
 - #128905 (gitignore: Add Zed and Helix editors)
 - #128908 (diagnostics: do not warn when a lifetime bound infers itself)
 - #128909 (Fix dump-ice-to-disk for RUSTC_ICE=0 users)
 - #128910 (Differentiate between methods and associated functions in diagnostics)
 - #128923 ([rustdoc] Stop showing impl items for negative impls)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-10 15:13:38 +00:00
Guillaume Gomez 65875b2f5a
Rollup merge of #128273 - Voultapher:improve-ord-violation-help, r=workingjubilee
Improve `Ord` violation help

Recent experience in #128083 showed that the panic message when an Ord violation is detected by the new sort implementations can be confusing. So this PR aims to improve it, together with minor bug fixes in the doc comments for sort*, sort_unstable* and select_nth_unstable*.

Is it possible to get these changes into the 1.81 release? It doesn't change behavior and would greatly help when users encounter this panic for the first time, which they may after upgrading to 1.81.

Tagging `@orlp`
2024-08-10 16:23:51 +02:00
Nadrieril c256de2253 Update std and compiler 2024-08-10 12:07:17 +02:00
Nadrieril cd40769c02 Stabilize `min_exhaustive_patterns` 2024-08-10 12:07:17 +02:00
Ben Kimock da15248d26 Add an optimizer hint for the capacity that with_capacity_in returns 2024-08-09 20:06:27 -04:00
Ben Kimock 4e98bc6730 Hoist IS_ZST check out of RawVecInner::from_*_in 2024-08-09 20:06:27 -04:00
Ben Kimock d6c0ebef50 Polymorphize RawVec 2024-08-09 20:06:26 -04:00
Michal Nazarewicz 7d1de7f994 core: optimise Debug impl for ascii::Char
Rather than writing character at a time, optimise Debug implementation
for core::ascii::Char such that it writes the entire representation as
with a single write_str call.

With that, add tests for Display and Debug implementations.
2024-08-09 22:50:57 +02:00
Evan Jones d5a7c45966
doc: std::env::var: Returns None for names with '=' or NUL byte
The documentation incorrectly stated that std::env::var could return
an error for variable names containing '=' or the NUL byte. Copy the
correct documentation from var_os.

var_os was fixed in Commit 8a7a665, Pull Request #109894, which
closed Issue #109893.

This documentation was incorrectly added in commit f2c0f292, which
replaced a panic in var_os by returning None, but documented the
change as "May error if ...".

Reference the specific error values and link to them.
2024-08-09 14:28:31 -04:00
Matthias Krüger 2e0c5adf04
Rollup merge of #128859 - MinxuanZ:mips-sig, r=Amanieu
Fix the name of signal 19 in library/std/src/sys/pal/unix/process/process_unix/tests.rs for mips/sparc linux

relate to #128816
2024-08-09 18:24:59 +02:00
Matthias Krüger 53729366a9
Rollup merge of #128817 - biabbas:vxworks_update, r=tgross35
VxWorks code refactored

1. Extern TaskNameSet as minimum supported version of os is VxWorks 7 which would have taskNameSet
2. Vx_TASK_NAME_LEN is 31 on VxWorks7, defined variable res.
3. Add unsafe blocks on Non::Zero usage in available_parallelism()
4. Update vxworks docs.
r? `@tgross35`
cc `@devnexen`
2024-08-09 18:24:56 +02:00
Ralf Jung ae09340350 make LocalWaker::will_wake consistent with Waker::will_wake 2024-08-09 18:05:57 +02:00
Lukas Bergdoll 1be60b5d2b Fix linkchecker issue 2024-08-09 15:05:37 +02:00
Chris Denton a1b2b7ff78
Exclude windows-targets from the workspace 2024-08-09 11:06:39 +00:00
Chris Denton acb024110f
Add windows-targets crate to std's sysroot 2024-08-09 10:43:43 +00:00
Matthias Krüger e88067927a
Rollup merge of #128824 - GuillaumeGomez:update-compiler-builtins, r=Amanieu
Update compiler-builtins version to 0.1.118

r? `@Amanieu`
2024-08-09 05:52:16 +02:00
B I Mohammed Abbas b20d9f0403
VxWorks: Add safety comment for vxCpuEnabledGet
Co-authored-by: Trevor Gross <t.gross35@gmail.com>
2024-08-09 09:05:09 +05:30
burlinchen bca0c5f2a9 fix: Ensure `Guard`'s `drop` method is removed at `opt-level=s` for `Copy` types
Added `#[inline]` to the `drop` method in the `Guard` implementation to ensure that the method is removed by the compiler at optimization level `opt-level=s` for `Copy` types. This change aims to align the method's behavior with optimization expectations and ensure it does not affect performance.
2024-08-09 11:10:30 +08:00
monstercatss 0106f5bcba delete space 2024-08-09 10:12:54 +08:00
monstercatss 625432c837 fix format 2024-08-09 09:36:22 +08:00
Min a3f8edff20 [SPARC] fix the name of signal 19 in sparc arch 2024-08-09 09:21:09 +08:00
Min 11b801bc4e [MIPS] fix the name of signal 19 in mips 2024-08-09 09:21:09 +08:00
Matthias Krüger 5f0461707a
Rollup merge of #128818 - RalfJung:std-miri-floats, r=tgross35
std float tests: special-case Miri in feature detection

Quick work-around to fix miri-test-libstd failures.

r? ``@tgross35``
2024-08-09 00:03:37 +02:00
Matthias Krüger 95b40727bd
Rollup merge of #128640 - RalfJung:rwlock-macos-miri, r=joboet
rwlock: disable 'frob' test in Miri on macOS

Due to https://github.com/rust-lang/rust/issues/121950, Miri will sometimes complain about this test on macOS. Better disable the test, as otherwise it can fail for unrelated PRs.

r? ``@joboet``
2024-08-09 00:03:35 +02:00
Matthias Krüger 127fbc8481
Rollup merge of #128749 - tgross35:float-inline, r=scottmcm
Mark `{f32,f64}::{next_up,next_down,midpoint}` inline

Most float functions are marked `#[inline]` so any float symbols used by these functions only need to be provided if the function itself is used. RFL recently noticed that `next_up`, `next_down`, and `midpoint` for `f32` and `f64` are not inline, which causes linker errors when building with certain configurations <https://lore.kernel.org/all/20240806150619.192882-1-ojeda@kernel.org/>.

Add the missing attributes so the symbols should no longer be required.
2024-08-08 18:57:02 +02:00
Matthias Krüger 3a9dd829d0
Rollup merge of #128306 - WiktorPrzetacznik:WiktorPrzetacznik-nonnull-alignoffset-update, r=Amanieu
Update NonNull::align_offset quarantees

This PR proposes to update [`NonNull::align_offset`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.align_offset) guarantees, which should to be matched with [`ptr::align_offset`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.align_offset-1)
(as `NonNull::align_offset` delegates to `ptr::align_offset`).

[PR #121201](https://github.com/rust-lang/rust/pull/121201) updated only `ptr::align_offset` docs.
2024-08-08 18:57:00 +02:00
Guillaume Gomez 6d69b2e408 Update compiler-builtins version to 0.1.118 2024-08-08 14:47:49 +02:00
Ralf Jung 5d968705b1 std float tests: special-case Miri in feature detection
also fix some cfg logic
2024-08-08 12:17:50 +02:00
B I Mohammed Abbas 2abcc6beeb Vxworks: Extern taskNameSet and fix build errors 2024-08-08 15:16:22 +05:30
Ralf Jung a120fb7031 rwlock: disable 'frob' test in Miri on macOS 2024-08-08 11:15:18 +02:00
B I Mohammed Abbas fb1dac21ff Fix VxWorks available parallelism: Move nonzero::uncheked into unsafe block 2024-08-08 12:59:04 +05:30
Trevor Gross 36b9aee947
Rollup merge of #128800 - clarfonthey:core-pattern-type, r=compiler-errors
Add tracking issue to core-pattern-type

While the actual `pattern_types` feature flag has an issue assigned, the exported macro and its module do not.

cc #123646
2024-08-07 20:49:05 -05:00
Trevor Gross 1d820dc9a6
Rollup merge of #128691 - tgross35:update-builtins, r=Amanieu
Update `compiler-builtins` to 0.1.117

This includes [1] which means we can remove the (nonworking) configuration of `no-f16-f128`.

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

[1]: https://github.com/rust-lang/compiler-builtins/pull/652

try-job: dist-various-1
2024-08-07 20:49:03 -05:00
ltdk 0257f42089 Add tracking issue to core-pattern-type 2024-08-07 20:43:05 -04:00
daxpedda 0732f7d5e1
Stabilize `Ready::into_inner()` 2024-08-08 00:18:19 +02:00
Matthias Krüger 2ee9678338
Rollup merge of #128261 - clarfonthey:iter-default, r=dtolnay
impl `Default` for collection iterators that don't already have it

There is a pretty strong precedent for implementing `Default` for collection iterators, and this does so for some where this implementation was missed.

I don't think this needs a separate ACP (since this precedent already exists, and these feel like they were just missed), however, it *will* need an FCP since these implementations are instantly stable.
2024-08-07 20:28:16 +02:00
Michael Howell 3312f5d652 alloc: make `to_string_str!` a bit less complex 2024-08-07 10:06:54 -07:00
Trevor Gross 6b3feb49c6 Mark `{f32,f64}::{next_up,next_down,midpoint}` inline
Most float functions are marked `#[inline]` so any float symbols used by
these functions only need to be provided if the function itself is used.
RFL recently noticed that `next_up`, `next_down`, and `midpoint` for
`f32` and `f64` are not inline, which causes linker errors when building
with certain configurations [1].

Add the missing attributes so the symbols should no longer be required.

Cc: Gary Guo <gary@garyguo.net>
Reported-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/all/20240806150619.192882-1-ojeda@kernel.org/ [1]
2024-08-07 03:24:55 -05:00
Trevor Gross 701bc03c52
Rollup merge of #128766 - Monadic-Cat:patch-1, r=tgross35
Trivial grammar fix in const keyword docs

This PR makes a trivial fix to the wording of a sentence in the `const` keyword docs.

> `const` items looks remarkably similar to `static` items, [...]

Either this should be written as
> A `const` items looks remarkably similar to a `static` item, [...]

or "looks" should be changed to "look".

I have selected the smaller diff.
2024-08-06 22:17:35 -05:00
Trevor Gross b3bfd66627
Rollup merge of #128417 - tgross35:f16-f128-math, r=dtolnay
Add `f16` and `f128` math functions

This adds intrinsics and math functions for `f16` and `f128` floating point types. Support is quite limited and some things are broken so tests don't run on many platforms, but this provides a starting point.
2024-08-06 22:17:32 -05:00
Monadic Cat f34ff1e05a
Trivial grammar fix in const keyword docs
> `const` items looks remarkably similar to `static` items, [...]

Either this should be written as
> A `const` items looks remarkably similar to a `static` item,

or "looks" should be changed to "look".

I have selected the smaller diff.
2024-08-06 21:59:04 -05:00
Trevor Gross 51e68c3006 Update `compiler-builtins` to 0.1.117
This includes [1] which means we can remove the (nonworking)
configuration of `no-f16-f128`.

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

[1]: https://github.com/rust-lang/compiler-builtins/pull/652
2024-08-06 21:48:32 -05:00
Matthias Krüger 6ed9a33001
Rollup merge of #128751 - devnexen:vxworks_set_thread_name, r=tgross35
std:🧵 set_name implementation proposal for vxWorks.
2024-08-07 00:34:15 +02:00
Matthias Krüger f00a55188f
Rollup merge of #128539 - biabbas:deny_unsafe, r=workingjubilee
Forbid unused unsafe in vxworks-specific std modules

Tracking issue #127747
Adding deny(unsafe_op_in_unsafe_fn) in VxWorks specific files did not cause any error.
Most of VxWorks falls back on Unix libraries. So we'll have to wait for Unix changes.

r? ```@workingjubilee```
2024-08-07 00:34:12 +02:00
Matthias Krüger 7e1360b1e1
Rollup merge of #128406 - lolbinarycat:bufreader_peek, r=Mark-Simulacrum
implement BufReader::peek

Part of https://github.com/rust-lang/rust/issues/128405
2024-08-07 00:34:12 +02:00
Matthias Krüger 16b251be10
Rollup merge of #125048 - dingxiangfei2009:stable-deref, r=amanieu
PinCoerceUnsized trait into core

cc ``@Darksonn`` ``@wedsonaf`` ``@ojeda``

This is a PR to introduce a `PinCoerceUnsized` trait in order to make trait impls generated by the proc-macro `#[derive(SmartPointer)]`, proposed by [RFC](e17e19ac7a/text/3621-derive-smart-pointer.md (pincoerceunsized-1)), sound. There you may find explanation, justification and discussion about the alternatives.

Note that we do not seek stabilization of this `PinCoerceUnsized` trait in the near future. The stabilisation of this trait does not block the eventual stabilization process of the `#[derive(SmartPointer)]` macro. Ideally, use of `DerefPure` is more preferrable except this will actually constitute a breaking change. `PinCoerceUnsized` emerges as a solution to the said soundness hole while avoiding the breaking change. More details on the `DerefPure` option have been described in this [section](e17e19ac7a/text/3621-derive-smart-pointer.md (derefpure)) of the RFC linked above.

Earlier discussion can be found in this [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/Pin.20and.20soundness.20of.20unsizing.20coercions) and [rust-for-linux thread](https://rust-lang.zulipchat.com/#narrow/stream/425075-rust-for-linux/topic/.23.5Bderive.28SmartPointer.29.5D.20and.20pin.20unsoundness.20rfc.233621).

try-job: dist-various-2
2024-08-07 00:34:11 +02:00
Michael Howell 1b587a6e76 alloc: add ToString specialization for `&&str`
Fixes #128690
2024-08-06 14:37:33 -07:00
David Carlier b9e8e99198
std:🧵 set_name implementation proposal for vxWorks. 2024-08-06 21:10:12 +01:00
David Tolnay ba3cb156cb
Remove unused lifetime parameter from spawn_unchecked 2024-08-06 10:20:48 -07:00
Flying-Toast b335ec9ec8 Add a special case for CStr/CString in the improper_ctypes lint
Instead of saying to "consider adding a `#[repr(C)]` or
`#[repr(transparent)]` attribute to this struct", we now tell users to
"Use `*const ffi::c_char` instead, and pass the value from
`CStr::as_ptr()`" when the type involved is a `CStr` or a `CString`.

Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
2024-08-06 13:56:59 +00:00
binarycat 4af77dfea5 implement BufReader::peek 2024-08-05 15:44:54 -04:00
Ralf Jung 212417b87f custom MIR: add support for tail calls 2024-08-05 18:23:14 +02:00
Ralf Jung 28e0907111 nontemporal_store: make sure that the intrinsic is truly just a hint 2024-08-05 10:57:14 +02:00
Georgii Rylov 8a61674559 WASI fixing unsafe_op_in_unsafe_fn for std::{os, sys} 2024-08-05 09:48:26 +01:00
bors 4d48a6be74 Auto merge of #128673 - matthiaskrgr:rollup-gtvpkm7, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #128026 (std:🧵 available_parallelism implementation for vxWorks proposal.)
 - #128471 (rustdoc: Fix handling of `Self` type in search index and refactor its representation)
 - #128607 (Use `object` in `run-make/symbols-visibility`)
 - #128609 (Remove unnecessary constants from flt2dec dragon)
 - #128611 (run-make: Remove cygpath)
 - #128619 (Correct the const stabilization of `<[T]>::last_chunk`)
 - #128630 (docs(resolve): more explain about `target`)
 - #128660 (tests: more crashes)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-05 06:55:50 +00:00
Matthias Krüger 74df517b90
Rollup merge of #128619 - glandium:last_chunk, r=scottmcm
Correct the const stabilization of `<[T]>::last_chunk`

`<[T]>::first_chunk` became const stable in 1.77, but `<[T]>::last_chunk` was left out. This was fixed in 3488679768, which reached stable in 1.80, making `<[T]>::last_chunk` const stable as of that version, but it is documented as being const stable as 1.77. While this is what should have happened, the documentation should reflect what actually did happen.
2024-08-05 08:22:24 +02:00
Matthias Krüger 1e951b70c7
Rollup merge of #128609 - swenson:smaller-faster-dragon, r=Amanieu
Remove unnecessary constants from flt2dec dragon

The "dragon" `flt2dec` algorithm uses multi-precision multiplication by (sometimes large) powers of 10. It has precomputed some values to help with these calculations.

BUT:

* There is no need to store powers of 10 and 2 * powers of 10: it is trivial to compute the second from the first.
* We can save a chunk of memory by storing powers of 5 instead of powers of 10 for the large powers (and just shifting as appropriate).
* This also slightly speeds up the routines (by ~1-3%) since the intermediate products are smaller and the shift is cheap.

In this PR, we remove the unnecessary constants and do the necessary adjustments.

Relevant benchmarks before (on my Threadripper 3970X, x86_64-unknown-linux-gnu):

```
num::flt2dec::bench_big_shortest                      137.92/iter   +/- 2.24
num::flt2dec::strategy:🐉:bench_big_exact_12   2135.28/iter  +/- 38.90
num::flt2dec::strategy:🐉:bench_big_exact_3     904.95/iter  +/- 10.58
num::flt2dec::strategy:🐉:bench_big_exact_inf 47230.33/iter +/- 320.84
num::flt2dec::strategy:🐉:bench_big_shortest   3915.05/iter  +/- 51.37
```

and after:

```
num::flt2dec::bench_big_shortest                      137.40/iter   +/- 2.03
num::flt2dec::strategy:🐉:bench_big_exact_12   2101.10/iter  +/- 25.63
num::flt2dec::strategy:🐉:bench_big_exact_3     873.86/iter   +/- 4.20
num::flt2dec::strategy:🐉:bench_big_exact_inf 47468.19/iter +/- 374.45
num::flt2dec::strategy:🐉:bench_big_shortest   3877.01/iter  +/- 45.74
```
2024-08-05 08:22:22 +02:00
Matthias Krüger 02c3837d8b
Rollup merge of #128026 - devnexen:available_parallelism_vxworks, r=Mark-Simulacrum
std:🧵 available_parallelism implementation for vxWorks proposal.
2024-08-05 08:22:21 +02:00
Matthias Krüger e4367cec5e
Rollup merge of #128309 - kmicklas:btreeset-cursor, r=Amanieu
Implement cursors for `BTreeSet`

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

This is a straightforward wrapping of the map API, except that map's `CursorMut` does not make sense, because there is no value to mutate. Hence, map's `CursorMutKey` is wrapped here as just `CursorMut`, since it's unambiguous for sets and we don't normally speak of "keys". On the other hand, I can see some potential for confusion with `CursorMut` meaning different things in each module. I'm happy to take suggestions to improve that.

r? ````@Amanieu````
2024-08-05 05:40:20 +02:00
Mike Hommey 70ab51f988 Correct the const stabilization of `<[T]>::last_chunk`
`<[T]>::first_chunk` became const stable in 1.77, but `<[T]>::last_chunk` was
left out. This was fixed in 3488679768, which reached stable in 1.80,
making `<[T]>::last_chunk` const stable as of that version, but it is
documented as being const stable as 1.77. While this is what should have
happened, the documentation should reflect what actually did happen.
2024-08-05 05:01:39 +09:00
bors 176e545209 Auto merge of #128534 - bjorn3:split_stdlib_workspace, r=Mark-Simulacrum
Move the standard library to a separate workspace

This ensures that the Cargo.lock packaged for it in the rust-src component is up-to-date, allowing rust-analyzer to run cargo metadata on the standard library even when the rust-src component is stored in a read-only location as is necessary for loading crates.io dependencies of the standard library.

This also simplifies tidy's license check for runtime dependencies as it can now look at all entries in library/Cargo.lock without having to filter for just the dependencies of runtime crates. In addition this allows removing an exception in check_runtime_license_exceptions that was necessary due to the compiler enabling a feature on the object crate which pulls in a dependency not allowed for the standard library.

While cargo workspaces normally enable dependencies of multiple targets to be reused, for the standard library we do not want this reusing to prevent conflicts between dependencies of the sysroot and of tools that are built using this sysroot. For this reason we already use an unstable cargo feature to ensure that any dependencies which would otherwise be shared get a different -Cmetadata argument as well as using separate build dirs.

This doesn't change the situation around vendoring. We already have several cargo workspaces that need to be vendored. Adding another one doesn't change much.

There are also no cargo profiles that are shared between the root workspace and the library workspace anyway, so it doesn't add any extra work when changing cargo profiles.
2024-08-04 18:40:03 +00:00
joboet 207ee73b7a
std: refactor UNIX random data generation
This PR makes a number of changes to the UNIX randomness implementation:
* Use `io::Error` for centralized error handling
* Move the file-fallback logic out of the `getrandom`-specific module
* Stop redefining the syscalls on macOS and DragonFly, they have appeared in `libc`
* Add a `OnceLock` to cache the random device file descriptor
2024-08-04 18:39:59 +02:00
Konippi 341511ad4e refactor: standardize duplicate processes in parser 2024-08-04 21:39:42 +09:00
Matthias Krüger c8a33f7e34
Rollup merge of #128526 - tshepang:patch-1, r=Amanieu
time.rs: remove "Basic usage text"

Only one example is given (for each method)
2024-08-04 11:32:34 +02:00
bors b389b0ab72 Auto merge of #128466 - sayantn:stdarch-update, r=tgross35
Update the stdarch submodule

cc `@tgross35` `@Amanieu`
r? `@tgross35`

try-job: dist-various-2
2024-08-04 02:11:27 +00:00
sayantn 01bda01e33 Update stdarch 2024-08-04 03:40:21 +05:30
sayantn 2cde11f2d1 Chore: add `x86_amx_intrinsics` feature flag to `core/lib.rs` and remove `issue-120720-reduce-nan.rs` 2024-08-04 03:08:18 +05:30
Matthias Krüger 06133811a6
Rollup merge of #128551 - Konippi:refactor-backtrace-style-in-panic, r=tgross35
chore: refactor backtrace style in panic

# Refactor get_backtrace_style for better readability and potential performance improvements

This PR aims to improve the readability and maintainability of the `set_backtrace_style` and `get_backtrace_style` function.
2024-08-03 20:51:53 +02:00
Matthias Krüger 53a56190af
Rollup merge of #128530 - scottmcm:repeat-n-unchecked, r=joboet
Implement `UncheckedIterator` directly for `RepeatN`

This just pulls the code out of `next` into `next_unchecked`, rather than making the `Some` and `unwrap_unchecked`ing it.

And while I was touching it, I added a codegen test that `array::repeat` for something that's just `Clone`, not `Copy`, still ends up optimizing to the same thing as `[x; n]`: <https://rust.godbolt.org/z/YY3a5ajMW>.
2024-08-03 20:51:52 +02:00
Christopher Swenson 36a805939e Remove unnecessary constants from flt2dec dragon
The "dragon" `flt2dec` algorithm uses multi-precision multiplication by
(sometimes large) powers of 10. It has precomputed some values to help
with these calculations.

BUT:

* There is no need to store powers of 10 and 2 * powers of 10: it is
  trivial to compute the second from the first.
* We can save a chunk of memory by storing powers of 5 instead of powers
  of 10 for the large powers (and just shifting by 2 as appropriate).
* This also slightly speeds up the routines (by ~1-3%) since the
  intermediate products are smaller and the shift is cheap.

In this PR, we remove the unnecessary constants and do the necessary
adjustments.

Relevant benchmarks before (on my Threadripper 3970X, x86_64-unknown-linux-gnu):

```
num::flt2dec::bench_big_shortest                      137.92/iter   +/- 2.24
num::flt2dec::strategy:🐉:bench_big_exact_12   2135.28/iter  +/- 38.90
num::flt2dec::strategy:🐉:bench_big_exact_3     904.95/iter  +/- 10.58
num::flt2dec::strategy:🐉:bench_big_exact_inf 47230.33/iter +/- 320.84
num::flt2dec::strategy:🐉:bench_big_shortest   3915.05/iter  +/- 51.37
```

and after:

```
num::flt2dec::bench_big_shortest                      137.40/iter   +/- 2.03
num::flt2dec::strategy:🐉:bench_big_exact_12   2101.10/iter  +/- 25.63
num::flt2dec::strategy:🐉:bench_big_exact_3     873.86/iter   +/- 4.20
num::flt2dec::strategy:🐉:bench_big_exact_inf 47468.19/iter +/- 374.45
num::flt2dec::strategy:🐉:bench_big_shortest   3877.01/iter  +/- 45.74
```
2024-08-03 08:49:38 -07:00
Lukas Bergdoll 613155c96a Apply review comments to PartialOrd section 2024-08-03 15:10:27 +02:00
bors 1f47624f9a Auto merge of #128404 - compiler-errors:revert-dead-code-changes, r=pnkfelix
Revert recent changes to dead code analysis

This is a revert to recent changes to dead code analysis, namely:
* efdf219 Rollup merge of #128104 - mu001999-contrib:fix/128053, r=petrochenkov
* a70dc297a8 Rollup merge of #127017 - mu001999-contrib:dead/enhance, r=pnkfelix
* 31fe9628cf Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix
* 2724aeaaeb Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix
* 977c5fd419 Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov
* 13314df21b Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix

There is an additional change stacked on top, which suppresses false-negatives that were masked by this work. I believe the functions that are touched in that code are legitimately unused functions and the types are not reachable since this `AnonPipe` type is not publically reachable -- please correct me if I'm wrong cc `@NobodyXu` who added these in ##127153.

Some of these reverts (#126315 and #126618) are only included because it makes the revert apply cleanly, and I think these changes were only done to fix follow-ups from the other PRs?

I apologize for the size of the PR and the churn that it has on the codebase (and for reverting `@mu001999's` work here), but I'm putting this PR up because I am concerned that we're making ad-hoc changes to fix bugs that are fallout of these PRs, and I'd like to see these changes reimplemented in a way that's more separable from the existing dead code pass. I am happy to review any code to reapply these changes in a more separable way.

cc `@mu001999`
r? `@pnkfelix`

Fixes #128272
Fixes #126169
2024-08-03 13:04:30 +00:00
Michael Goulet cbd27db9a9 Suppress new false-negatives that were masked by dead code analysis changes 2024-08-03 07:57:31 -04:00
Michael Goulet 5f5b4ee128 Revert "Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix"
This reverts commit 31fe9628cf, reversing
changes made to f20307851e.
2024-08-03 07:57:31 -04:00
Matthias Krüger 2f549aac39
Rollup merge of #128368 - nnethercote:rustfmt-tweaks, r=cuviper
Formatting tweaks

Some small post-#125443 formatting tweaks.

r? ``@cuviper``
2024-08-03 11:17:44 +02:00
Matthias Krüger 95d9f1c4ab
Rollup merge of #128303 - NobodyXu:specialise-for-pipe, r=cuviper
Enable `std::io::copy` specialisation for `std::pipe::{PipeReader, PipeWriter}`

Enable `std::io::copy` specialisation on unix for the newly added anonymous pipe API, tracking issue rust-lang/rust#127154
2024-08-03 11:17:43 +02:00
Matthias Krüger 1f700139f8
Rollup merge of #127586 - zachs18:more-must-use, r=cuviper
Add `#[must_use]` to some `into_raw*` functions.

cc #121287

r? ``@cuviper``

Adds `#[must_use = "losing the pointer will leak memory"]`[^1] to `Box::into_raw(_with_allocator)`, `Vec::into_raw_parts(_with_alloc)`, `String::into_raw_parts`[^2], and `rc::{Rc, Weak}::into_raw_with_allocator` (Rc's normal `into_raw` and all of `Arc`'s `into_raw*`s are already `must_use`).

Adds `#[must_use = "losing the raw <resource name may leak resources"]` to `IntoRawFd::into_raw_fd`, `IntoRawSocket::into_raw_socket`, and `IntoRawHandle::into_raw_handle`.

[^1]: "*will* leak memory" may be too-strong wording (since `Box`/`Vec`/`String`/`rc::Weak` might not have a backing allocation), but I left it as-is for simplicity and consistency.

[^2]: `String::into_raw_parts`'s `must_use` message is changed from the previous (possibly misleading) "`self` will be dropped if the result is not used".
2024-08-03 11:17:42 +02:00
Matthias Krüger 8aa18290a4
Rollup merge of #126704 - sayantn:sha, r=Amanieu
Added SHA512, SM3, SM4 target-features and `sha512_sm_x86` feature gate

This is an effort towards #126624. This adds support for these 3 target-features and introduces the feature flag `sha512_sm_x86`, which would gate these target-features and the yet-to-be-implemented detection and intrinsics in stdarch.
2024-08-03 11:17:41 +02:00
B I Mohammed Abbas c2c46e3e30 Forbid unsafe_op_in_unsafe_fn in vxworks specific os and sys files 2024-08-03 08:00:39 +05:30
Konippi a798e0f488 chore: refactor backtrace style in panic 2024-08-03 11:12:16 +09:00
bors 1df0458781 Auto merge of #128528 - workingjubilee:you-dont-need-to-see-this-cpuid-move-along, r=Amanieu
Finish removing `has_cpuid`

The one use of it was guaranteed to be always true.

try-job: test-various
2024-08-03 00:18:15 +00:00
bjorn3 1f3be75f56 Move the standard library to a separate workspace
This ensures that the Cargo.lock packaged for it in the rust-src
component is up-to-date, allowing rust-analyzer to run cargo metadata on
the standard library even when the rust-src component is stored in a
read-only location as is necessary for loading crates.io dependencies of
the standard library.

This also simplifies tidy's license check for runtime dependencies as it
can now look at all entries in library/Cargo.lock without having to
filter for just the dependencies of runtime crates. In addition this
allows removing an exception in check_runtime_license_exceptions that
was necessary due to the compiler enabling a feature on the object crate
which pulls in a dependency not allowed for the standard library.

While cargo workspaces normally enable dependencies of multiple targets
to be reused, for the standard library we do not want this reusing to
prevent conflicts between dependencies of the sysroot and of tools that
are built using this sysroot. For this reason we already use an unstable
cargo feature to ensure that any dependencies which would otherwise be
shared get a different -Cmetadata argument as well as using separate
build dirs.

This doesn't change the situation around vendoring. We already have
several cargo workspaces that need to be vendored. Adding another one
doesn't change much.

There are also no cargo profiles that are shared between the root
workspace and the library workspace anyway, so it doesn't add any extra
work when changing cargo profiles.
2024-08-02 10:48:12 +00:00
bors 19326022d2 Auto merge of #128254 - Amanieu:orig-binary-search, r=tgross35
Rewrite binary search implementation

This PR builds on top of #128250, which should be merged first.

This restores the original binary search implementation from #45333 which has the nice property of having a loop count that only depends on the size of the slice. This, along with explicit conditional moves from #128250, means that the entire binary search loop can be perfectly predicted by the branch predictor.

Additionally, LLVM is able to unroll the loop when the slice length is known at compile-time. This results in a very compact code sequence of 3-4 instructions per binary search step and zero branches.

Fixes #53823
Fixes #115271
2024-08-02 08:20:35 +00:00
Scott McMurray 77ca30f195 Implement `UncheckedIterator` directly for `RepeatN` 2024-08-01 21:58:34 -07:00
Matthias Krüger 55ed05cbac
Rollup merge of #128491 - c410-f3r:unlock-rfc-2011, r=workingjubilee
[`macro_metavar_expr_concat`] Dogfooding

cc #124225

Starts inner usage to test the robustness of the implementation.
2024-08-02 06:43:43 +02:00
Matthias Krüger 67fcb58347
Rollup merge of #128453 - RalfJung:raw_eq, r=saethlin
raw_eq: using it on bytes with provenance is not UB (outside const-eval)

The current behavior of raw_eq violates provenance monotonicity. See https://github.com/rust-lang/rust/pull/124921 for an explanation of provenance monotonicity. It is violated in raw_eq because comparing bytes without provenance is well-defined, but adding provenance makes the operation UB.

So remove the no-provenance requirement from raw_eq. However, the requirement stays in-place for compile-time invocations of raw_eq, that indeed cannot deal with provenance.

Cc `@rust-lang/opsem`
2024-08-02 06:43:43 +02:00
Jubilee Young 2f0aaaf2b9 std: Remove has_cpuid
The one use of it was guaranteed to be always true.
2024-08-01 20:45:38 -07:00
Tshepang Mbambo af79a6396c
time.rs: remove "Basic usage text"
Only one example is given (for each method)
2024-08-02 05:16:01 +02:00
Caio b2f7e71f0b Dogfood 2024-08-01 21:32:12 -03:00
sayantn 41b017ec99 Add the `sha512`, `sm3` and `sm4` target features
Add the feature in `core/lib.rs`
2024-08-02 02:29:15 +05:30
Ken Micklas 0bc501e0ad Fix mutability in doc tests for `BTreeSet` cursors 2024-08-01 21:02:51 +01:00
Trevor Gross 8e2ca0c9d5 Add a disclaimer about x86 `f128` math functions
Due to a LLVM bug, `f128` math functions link successfully but LLVM
chooses the wrong symbols (`long double` symbols rather than those for
binary128).

Since this is a notable problem that may surprise a number of users, add
a note about it.

Link: https://github.com/llvm/llvm-project/issues/44744
2024-08-01 15:38:53 -04:00