Commit Graph

18812 Commits

Author SHA1 Message Date
bors
1bc56185ee Auto merge of #139430 - scottmcm:polymorphic-array-into-iter, r=cuviper
Polymorphize `array::IntoIter`'s iterator impl

Today we emit all the iterator methods for every different array width.  That's wasteful since the actual array length never even comes into it -- the indices used are from the separate `alive: IndexRange` field, not even the `N` const param.

This PR switches things so that an `array::IntoIter<T, N>` stores a `PolymorphicIter<[MaybeUninit<T>; N]>`, which we *unsize* to `PolymorphicIter<[MaybeUninit<T>]>` and call methods on that non-`Sized` type for all the iterator methods.

That also necessarily makes the layout consistent between the different lengths of arrays, because of the unsizing.  Compare that to today <https://rust.godbolt.org/z/Prb4xMPrb>, where different widths can't even be deduped because the offset to the indices is different for different array widths.
2025-04-11 23:21:31 +00:00
Jacob Pratt
a6608294a9
Rollup merge of #137835 - scottmcm:signum, r=compiler-errors
Use `BinOp::Cmp` for `iNN::signum`

This way it can use the nice new LLVM intrinsic in LLVM20.
2025-04-11 21:20:59 +02:00
Stuart Cook
c8acc23d1d
Rollup merge of #139600 - tgross35:update-builtins, r=tgross35
Update `compiler-builtins` to 0.1.153

Includes the following changes:

* Avoid OOB access in `memcpy` and `memmove` [1]
* Enable intrinsics on AVR [2]
* `libm` updates to avoid using `core::arch` vector intrinsics [3]
* Re-enable `f16` on aarch64 without Neon [4]

[1]: https://github.com/rust-lang/compiler-builtins/pull/799
[2]: https://github.com/rust-lang/compiler-builtins/pull/791
[3]: https://github.com/rust-lang/compiler-builtins/pull/814
[4]: https://github.com/rust-lang/compiler-builtins/pull/809
2025-04-11 13:31:49 +10:00
Stuart Cook
a7d7a6d0eb
Rollup merge of #139447 - izarma:issue-108131-fix, r=scottmcm
doc changes: debug assertions -> overflow checks

This PR is for the following issue:
https://github.com/rust-lang/rust/issues/108131

has some changes in docs
2025-04-11 13:31:46 +10:00
Stuart Cook
45ebc4060b
Rollup merge of #137447 - folkertdev:simd-extract-insert-dyn, r=scottmcm
add `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}`

fixes https://github.com/rust-lang/rust/issues/137372

adds `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}`, which contrary to their non-dyn counterparts allow a non-const index. Many platforms (but notably not x86_64 or aarch64) have dedicated instructions for this operation, which stdarch can emit with this change.

Future work is to also make the `Index` operation on the `Simd` type emit this operation, but the intrinsic can't be used directly. We'll need some MIR shenanigans for that.

r? `@ghost`
2025-04-11 13:31:43 +10:00
bors
0fe8f3454d Auto merge of #137412 - scottmcm:redo-swap, r=cuviper
Ensure `swap_nonoverlapping` is really always untyped

This replaces #134954, which was arguably overcomplicated.

## Fixes #134713

Actually using the type passed to `ptr::swap_nonoverlapping` for anything other than its size + align turns out to not work, so this goes back to always erasing the types down to just bytes.

(Except in `const`, which keeps doing the same thing as before to preserve `@RalfJung's` fix from #134689)

## Fixes #134946

I'd previously moved the swapping to use auto-vectorization *on bytes*, but someone pointed out on Discord that the tail loop handling from that left a whole bunch of byte-by-byte swapping around.  This goes back to manual tail handling to avoid that, then still triggers auto-vectorization on pointer-width values.  (So you'll see `<4 x i64>` on `x86-64-v3` for example.)
2025-04-10 20:19:11 +00:00
Folkert de Vries
59c55339af
add simd_insert_dyn and simd_extract_dyn 2025-04-10 21:22:07 +02:00
Trevor Gross
b435def33c Update compiler-builtins to 0.1.153
Includes the following changes:

* Avoid OOB access in `memcpy` and `memmove` [1]
* Enable intrinsics on AVR [2]
* `libm` updates to avoid using `core::arch` vector intrinsics [3]
* Re-enable `f16` on aarch64 without Neon [4]

[1]: https://github.com/rust-lang/compiler-builtins/pull/799
[2]: https://github.com/rust-lang/compiler-builtins/pull/791
[3]: https://github.com/rust-lang/compiler-builtins/pull/814
[4]: https://github.com/rust-lang/compiler-builtins/pull/809
2025-04-10 17:40:15 +00:00
Scott McMurray
4207c786e7 PR feedback 2025-04-09 21:44:59 -07:00
bors
6813f955a6 Auto merge of #139279 - BoxyUwU:bump-boostrap, r=jieyouxu
Bump boostrap compiler to new beta

try-job: `*msvc*`
2025-04-10 00:43:25 +00:00
bors
51548ce71f Auto merge of #139595 - matthiaskrgr:rollup-kaa8aim, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #138470 (Test interaction between RFC 2229 migration and use closures)
 - #138628 (Add more ergonomic clone tests)
 - #139164 (std: improve documentation for get_mut() methods regarding forgotten guards)
 - #139488 (Add missing regression GUI test)
 - #139489 (compiletest: Add directive `dont-require-annotations`)
 - #139513 (Report higher-ranked trait error when higher-ranked projection goal fails in new solver)
 - #139521 (triagebot: roll compiler reviewers for rustc/unstable book)
 - #139532 (Update `u8`-to-and-from-`i8` suggestions.)
 - #139551 (report call site of inlined scopes for large assignment lints)
 - #139575 (Remove redundant words)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-09 21:35:22 +00:00
Matthias Krüger
7aab307541
Rollup merge of #139575 - timesince:master, r=wesleywiser
Remove redundant words

Remove redundant words
2025-04-09 20:23:13 +02:00
Matthias Krüger
a8b0d56f6f
Rollup merge of #139532 - bjoernager:master, r=tgross35
Update `u8`-to-and-from-`i8` suggestions.

`u8::cast_signed` and `i8::cast_unsigned` have been stabilised, but `i8::from_ne_bytes` et al. still suggest using `as i8` or `as u8`.
2025-04-09 20:23:12 +02:00
Matthias Krüger
d5f930fe76
Rollup merge of #139164 - xizheyin:issue-139034, r=joboet
std: improve documentation for get_mut() methods regarding forgotten guards

Fixes #139034

This PR improves the documentation for `get_mut()` methods in `Mutex`, `RefCell`, and `RwLock` to clarify their behavior when lock guards are forgotten (e.g., via std::mem::forget).

The current documentation for these methods states that a mutable borrow "statically guarantees no locks exist", which is not entirely accurate. While a mutable borrow prevents new locks from being created, it does not clear or detect previously abandoned locks through `forget()`. This can lead to counterintuitive behavior:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=e68cefec12dcd435daf2237c16824ed3
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=81263ad652c752afd63c903113d3082c
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=311baa4edb3abf82a25c8d7bf21a4a52

r? libs
2025-04-09 20:23:09 +02:00
bors
934880f586 Auto merge of #124810 - lincot:speed-up-string-push-and-string-insert, r=tgross35
speed up `String::push` and `String::insert`

Addresses the concerns described in #116235.

The performance gain comes mainly from avoiding temporary buffers.

Complex pattern matching in `encode_utf8` (introduced in #67569) has been simplified to a comparison and an exhaustive `match` in the `encode_utf8_raw_unchecked` helper function. It takes a slice of `MaybeUninit<u8>` because otherwise we'd have to construct a normal slice to uninitialized data, which is not desirable, I guess.

Several functions still have that [unneeded zeroing](https://rust.godbolt.org/z/5oKfMPo7j), but a single instruction is not that important, I guess.

`@rustbot` label T-libs C-optimization A-str
2025-04-09 17:58:25 +00:00
Scott McMurray
50d0ce1b42 Ensure swap_nonoverlapping is really always untyped 2025-04-09 09:09:37 -07:00
Matthias Krüger
4d1a63975c
Rollup merge of #139099 - scottmcm:from_fn_docs, r=Amanieu
Promise `array::from_fn` is generated in order of increasing indices

Fixes #139061

I agree this needs to be documented because of the `FnMut`, either with a guarantee or to explicitly disclaim one.

I'm pretty sure this will be non-controversial (like the other "well sure you *could* do it in a different order, but why?" things were), but I couldn't find any previous libs-api decision on it so it's seemingly a new promise that will need FCP.

Basically, yes, it would be plausible to fill in the reverse order, but there's no obvious way we could ever know that that might even be a good idea, so forward seems like an easy thing to promise.  We could always add a `from_fn_rev` or something later if there's ever a strong enough need, but it seems unlikely.

Let's just do the obvious thing so it matches what `[gen(0), gen(1), …, gen(N-1)]` does.
2025-04-09 14:52:37 +02:00
Matthias Krüger
19d4d9f371
Rollup merge of #138993 - CAD97:cfg_match_semitransparent, r=dtolnay
Make `cfg_match!` a semitransparent macro

IIUC this is preferred when (potentially) stabilizing `macro` items, to avoid potentially utilizing def-site hygiene instead of mixed-site.

Tracking issue: #115585
2025-04-09 14:52:36 +02:00
Matthias Krüger
9e541c4673
Rollup merge of #138869 - ChrisDenton:command-curdir, r=tgross35
Try not to use verbatim paths in `Command::current_dir`

If possible, we should try not to use verbatim paths in `Command::current_dir`. It might work but it might also break code in the subprocess that assume the current directory isn't verbatim (including Windows APIs). cc ``@ehuss``

Side note: we now have a lot of ad-hoc fixes like this spread about the place. It'd be good to make a proper `WindowsPath` type that handles all this in one place. But that's a bigger job for another PR.
2025-04-09 14:52:36 +02:00
Boxy
acf678bd4c intra-doc link 2025-04-09 12:29:59 +01:00
Boxy
c93005ee65 update cfgs 2025-04-09 12:29:59 +01:00
Boxy
a6c2ec04b4 replace version placeholder 2025-04-09 12:29:59 +01:00
timesince
069fd02588
Remove redundant words 2025-04-09 18:46:50 +08:00
lincot
ff248de852
Add missing black_box in String benchmarks 2025-04-09 13:06:10 +03:00
lincot
09d5bcf1ad
Speed up String::push and String::insert
Improve performance of `String` methods by avoiding unnecessary memcpy
for the character bytes, with added codegen check to ensure compliance.
2025-04-09 13:06:10 +03:00
bors
97c966bb40 Auto merge of #139552 - matthiaskrgr:rollup-b194mk8, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #139494 (Restrict some queries by def-kind more)
 - #139496 (Revert r-a changes of rust-lang/rust#139455)
 - #139506 (add missing word in doc comment (part 2))
 - #139515 (Improve presentation of closure signature mismatch from `Fn` trait goal)
 - #139520 (compiletest maintenance: sort deps and drop dep on `anyhow`)
 - #139523 (Rustc dev guide subtree update)
 - #139526 (Fix deprecation note for std::intrinsics)
 - #139528 (compiletest: Remove the `--logfile` flag)
 - #139541 (Instantiate higher-ranked transmute goal w/ placeholders before emitting sub-obligations)
 - #139547 (Update library tracking issue template to set S-tracking-unimplemented)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-09 05:39:18 +00:00
Chris Denton
edfc747225
Avoid verbatim paths in Command::current_dir
If possible, we should try not to use verbatim paths in Command::current_dir. It might work but it might also break code (including some Windows APIs) that assume the current directory isn't verbatim.
2025-04-09 01:32:19 +00:00
Matthias Krüger
51bc376737
Rollup merge of #139526 - smanilov:issue-139505, r=RalfJung
Fix deprecation note for std::intrinsics

Also checked the rest of the mentions of std::mem in the changed file and they look good to me.

Fixes #139505
2025-04-08 21:26:01 +02:00
Matthias Krüger
890c6de310
Rollup merge of #139500 - jogru0:117437, r=tgross35
document panic behavior of Vec::resize and Vec::resize_with

This adds panic documentation to ´Vec::resize´ and ´Vec::resize_with´. Fixes #117437.
2025-04-08 18:05:29 +02:00
Gabriel Bjørnager Jensen
f2dee82052 Update 'u8'-to-and-from-'i8' suggestions; 2025-04-08 17:07:50 +02:00
Stan Manilov
245cf8e734 Fix deprecation note for std::intrinsics
Also checked the rest of the mentions of std::mem in the changed file
and they look good to me.
2025-04-08 14:36:12 +03:00
Jonathan Gruner
4aab8e88e4 document panic behavior of Vec::resize and Vec::resize_with 2025-04-08 00:00:38 +02:00
Ralf Jung
a7400a8b90 update intrinsics/mod.rs comment about const intrinsics 2025-04-07 19:06:34 +02:00
Stuart Cook
9209c5eb60
Rollup merge of #139455 - Skgland:remove_rust-intrinsic_ABI, r=oli-obk
Remove support for `extern "rust-intrinsic"` blocks

Part of rust-lang/rust#132735

Looked manageable and there didn't appear to have been progress in the last two weeks,
so decided to give it a try.
2025-04-07 22:29:20 +10:00
bors
25a615bf82 Auto merge of #138951 - jwnrt:alloc-raw-vec-strict-prov, r=Noratrieb
Replace last `usize` -> `ptr` transmute in `alloc` with strict provenance API

This replaces the `usize -> ptr` transmute in `RawVecInner::new_in` with a strict provenance API (`NonNull::without_provenance`).

The API is changed to take an `Alignment` which encodes the non-null constraint needed for `Unique` and allows us to do the construction safely.

Two internal-only APIs were added to let us avoid UB-checking in this hot code: `Layout::alignment` to get the `Alignment` type directly rather than as a `usize`, and `Unique::from_non_null` to create `Unique` in const context without a transmute.
2025-04-06 23:07:48 +00:00
bors
2fa8b11f09 Auto merge of #136077 - rust-lang:cargo_update, r=clubby789
Weekly `cargo update`

Automation to keep dependencies in `Cargo.lock` current.

The following is the output from `cargo update`:

```txt

compiler & tools dependencies:
     Locking 11 packages to latest compatible versions
    Updating blake3 v1.8.0 -> v1.8.1
    Updating ctrlc v3.4.5 -> v3.4.6
    Updating env_logger v0.11.7 -> v0.11.8
    Updating errno v0.3.10 -> v0.3.11
    Updating flate2 v1.1.0 -> v1.1.1
    Updating indexmap v2.8.0 -> v2.9.0
    Updating miniz_oxide v0.8.5 -> v0.8.7
    Updating openssl-sys v0.9.106 -> v0.9.107
    Updating redox_syscall v0.5.10 -> v0.5.11
    Updating smallvec v1.14.0 -> v1.15.0
    Updating tokio v1.44.1 -> v1.44.2
note: pass `--verbose` to see 40 unchanged dependencies behind latest

library dependencies:
     Locking 1 package to latest compatible version
    Updating miniz_oxide v0.8.5 -> v0.8.7
note: pass `--verbose` to see 4 unchanged dependencies behind latest

rustbook dependencies:
     Locking 30 packages to latest compatible versions
    Updating cc v1.2.17 -> v1.2.18
    Updating clap v4.5.32 -> v4.5.35
    Updating clap_builder v4.5.32 -> v4.5.35
    Updating darling v0.20.10 -> v0.20.11
    Updating darling_core v0.20.10 -> v0.20.11
    Updating darling_macro v0.20.10 -> v0.20.11
    Updating env_logger v0.11.7 -> v0.11.8
    Updating errno v0.3.10 -> v0.3.11
    Updating flate2 v1.1.0 -> v1.1.1
    Updating iana-time-zone v0.1.61 -> v0.1.63
    Updating icu_locid_transform_data v1.5.0 -> v1.5.1
    Updating icu_normalizer_data v1.5.0 -> v1.5.1
    Updating icu_properties_data v1.5.0 -> v1.5.1
    Updating indexmap v2.8.0 -> v2.9.0
    Updating log v0.4.26 -> v0.4.27
    Updating miniz_oxide v0.8.5 -> v0.8.7
    Updating once_cell v1.21.1 -> v1.21.3
    Updating pest v2.7.15 -> v2.8.0
    Updating pest_derive v2.7.15 -> v2.8.0
    Updating pest_generator v2.7.15 -> v2.8.0
    Updating pest_meta v2.7.15 -> v2.8.0
    Updating redox_syscall v0.5.10 -> v0.5.11
    Updating rustix v1.0.3 -> v1.0.5
    Updating smallvec v1.14.0 -> v1.15.0
    Updating string_cache v0.8.8 -> v0.8.9
    Updating windows-core v0.52.0 -> v0.61.0
      Adding windows-implement v0.60.0
      Adding windows-interface v0.59.1
      Adding windows-result v0.3.2
      Adding windows-strings v0.4.0
```
2025-04-06 19:57:47 +00:00
Bennet Bleßmann
6dfb29624c
update docs
- src\doc\nomicon\src\ffi.md should also have its ABI list updated
2025-04-06 21:41:47 +02:00
Guillaume Gomez
ed81e347f1
Rollup merge of #139367 - GuillaumeGomez:proc-macro-values, r=Urgau
Add `*_value` methods to proc_macro lib

This is the (re-)implementation of https://github.com/rust-lang/libs-team/issues/459.

It allows to get the actual value (unescaped) of the different string literals.

It was originally done in https://github.com/rust-lang/rust/pull/136355 but it broke the artifacts build so we decided to move the crate to crates.io to go around this limitation.

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

Considering this is a copy-paste of the originally approved PR, no need to go through the whole process again. \o/

r? `@Urgau`
2025-04-06 18:08:10 +02:00
Guillaume Gomez
d1da78b201
Rollup merge of #139072 - nickkuk:align_to_uninit_mut, r=Mark-Simulacrum
Add `slice::align_to_uninit_mut`

Add new `slice::align_to_uninit_mut` method.

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

ACP: https://github.com/rust-lang/libs-team/issues/564
2025-04-06 18:08:10 +02:00
Guillaume Gomez
962fa98eeb
Rollup merge of #138876 - thaliaarchi:trusty-stdio, r=Noratrieb
Trusty: Implement `write_vectored` for stdio

Currently, `write` for stdout and stderr on Trusty is implemented with the semantics of `write_all`. Instead, call the underlying syscall only once in `write` and use the default implementation of `write_all` like other platforms. Also, implement `write_vectored` by adding support for `IoSlice`.

Refactor stdin to reuse the unsupported type like https://github.com/rust-lang/rust/pull/136769.

It requires #138875 to fix the build for Trusty, though they do not conflict and can merge in either order.

cc `@randomPoison`
2025-04-06 18:08:09 +02:00
Guillaume Gomez
7bd89b90e8
Rollup merge of #138562 - kornelski:nth-panic, r=Noratrieb
Optimize slice {Chunks,Windows}::nth

I've noticed that the `nth` functions on slice iters had non-optimized-out bounds checks.

The new implementation even generates branchless code.
2025-04-06 18:08:08 +02:00
izarma
f21d18063c doc changes 2025-04-06 15:09:59 +05:30
Stuart Cook
fededb9906
Rollup merge of #139123 - thaliaarchi:core-alloc-test-paths, r=bjorn3
tidy: Fix paths to `coretests` and `alloctests`

Following `#135937` and `#136642`, tests for core and alloc are in coretests and alloctests. Fix tidy to lint for the new paths. Also, update comments referring to the old locations.

Some context for changes which don't match that pattern:
- `library/std/src/thread/local/dynamic_tests.rs` and `library/std/src/sync/mpsc/sync_tests.rs` were moved under `library/std/tests/` in 332fb7e6f1 (Move std::thread_local unit tests to integration tests, 2025-01-17) and b8ae372e48 (Move std::sync unit tests to integration tests, 2025-01-17), respectively, so are no longer special cases.
- There never was a `library/core/tests/fmt.rs` file. That comment previously referred to `src/test/ui/ifmt.rs`, which was folded into `library/alloc/tests/fmt.rs` in 949c96660c (move format! interface tests, 2020-09-08).

Now, the only matches for `(alloc|core)/tests` are in `compiler/rustc_codegen_{cranelift,gcc}/patches`. I don't know why CI hasn't broken because those patches can't apply. Or maybe they somehow still can apply?

r? `@bjorn3`
2025-04-06 16:21:02 +10:00
Scott McMurray
e30cb329d8 Polymorphize array::IntoIter's iterator impl 2025-04-05 17:55:24 -07:00
github-actions
d1eebd4b8c cargo update
compiler & tools dependencies:
     Locking 11 packages to latest compatible versions
    Updating blake3 v1.8.0 -> v1.8.1
    Updating ctrlc v3.4.5 -> v3.4.6
    Updating env_logger v0.11.7 -> v0.11.8
    Updating errno v0.3.10 -> v0.3.11
    Updating flate2 v1.1.0 -> v1.1.1
    Updating indexmap v2.8.0 -> v2.9.0
    Updating miniz_oxide v0.8.5 -> v0.8.7
    Updating openssl-sys v0.9.106 -> v0.9.107
    Updating redox_syscall v0.5.10 -> v0.5.11
    Updating smallvec v1.14.0 -> v1.15.0
    Updating tokio v1.44.1 -> v1.44.2
note: pass `--verbose` to see 40 unchanged dependencies behind latest

library dependencies:
     Locking 1 package to latest compatible version
    Updating miniz_oxide v0.8.5 -> v0.8.7
note: pass `--verbose` to see 4 unchanged dependencies behind latest

rustbook dependencies:
     Locking 30 packages to latest compatible versions
    Updating cc v1.2.17 -> v1.2.18
    Updating clap v4.5.32 -> v4.5.35
    Updating clap_builder v4.5.32 -> v4.5.35
    Updating darling v0.20.10 -> v0.20.11
    Updating darling_core v0.20.10 -> v0.20.11
    Updating darling_macro v0.20.10 -> v0.20.11
    Updating env_logger v0.11.7 -> v0.11.8
    Updating errno v0.3.10 -> v0.3.11
    Updating flate2 v1.1.0 -> v1.1.1
    Updating iana-time-zone v0.1.61 -> v0.1.63
    Updating icu_locid_transform_data v1.5.0 -> v1.5.1
    Updating icu_normalizer_data v1.5.0 -> v1.5.1
    Updating icu_properties_data v1.5.0 -> v1.5.1
    Updating indexmap v2.8.0 -> v2.9.0
    Updating log v0.4.26 -> v0.4.27
    Updating miniz_oxide v0.8.5 -> v0.8.7
    Updating once_cell v1.21.1 -> v1.21.3
    Updating pest v2.7.15 -> v2.8.0
    Updating pest_derive v2.7.15 -> v2.8.0
    Updating pest_generator v2.7.15 -> v2.8.0
    Updating pest_meta v2.7.15 -> v2.8.0
    Updating redox_syscall v0.5.10 -> v0.5.11
    Updating rustix v1.0.3 -> v1.0.5
    Updating smallvec v1.14.0 -> v1.15.0
    Updating string_cache v0.8.8 -> v0.8.9
    Updating windows-core v0.52.0 -> v0.61.0
      Adding windows-implement v0.60.0
      Adding windows-interface v0.59.1
      Adding windows-result v0.3.2
      Adding windows-strings v0.4.0
2025-04-06 00:23:40 +00:00
Thalia Archibald
3af666ea91 tidy: Fix paths to coretests and alloctests
Following `#135937` and `#136642`, tests for core and alloc are in
coretests and alloctests. Fix tidy to lint for the new paths. Also,
update comments referring to the old locations.

Some context for changes which don't match that pattern:
* library/std/src/thread/local/dynamic_tests.rs and
  library/std/src/sync/mpsc/sync_tests.rs were moved under
  library/std/tests/ in 332fb7e6f1 (Move std::thread_local unit tests
  to integration tests, 2025-01-17) and b8ae372e48 (Move std::sync unit
  tests to integration tests, 2025-01-17), respectively, so are no
  longer special cases.
* There never was a library/core/tests/fmt.rs file. That comment
  previously referred to src/test/ui/ifmt.rs, which was folded into
  library/alloc/tests/fmt.rs in 949c96660c (move format! interface
  tests, 2020-09-08).
2025-04-05 12:15:49 -07:00
Matthias Krüger
527725b025
Rollup merge of #139121 - thaliaarchi:rename-thread_local-statik, r=Noratrieb
Rename internal module from `statik` to `no_threads`

This module is named in reference to the keyword, but the term is somewhat overloaded. Rename it to more clearly describe it and avoid the misspelling.
2025-04-05 19:40:24 +02:00
Matthias Krüger
0b342873e3
Rollup merge of #136877 - Sky9x:const-inherent-ptr-replace, r=jhpratt
Fix missing const for inherent pointer `replace` methods

`ptr::replace` (the free fn) is already const stable. However, there are inherent convenience methods on `*mut T` and `NonNull<T>`, allowing you to write eg. `unsafe { foo.replace(bar) }` where `foo` is `*mut T` or `NonNull<T>`.

It seems const was never added to the inherent method (likely oversight), so this PR adds it.
I don't believe this needs another[^1] FCP as the inherent methods are already stable and `ptr::replace` is already const stable, so this adds no new API.

Original tracking issue: #83164
`ptr::replace` constified in #83091
`ptr::replace` const stabilized in #130954

[^1]: `const_replace` FCP completed: https://github.com/rust-lang/rust/issues/83164#issuecomment-2385670050
2025-04-05 19:40:23 +02:00
Matthias Krüger
a64ccf4a46
Rollup merge of #139092 - thaliaarchi:move-fd-pal, r=joboet
Move `fd` into `std::sys`

Move platform definitions of `fd` into `std::sys`, as part of https://github.com/rust-lang/rust/issues/117276.

Unlike other modules directly under `std::sys`, this is only available on some platforms and I have not provided a fallback abstraction for unsupported platforms. That is similar to how `std::os::fd` is gated to only supported platforms.

Also, fix the `unsafe_op_in_unsafe_fn` lint, which was allowed for the Unix fd impl. Since macro expansions from `std::sys::pal::unix::weak` trigger this lint, fix it there too.

cc `@joboet,` `@ChrisDenton`

try-job: x86_64-gnu-aux
2025-04-05 10:18:04 +02:00
Matthias Krüger
56ffb43629
Rollup merge of #138381 - thaliaarchi:bstr-sliceindex, r=joshtriplett
Implement `SliceIndex` for `ByteStr`

Implement `Index` and `IndexMut` for `ByteStr` in terms of `SliceIndex`. Implement it for the same types that `&[u8]` supports (a superset of those supported for `&str`, which does not have `usize` and `ops::IndexRange`).

At the same time, move compare and index traits to a separate file in the `bstr` module, to give it more space to grow as more functionality is added (e.g., iterators and string-like ops). Order the items in `bstr/traits.rs` similarly to `str/traits.rs`.

cc `@joshtriplett`

`ByteStr`/`ByteString` tracking issue: https://github.com/rust-lang/rust/issues/134915
2025-04-05 10:18:03 +02:00