about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2024-05-12Auto merge of #125045 - GuillaumeGomez:rollup-em6qdzw, r=GuillaumeGomezbors-1/+2
Rollup of 4 pull requests Successful merges: - #125021 (Update reference safety requirements) - #125022 (Migrate rustdoc scrape examples ordering) - #125030 (Fix some minor issues from the ui-test auto-porting) - #125036 (solve: all "non-structural" logging to trace) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-12Rollup merge of #125021 - joshlf:patch-11, r=RalfJungGuillaume Gomez-1/+2
Update reference safety requirements Per https://github.com/rust-lang/rust/pull/116677#issuecomment-1945495786, the language as written promises too much. This PR relaxes the language to be consistent with current semantics. If and when #117945 is implemented, we can revert to the old language. While we're here, we also require that references be non-null. cc ``@RalfJung``
2024-05-12Auto merge of #124798 - devnexen:illumos_memalign_fix, r=RalfJungbors-2/+0
std::alloc: use posix_memalign instead of memalign on solarish `memalign` on Solarish requires the alignment to be at least the size of a pointer, which we did not honor. `posix_memalign` also requires that, but that code path already takes care of this requirement. close GH-124787
2024-05-12Auto merge of #125012 - RalfJung:format-error, r=Mark-Simulacrum,workingjubileebors-2/+8
io::Write::write_fmt: panic if the formatter fails when the stream does not fail Follow-up to https://github.com/rust-lang/rust/pull/124954
2024-05-11Rollup merge of #124981 - zachs18:rc-allocator-generalize-1, r=Mark-SimulacrumMatthias Krüger-32/+33
Relax allocator requirements on some Rc/Arc APIs. Split out from #119761 * Remove `A: Clone` bound from `Rc::assume_init`(s), `Rc::downcast`, and `Rc::downcast_unchecked` (`Arc` methods were already relaxed by #120445) * Make `From<Rc<[T; N]>> for Rc<[T]>` allocator-aware (`Arc`'s already is). * Remove `A: Clone` from `Rc/Arc::unwrap_or_clone` Internal changes: * Made `Arc::internal_into_inner_with_allocator` method into `Arc::into_inner_with_allocator` associated fn. * Add private `Rc::into_inner_with_allocator` (to match Arc), so other fns don't have to juggle `ManuallyDrop`.
2024-05-11References must also be non-nullJoshua Liebow-Feeser-0/+1
2024-05-11Relax slice safety requirementsJoshua Liebow-Feeser-1/+1
Per https://github.com/rust-lang/rust/pull/116677#issuecomment-1945495786, the language as written promises too much. This PR relaxes the language to be consistent with current semantics. If and when #117945 is implemented, we can revert to the old language.
2024-05-11std::alloc: using posix_memalign instead of memalign on solarish.David Carlier-2/+0
simpler code path since small alignments are already taking care of. close GH-124787
2024-05-11Auto merge of #124213 - rust-lang:cargo_update, r=Mark-Simulacrumbors-2/+3
Weekly `cargo update` Automation to keep dependencies in `Cargo.lock` current. The following is the output from `cargo update`: ```txt Locking 77 packages to latest compatible versions Updating allocator-api2 v0.2.16 -> v0.2.18 Updating anstream v0.6.13 -> v0.6.14 Updating anstyle v1.0.6 -> v1.0.7 Updating anstyle-lossy v1.1.0 -> v1.1.1 Updating anstyle-parse v0.2.3 -> v0.2.4 Updating anstyle-query v1.0.2 -> v1.0.3 Updating anstyle-svg v0.1.3 -> v0.1.4 Updating anstyle-wincon v3.0.2 -> v3.0.3 Updating anyhow v1.0.81 -> v1.0.83 Updating autocfg v1.2.0 -> v1.3.0 Updating bumpalo v3.15.4 -> v3.16.0 Updating bytecount v0.6.7 -> v0.6.8 Updating clap_complete v4.5.1 -> v4.5.2 Updating color-print v0.3.5 -> v0.3.6 Updating color-print-proc-macro v0.3.5 -> v0.3.6 Updating colorchoice v1.0.0 -> v1.0.1 Updating dissimilar v1.0.7 -> v1.0.9 Updating either v1.10.0 -> v1.11.0 Updating encoding_rs v0.8.33 -> v0.8.34 Updating errno v0.3.8 -> v0.3.9 Updating fastrand v2.0.2 -> v2.1.0 Updating flate2 v1.0.28 -> v1.0.30 Updating fluent-bundle v0.15.2 -> v0.15.3 Updating fluent-syntax v0.11.0 -> v0.11.1 Updating getrandom v0.2.13 -> v0.2.14 (latest: v0.2.15) Updating hashbrown v0.14.3 -> v0.14.5 Updating intl-memoizer v0.5.1 -> v0.5.2 Adding is_terminal_polyfill v1.70.0 Updating jobserver v0.1.28 -> v0.1.31 Updating lock_api v0.4.11 -> v0.4.12 Updating num-traits v0.2.18 -> v0.2.19 Removing packed_simd v0.3.9 Updating parking_lot v0.12.1 -> v0.12.2 Updating parking_lot_core v0.9.9 -> v0.9.10 Updating pest v2.7.9 -> v2.7.10 Updating pest_derive v2.7.9 -> v2.7.10 Updating pest_generator v2.7.9 -> v2.7.10 Updating pest_meta v2.7.9 -> v2.7.10 Updating proc-macro2 v1.0.79 -> v1.0.82 Updating pulldown-cmark v0.10.2 -> v0.10.3 Updating pulldown-cmark-escape v0.10.0 -> v0.10.1 Updating quote v1.0.35 -> v1.0.36 Adding redox_syscall v0.5.1 Updating rustc-demangle v0.1.23 -> v0.1.24 Updating rustix v0.38.32 -> v0.38.34 Updating rustversion v1.0.15 -> v1.0.16 Updating ryu v1.0.17 -> v1.0.18 Updating security-framework v2.10.0 -> v2.11.0 Updating security-framework-sys v2.10.0 -> v2.11.0 Updating self_cell v1.0.3 -> v1.0.4 Updating semver v1.0.22 -> v1.0.23 Updating serde v1.0.197 -> v1.0.201 Updating serde_derive v1.0.197 -> v1.0.201 Updating serde_json v1.0.115 -> v1.0.117 Updating socket2 v0.5.6 -> v0.5.7 Updating syn v2.0.58 -> v2.0.62 Updating sysinfo v0.30.8 -> v0.30.12 Updating thiserror v1.0.58 -> v1.0.60 Updating thiserror-impl v1.0.58 -> v1.0.60 Updating tokio-util v0.7.10 -> v0.7.11 Updating type-map v0.4.0 -> v0.5.0 Updating unic-langid v0.9.4 -> v0.9.5 Updating unic-langid-impl v0.9.4 -> v0.9.5 Updating unic-langid-macros v0.9.4 -> v0.9.5 Updating unic-langid-macros-impl v0.9.4 -> v0.9.5 Updating unicode-width v0.1.11 -> v0.1.12 Updating winapi-util v0.1.6 -> v0.1.8 Updating windows-targets v0.52.4 -> v0.52.5 Updating windows_aarch64_gnullvm v0.52.4 -> v0.52.5 Updating windows_aarch64_msvc v0.52.4 -> v0.52.5 Updating windows_i686_gnu v0.52.4 -> v0.52.5 Adding windows_i686_gnullvm v0.52.5 Updating windows_i686_msvc v0.52.4 -> v0.52.5 Updating windows_x86_64_gnu v0.52.4 -> v0.52.5 Updating windows_x86_64_gnullvm v0.52.4 -> v0.52.5 Updating windows_x86_64_msvc v0.52.4 -> v0.52.5 Updating zerocopy v0.7.32 -> v0.7.34 Updating zerocopy-derive v0.7.32 -> v0.7.34 note: pass `--verbose` to see 94 unchanged dependencies behind latest ```
2024-05-11Pin libc back to 0.2.153Mark Rousskov-2/+3
2024-05-11io::Write::write_fmt: panic if the formatter fails when the stream does not failRalf Jung-2/+8
2024-05-11Rollup merge of #124954 - kpreid:fmterr, r=NilstriebMatthias Krüger-16/+36
Document proper usage of `fmt::Error` and `fmt()`'s `Result`. I've seen several newcomers wonder why `fmt::Error` doesn't have any error detail information, or propose to return it in response to an error condition found inside a `impl fmt::Display for MyType`. That is incorrect, per [a lone paragraph of the `fmt` module's documentation](https://doc.rust-lang.org/1.78.0/std/fmt/index.html#formatting-traits). However, users looking to implement a formatting trait won't necessarily look there. Therefore, let's add the critical information (that formatting per se is infallible) to all the involved items: every `fmt()` method, and `fmt::Error`. This PR is not intended to make any novel claims about `fmt`; only to repeat an existing one in places where it will be more visible.
2024-05-11Rollup merge of #124928 - okaneco:trim_ascii, r=workingjubileeMatthias Krüger-21/+15
Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str` Remove feature from documentation examples Update intra-doc link for `u8::is_ascii_whitespace` on `&[u8]` functions Closes #94035 FCP has successfully completed https://github.com/rust-lang/rust/issues/94035#issuecomment-2102690397
2024-05-11Rollup merge of #124991 - Infinixius:patch-1, r=NilstriebMatthias Krüger-1/+1
Fix typo in ManuallyDrop's documentation ```diff - /// A wrapper to inhibit compiler from automatically calling `T`’s destructor. + /// A wrapper to inhibit the compiler from automatically calling `T`’s destructor. ```
2024-05-11Rollup merge of #124766 - devnexen:getrandom_solarish, r=Mark-SimulacrumMatthias Krüger-1/+12
std::rand: adding solaris/illumos for getrandom support. To help solarish support for miri https://https://github.com/rust-lang/miri/issues/3567
2024-05-10Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str`okaneco-21/+15
Remove feature from documentation examples Add rustc_const_stable attribute to stabilized functions Update intra-doc link for `u8::is_ascii_whitespace` on `&[u8]` functions
2024-05-10Fix typo in ManuallyDrop's documentationInfinixius-1/+1
2024-05-10Relax A: Clone requirement on Rc/Arc::unwrap_or_clone.Zachary S-0/+4
2024-05-10Relax allocator requirements on some Rc APIs.Zachary S-32/+29
* Remove A: Clone bound from Rc::assume_init, Rc::downcast, and Rc::downcast_unchecked. * Make From<Rc<[T; N]>> for Rc<[T]> allocator-aware. Internal changes: * Made Arc::internal_into_inner_with_allocator method into Arc::into_inner_with_allocator associated fn. * Add private Rc::into_inner_with_allocator (to match Arc), so other fns don't have to juggle ManuallyDrop.
2024-05-10Auto merge of #124863 - DaniPopes:from-str-radix-panic, r=Amanieubors-6/+6
from_str_radix: outline only the panic function In the `{integer}::from_str_radix` function, the radix check is labeled as `cold` and `inline(never)`, along with its corresponding panic. It probably was intended to apply these attributes only to the panic function.
2024-05-10Auto merge of #124774 - the8472:subnanosecond-benches, r=jhprattbors-12/+15
Display walltime benchmarks with subnanosecond precision With modern CPUs running at more than one cycle per nanosecond the current precision is insufficient to resolve differences worth several cycles per iteration. Granted, walltime benchmarks often are noisy but occasionally, especially when no allocations are involved, the difference really is just a few cycles. example results when benchmarking 1-4 serialized ADD instructions and an empty bench body ``` running 4 tests test add ... bench: 0.24 ns/iter (+/- 0.00) test add2 ... bench: 0.48 ns/iter (+/- 0.01) test add3 ... bench: 0.72 ns/iter (+/- 0.01) test add4 ... bench: 0.96 ns/iter (+/- 0.01) test empty ... bench: 0.24 ns/iter (+/- 0.00) ```
2024-05-10Rollup merge of #124551 - Swatinem:debug-str-bench, r=cuviperMatthias Krüger-0/+80
Add benchmarks for `impl Debug for str` In order to inform future perf improvements and prevent regressions, lets add some benchmarks that stress `impl Debug for str`. --- As I am currently working on improving the perf in https://github.com/rust-lang/rust/pull/121150, its nice to have these benchmarks. Writing them, I also saw that escapes are written out one char at a time, even though other parts of the code are already optimizing that via `as_str`, which I intend to do as well as a followup improvement. r? ``@cuviper`` ☝🏻 as you were also assigned to https://github.com/rust-lang/rust/pull/121150, CC ``@the8472`` if you want to steal the review :-)
2024-05-09Document proper usage of `fmt::Error` and `fmt()`'s `Result`.Kevin Reid-16/+36
Documentation of these properties previously existed in a lone paragraph in the `fmt` module's documentation: <https://doc.rust-lang.org/1.78.0/std/fmt/index.html#formatting-traits> However, users looking to implement a formatting trait won't necessarily look there. Therefore, let's add the critical information (that formatting per se is infallible) to all the involved items.
2024-05-09Auto merge of #124773 - Marcondiro:master, r=joboetbors-4/+9
fix #124714 str.to_lowercase sigma handling Hello, This PR fixes issue #124714 about 'Σ' handling in `str.to_lowercase()`. The fix consists in considering the full original string during 'Σ' handling instead of considering just the substring left after the optimized ascii handling. A new test is added to avoid regression. Thanks!
2024-05-09Auto merge of #124793 - scottmcm:simplify-as-chunks, r=Nilstriebbors-4/+8
Implement `as_chunks` with `split_at_unchecked` We were discussing various ways to do [this on Discord](https://discord.com/channels/273534239310479360/273541522815713281/1236946363120619521), and in the process I noticed that <https://rust.godbolt.org/z/1P16P37Go> is emitting a panic path inside `as_chunks`. It optimizes out in release, but we could just not do that in the first place. We're already doing unsafe code that depends on this value being calculated correctly, so might as well call `split_at_unchecked` instead of `split_at`.
2024-05-08Auto merge of #124910 - matthiaskrgr:rollup-lo1uvdn, r=matthiaskrgrbors-189/+187
Rollup of 8 pull requests Successful merges: - #123344 (Remove braces when fixing a nested use tree into a single item) - #124587 (Generic `NonZero` post-stabilization changes.) - #124775 (crashes: add lastest batch of crash tests) - #124869 (Make sure we don't deny macro vars w keyword names) - #124876 (Simplify `use crate::rustc_foo::bar` occurrences.) - #124892 (Update cc crate to v1.0.97) - #124903 (Ignore empty RUSTC_WRAPPER in bootstrap) - #124909 (Reapply the part of #124548 that bors forgot) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-08Rollup merge of #124892 - jfgoog:update-cc, r=workingjubileeMatthias Krüger-1/+1
Update cc crate to v1.0.97
2024-05-08Auto merge of #124795 - scottmcm:simplify-slice-from-raw-parts, r=joboetbors-2/+2
Avoid a cast in `ptr::slice_from_raw_parts(_mut)` Casting to `*const ()` or `*mut ()` is no longer needed after https://github.com/rust-lang/rust/pull/123840 so let's make the MIR smaller (and more inline-able, as seen in the tests). If [ACP#362](https://github.com/rust-lang/libs-team/issues/362) goes through we can keep calling `ptr::from_raw_parts(_mut)` in these also without the cast, but that hasn't had any libs-api attention yet, so I'm not waiting on it.
2024-05-08Use generic `NonZero`.Markus Reiter-5/+5
2024-05-08Use generic `NonZero` in examples.Markus Reiter-183/+181
2024-05-08Update cc crate to v1.0.97James Farrell-1/+1
2024-05-08fix #124714 str.to_lowercase sigma handlingMarcondiro-4/+9
2024-05-08Rollup merge of #124838 - RalfJung:next_power_of_two, r=scottmcmJubilee-0/+1
next_power_of_two: add a doctest to show what happens on 0
2024-05-08Rollup merge of #124788 - madsmtm:reduce-target_os-macos, r=workingjubileeJubilee-21/+32
Convert instances of `target_os = "macos"` to `target_vendor = "apple"` https://github.com/rust-lang/rust/pull/124491 migrated towards using `target_vendor = "apple"` more, as there's very little difference between iOS, tvOS, watchOS and visionOS. In that PR, I only did the changes where the standard library already had fixes for iOS, that I could confidently apply to the other targets. However, there's actually also not that big of a gap between macOS and the aforementioned platforms - so in this PR, I've gone through a few of the instances of `target_os = "macos"` and replaced it with `target_vendor = "apple"` to improve support on those platforms, see the commits for details. r? workingjubilee CC `@thomcc` `@simlay` (do tell me if I should stop pinging you on these Apple PRs) `@rustbot` label O-apple
2024-05-08Rollup merge of #124782 - anatawa12:docs-create-new-already-exists, ↵Jubilee-0/+9
r=workingjubilee add note about `AlreadyExists` to `create_new` Fixes #119244
2024-05-08Rollup merge of #124470 - devnexen:no_sigpipe_fbsd, r=workingjubileeJubilee-1/+8
std::net: Socket::new_raw now set to SO_NOSIGPIPE on freebsd.
2024-05-08from_str_radix: outline only the panic functionDaniPopes-6/+6
2024-05-07Auto merge of #124836 - tgross35:const-slice-last-chunk, r=BurntSushibors-1/+1
Correct the const stabilization of `last_chunk` for slices `<[T]>::last_chunk` should have become const stable as part of <https://github.com/rust-lang/rust/pull/117561>. Update the const stability gate to reflect this.
2024-05-07next_power_of_two: add a doctest to show what happens on 0Ralf Jung-0/+1
2024-05-07Correct the const stabilization of `last_chunk` for slicesTrevor Gross-1/+1
`<[T]>::last_chunk` should have become const stable as part of <https://github.com/rust-lang/rust/pull/117561>. Update the const stability gate to reflect this.
2024-05-06f16::is_sign_{positive,negative} were feature-gated on f128Trevor Spiteri-2/+2
2024-05-06Auto merge of #124811 - matthiaskrgr:rollup-4zpov13, r=matthiaskrgrbors-3/+7
Rollup of 4 pull requests Successful merges: - #124520 (Document that `create_dir_all` calls `mkdir`/`CreateDirW` multiple times) - #124724 (Prefer lower vtable candidates in select in new solver) - #124771 (Don't consider candidates with no failing where clauses when refining obligation causes in new solver) - #124808 (Use `super_fold` in `RegionsToStatic` visitor) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-06Rollup merge of #124520 - tbu-:pr_create_dir_all_doc, r=AmanieuMatthias Krüger-3/+7
Document that `create_dir_all` calls `mkdir`/`CreateDirW` multiple times
2024-05-06Auto merge of #123850 - tspiteri:f16_f128_consts, r=Amanieubors-4/+382
Add constants for f16 and f128 - Commit 1 adds associated constants for `f16`, excluding NaN and infinities as these are implemented using arithmetic for `f32` and `f64`. - Commit 2 adds associated constants for `f128`, excluding NaN and infinities. - Commit 3 adds constants in `std::f16::consts`. - Commit 4 adds constants in `std::f128::consts`.
2024-05-06std::rand: adding solaris/illumos for getrandom support.David Carlier-1/+12
To help solarish support for miri https://rust-lang/miri/issues/3567
2024-05-06Auto merge of #124497 - rytheo:move-std-tests-to-library, r=workingjubileebors-0/+330
Move some stdlib tests from `tests/ui` to `library/std/tests` Related to #99417
2024-05-06Avoid a cast in `ptr::slice_from_raw_parts(_mut)`Scott McMurray-2/+2
Casting to `*const ()` or `*mut ()` just bloats the MIR, so let's not. If ACP#362 goes through we can keep calling `ptr::from_raw_parts(_mut)` in these also without the cast, but that hasn't had any libs-api attention yet, so I'm not waiting on it.
2024-05-06Implement `as_chunks` with `split_at_unchecked`Scott McMurray-4/+8
2024-05-06iOS/tvOS/watchOS/visionOS: Improve File Debug implMads Marquart-9/+9
This uses `libc::fcntl`, which, while not explicitly marked as available in the headers, is already used by `File::sync_all` and `File::sync_data` on these platforms, so should be fine to use here as well.
2024-05-06iOS/tvOS/watchOS/visionOS: Fix reading large filesMads Marquart-5/+6
Tested in the iOS simulator with something like: ``` let mut buf = vec![0; c_int::MAX as usize - 1 + 2]; let read_bytes = f.read(&mut buf).unwrap(); ```