Commit Graph

8402 Commits

Author SHA1 Message Date
Peter Jaszkowiak
9c03369c17 add IntoBounds trait
for `range_into_bounds`  feature, #136903
2025-02-12 17:38:44 -07:00
Guillaume Gomez
269d784dd5
Rollup merge of #136890 - saethlin:swap_nonoverlapping, r=RalfJung
Change swap_nonoverlapping from lang to library UB

The implementation of ptr::swap_nonoverlapping does not always escalate its safety contract to language UB, so it should be `check_library_ub`.

Fixes https://github.com/rust-lang/miri/issues/4188
2025-02-12 20:30:54 +01:00
Ben Kimock
21bb8cb946 Change swap_nonoverlapping from lang to library UB 2025-02-12 12:20:14 -05:00
Matthias Krüger
72fd5719aa
Rollup merge of #136874 - tgross35:likely-unlikely-tracking, r=jhpratt
Change the issue number for `likely_unlikely` and `cold_path`

These currently point to rust-lang/rust#26179, which is nearly a decade old and has a lot of outdated discussion. Move these features to a new tracking issue specifically for the recently added API.

New tracking issue: https://github.com/rust-lang/rust/issues/136873
2025-02-12 06:07:38 +01:00
Kevin Reid
d2ed8cf661 Optionally add type names to TypeIds.
This feature is intended to provide expensive but thorough help for
developers who have an unexpected `TypeId` value and need to determine
what type it actually is. It causes `impl Debug for TypeId` to print
the type name in addition to the opaque ID hash, and in order to do so,
adds a name field to `TypeId`. The cost of this is the increased size of
`TypeId` and the need to store type names in the binary; therefore, it
is an optional feature.

It may be enabled via `cargo -Zbuild-std -Zbuild-std-features=debug_typeid`.
(Note that `-Zbuild-std-features` disables default features which you
may wish to reenable in addition; see
<https://doc.rust-lang.org/cargo/reference/unstable.html#build-std-features>.)

Example usage and output:

```
fn main() {
    use std::any::{Any, TypeId};
    dbg!(TypeId::of::<usize>(), drop::<usize>.type_id());
}
```

```
TypeId::of::<usize>() = TypeId(0x763d199bccd319899208909ed1a860c6 = usize)
drop::<usize>.type_id() = TypeId(0xe6a34bd13f8c92dd47806da07b8cca9a = core::mem::drop<usize>)
```

Also added feature declarations for the existing `debug_refcell` feature
so it is usable from the `rust.std-features` option of `config.toml`.
2025-02-11 18:42:19 -08:00
Eric Huss
8c24c0a023 Remove the common prelude module
This fixes the issues described in
https://github.com/rust-lang/rust/issues/136102. Primarily, this
resolves some issues with how the documentation for the prelude is
generated:

- It avoids showing "unstable" for macros in the prelude that are
  actually stable.
- Avoids duplication of some pages due to the previous lack of
  `doc(no_inline)`.
- Makes the different edition preludes consistent, and sets a pattern
  that can be used by future editions.

We may need to rearrange these modules in the future if we decide to
remove anything from the prelude again. If we do, I think we should look
into a different solution that avoids the documentation problems.
2025-02-11 13:04:27 -08:00
Matthias Krüger
052ebc65b2
Rollup merge of #136246 - hkBst:patch-29, r=ibraheemdev
include note on variance and example

Fixes #89150
2025-02-11 18:04:38 +01:00
Trevor Gross
e32f79583c Change the issue number for likely_unlikely and cold_path
These currently point to rust-lang/rust#26179, which is nearly a decade
old and has a lot of outdated discussion. Move these features to a new
tracking issue specifically for the recently added API.

New tracking issue: https://github.com/rust-lang/rust/issues/136873
2025-02-11 16:10:35 +00:00
bors
69482e8e5a Auto merge of #136851 - jhpratt:rollup-ftijn95, r=jhpratt
Rollup of 11 pull requests

Successful merges:

 - #136606 (Fix long lines which rustfmt fails to format)
 - #136663 (Stabilize `NonZero::count_ones`)
 - #136672 (library: doc: core::alloc::Allocator: trivial typo fix)
 - #136704 (Improve examples for file locking)
 - #136721 (cg_llvm: Reduce visibility of some items outside the `llvm` module)
 - #136813 (rustc_target: Add the fp16 target feature for AArch32)
 - #136830 (fix i686-unknown-hurd-gnu x87 footnote)
 - #136832 (Fix platform support table for i686-unknown-uefi)
 - #136835 (Stop using span hack for contracts feature gating)
 - #136837 (Overhaul how contracts are lowered on fn-like bodies)
 - #136839 (fix ensure_monomorphic_enough)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-11 10:17:02 +00:00
Marijn Schouten
e279c4eadb include note on variance and example
Fixes #89150

Co-authored-by: Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>
2025-02-11 09:20:59 +01:00
Jacob Pratt
aaf2c46202
Rollup merge of #136672 - safinaskar:alloc-2025-02-07-09-10, r=cuviper
library: doc: core::alloc::Allocator: trivial typo fix

(see subject)
2025-02-11 01:02:39 -05:00
Jacob Pratt
67e4e3aea9
Rollup merge of #136663 - WaffleLapkin:count-non-zero-ones, r=cuviper
Stabilize `NonZero::count_ones`

As per https://github.com/rust-lang/rust/issues/120287#issuecomment-2639187140

r? libs
2025-02-11 01:02:38 -05:00
Matthias Krüger
af3c51d849
Rollup merge of #136107 - dingxiangfei2009:coerce-pointee-wellformed, r=compiler-errors
Introduce CoercePointeeWellformed for coherence checks at typeck stage

Fix #135206

This is the first PR to introduce the "wellformedness" check for `derive(CoercePointee)`.

This patch introduces a new error code to cover all the prerequisites of the said macro. The checks that is enforced with this patch is whether the data is indeed `struct` and whether the layout is set to `repr(transparent)`.

A following series of patch will arrive later to address the following concern.
1. #135217 so that we would only admit one single coercion on one type parameter, and leave the rest for future consideration in tandem of development of other coercion rules.
1. Enforcement of data field requirements.

**An open question** is whether there is a good schema to encode the `#[pointee]` as well, so that we could also check if the `#[pointee]` type parameter is indeed `?Sized`.

``@rustbot`` label F-derive_coerce_pointee
2025-02-11 02:53:42 +01:00
Michael Goulet
17026e2412
Reword doc comment on CoercePointeeValidated 2025-02-10 11:50:02 -05:00
Jubilee
72f0205d28
Rollup merge of #136705 - compiler-errors:edition-library, r=jhpratt
Some miscellaneous edition-related library tweaks

Some library edition tweaks that can be done separately from upgrading the whole standard library to edition 2024 (which is blocked on getting the submodules upgraded, for example)
2025-02-10 00:51:54 -08:00
Ding Xiang Fei
18483434ae
block coerce_pointee_validated for stabilization 2025-02-10 04:36:43 +08:00
Michael Goulet
a4e7f8f9bf Mark extern blocks as unsafe 2025-02-09 17:11:13 +00:00
Michael Goulet
04bbc8340a Rename field in OnceWith from gen to make 2025-02-09 17:10:50 +00:00
bors
124cc92199 Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrum
Update bootstrap compiler and rustfmt

The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same
time.
2025-02-09 15:44:16 +00:00
bors
a26e97be88 Auto merge of #136754 - Urgau:rollup-qlkhjqr, r=Urgau
Rollup of 5 pull requests

Successful merges:

 - #134679 (Windows: remove readonly files)
 - #136213 (Allow Rust to use a number of libc filesystem calls)
 - #136530 (Implement `x perf` directly in bootstrap)
 - #136601 (Detect (non-raw) borrows of null ZST pointers in CheckNull)
 - #136659 (Pick the max DWARF version when LTO'ing modules with different versions )

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-09 12:54:26 +00:00
Ding Xiang Fei
c067324637
rename the trait to validity and place a feature gate afront 2025-02-09 20:40:42 +08:00
Ding Xiang Fei
de405dcb8f
introduce CoercePointeeWellformed for coherence checks at typeck stage 2025-02-09 20:40:41 +08:00
Jubilee
bf2c5323e0
Rollup merge of #136724 - steffahn:asyncfn-non-fundamental, r=compiler-errors
Make `AsyncFnOnce`, `AsyncFnMut`, `AsyncFn` non-`#[fundamental]`

Address the issue #136723 on nightly (the issue will only *actually* be fixed with a beta backport).
2025-02-08 20:41:22 -08:00
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
Lukas Bergdoll
4c9b9d7258 Use more explicit and reliable ptr select in sort impls
Using if ... with the intent to avoid branches can be surprising to readers and
carries the risk of turning into jumps/branches generated by some future
compiler version, breaking crucial optimizations.

This commit replaces their usage with the explicit and IR annotated
`bool::select_unpredictable`.
2025-02-07 15:22:42 +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
Ralf Jung
04e7a10af6 intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic 2025-02-04 16:27:29 +01: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
Urgau
5914fb779f Stabilize num_midpoint_signed feature 2025-01-27 18:10:32 +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
bjorn3
fcf78bbd75 Update comment 2025-01-26 10:26:37 +00:00
bjorn3
b6a3841942 Put all coretests in a separate crate 2025-01-26 10:26:36 +00:00
Jacob Pratt
359c5047ab
Rollup merge of #136019 - scottmcm:alias-unchecked-div, r=Mark-Simulacrum
Add an `unchecked_div` alias to the `Div<NonZero<_>>` impls

Inspired by https://github.com/rust-lang/libs-team/issues/526, if people are looking for `unchecked_div`, point them to `u32: Div<NonZero<u32>>` and friends which do no runtime checks -- and are safe! -- rather than today's behaviour of [the intrinsic being the top result](https://doc.rust-lang.org/std/?search=unchecked_div).

![image](https://github.com/user-attachments/assets/cf2a3c06-4876-49c1-8e33-64cd431c772a)
2025-01-26 01:51:18 -05:00
Jacob Pratt
b3a5d0a5f4
Implement phantom variance markers 2025-01-26 04:57:11 +00:00
Jacob Pratt
b58221ec9d
Rollup merge of #135948 - bjorn3:update_emscripten_std_tests, r=Mark-Simulacrum
Update emscripten std tests

This disables a bunch of emscripten tests that test things emscripten doesn't support and re-enables a whole bunch of tests which now work just fine on emscripten.

Tested with `EMCC_CFLAGS="-s MAXIMUM_MEMORY=2GB" ./x.py test library/ --target wasm32-unknown-emscripten`.
2025-01-25 23:27:00 -05:00
Matthias Krüger
65fb6286e0
Rollup merge of #136039 - nvanbenschoten:pin-typo, r=Amanieu
docs: fix typo in std::pin overview

Unimportant fix in `std::pin` documentation.
2025-01-25 23:15:25 +01:00
Matthias Krüger
f14993b454
Rollup merge of #136005 - BLANKatGITHUB:library, r=RalfJung
ports last few library files to new intrinsic style

This pr ports the last 2 library files to new intrinsic style this pr is part of issue #132735
2025-01-25 23:15:24 +01:00
Matthias Krüger
5c821ae4e8
Rollup merge of #135977 - nyurik:fix-fmt-options, r=joboet
Fix `FormattingOptions` instantiation with `Default`

The `fill` value by default should be set to `' '` (space), but the current implementation uses `#[derive(Default)]` which sets it to `\0`.

Note that `FormattingOptions` is being released as part of 1.85 (unstable) - so this might warrant a backport to that branch.

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

Follow up from https://github.com/rust-lang/rust/pull/118159

CC: ``@EliasHolzmann`` ``@programmerjake``

r? ``@m-ou-se``
2025-01-25 08:03:34 +01:00
Nathan VanBenschoten
83c09ff3bd docs: fix typo in std::pin overview 2025-01-24 23:26:02 -07:00
Matthias Krüger
884ec6b4ab
Rollup merge of #135938 - carlsverre:master, r=joboet
Add memory layout documentation to generic NonZero<T>

The documentation I've added is based on the same Layout documentation that appears on the other `NonZero*` types. For example see [the Layout docs on `NonZeroI8`](https://doc.rust-lang.org/std/num/type.NonZeroI8.html#layout-1).
2025-01-24 23:25:44 +01:00
Scott McMurray
2d11559f56 Add an unchecked_div alias to the Div<NonZero<_>> impls 2025-01-24 09:51:59 -08:00
Carl Sverre
4a8de9ac41
Update library/core/src/num/nonzero.rs
Tweak language

Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2025-01-24 09:15:19 -08:00
aaishwarymishra@gmail.com
72e514981f ports last few library files to new intrinsic style 2025-01-24 21:50:56 +05:30
bjorn3
88ff147c56 Remove a bunch of emscripten test ignores
They are either outdated as emscripten now supports i128 or they are
subsumed by #[cfg_attr(not(panic = "unwind"), ignore]
2025-01-24 09:25:34 +00:00
Matthias Krüger
a3fb2a0572
Rollup merge of #135489 - RalfJung:TryFromSliceError, r=tgross35
remove pointless allowed_through_unstable_modules on TryFromSliceError

This got added in https://github.com/rust-lang/rust/pull/132482 but the PR does not explain why. `@lukas-code` do you still remember? Also Cc `@Noratrieb` as reviewer of that PR.

If I understand the issue description correctly, all paths under which this type is exported are stable now: `core::array::TryFromSliceError` and `std::array::TryFromSliceError`. If that is the case, we shouldn't have the attribute; it's a terrible hack that should only be used when needed to maintain backward compatibility. Getting some historic information right is IMO *not* sufficient justification to risk accidentally exposing this type via more unstable paths today or in the future.
2025-01-24 08:08:06 +01:00
Yuri Astrakhan
c9ae0bbffb Fix FormattingOptions instantiation with Default
The `fill` value by default should be set to `' '` (space), but the current implementation uses `#[derive(Default)]` which sets it to `\0`
2025-01-24 01:58:33 -05:00
Matthias Krüger
08d5b2303a
Rollup merge of #135073 - joshtriplett:bstr, r=BurntSushi
Implement `ByteStr` and `ByteString` types

Approved ACP: https://github.com/rust-lang/libs-team/issues/502
Tracking issue: https://github.com/rust-lang/rust/issues/134915

These types represent human-readable strings that are conventionally,
but not always, UTF-8. The `Debug` impl prints non-UTF-8 bytes using
escape sequences, and the `Display` impl uses the Unicode replacement
character.

This is a minimal implementation of these types and associated trait
impls. It does not add any helper methods to other types such as `[u8]`
or `Vec<u8>`.

I've omitted a few implementations of `AsRef`, `AsMut`, and `Borrow`,
when those would be the second implementation for a type (counting the
`T` impl), to avoid potential inference failures. We can attempt to add
more impls later in standalone commits, and run them through crater.

In addition to the `bstr` feature, I've added a `bstr_internals` feature
for APIs provided by `core` for use by `alloc` but not currently
intended for stabilization.

This API and its implementation are based *heavily* on the `bstr` crate
by Andrew Gallant (`@BurntSushi).`

r? `@BurntSushi`
2025-01-23 19:54:23 +01:00
Carl Sverre
f4166487ff Add memory layout documentation to generic NonZero<T> 2025-01-23 08:51:21 -08:00
Pavel Grigorenko
c06ed545df Implement AtomicT::update & AtomicT::try_update 2025-01-22 23:22:21 +03:00
Josh Triplett
865471f99b Implement CloneToUninit for ByteStr 2025-01-22 17:53:39 +02:00
Josh Triplett
022e7c0bb9 Add doc aliases for BStr and BString 2025-01-22 09:19:24 +02:00
Lukas Markeffsky
cc19dfa125 Add AsyncFn* to core prelude 2025-01-22 00:20:54 +01:00
Matthias Krüger
317769f152
Rollup merge of #135750 - scottmcm:cma-example, r=cuviper
Add an example of using `carrying_mul_add` to write wider multiplication

Just the basic quadratic version that you wouldn't actually use for really-big integers, but it's nice and short so is useful as for a demonstration of why you might find `carrying_mul_add` useful :)

cc #85532 ``````@clarfonthey``````
2025-01-21 23:30:19 +01:00
edwloef
6b48b67dfc
optimize slice::ptr_rotate for compile-time-constant small rotates 2025-01-21 22:54:39 +01:00