Commit Graph

8325 Commits

Author SHA1 Message Date
Michael Goulet
a61537f6c0 occured -> occurred 2025-02-08 22:28:21 +00:00
bjorn3
1fcae03369 Rustfmt 2025-02-08 22:12:13 +00:00
Jaken Herman
4457f44065 Document Sum::sum returns additive identities for []
Because the neutral element of `<fNN as iter::Sum>` was changed to
`neg_zero`, the documentation needed to be updated, as it was reporting
inadequate information about what should be expected from the return.

Co-authored-by: Jubilee <workingjubilee@gmail.com>
2025-02-08 14:06:13 -08:00
Frank Steffahn
7155382240 Make AsyncFnOnce, AsyncFnMut, AsyncFn non-#[fundamental] 2025-02-08 02:45:29 +01:00
Askar Safin
ac31e9572b library: doc: core::alloc::Allocator: trivial typo fix 2025-02-07 09:14:17 +03:00
Waffle Lapkin
82b32ba03d
stabilize NonZero::count_ones 2025-02-06 22:40:25 +01:00
bors
59588250ad Auto merge of #136613 - workingjubilee:rollup-ry6rw0m, r=workingjubilee
Rollup of 13 pull requests

Successful merges:

 - #133932 (Avoid using make_direct_deprecated() in extern "ptx-kernel")
 - #136269 (Pass spans around new solver)
 - #136550 (Fix `rustc_hidden_type_of_opaques` for RPITITs with no default body)
 - #136558 (Document minimum supported host tooling on macOS)
 - #136563 (Clean up `Trivial*Impls` macros)
 - #136566 (Fix link in from_fn.rs)
 - #136573 (Document why some "type mismatches" exist)
 - #136583 (Only highlight unmatchable parameters at the definition site)
 - #136587 (Update browser-ui-test version to `0.20.2`)
 - #136590 (Implement RustcInternal for RawPtrKind)
 - #136591 (Add `rustc_hir_pretty::expr_to_string` function)
 - #136595 (Fix `unreachable_pub` lint for hermit target)
 - #136611 (cg_llvm: Remove the `mod llvm_` hack, which should no longer be necessary)

Failed merges:

 - #136565 (compiler: Clean up weird `rustc_abi` reexports)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-06 06:45:07 +00:00
Jubilee
8964e70051
Rollup merge of #136566 - hkBst:patch-1, r=scottmcm
Fix link in from_fn.rs
2025-02-05 19:53:49 -08:00
bors
c753cb9b42 Auto merge of #136409 - TDecking:mul_hi, r=Mark-Simulacrum
Use `widening_mul` instead of a separate function

A helper function became obsolete after `widening_mul` became available for `u128` values.
2025-02-06 03:43:58 +00:00
许杰友 Jieyou Xu (Joe)
fd4623bdcc
Rollup merge of #136555 - cramertj:split_off, r=dtolnay
Rename `slice::take...` methods to `split_off...`

This rename was discussed and recommended in a recent t-libs meeting.

cc https://github.com/rust-lang/rust/issues/62280

There's an additional commit here which modifies internals of unstable `OneSidedRange` APIs in order to implement `split_off` methods in a panic-free way (remove `unreachable!()`) as recommended in https://github.com/rust-lang/rust/pull/88502/files#r760177240. I can split this out into a separate PR if needed.
2025-02-05 19:09:38 +08:00
许杰友 Jieyou Xu (Joe)
7ad1a3b8d8
Rollup merge of #136517 - m4rch3n1ng:inherent-str-constructors, r=jhpratt
implement inherent str constructors

implement #131114

this implements
- str::from_utf8
- str::from_utf8_mut
- str::from_utf8_unchecked
- str::from_utf8_unchecked_mut

i left `std::str::from_raw_parts` and `std::str::from_raw_parts_mut` out of this as those are unstable and were not mentioned by the tracking issue or the original pull request, but i can  add those here as well.

i was also unsure of what to do with the `rustc_const_(un)stable` attributes: i removed the `#[rustc_const_stable]` attribute from `str::from_utf8`, `str::from_utf8_unchecked` and `str::from_utf8_unchecked_mut`, and left the`#[rust_const_unstable]` in `str::from_utf8_mut` (btw why is that one not const stable yet with #57349 merged?).

is there a way to redirect users to the stable `std::str::from_utf8` instead of only saying "hey this is unstable"?

for now i just removed the check for `str::from_utf8` in the test in `tests/ui/suggestions/suggest-std-when-using-type.rs`.
2025-02-05 19:09:36 +08:00
Marijn Schouten
6770d3ddf4
Fix link in from_fn.rs 2025-02-05 08:52:13 +01:00
León Orell Valerian Liehr
ba420062f1
Rollup merge of #136502 - yotamofek:pr/fmt-from-fn-must-use, r=dtolnay
Mark `std::fmt::from_fn` as `#[must_use]`

While working on #135494 I managed to shoot my own foot a few times by forgetting to actually use the result of `fmt::from_fn`, so I think a `#[must_use]` could be appropriate!

Didn't have a good message to put in the attr so left it blank, still unstable so we can come back to it I guess?

cc #117729 (and a huge +1 for getting it stabilized, it's very useful IMHO)
2025-02-05 05:03:06 +01:00
León Orell Valerian Liehr
d81701b610
Rollup merge of #128045 - pnkfelix:rustc-contracts, r=oli-obk
#[contracts::requires(...)]  + #[contracts::ensures(...)]

cc https://github.com/rust-lang/rust/issues/128044

Updated contract support: attribute syntax for preconditions and postconditions, implemented via a series of desugarings  that culminates in:
1. a compile-time flag (`-Z contract-checks`) that, similar to `-Z ub-checks`, attempts to ensure that the decision of enabling/disabling contract checks is delayed until the end user program is compiled,
2. invocations of lang-items that handle invoking the precondition,  building a checker for the post-condition, and invoking that post-condition checker at the return sites for the function, and
3. intrinsics for the actual evaluation of pre- and post-condition predicates that third-party verification tools can intercept and reinterpret for their own purposes (e.g. creating shims of behavior that abstract away the function body and replace it solely with the pre- and post-conditions).

Known issues:

 * My original intent, as described in the MCP (https://github.com/rust-lang/compiler-team/issues/759) was   to have a rustc-prefixed attribute namespace (like   rustc_contracts::requires). But I could not get things working when I tried   to do rewriting via a rustc-prefixed builtin attribute-macro. So for now it  is called `contracts::requires`.

 * Our attribute macro machinery does not provide direct support for attribute arguments that are parsed like rust expressions. I spent some time trying to add that (e.g. something that would parse the attribute arguments as an AST while treating the remainder of the items as a token-tree), but its too big a lift for me to undertake. So instead I hacked in something approximating that goal, by semi-trivially desugaring the token-tree attribute contents into internal AST constucts. This may be too fragile for the long-term.
   * (In particular, it *definitely* breaks when you try to add a contract to a function like this: `fn foo1(x: i32) -> S<{ 23 }> { ... }`, because its token-tree based search for where to inject the internal AST constructs cannot immediately see that the `{ 23 }` is within a generics list. I think we can live for this for the short-term, i.e. land the work, and continue working on it while in parallel adding a new attribute variant that takes a token-tree attribute alongside an AST annotation, which would completely resolve the issue here.)

* the *intent* of `-Z contract-checks` is that it behaves like `-Z ub-checks`, in that we do not prematurely commit to including or excluding the contract evaluation in upstream crates (most notably, `core` and `std`). But the current test suite does not actually *check* that this is the case. Ideally the test suite would be extended with a multi-crate test that explores the matrix of enabling/disabling contracts on both the upstream lib and final ("leaf") bin crates.
2025-02-05 05:03:01 +01:00
Taylor Cramer
836a989820 Add OneSidedRangeBound to eliminate panic in split_point_of
See discussion in https://github.com/rust-lang/rust/pull/88502/files#r760177240
2025-02-04 11:45:21 -08:00
Taylor Cramer
07cf20e987 Rename slice::take methods to split_off 2025-02-04 11:09:17 -08:00
bors
3f33b30e19 Auto merge of #135760 - scottmcm:disjoint-bitor, r=WaffleLapkin
Add `unchecked_disjoint_bitor` per ACP373

Following the names from libs-api in https://github.com/rust-lang/libs-team/issues/373#issuecomment-2085686057

Includes a fallback implementation so this doesn't have to update cg_clif or cg_gcc, and overrides it in cg_llvm to use `or disjoint`, which [is available in LLVM 18](https://releases.llvm.org/18.1.0/docs/LangRef.html#or-instruction) so hopefully we don't need any version checks.
2025-02-04 17:46:06 +00:00
bors
01e4f19cc8 Auto merge of #136534 - jhpratt:rollup-dnz57dq, r=jhpratt
Rollup of 6 pull requests

Successful merges:

 - #136398 (add UnsafeCell direct access APIs)
 - #136465 (Some `rustc_middle` cleanups)
 - #136479 (std::fs: further simplify dirent64 handling)
 - #136504 (Fix last compare-mode false negatives in tests)
 - #136511 (Add `cast_signed` and `cast_unsigned` methods for `NonZero` types)
 - #136518 (Add note about `FnPtr` trait being exposed as public bound)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-04 14:59:25 +00:00
bors
7b31983d55 Auto merge of #136533 - jhpratt:rollup-s0ign8n, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - #134777 (Enable more tests on Windows)
 - #135621 (Move some std tests to integration tests)
 - #135844 ( Add new tool for dumping feature status based on tidy )
 - #136167 (Implement unstable `new_range` feature)
 - #136334 (Extract `core::ffi` primitives to a separate (internal) module)

Failed merges:

 - #136201 (Removed dependency on the field-offset crate, alternate approach)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-04 12:13:02 +00:00
Jacob Pratt
af178aa806
Rollup merge of #136518 - Urgau:fn_ptr-public-bound, r=Noratrieb
Add note about `FnPtr` trait being exposed as public bound
2025-02-04 05:38:06 -05:00
Jacob Pratt
5178a3630e
Rollup merge of #136511 - joshtriplett:nonzero-cast-signed-unsigned, r=dtolnay
Add `cast_signed` and `cast_unsigned` methods for `NonZero` types

Requested in https://github.com/rust-lang/rust/issues/125882 .

Note that this keeps the same names as the methods currently present on other
integer types. If we want to rename them, we can rename them all at the same
time.
2025-02-04 05:38:05 -05:00
Jacob Pratt
d89e98dcbf
Rollup merge of #136398 - pitaj:unsafecell_access, r=dtolnay
add UnsafeCell direct access APIs

- Implementation for ACP: https://github.com/rust-lang/libs-team/issues/521
- Tracking issue #136327
2025-02-04 05:38:03 -05:00
Jacob Pratt
54f9ef9eda
Rollup merge of #136334 - ricci009:primitivers, r=tgross35
Extract `core::ffi` primitives to a separate (internal) module

### Introduce library/core/src/ffi/primitives.rs

The regex preprocessing for PR #133944 would be more robust if the relevant types from core/src/ffi/mod.rs were first moved to library/core/src/ffi/primitives.rs, then there isn't a need to deal with traits / c_str / va_list / whatever might wind up in that module in the future

r? `@tgross35`
2025-02-04 05:36:53 -05:00
Jacob Pratt
d31e137d6a
Rollup merge of #136167 - pitaj:new_range, r=Nadrieril
Implement unstable `new_range` feature

Switches `a..b`, `a..`, and `a..=b` to resolve to the new range types.

For rust-lang/rfcs#3550
Tracking issue #123741

also adds the re-export that was missed in the original implementation of `new_range_api`
2025-02-04 05:36:52 -05:00
bors
019fc4de2f Auto merge of #135265 - pascaldekloe:fmt-int-speed, r=tgross35,ChrisDenton
Display of integers without raw pointers and without overflowing_literals

The benchmarks as is measure formatting speed of literals. The first commit `black_box`-es input to simulate runtime speed instead.

The second commit replaces `unsafe` pointer optimizations with plain array indices. The performance is equivalent on Apple M1. Needs peer review on Intel.

Happy to do the 128-bit version too if such change is welcome.
2025-02-04 09:15:53 +00:00
may
15adc38ffc
specify a prim@slice in docs
i am not quite sure how this failure is in any way related to this pr,
since i am only touching inherent functions on str? but sure.
2025-02-04 02:51:44 +01:00
may
03eed12168
implement inherent str constructors 2025-02-04 02:51:44 +01:00
Urgau
d47cb21188 Add note about FnPtr being exposed as public bound 2025-02-03 23:59:43 +01:00
ricci009
3419e2f408 primitive type migration from mod.rs to primitives.rs 2025-02-03 17:21:32 -05:00
Celina G. Val
ddbf54b67d Rename rustc_contract to contract
This has now been approved as a language feature and no longer needs
a `rustc_` prefix.

Also change the `contracts` feature to be marked as incomplete and
`contracts_internals` as internal.
2025-02-03 13:55:15 -08:00
Celina G. Val
2bb1464cb6 Improve contracts intrisics and remove wrapper function
1. Document the new intrinsics.
2. Make the intrinsics actually check the contract if enabled, and
   remove `contract::check_requires` function.
3. Use panic with no unwind in case contract is using to check for
   safety, we probably don't want to unwind. Following the same
   reasoning as UB checks.
2025-02-03 13:55:15 -08:00
Felix S. Klock II
6a6c6b891b Separate contract feature gates for the internal machinery
The extended syntax for function signature that includes contract clauses
should never be user exposed versus the interface we want to ship
externally eventually.
2025-02-03 13:55:15 -08:00
Felix S. Klock II
ae7eff0be5 Desugars contract into the internal AST extensions
Check ensures on early return due to Try / Yeet

Expand these two expressions to include a call to contract checking
2025-02-03 13:54:32 -08:00
Josh Triplett
f4a92e3262 Add cast_signed and cast_unsigned methods for NonZero types 2025-02-03 22:18:44 +01:00
Celina G. Val
38eff16d0a Express contracts as part of function header and lower it to the contract lang items
includes post-developed commit: do not suggest internal-only keywords as corrections to parse failures.

includes post-developed commit: removed tabs that creeped in into rustfmt tool source code.

includes post-developed commit, placating rustfmt self dogfooding.

includes post-developed commit: add backquotes to prevent markdown checking from trying to treat an attr as a markdown hyperlink/

includes post-developed commit: fix lowering to keep contracts from being erroneously inherited by nested bodies (like closures).

Rebase Conflicts:
 - compiler/rustc_parse/src/parser/diagnostics.rs
 - compiler/rustc_parse/src/parser/item.rs
 - compiler/rustc_span/src/hygiene.rs

Remove contracts keywords from diagnostic messages
2025-02-03 12:54:00 -08:00
Felix S. Klock II
777def87d5 contracts: added lang items that act as hooks for rustc-injected code to invoke.
see test for an example of the kind of injected code that is anticipated here.
2025-02-03 12:54:00 -08:00
Felix S. Klock II
bcb8565f30 Contracts core intrinsics.
These are hooks to:

  1. control whether contract checks are run
  2. allow 3rd party tools to intercept and reintepret the results of running contracts.
2025-02-03 12:53:57 -08:00
Yotam Ofek
6b016d7e59 Mark std::fmt::from_fn as #[must_use] 2025-02-03 20:17:27 +00:00
Matthias Krüger
f2b7a299d2
Rollup merge of #136289 - Pyr0de:oncecell-docs, r=tgross35
OnceCell & OnceLock docs: Using (un)initialized consistently

Changed
* `set` / `initialize` / `full` to `initialized state`
* `uninitialize` / `empty` to `uninitialized state`
* `f` to `f()`
* Added explaination of `uninitialized state` & `initialized state`

[OnceCell Docs](https://doc.rust-lang.org/nightly/std/cell/struct.OnceCell.html)
[OnceLock Docs](https://doc.rust-lang.org/nightly/std/sync/struct.OnceLock.html)

Fixes #85716
``@rustbot`` label +A-docs
2025-02-03 21:11:33 +01:00
Pascal S. de Kloe
ebeaf2e302 no unsafe pointer and no overflowing_literals in fmt::Display of integers 2025-02-03 17:44:02 +01:00
Josh Triplett
37c77defb4 For NonZero impl macros, give unsigned impls access to the corresponding signed type
There was a macro parameter giving signed impls access to the
corresponding unsigned type, but not the other way around.

This will allow implementing methods converting in both directions.
2025-02-03 16:37:59 +01:00
Pyrode
f8b01b3d19 OnceCell & OnceLock docs: Using (un)initialized consistently 2025-02-03 17:48:39 +05:30
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
Tobias Decking
4f5116e236
Use widening_mul 2025-02-01 23:44:52 +01:00
Peter Jaszkowiak
670d892dc9 add UnsafeCell direct access APIs 2025-02-01 13:34:45 -07: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
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
Marijn Schouten
55dc6dbcf0 document ptr comparison being by address 2025-02-01 15:28:44 +01:00
Scott McMurray
5e6ae8bb5c More PR feedback 2025-01-31 22:31:43 -08:00
Scott McMurray
61150a80f5 PR feedback 2025-01-31 22:29:09 -08:00
Scott McMurray
f23025305f Add unchecked_disjoint_bitor with fallback intrinsic implementation 2025-01-31 22:29:08 -08: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
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
Peter Jaszkowiak
f530a29944 implement unstable new_range feature
for RFC 3550, tracking issue #123741
2025-01-30 21:33:11 -07: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
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
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
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
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
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
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
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
Matthias Krüger
36b5c58ef8
Rollup merge of #136173 - taiki-e:c-char, r=tgross35
Update comments and sort target_arch in c_char_definition

Follow-up to https://github.com/rust-lang/rust/pull/132975.

- Clang's wrong default on MSP430 has been fixed in https://github.com/llvm/llvm-project/pull/115964, and will be included in LLVM 20, which will be used soon.
- Add a reference on Xtensa's default (from https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240).
- Fix link for Windows's default.
- Add a link to the discussion on L4Re (https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240)
- Sort `target_arch`. (now match with `target_arch`s in comments)

r? `@tgross35`
2025-01-28 18:17:30 +01:00
Matthias Krüger
6b4757b5de
Rollup merge of #135869 - hkBst:patch-12, r=Noratrieb
Make docs for AtomicUsize::from_mut platform-independent

fixes #133342
2025-01-28 18:17:22 +01:00
Pavel Grigorenko
1abc853562 Stabilize get_many_mut as get_disjoint_mut
* Renames the methods:
	* `get_many_mut` -> `get_disjoint_mut`
	* `get_many_unchecked_mut` -> `get_disjoint_unchecked_mut`
* Does not rename the feature flag: `get_many_mut`
* Marks the feature as stable
* Renames some helper stuff:
	* `GetManyMutError` -> `GetDisjointMutError`
	* `GetManyMutIndex` -> `GetDisjointMutIndex`
	* `get_many_mut_helpers` -> `get_disjoint_mut_helpers`
	* `get_many_check_valid` -> `get_disjoint_check_valid`

This only touches slice methods.
HashMap's methods and feature gates are not renamed here
(nor are they stabilized).
2025-01-28 17:59:31 +03:00
Matthias Krüger
448fa117f8
Rollup merge of #135886 - hkBst:patch-14, r=workingjubilee
Document purpose of closure in from_fn.rs more clearly

partial fix for #135087 together with https://github.com/rust-lang/rust/pull/135895
2025-01-28 14:23:23 +01:00
Matthias Krüger
da5e22de0a
Rollup merge of #133829 - GrigorenkoPV:fetch_update_infallible, r=Noratrieb
Implement `AtomicT::update` & `AtomicT::try_update`

ACP accepted in https://github.com/rust-lang/libs-team/issues/490

``@rustbot`` label +T-libs-api
2025-01-28 14:23:20 +01:00
Marijn Schouten
aa1f941116 Fix platform-specific doc string for AtomicUsize::from_mut to be platform-independent 2025-01-28 14:12:55 +01:00
Taiki Endo
ea70688f7d Update comments and sort target_arch in c_char_definition 2025-01-28 14:41:15 +09:00
Caleb Zulawski
44b2e6c07d Stabilize target_feature_11 2025-01-27 23:44:47 +01:00
Guillaume Gomez
314a695295
Rollup merge of #135807 - jhpratt:phantom-variance, r=Amanieu
Implement phantom variance markers

ACP accepted https://github.com/rust-lang/libs-team/issues/488

Tracking issue #135806
2025-01-27 15:38:24 +01:00
Guillaume Gomez
b7476f1784
Rollup merge of #135773 - hkBst:patch-10, r=tgross35
Clarify WindowsMut (Lending)Iterator

fixes #133628
2025-01-27 15:38:22 +01:00
Marijn Schouten
f630f7f410 Clarify WindowsMut (Lending)Iterator
fixes 133628
2025-01-27 10:53:58 +01:00
Trevor Gross
395f0c9ecd Stabilize const_black_box
This has been unstably const since [1], but a tracking issue was never
created. Per discussion on Zulip [2], 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.

[1]: https://github.com/rust-lang/rust/pull/92226
[2]: https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/const_black_box
2025-01-27 07:54:58 +00:00
bors
55459598c2 Auto merge of #136116 - fmease:rollup-c8pk3mj, r=fmease
Rollup of 8 pull requests

Successful merges:

 - #126604 (Uplift `clippy::double_neg` lint as `double_negations`)
 - #135158 (Add `TooGeneric` variant to `LayoutError` and emit `Unknown`)
 - #135635 (Move `std::io::pipe` code into its own file)
 - #136072 (add two old crash tests)
 - #136079 (compiler_fence: fix example)
 - #136091 (Add some tracing to core bootstrap logic)
 - #136097 (rustc_ast: replace some len-checks + indexing with slice patterns etc.)
 - #136101 (triagebot: set myself on vacation)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-27 06:54:42 +00:00
bors
633a3fe36d Auto merge of #135937 - bjorn3:separate_coretests_crate, r=jieyouxu,tgross35
Put the core unit tests in a separate coretests package

Having standard library tests in the same package as a standard library crate has bad side effects. It causes the test to have a dependency on a locally built standard library crate, while also indirectly depending on it through libtest. Currently this works out fine in the context of rust's build system as both copies are identical, but for example in cg_clif's tests I've found it basically impossible to compile both copies with the exact same compiler flags and thus the two copies would cause lang item conflicts.

This PR moves the tests of libcore to a separate package which doesn't depend on libcore, thus preventing the duplicate crates even when compiler flags don't exactly match between building the sysroot (for libtest) and building the test itself. The rest of the standard library crates do still have this issue however.
2025-01-27 03:57:37 +00:00
León Orell Valerian Liehr
bd2f6d7ee8
Rollup merge of #136079 - RalfJung:compiler-fence-example, r=jhpratt
compiler_fence: fix example

The old example was wrong, an acquire fence is required in the signal handler. To make the point more clear, I changed the "data" variable to use non-atomic accesses.

Fixes https://github.com/rust-lang/rust/issues/133014
2025-01-27 04:34:52 +01:00
Ralf Jung
9c972c0ea5 compiler_fence: fix example 2025-01-26 17:34:33 -07:00
Marijn Schouten
d3cd832dda Document purpose of closure in from_fn.rs more clearly 2025-01-26 13:43:55 +01:00
bors
15c6f7e1a3 Auto merge of #136087 - jhpratt:rollup-tam1mzn, r=jhpratt
Rollup of 7 pull requests

Successful merges:

 - #133631 (Support QNX 7.1 with `io-sock`+libstd and QNX 8.0 (`no_std` only))
 - #134358 (compiler: Set `target_abi = "ilp32e"` on all riscv32e targets)
 - #135812 (Fix GDB `OsString` provider on Windows )
 - #135842 (TRPL: more backward-compatible Edition changes)
 - #135946 (Remove extra whitespace from rustdoc breadcrumbs for copypasting)
 - #135953 (ci.py: check the return code in `run-local`)
 - #136019 (Add an `unchecked_div` alias to the `Div<NonZero<_>>` impls)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-26 12:10:05 +00:00