Commit Graph

15973 Commits

Author SHA1 Message Date
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
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
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
Chai T. Rex c836739529 Change `assert_unsafe_precondition` docs to refer to `check_language_ub` 2024-08-21 17:35:54 -04: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
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
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
许杰友 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 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