Jacob Pratt
eb7d246d85
Rollup merge of #142520 - hkBst:less-static-mut, r=tgross35
...
alloc: less static mut + some cleanup
I'm looking into https://github.com/rust-lang/rust/issues/125035 and would like some feedback on my approach.
2025-06-17 23:19:35 +02:00
Jubilee
346adcef4f
Rollup merge of #138538 - hkBst:patch-4, r=tgross35
...
Make performance description of String::{insert,insert_str,remove} more precise
2025-06-17 00:28:13 -07:00
Marijn Schouten
2d3a37d1e5
linked_list tests: buff check_links
2025-06-17 07:01:40 +00:00
Marijn Schouten
0348a4a717
Make performance of String::insert_str more precise
2025-06-17 06:04:04 +00:00
Marijn Schouten
e8dfd812dd
linked_list tests: less static mut
2025-06-16 04:46:06 +00:00
Matthias Krüger
22f91aefd5
Rollup merge of #142484 - dtolnay:bsetextract, r=m-ou-se
...
Remove unneeded lifetime bound from signature of BTreeSet::extract_if
One way to observe the difference between these signatures, using 0 explicit lifetimes and 0 contrived where-clauses:
```rust
use std::collections::btree_set::{BTreeSet, ExtractIf};
use std::ops::RangeFull;
fn repro(
set: &mut BTreeSet<i32>,
predicate: impl Fn(i32) -> bool,
) -> ExtractIf<i32, RangeFull, impl FnMut(&i32) -> bool> {
set.extract_if(.., move |x| predicate(*x))
}
```
**Before:**
```console
error[E0311]: the parameter type `impl Fn(i32) -> bool` may not live long enough
--> src/lib.rs:8:5
|
5 | set: &mut BTreeSet<i32>,
| ------------------ the parameter type `impl Fn(i32) -> bool` must be valid for the anonymous lifetime defined here...
...
8 | set.extract_if(.., move |x| predicate(*x))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `impl Fn(i32) -> bool` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound
|
4 ~ fn repro<'a>(
5 ~ set: &'a mut BTreeSet<i32>,
6 ~ predicate: impl Fn(i32) -> bool + 'a,
7 ~ ) -> ExtractIf<'a, i32, RangeFull, impl FnMut(&i32) -> bool> {
|
```
**After:** compiles success.
- Tracking issue: https://github.com/rust-lang/rust/issues/70530
2025-06-14 11:27:12 +02:00
Jubilee
b38ee5e689
Rollup merge of #142046 - Qelxiros:122742-vec_peek_mut, r=cuviper
...
add Vec::peek_mut
Tracking issue: rust-lang/rust#122742
2025-06-13 20:59:16 -07:00
David Tolnay
dac9d78647
Remove unneeded lifetimes from signature of BTreeSet::extract_if
2025-06-13 20:33:54 -07:00
Tamir Duberstein
a82062055a
Delegate <CStr as Debug> to ByteStr
...
This allows UTF-8 characters to be printed without escapes, rather than
just ASCII.
2025-06-12 12:53:14 -04:00
Jeremy Smart
9d19cbe29b
update docs, test
2025-06-11 22:57:57 -04:00
Trevor Gross
fd06f6d658
Rollup merge of #142238 - RalfJung:nonnull_provenance, r=workingjubilee
...
stabilize nonnull_provenance
Fixes https://github.com/rust-lang/rust/issues/135243
FCP passed in https://github.com/rust-lang/rust/issues/135243
2025-06-09 12:17:55 -05:00
Trevor Gross
ab87ed150b
Rollup merge of #141993 - tgross35:use-in-tree-builtins, r=bjorn3
...
Use the in-tree `compiler-builtins` for the sysroot
Many of `std`'s dependency have a dependency on the crates.io `compiler-builtins` when used with the feature `rustc-std-workspace-core`. Use a Cargo patch to select the in-tree version instead.
`compiler-builtins` is also added as a dependency of `rustc-std-workspace-core` so these crates can remove their crates.io dependency in the future.
Zulip discussion: [#t-compiler > Using in-tree compiler-builtins](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Using.20in-tree.20compiler-builtins/with/522445336 )
Once this merges, the following PRs will need to make it to a release for the relevant crates:
- https://github.com/rust-lang/getopts/pull/119 (can merge at any time)
- https://github.com/rust-lang/hashbrown/pull/625 (can merge at any time)
- https://github.com/rust-lang/stdarch/pull/1825
- https://github.com/rust-lang/rustc-demangle/pull/80
- https://github.com/rust-lang/cfg-if/pull/84
- https://github.com/unicode-rs/unicode-width/pull/77
The above should cover all tier 1 targets with no `std` features enabled. The remaining cover the rest:
- https://github.com/alexcrichton/dlmalloc-rs/pull/50 (wasm, xous, sgx)
- https://github.com/gimli-rs/gimli/pull/769
- https://github.com/r-efi/r-efi/pull/89 (efi)
- https://github.com/r-efi/r-efi-alloc/pull/9 (efi)
- https://github.com/fortanix/rust-sgx/pull/770 (sgx)
- https://github.com/hermit-os/hermit-rs/pull/718 (hermit)
- https://github.com/bytecodealliance/wasi-rs/pull/108 (wasi)
- https://github.com/gimli-rs/addr2line/pull/345
- https://github.com/oyvindln/adler2/pull/2
- https://github.com/BurntSushi/memchr/pull/180
- https://github.com/Frommi/miniz_oxide/pull/173
- https://github.com/gimli-rs/object/pull/777
try-job: x86_64-gnu
try-job: test-various
2025-06-09 12:17:53 -05:00
Ralf Jung
3164ca8bb4
stabilize nonnull_provenance
2025-06-09 12:36:24 +02:00
Trevor Gross
cc3e57147e
Use the in-tree compiler-builtins
...
Many of `std`'s dependency have a dependency on the crates.io
`compiler-builtins` when used with the feature
`rustc-std-workspace-core`. Use a Cargo patch to select the in-tree
version instead.
`compiler-builtins` is also added as a dependency of
`rustc-std-workspace-core` so these crates can remove their crates.io
dependency in the future.
2025-06-08 02:36:58 +00:00
Jeremy Smart
cc80429021
fix tests
2025-06-06 19:22:15 -04:00
Tshepang Mbambo
0ffff4657a
remove extraneous text
...
"Basic usage" implies there is an example that shows advanced usage
2025-06-06 06:39:51 +02:00
Jeremy Smart
188c40126d
add Vec::peek_mut
2025-06-04 18:15:12 -04:00
Matthias Krüger
98421b765f
Rollup merge of #141924 - rs-sac:extr-doc, r=jhpratt
...
Lightly tweak docs for BTree{Map,Set}::extract_if
- Move explanations into comments to match style
- Explain the second examples
- Make variable names match the data structure
Related rust-lang/rust#70530
2025-06-04 16:24:09 +02:00
Josh Stone
c87b072952
Remove more library bootstrap
2025-06-02 14:46:19 -07:00
Sidney Cammeresi
a20cf473e7
Lightly tweak docs for BTree{Map,Set}::extract_if
...
- Move explanations into comments to match style
- Explain the second examples
- Make variable names match the data structure
2025-06-02 10:10:00 -07:00
Matthias Krüger
04641b14a3
Rollup merge of #141805 - tgross35:update-builtins, r=tgross35
...
Update `compiler-builtins` to 0.1.160
Includes the following changes:
* Enable `__powitf2` on MSVC [1]
* Update `CmpResult` to use a pointer-sized return type [2]
* Better code reuse between `libm` and `compiler-builtins` [3], [4]
* Stop building C versions of `__netf2` [5] since we have our own implementation
[1]: https://github.com/rust-lang/compiler-builtins/pull/918
[2]: https://github.com/rust-lang/compiler-builtins/pull/920
[3]: https://github.com/rust-lang/compiler-builtins/pull/879
[4]: https://github.com/rust-lang/compiler-builtins/pull/925
[5]: https://github.com/rust-lang/compiler-builtins/pull/828
2025-05-31 18:51:50 +02:00
Trevor Gross
ca1c67ad76
Update compiler-builtins to 0.1.160
...
Includes the following changes:
* Enable `__powitf2` on MSVC [1]
* Update `CmpResult` to use a pointer-sized return type [2]
* Better code reuse between `libm` and `compiler-builtins` [3], [4]
* Stop building C versions of `__netf2` [5] since we have our own
implementation
[1]: https://github.com/rust-lang/compiler-builtins/pull/918
[2]: https://github.com/rust-lang/compiler-builtins/pull/920
[3]: https://github.com/rust-lang/compiler-builtins/pull/879
[4]: https://github.com/rust-lang/compiler-builtins/pull/925
[5]: https://github.com/rust-lang/compiler-builtins/pull/828
2025-05-30 16:09:12 +00:00
Sidney Cammeresi
8656d9e619
Unit test for Range parameter of BTreeMap::extract_if
2025-05-27 08:31:56 -07:00
Sidney Cammeresi
38c37eb3cb
Update docs for new Range parameter to BTreeMap::extract_if etc.
2025-05-27 08:31:56 -07:00
Sidney Cammeresi
1ae96fcd79
Update tests with Range parameter to BTreeMap::extract_if etc.
2025-05-27 08:31:56 -07:00
Sidney Cammeresi
51d247c2cf
Add Range parameter to BTreeMap::extract_if and BTreeSet::extract_if
...
This change was requested in the btree_extract_if tracking issue:
https://github.com/rust-lang/rust/issues/70530#issuecomment-2486566328
2025-05-27 08:31:40 -07:00
Jacob Pratt
3338ff7dcf
Rollup merge of #141108 - PaulDance:fix-extract_if-docs, r=Mark-Simulacrum
...
Docs(lib): Fix `extract_if` docs
Various fixes to the documentation comments of the several `extract_if` collection methods available. It originally started with a small typo fix in `Vec`'s spotted when reading the 1.87 release notes, but then by looking at the others' for comparison in order to try determining what was the intended sentence, some inconsistencies were spotted. Therefore, some other changes are also proposed here to reduce these avoidable differences, going more and more nit-picky along the way. See the individual commits for more details about each change.
`@rustbot` label T-libs A-collections A-docs
2025-05-25 04:00:56 +02:00
Matthias Krüger
a31a39833a
Rollup merge of #141370 - WaffleLapkin:hiiii, r=jhpratt
...
add doc alias `replace_first` for `str::replacen`
`replace_first` is a sensible name for a function, analogous to actually existing `<[_]>::split_first`, for example. (I just saw someone try to search for it)
I think it's reasonable to add such an alias for `replacen`, which replaces the first occurrence of passed a 1.
2025-05-22 07:19:04 +02:00
waffle
cff790c98e
add doc alias replace_first for str::replacen
2025-05-21 23:43:57 +02:00
Matthias Krüger
b5edec2811
Rollup merge of #141230 - xizheyin:issue-141217, r=tgross35
...
std: fix doctest and explain for `as_slices` and `as_mut_slices` in `VecDeque`
Fixes #141217
r? libs
2025-05-21 22:14:58 +02:00
Matthias Krüger
d4b7915a59
Rollup merge of #140526 - Natr1x:sort-direction-documentation, r=dtolnay
...
docs: Specify that common sort functions sort in an ascending direction
From [forum discussion](https://users.rust-lang.org/t/is-there-a-way-to-sort-a-slice-in-specifically-ascending-or-descending-order/128998?u=natr1x ) it seems like the sorting direction can be expected to always be ascending (in terms of `cmp::Ordering`).
If this is the case then it would be nice to have this stated in the documentation.
2025-05-21 22:14:57 +02:00
xizheyin
46a5c91591
std: fix doctest and explain for as_slices and as_mut_slices in VecDeque
...
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-21 22:13:23 +08:00
Matthias Krüger
c052d263d0
Rollup merge of #141289 - compiler-errors:more-self, r=jhpratt
...
use `Self` alias in self types rather than manually substituting it
Of the rougly 145 uses of `self: Ty` in the standard library, 5 of them don't use `Self` but instead choose to manually "substitute" the `impl`'s self type into the type.
This leads to weird behavior sometimes (https://github.com/rust-lang/rust/issues/140611#issuecomment-2883761300 ) -- **to be clear**, none of these usages actually trigger any bugs, but it's possible that they may break in the future (or at least lead to lints), so let's just "fix" them proactively.
2025-05-20 20:57:28 +02:00
Michael Goulet
7b5ea0e7f5
use Self alias in self types rather than manually substituting it
2025-05-20 16:03:04 +02:00
Paul Mabileau
b1d7480acb
Docs(lib/extract_if): Unify example description
...
Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17 02:54:21 +02:00
Paul Mabileau
014434e96f
Docs(lib/extract_if): Unify paragraph about elements mutation
...
Take the one from `BTreeMap` that seems the best-worded and most
precise among the available variations.
Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17 02:45:56 +02:00
Paul Mabileau
9205ee27a8
Docs(lib/extract_if): Unify paragraph about closure actions
...
Also fixes `HashSet`'s that incorrectly designated itself as a `list`.
Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17 02:36:08 +02:00
Paul Mabileau
35f8473637
Docs(lib/coll/btm): Split extract_if's first sentence from the following ones
...
This also seems like a small mistake: the first main sentence is put in
the same paragraph as the other two following ones while other
equivalents all have it split. Therefore, do the same here.
Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17 02:29:37 +02:00
Paul Mabileau
d29d1a332b
Docs(lib/alloc/vec): Add the missing an to extract_if's first sentence
...
As inspired by the equivalent methods from other collection types.
Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17 02:09:06 +02:00
bors
6d1875f99b
Auto merge of #141050 - matthiaskrgr:rollup-uyzqbmj, r=matthiaskrgr
...
Rollup of 7 pull requests
Successful merges:
- #139749 (docs(library/core/src/pin): fix typo "necessarily" -> "necessary")
- #140685 (Simplify `Vec::as_non_null` implementation and make it `const`)
- #140712 (normalization: avoid incompletely constraining GAT args)
- #140768 (Improve `dangerous_implicit_aurorefs` diagnostic output)
- #140947 (Flush errors before deep normalize in `dropck_outlives`)
- #140990 (VxWorks: updates from recent libc versions)
- #141027 (remove `RustfmtState` to reduce `initial_rustfmt` complexity)
r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-15 23:30:38 +00:00
Matthias Krüger
7a8fd9985d
Rollup merge of #140685 - viliml:patch-1, r=Mark-Simulacrum
...
Simplify `Vec::as_non_null` implementation and make it `const`
Tracking issue: #130364 .
2025-05-15 22:28:50 +02:00
bors
d97326eabf
Auto merge of #136264 - GuillaumeGomez:optimize-integers-to-string, r=Amanieu
...
Optimize `ToString` implementation for integers
Part of https://github.com/rust-lang/rust/issues/135543 .
Follow-up of https://github.com/rust-lang/rust/pull/133247 and https://github.com/rust-lang/rust/pull/128204 .
The benchmark results are:
| name| 1.87.0-nightly (3ea711f17 2025-03-09) | With this PR | diff |
|-|-|-|-|
| bench_i16 | 32.06 ns/iter (+/- 0.12) | 17.62 ns/iter (+/- 0.03) | -45% |
| bench_i32 | 31.61 ns/iter (+/- 0.04) | 15.10 ns/iter (+/- 0.06) | -52% |
| bench_i64 | 31.71 ns/iter (+/- 0.07) | 15.02 ns/iter (+/- 0.20) | -52% |
| bench_i8 | 13.21 ns/iter (+/- 0.14) | 14.93 ns/iter (+/- 0.16) | +13% |
| bench_u16 | 31.20 ns/iter (+/- 0.06) | 16.14 ns/iter (+/- 0.11) | -48% |
| bench_u32 | 33.27 ns/iter (+/- 0.05) | 16.18 ns/iter (+/- 0.10) | -51% |
| bench_u64 | 31.44 ns/iter (+/- 0.06) | 16.62 ns/iter (+/- 0.21) | -47% |
| bench_u8 | 10.57 ns/iter (+/- 0.30) | 13.00 ns/iter (+/- 0.43) | +22% |
More information about it in [the original comment](https://github.com/rust-lang/rust/pull/136264#discussion_r1987542954 ).
r? `@workingjubilee`
2025-05-15 20:20:30 +00:00
Pietro Albini
ce6e29679c
bump compiler_builtins
2025-05-13 11:30:36 +02:00
Pietro Albini
2ce08ca5d6
update cfg(bootstrap)
2025-05-12 15:33:37 +02:00
Pietro Albini
a360940ac9
update version placeholders
2025-05-12 15:33:30 +02:00
Guillaume Gomez
aca12a8216
Rollup merge of #140724 - tgross35:update-builtins, r=tgross35
...
Update `compiler-builtins` to 0.1.158
Includes the following changes:
* Require `target_has_atomic = "ptr"` for runtime feature detection [1]
[1]: https://github.com/rust-lang/compiler-builtins/pull/909
2025-05-07 10:50:50 +02:00
Jacob Pratt
5b165aab89
Rollup merge of #140668 - vkrivopalov:vecdeque-truncate-front, r=jhpratt
...
Implement `VecDeque::truncate_front()`
Tracking issue: #140667
2025-05-07 00:29:24 +00:00
Jacob Pratt
25631ff093
Rollup merge of #140483 - baumanj:patch-1, r=workingjubilee
...
Comment on `Rc` abort-guard strategy without naming unrelated fn
`wrapped_add` is used, not `checked_add`, so avoid mentioning specific fn calls that may vary slightly based on "whatever produces the best code" and focus on things that will remain constant into the future.
2025-05-07 00:29:22 +00:00
Trevor Gross
4de822c3d2
Update compiler-builtins to 0.1.158
...
Includes the following changes:
* Require `target_has_atomic = "ptr"` for runtime feature detection
[1]: https://github.com/rust-lang/compiler-builtins/pull/909
2025-05-06 23:40:50 +00:00
Jon Bauman
6a4af821b0
Update rc.rs docs
...
Update comment per review feedback
2025-05-06 13:19:42 -07:00