Commit Graph

17872 Commits

Author SHA1 Message Date
Laine Taffin Altman
baa1cdde29
Docs for f16 and f128: correct a typo and add details 2025-02-02 19:48:57 -08:00
Matthias Krüger
961bf7ffa6
Rollup merge of #136434 - RalfJung:rustc_allowed_through_unstable_modules-deprecation-required, r=compiler-errors
rustc_allowed_through_unstable_modules: require deprecation message

This changes the `#[rustc_allowed_through_unstable_modules]` attribute so that a deprecation message (ideally directing people towards the stable path) is required.
2025-02-02 18:05:25 +01:00
Matthias Krüger
198384c8cc
Rollup merge of #136283 - hkBst:patch-31, r=workingjubilee
Update encode_utf16 to mention it is native endian

Fixes #83102
2025-02-02 18:05:22 +01:00
Matthias Krüger
48aede0773
Rollup merge of #134272 - RalfJung:destabilize-rustc_encodable_decodable, r=oli-obk
Remove rustc_encodable_decodable feature

This has been shown in future-compat reports since Rust 1.79 (https://github.com/rust-lang/rust/pull/116016), released June 2024. Let's see if crater still finds any issues.

Part of https://github.com/rust-lang/rust/issues/134301.

Cc ``@rust-lang/libs-api``
2025-02-02 18:05:22 +01:00
Ralf Jung
3320e91575 rustc_allowed_through_unstable_modules: require deprecation message 2025-02-02 12:36:12 +01:00
Matthias Krüger
555dd6fe76
Rollup merge of #136133 - hkBst:patch-23, r=ibraheemdev
Fix sentence in process::abort
2025-02-02 12:31:55 +01:00
Matthias Krüger
15a5f5f5e0
Rollup merge of #136364 - hkBst:ptr_cmp_docs, r=tgross35
document that ptr cmp is unsigned

Fixes #77497
2025-02-01 16:41:05 +01:00
Matthias Krüger
cbcb695f9e
Rollup merge of #136360 - slanterns:once_wait, r=tgross35
Stabilize `once_wait`

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

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

r? libs-api
2025-02-01 16:41:04 +01:00
Matthias Krüger
a56e85a827
Rollup merge of #136307 - WaffleLapkin:minminmin, r=scottmcm
Implement all mix/max functions in a (hopefully) more optimization amendable way

Previously the graph was like this:

```
min -> Ord::min -> min_by -> match on compare() (in these cases compare = Ord::cmp)
                                      ^
                                      |
                                 min_by_key
```
now it looks like this:
```
min -> Ord::min -> `<=` <- min_by_key

min_by -> `Ordering::is_le` of `compare()`
```
(`max*` and `minmax*` are the exact same, i.e. they also use `<=` and `is_le`)

I'm not sure how to test this, but it should probably be easier for the backend to optimize.

r? `@scottmcm`
cc https://github.com/rust-lang/rust/issues/115939#issuecomment-2622161134
2025-02-01 16:41:04 +01:00
Matthias Krüger
9dfdef618c
Rollup merge of #135684 - ranger-ross:mutex-docs, r=joboet
docs: Documented Send and Sync requirements for Mutex + MutexGuard

This an attempt to continue where #123225 left off.

I did some light clean up from the work done in that PR.
I also documented the `!Send` + `Sync` implementations for `MutexGuard` to the best of my knowledge.
Let me know if I got anything wrong 😄

fixes #122856

cc: ``@IoaNNUwU``

r? ``@joboet``
2025-02-01 16:41:03 +01:00
Marijn Schouten
55dc6dbcf0 document ptr comparison being by address 2025-02-01 15:28:44 +01:00
Marijn Schouten
06171066d2 Fix sentence in process::abort 2025-02-01 13:32:01 +01:00
Ross Sullivan
3d84a49c37
docs: Documented Send and Sync requirements for Mutex + MutexGuard 2025-02-01 14:20:03 +09:00
Matthias Krüger
70894fed76
Rollup merge of #136351 - Darksonn:coerce-pointee-docs, r=compiler-errors
Add documentation for derive(CoercePointee)

Part of [RFC 3621][rfc] tracked by #123430. This text is heavily based on the guide-level explanation from the RFC.

``@rustbot`` label F-derive_coerce_pointee

[rfc]: https://rust-lang.github.io/rfcs/3621-derive-smart-pointer.html
2025-02-01 01:19:22 +01:00
Matthias Krüger
f90c321eb2
Rollup merge of #136163 - uellenberg:driftsort-off-by-one, r=Mark-Simulacrum
Fix off-by-one error causing slice::sort to abort the program

Fixes #136103.
Based on the analysis by ``@jonathan-gruber-jg`` and ``@orlp.``
2025-02-01 01:19:20 +01:00
Slanterns
6fa6168e71
stabilize once_wait 2025-02-01 02:10:02 +08:00
bors
aa4cfd0809 Auto merge of #134424 - 1c3t3a:null-checks, r=saethlin
Insert null checks for pointer dereferences when debug assertions are enabled

Similar to how the alignment is already checked, this adds a check
for null pointer dereferences in debug mode. It is implemented similarly
to the alignment check as a `MirPass`.

This inserts checks in the same places as the `CheckAlignment` pass and additionally
also inserts checks for `Borrows`, so code like
```rust
let ptr: *const u32 = std::ptr::null();
let val: &u32 = unsafe { &*ptr };
```
will have a check inserted on dereference. This is done because null references
are UB. The alignment check doesn't cover these places, because in `&(*ptr).field`,
the exact requirement is that the final reference must be aligned. This is something to
consider further enhancements of the alignment check.

For now this is implemented as a separate `MirPass`, to make it easy to disable
this check if necessary.

This is related to a 2025H1 project goal for better UB checks in debug
mode: https://github.com/rust-lang/rust-project-goals/pull/177.

r? `@saethlin`
2025-01-31 15:56:53 +00:00
Alice Ryhl
209bb81483 Add documentation for derive(CoercePointee) 2025-01-31 11:37:41 +00:00
Bastian Kersting
b151b513ba Insert null checks for pointer dereferences when debug assertions are enabled
Similar to how the alignment is already checked, this adds a check
for null pointer dereferences in debug mode. It is implemented similarly
to the alignment check as a MirPass.

This is related to a 2025H1 project goal for better UB checks in debug
mode: https://github.com/rust-lang/rust-project-goals/pull/177.
2025-01-31 11:13:34 +00:00
Marijn Schouten
860476f6e0 Update encode_utf16 to mention it is native endian 2025-01-31 11:44:11 +01:00
bors
7f36543a48 Auto merge of #136332 - jhpratt:rollup-aa69d0e, r=jhpratt
Rollup of 9 pull requests

Successful merges:

 - #132156 (When encountering unexpected closure return type, point at return type/expression)
 - #133429 (Autodiff Upstreaming - rustc_codegen_ssa, rustc_middle)
 - #136281 (`rustc_hir_analysis` cleanups)
 - #136297 (Fix a typo in profile-guided-optimization.md)
 - #136300 (atomic: extend compare_and_swap migration docs)
 - #136310 (normalize `*.long-type.txt` paths for compare-mode tests)
 - #136312 (Disable `overflow_delimited_expr` in edition 2024)
 - #136313 (Filter out RPITITs when suggesting unconstrained assoc type on too many generics)
 - #136323 (Fix a typo in conventions.md)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-31 09:42:28 +00:00
Jacob Pratt
e2a73ab7ad
Rollup merge of #136300 - RalfJung:compare-and-swap, r=joboet
atomic: extend compare_and_swap migration docs

Fixes https://github.com/rust-lang/rust/issues/80486
2025-01-31 00:26:32 -05:00
Jacob Pratt
08dc8c931f
Rollup merge of #136296 - RalfJung:float-min-max, r=tgross35
float::min/max: mention the non-determinism around signed 0

Turns out this can actually produce different results on different machines [in practice](https://github.com/rust-lang/rust/issues/83984#issuecomment-2623859230); that seems worth documenting. I assume LLVM will happily const-fold these operations so so there could be different results for the same input even on the same machine, depending on whether things get const-folded or not.

`@nikic` I remember there was an LLVM soundness fix regarding scalar evolution for loops that had to recognize certain operations as non-deterministic... it seems to me that pass would also have to avoid predicting the result of `llvm.{min,max}num`, for the same reason?

r? `@tgross35`
Cc `@rust-lang/libs-api`

If this lands we should also make Miri non-deterministic here.

Fixes https://github.com/rust-lang/rust/issues/83984
2025-01-31 00:25:38 -05:00
Jacob Pratt
b249760c51
Rollup merge of #135414 - tgross35:stabilize-const_black_box, r=dtolnay
Stabilize `const_black_box`

This has been unstably const since #92226, but a tracking issue was never created. Per [discussion on Zulip][zulip], there should not be any blockers to making this const-stable. The function does not provide any functionality at compile time but does allow code reuse between const- and non-const functions, so stabilize it here.

[zulip]: https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/const_black_box
2025-01-31 00:25:34 -05:00
Waffle Lapkin
c5835cd648
implement all min/max fns in terms of </is_lt
`<` seems to be the "lucky one" for llvm
2025-01-31 05:45:12 +01:00
Waffle Lapkin
b20307b3e9
improve doc tests for (min/max/minmax).* functions
- add tests for `a == b` where missing
- try to make all the tests more similar
- try to use more illustrative test values
2025-01-31 05:30:32 +01:00
Matthias Krüger
867317835d
Rollup merge of #136288 - joshtriplett:would-you-could-you-with-some-locks--would-you-could-you-in-some-docs, r=m-ou-se
Improve documentation for file locking

Add notes to each method stating that locks get dropped on close.

Clarify the return values of the try methods: they're only defined if
the lock is held via a *different* file handle/descriptor. That goes
along with the documentation that calling them while holding a lock via
the *same* file handle/descriptor may deadlock.

Document the behavior of unlock if no lock is held.

r? `@m-ou-se`
(Documentation changes requested in https://github.com/rust-lang/rust/issues/130994 .)
2025-01-30 20:47:09 +01:00
Matthias Krüger
410442f610
Rollup merge of #136271 - Sky9x:debug-maybeuninit-footgun, r=tgross35
Remove minor future footgun in `impl Debug for MaybeUninit`

No longer breaks if `MaybeUninit` moves modules (technically it could break if `MaybeUninit` were renamed but realistically that will never happen)

Debug impl originally added in #133282
2025-01-30 20:47:08 +01:00
Matthias Krüger
c32f2c7172
Rollup merge of #135852 - lukas-code:asyncfn-prelude-core, r=compiler-errors
Add `AsyncFn*` to `core` prelude

In https://github.com/rust-lang/rust/pull/132611 these got added to the `std` prelude only, which looks like an oversight.

r? libs-api
cc `@compiler-errors`
2025-01-30 20:47:05 +01:00
Matthias Krüger
55c7a02a8b
Rollup merge of #135475 - Ayush1325:uefi-absolute-path, r=jhpratt
uefi: Implement path

This PR is split off from https://github.com/rust-lang/rust/pull/135368 to reduce noise.

UEFI paths can be of 4 types:
1. Absolute Shell Path: Uses shell mappings
2. Absolute Device Path: this is what we want
3. Relative root: path relative to the current root.
4. Relative

Absolute shell path can be identified with `:` and Absolute Device path can be identified with `/`. Relative root path will start with `\`.

The algorithm is mostly taken from edk2 UEFI shell implementation and is somewhat simple. Check for the path type in order.

For Absolute Shell path, use `EFI_SHELL->GetDevicePathFromMap` to get a BorrowedDevicePath for the volume.

For Relative paths, we use the current working directory to construct the new path.

BorrowedDevicePath abstraction is needed to interact with `EFI_SHELL->GetDevicePathFromMap` which returns a Device Path Protocol with the lifetime of UEFI shell.

Absolute Shell paths cannot exist if UEFI shell is missing.

cc `@nicholasbishop`
2025-01-30 20:47:04 +01:00
bors
a6434ef9c0 Auto merge of #134824 - niklasf:int_from_ascii, r=ibraheemdev
Implement `int_from_ascii` (#134821)

Provides unstable `T::from_ascii()` and `T::from_ascii_radix()` for integer types `T`, as drafted in tracking issue #134821.

To deduplicate documentation without additional macros, implementations of `isize` and `usize` no longer delegate to equivalent integer types. After #132870 they are inlined anyway.
2025-01-30 14:25:22 +00:00
Ralf Jung
46b7da8243 atomic: extend compare_and_swap migration docs 2025-01-30 14:40:08 +01:00
Ralf Jung
6b699ccee4 float::min/max: mention the non-determinism around signed 0 2025-01-30 13:44:13 +01:00
Josh Triplett
fb1ad2fe02 Improve documentation for file locking
Add notes to each method stating that locks get dropped on close.

Clarify the return values of the try methods: they're only defined if
the lock is held via a *different* file handle/descriptor. That goes
along with the documentation that calling them while holding a lock via
the *same* file handle/descriptor may deadlock.

Document the behavior of unlock if no lock is held.
2025-01-30 11:48:26 +01:00
Stuart Cook
4059a796d5
Rollup merge of #136259 - hkBst:patch-30, r=thomcc
Cleanup docs for Allocator

This is an attempt to remove ungrammatical constructions and clean up the prose. I've sometimes had to try hard to understand what was being stated, so it is possible that I've misunderstood the original meaning. In particular, I did not see a difference between:
 - the borrow-checker lifetime of the allocator type itself.
 - as long as at least one of the allocator instance and all of its clones has not been dropped.
2025-01-30 14:25:07 +11:00
Stuart Cook
3a2f26f542
Rollup merge of #136215 - btj:patch-1, r=cuviper
btree/node.rs: remove incorrect comment from pop_internal_level docs
2025-01-30 14:25:05 +11:00
Stuart Cook
6ebe590e41
Rollup merge of #135847 - edwloef:slice_ptr_rotate_opt, r=scottmcm
optimize slice::ptr_rotate for small rotates

r? `@scottmcm`

This swaps the positions and numberings of algorithms 1 and 2 in `slice::ptr_rotate`, and pulls the entire outer loop into algorithm 3 since it was redundant for the first two. Effectively, `ptr_rotate` now always does the `memcpy`+`memmove`+`memcpy` sequence if the shifts fit into the stack buffer.
With this change, an `IndexMap`-style `move_index` function is optimized correctly.

Assembly comparisons:
- `move_index`, before: https://godbolt.org/z/Kr616KnYM
- `move_index`, after: https://godbolt.org/z/1aoov6j8h
- the code from `#89714`, before: https://godbolt.org/z/Y4zaPxEG6
- the code from `#89714`, after: https://godbolt.org/z/1dPx83axc

related to #89714
some relevant discussion in https://internals.rust-lang.org/t/idea-shift-move-to-efficiently-move-elements-in-a-vec/22184

Behavior tests pass locally. I can't get any consistent microbenchmark results on my machine, but the assembly diffs look promising.
2025-01-30 14:25:04 +11:00
Sky
b320e1741c
Remove minor future footgun in impl Debug for MaybeUninit
No longer breaks if `MaybeUninit` moves modules (technically it could break if `MaybeUninit` were renamed but realistically that will never happen)
2025-01-29 20:23:59 -05:00
Marijn Schouten
52519e145e Cleanup docs for Allocator 2025-01-29 20:15:49 +01:00
edwloef
fb3d1d0c4b
add inline attribute and codegen test 2025-01-29 19:34:19 +01:00
edwloef
311c3b71f0
split slice::ptr_rotate into three separate algorithms, to hopefully help inlining 2025-01-29 19:34:15 +01:00
bors
0cc4f4f7b8 Auto merge of #136248 - matthiaskrgr:rollup-leaxgfd, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #133382 (Suggest considering casting fn item as fn pointer in more cases)
 - #136092 (Test pipes also when not running on Windows and Linux simultaneously)
 - #136190 (Remove duplicated code in RISC-V asm bad-reg test)
 - #136192 (ci: remove unused windows runner)
 - #136205 (Properly check that array length is valid type during built-in unsizing in index)
 - #136211 (Update mdbook to 0.4.44)
 - #136212 (Tweak `&mut self` suggestion span)
 - #136214 (Make crate AST mutation accessible for driver callback)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-29 16:18:29 +00:00
Matthias Krüger
da7980b315
Rollup merge of #136092 - tbu-:pr_io_pipe_test, r=joboet
Test pipes also when not running on Windows and Linux simultaneously

Fixes https://github.com/rust-lang/rust/pull/135635#pullrequestreview-2574184488.

Based on top of #135635 to avoid merge conflicts.
2025-01-29 15:29:30 +01:00
bors
a1d7676d6a Auto merge of #136227 - fmease:rollup-ewpvznh, r=fmease
Rollup of 9 pull requests

Successful merges:

 - #136121 (Deduplicate operand creation between scalars, non-scalars and string patterns)
 - #136134 (Fix SIMD codegen tests on LLVM 20)
 - #136153 (Locate asan-odr-win with other sanitizer tests)
 - #136161 (rustdoc: add nobuild typescript checking to our JS)
 - #136166 (interpret: is_alloc_live: check global allocs last)
 - #136168 (GCI: Don't try to eval / collect mono items inside overly generic free const items)
 - #136170 (Reject unsound toggling of Arm atomics-32 target feature)
 - #136176 (Render pattern types nicely in mir dumps)
 - #136186 (uefi: process: Fix args)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-29 11:27:18 +00:00
uellenberg
1565254478 Fix off-by-one error causing driftsort to crash
Fixes #136103.
Based on the analysis by @jonathan-gruber-jg and @orlp.
2025-01-28 23:39:46 -08:00
Bart Jacobs
810e4c1bc6
btree/node.rs: pop_internal_level: does not invalidate other handles 2025-01-29 08:35:29 +01:00
León Orell Valerian Liehr
7e60f276ce
Rollup merge of #136186 - Ayush1325:uefi-process-args-fix, r=nicholasbishop,Noratrieb
uefi: process: Fix args

- While working on process env support, I found that args were currently broken. Not sure how I missed it in the PR, but well here is the fix.
- Additionally, no point in adding space at the end of args.
2025-01-29 06:03:25 +01:00
León Orell Valerian Liehr
53f343f396
Rollup merge of #135625 - c410-f3r:cfg-match-foo-bar-baz, r=tgross35,jhpratt
[cfg_match] Document the use of expressions.

cc #115585

Adds documentation to this new feature introduced in #133720.
2025-01-29 03:12:18 +01:00
Bart Jacobs
6763561161
btree/node.rs: remove incorrect comment from pop_internal_level docs 2025-01-28 21:42:51 +01:00
bors
bf1b174e7d Auto merge of #136203 - matthiaskrgr:rollup-1k0f44l, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #135869 (Make docs for AtomicUsize::from_mut platform-independent)
 - #135892 (-Znext-solver: "normalize" signature before checking it mentions self in `deduce_closure_signature`)
 - #136055 (Implement MIR const trait stability checks)
 - #136066 (Pass spans to `perform_locally_in_new_solver`)
 - #136071 ([Clippy] Add vec_reserve & vecdeque_reserve diagnostic items)
 - #136124 (Arbitrary self types v2: explain test.)
 - #136149 (Flip the `rustc-rayon`/`indexmap` dependency order)
 - #136173 (Update comments and sort target_arch in c_char_definition)
 - #136178 (Update username in build helper example)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-28 20:15:51 +00:00