about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2025-02-21Clarify/update comments in `BufRead::read_line`'s default bodyFrank Steffahn-1/+1
with where to *actually* look for more details
2025-02-20Implement read_buf for WASI stdinThalia Archibald-1/+6
2025-02-20Implement read_buf for zkVM stdinThalia Archibald-1/+9
For the zkVM, even when a guest buffer is uninitialized, from the host's perspective it is just a normal piece of memory which was initialized before letting the guest write into it. This makes `sys_read` safe to use with an uninitialized buffer. See https://github.com/risc0/risc0/issues/2853.
2025-02-20Rollup merge of #137270 - QianNangong:master, r=ChrisDentonJubilee-8/+8
Fix `*-win7-windows-msvc` target since 26eeac1a1e9fe46ffd80dd0d3dafdd2c2a644306 That commit make it failed to build `std` with `*-win7-windows-msvc` so fix it.
2025-02-20Rollup merge of #134340 - Urgau:stabilize-num_midpoint_signed, r=scottmcmJubilee-5/+4
Stabilize `num_midpoint_signed` feature This PR proposes that we stabilize the signed variants of [`iN::midpoint`](https://github.com/rust-lang/rust/issues/110840#issue-1684506201), the operation is equivalent to doing `(a + b) / 2` in a sufficiently large number. The stabilized API surface would be: ```rust /// Calculates the middle point of `self` and `rhs`. /// /// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a /// sufficiently-large signed integer type. This implies that the result is /// always rounded towards zero and that no overflow will ever occur. impl i{8,16,32,64,128,size} { pub const fn midpoint(self, rhs: Self) -> Self; } ``` T-libs-api previously stabilized the unsigned (and float) variants in #131784, the signed variants were left out because of the rounding that should be used in case of negative midpoint. This stabilization proposal proposes that we round towards zero because: - it makes the obvious `(a + b) / 2` in a sufficiently-large number always true - using another rounding for the positive result would be inconsistent with the unsigned variants - it makes `midpoint(-a, -b)` == `-midpoint(a, b)` always true - it is consistent with `midpoint(a as f64, b as f64) as i64` - it makes it possible to always suggest `midpoint` as a replacement for `(a + b) / 2` expressions *(which we may want to do as a future work given the 21.2k hits on [GitHub Search](https://github.com/search?q=lang%3Arust+%2F%5C%28%5Ba-zA-Z_%5D*+%5C%2B+%5Ba-zA-Z_%5D*%5C%29+%5C%2F+2%2F&type=code&p=1))* `@scottmcm` mentioned a drawback in https://github.com/rust-lang/rust/pull/132191#issuecomment-2439891200: > I'm torn, because rounding towards zero makes it "wider" than other values, which `>> 1` avoids -- `(a + b) >> 1` has the nice behaviour that `midpoint(a, b) + 2 == midpoint(a + 2, b + 2)`. > > But I guess overall sticking with `(a + b) / 2` makes sense as well, and I do like the negation property 🤷 Which I think is outweigh by the advantages cited above. Closes #110840 cc `@rust-lang/libs-api` cc `@scottmcm` r? `@dtolnay`
2025-02-20Stabilise `os_str_display`riverbl-7/+5
2025-02-20Auto merge of #136771 - scottmcm:poke-slice-iter-next, r=joboetbors-6/+29
Simplify `slice::Iter::next` enough that it inlines Inspired by this zulip conversation: <https://rust-lang.zulipchat.com/#narrow/channel/189540-t-compiler.2Fwg-mir-opt/topic/Feedback.20on.20a.20MIR.20optimization.20idea/near/498579990> ~~Draft for now because it needs #136735 to get the codegen tests to pass.~~
2025-02-20Undeprecate env::home_dirArlo Siemsen-5/+0
2025-02-20Implement 'PartialEq<{&Self, CString, Cow<Self>}>' for 'CStr'; Implement ↵Gabriel Bjørnager Jensen-0/+123
'PartialEq<{CStr, &CStr, Cow<CStr>}>' for 'CString'; Implement 'PartialEq<{CStr, &CStr, CString}>' for 'Cow<CStr>';
2025-02-20Guarantee behavior of transmuting Option::<T>::None subject to NPOJoshua Liebow-Feeser-14/+16
2025-02-21Correct doc about `temp_dir()` behavior on AndroidWang Han-1/+3
Since commit https://github.com/aosp-mirror/platform_frameworks_base/commit/d5ccb038f69193fb63b5169d7adc5da19859c9d8, `TMPDIR` will be set to application's cache dir when app starts.
2025-02-20Enable `f16` for MIPSMartin Nordholts-1/+0
It seems as if `f16` works on MIPS now according to my testing on Rust master with LLVM 20, and I was asked to create PRs with my changes. I only tested on the flavour of `mipsel-unknown-linux-gnu` hardware that happens to be available to me, so I can't say anything about other MIPS hardware, but from a casual skimming of the LLVM code ([1], [2]) it seems like `f16` should work on all MIPS hardware. So enable it for all MIPS hardware. [1]: https://github.com/rust-lang/llvm-project/blob/rustc/20.1-2025-02-13/llvm/lib/Target/Mips/MipsISelLowering.h#L370 [2]: https://github.com/rust-lang/llvm-project/blob/rustc/20.1-2025-02-13/llvm/lib/CodeGen/TargetLoweringBase.cpp#L1367-L1388
2025-02-20Implement feature `isolate_most_least_significant_one` for integer typesokaneco-0/+325
Implement accepted ACP for functions that isolate the most significant set bit and least significant set bit on unsigned, signed, and NonZero integers. Add function `isolate_most_significant_one` Add function `isolate_least_significant_one` Add tests
2025-02-19add `IntoBounds::intersect` and `RangeBounds::is_empty`Peter Jaszkowiak-5/+135
2025-02-19Skip scanning for surrogates when not known validThalia Archibald-1/+1
2025-02-19Add fast path for displaying pre-validated Wtf8BufThalia Archibald-2/+26
2025-02-20Auto merge of #137295 - matthiaskrgr:rollup-tdu3t39, r=matthiaskrgrbors-18/+7
Rollup of 9 pull requests Successful merges: - #135296 (interpret: adjust vtable validity check for higher-ranked types) - #137106 (Add customized compare for Link in rustdoc) - #137253 (Restrict `bevy_ecs` `ParamSet` hack) - #137262 (Make fewer crates depend on `rustc_ast_ir`) - #137263 (Register `USAGE_OF_TYPE_IR_INHERENT`, remove inherent usages) - #137266 (MIR visitor tweaks) - #137269 (Pattern Migration 2024: properly label `&` patterns whose subpatterns are from macro expansions) - #137277 (stabilize `inherent_str_constructors`) - #137281 (Tweak "expected ident" parse error to avoid talking about doc comments) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-19chore: release v0.1.147github-actions[bot]-1/+7
2025-02-20Rollup merge of #137277 - m4rch3n1ng:stabilize-inherent-str-constructors, ↵Matthias Krüger-18/+7
r=tgross35 stabilize `inherent_str_constructors` fcp done in https://github.com/rust-lang/rust/issues/131114#issuecomment-2668859969. tracking issue: #131114 closes: #131114
2025-02-19Auto merge of #137290 - matthiaskrgr:rollup-a7xdbi4, r=matthiaskrgrbors-170/+234
Rollup of 8 pull requests Successful merges: - #120580 (Add `MAX_LEN_UTF8` and `MAX_LEN_UTF16` Constants) - #132268 (Impl TryFrom<Vec<u8>> for String) - #136093 (Match Ergonomics 2024: update old-edition behavior of feature gates) - #136344 (Suggest replacing `.` with `::` in more error diagnostics.) - #136690 (Use more explicit and reliable ptr select in sort impls) - #136815 (CI: Stop /msys64/bin from being prepended to PATH in msys2 shell) - #136923 (Lint `#[must_use]` attributes applied to methods in trait impls) - #137155 (Organize `OsString`/`OsStr` shims) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-19remove win64_128bit_abi_hackRalf Jung-80/+2
2025-02-19ci: Pin the nightly toolchain for aarch64-unknown-linux-gnuTrevor Gross-1/+2
Pin aarch64-unknown-linux-gnu to nightly-2025-02-07 until [1] is resolved. [1]: https://github.com/llvm/llvm-project/issues/127804
2025-02-19ci: Pin the nightly toolchain for i686-pc-windows-gnuTrevor Gross-1/+2
Pin i686-pc-windows-gnu to nightly-2025-02-07 until [1] is resolved. [1]: https://github.com/rust-lang/rust/issues/136795
2025-02-19ci: Update actions/cache to v4Trevor Gross-1/+1
Github has deprecated v2 so this needs to be bumped.
2025-02-19Rollup merge of #137155 - thaliaarchi:wtf8-organize, r=ChrisDentonMatthias Krüger-109/+154
Organize `OsString`/`OsStr` shims Synchronize the `bytes.rs` and `wtf8.rs` shims for `OsString`/`OsStr` so they're easier to diff between each other. This is mostly ordering items the same between the two. I tried to minimize moves and went for the average locations between the files. With them in the same order, it is clear that `FromInner<_>` is not implemented for `bytes::Buf` and `Clone::clone_from` is not implemented for `wtf8::Buf`, but they are for the other. Fix that. I added #[inline] to all inherent methods of the `OsString`/`OsStr` shims, because it seemed that was already the rough pattern. `bytes.rs` has more inlining than `wtf8.rs`, so I added the corresponding ones to `wtf8.rs`. Then, the common missing ones have no discernible pattern to me. They're not divided by non-allocating/allocating. Perhaps the pattern is that UTF-8 validation isn't inlined? Since these types are merely the inner values in `OsStr`/`OsString`, I put inline on all methods and let those public types dictate inlining. I have not inspected codegen or run benchmarks. Also, touch up some (private) documentation comments. r? ``````@ChrisDenton``````
2025-02-19Rollup merge of #136923 - samueltardieu:push-vxxqvqwspssv, r=davidtwcoMatthias Krüger-25/+0
Lint `#[must_use]` attributes applied to methods in trait impls The `#[must_use]` attribute has no effect when applied to methods in trait implementations. This PR adds it to the unused `#[must_use]` lint, and cleans the extra attributes in portable-simd and Clippy.
2025-02-19Rollup merge of #136690 - ↵Matthias Krüger-18/+13
Voultapher:use-more-explicit-and-reliable-ptr-select, r=thomcc 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-19Rollup merge of #132268 - elichai:string_try_from_vec, r=AmanieuMatthias Krüger-0/+18
Impl TryFrom<Vec<u8>> for String I think this is useful enough to have :) As a general question, is there any policy around adding "missing" trait implementations? (like adding `AsRef<T> for T` for std types), I mostly stumble upon them when using a lot of "impl Trait in argument position" like (`foo: impl Into<String>`)
2025-02-19Rollup merge of #120580 - HTGAzureX1212:HTGAzureX1212/issue-45795, r=m-ou-seMatthias Krüger-18/+49
Add `MAX_LEN_UTF8` and `MAX_LEN_UTF16` Constants This pull request adds the `MAX_LEN_UTF8` and `MAX_LEN_UTF16` constants as per #45795, gated behind the `char_max_len` feature. The constants are currently applied in the `alloc`, `core` and `std` libraries.
2025-02-19stabilize `inherent_str_constructors`may-18/+7
2025-02-19Rollup merge of #136794 - cberner:stabilize, r=joshtriplettMatthias Krüger-10/+5
Stabilize file_lock Closes #130994
2025-02-19Rollup merge of #136347 - allevo:patch-1, r=AmanieuMatthias Krüger-0/+1
Add a bullet point to `std::fs::copy` I needed to copy a file but I got the following error: ``` Os { code: 2, kind: NotFound, message: "No such file or directory" } ``` After read the documentation, I though the error was generated by the `from` parameter, forgetting the `to` part. Anyway, I got the error because the parent folder of `to` didn't exist. Even if the documentation explicitly saying `but is not limited to just these cases`, I would like to add this case because I spent 3 hours around it. This PR just wants to put a mention about it.
2025-02-19Rollup merge of #136301 - hkBst:patch-33, r=thomccMatthias Krüger-2/+8
Improve instant docs This should be enough to close #79881.
2025-02-19Rollup merge of #134995 - DaniPopes:stable-const_slice_flatten, r=AmanieuMatthias Krüger-2/+2
Stabilize const_slice_flatten Const-stabilizes `slice::as_flattened{,_mut}`: ```rust // core::slice impl<T, const N: usize> [[T; N]] { pub const fn as_flattened(&self) -> &[T]; pub const fn as_flattened_mut(&mut self) -> &mut [T]; } ``` Tracking issue: https://github.com/rust-lang/rust/issues/95629 Requires separate FCP, as per https://github.com/rust-lang/rust/issues/95629#issuecomment-2566546257. Closes https://github.com/rust-lang/rust/issues/95629. `````@rustbot````` modify labels: +T-libs-api Happy new year!
2025-02-19Update wasm sub sat intrinsics for LLVM 20Nikita Popov-4/+4
The wasm-specific intrinsics have been removed in https://github.com/llvm/llvm-project/pull/109405, use the generic ones instead.
2025-02-19fix by commentsxizheyin-21/+17
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-19Fix `*-win7-windows-msvc` target since 26eeac1a1e9fe46ffd80dd0d3dafdd2c2a644306Li Keqing-8/+8
2025-02-19Update library/std/src/fs.rsTommaso Allevi-1/+1
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2025-02-19core/net: IpAddr*::as_octets()Nathan Perry-0/+60
Adds `const` `Ip*Addr::as_octets` methods providing reference access to `Ip*Addr` octets contents. See https://github.com/rust-lang/libs-team/issues/535 for accepted ACP with a more detailed justification.
2025-02-19remove assume_init in stack_overflowxizheyin-7/+9
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-19Rollup merge of #137228 - steffahn:one-coerces-to-supertypes-not-subtypes, ↵Matthias Krüger-4/+4
r=the8472 Fix typo in hidden internal docs of `TrustedRandomAccess` I typoed the coercion direction here 4 years ago; fixing it now
2025-02-19Rollup merge of #137026 - GrigorenkoPV:integer_sign_cast, r=jhprattMatthias Krüger-9/+8
Stabilize (and const-stabilize) `integer_sign_cast` Tracking issue: #125882 Closes: #125882 FCP completed: https://github.com/rust-lang/rust/issues/125882#issuecomment-2658274124
2025-02-18Auto merge of #137235 - matthiaskrgr:rollup-2kjua2t, r=matthiaskrgrbors-46/+66
Rollup of 10 pull requests Successful merges: - #135711 (Do not ICE on default_field_value const with lifetimes) - #136599 (librustdoc: more usages of `Joined::joined`) - #136876 (Locking documentation updates) - #137000 (Deeply normalize item bounds in new solver) - #137126 (fix docs for inherent str constructors) - #137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions) - #137191 (Update mdbook and move error_index_generator) - #137203 (Improve MIR modification) - #137206 (Make E0599 a structured error) - #137218 (misc `layout_of` cleanup) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-18Remove outdated target `unexpected_cfgs`Josh Stone-3/+0
2025-02-19std::fs: slightly reformat `remove_dir_all` error docs许杰友 Jieyou Xu (Joe)-3/+5
To make the error cases easier to spot on a quick glance.
2025-02-18Rollup merge of #137126 - m4rch3n1ng:fix-inherent-str-docs, r=AmanieuMatthias Krüger-8/+8
fix docs for inherent str constructors related to #131114 when implementing inherent str constructors in #136517, i forgot to change the docs, so the code examples still imported the `std::str` module and used the constructor from there, instead of using "itself" (the inherent constructor).
2025-02-18Rollup merge of #136876 - joshtriplett:locking-might-not-be-advisory, r=AmanieuMatthias Krüger-38/+58
Locking documentation updates - Reword file lock documentation to clarify advisory vs mandatory. Remove the word "advisory", and make it more explicit that the lock may be advisory or mandatory depending on platform. - Document that locking a file fails on Windows if the file is opened only for append
2025-02-18Rollup merge of #137214 - cyrgani:clippy_diagnostic_items, r=compiler-errorsUrgau-0/+7
add last std diagnostic items for clippy Part of https://github.com/rust-lang/rust-clippy/issues/5393. Add diagnostic item attributes to the items in `std` and `core` where clippy currently uses hardcoded paths (https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/paths.rs).
2025-02-18Rollup merge of #137205 - thaliaarchi:remove-wasi-fileext-tell, r=alexcrichtonUrgau-11/+0
Remove `std::os::wasi::fs::FileExt::tell` Following #137165 (Use `tell` for `<File as Seek>::stream_position`), `tell` is now directly exposed via `stream_position`, making `<File as FileExt>::tell` redundant. Remove it. `std::os::wasi::fs::FileExt::tell` is currently unstable and tracked in https://github.com/rust-lang/rust/issues/71213. ``@rustbot`` ping wasi
2025-02-18Rollup merge of #137167 - martn3:reliable_f16_math-f16-erfc, r=tgross35Urgau-0/+2
tests: Also gate `f16::erfc()` doctest with `reliable_f16_math` cfg In #136324 the doctest for `f16::erf()` was gated with `reliable_f16_math`. Add the same gate on `f16::erfc()` to avoid: rust_out.71e2e529d20ea47d-cgu.0:\ (.text._ZN8rust_out4main43_doctest_main_library_std_src_f16_rs_1321_017h485f3ffe6bf2a981E+0x38): \ undefined reference to `__gnu_h2f_ieee' on MIPS (and maybe other architectures). r? tgross35