about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2025-04-01std: use the address of `errno` to identify threads in `unique_thread_exit`joboet-24/+21
Getting the address of `errno` should be just as cheap as `pthread_self()` and avoids having to use the expensive `Mutex` logic because it always results in a pointer.
2025-04-01io: Avoid Avoid marking bytes as uninit in `BufReader::peek`Benoît du Garreau-1/+0
2025-04-01io: Avoid marking buffer as uninit when copying to `BufWriter`Benoît du Garreau-1/+4
2025-03-31Refactor `diy_float`Tobias Decking-47/+15
2025-03-31Rollup merge of #139157 - mejrs:never, r=NoratriebMatthias Krüger-5/+3
Remove mention of `exhaustive_patterns` from `never` docs The example shows an exhaustive match: ```rust #![feature(exhaustive_patterns)] use std::str::FromStr; let Ok(s) = String::from_str("hello"); ``` But https://github.com/rust-lang/rust/issues/119612 moved this functionality to `#![feature(min_exhaustive_patterns)` and then stabilized it.
2025-03-31std: clarify Mutex::get_mut more clearlyxizheyin-1/+5
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-31Auto merge of #139154 - jhpratt:rollup-rv8f915, r=jhprattbors-10/+2
Rollup of 5 pull requests Successful merges: - #139044 (bootstrap: Avoid cloning `change-id` list) - #139111 (Properly document FakeReads) - #139122 (Remove attribute `#[rustc_error]`) - #139132 (Improve hir_pretty for struct expressions.) - #139141 (Switch some rustc_on_unimplemented uses to diagnostic::on_unimplemented) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-31Remove mention of `exhaustive_patterns` from `never` docsmejrs-5/+3
2025-03-30Rollup merge of #139141 - mejrs:on_unimpl, r=NoratriebJacob Pratt-10/+2
Switch some rustc_on_unimplemented uses to diagnostic::on_unimplemented The use on the SliceIndex impl appears unreachable, there is no mention of "vector indices" in any test output and I could not get it to show up in error messages.
2025-03-30Auto merge of #139131 - m-ou-se:format-args-struct-expr, r=Mark-Simulacrumbors-7/+1
Simplify expansion for format_args!(). Instead of calling `Placeholder::new()`, we can just use a struct expression directly. Before: ```rust Placeholder::new(…, …, …, …) ``` After: ```rust Placeholder { position: …, flags: …, width: …, precision: …, } ``` (I originally avoided the struct expression, because `Placeholder` had a lot of fields. But now that https://github.com/rust-lang/rust/pull/136974 is merged, it only has four fields left.) This will make the `fmt` argument to `fmt::Arguments::new_v1_formatted()` a candidate for const promotion, which is important if we ever hope to tackle https://github.com/rust-lang/rust/issues/92698 (It doesn't change anything yet though, because the `args` argument to `fmt::Arguments::new_v1_formatted()` is not const-promotable.)
2025-03-30slice: Remove some uses of unsafe in first/last chunk methodsokaneco-60/+34
Remove unsafe `split_at_unchecked` and `split_at_mut_unchecked` in some slice `split_first_chunk`/`split_last_chunk` methods. Replace those calls with the safe `split_at` and `split_at_checked` where applicable. Add codegen tests to check for no panics when calculating the last chunk index using `checked_sub` and `split_at`
2025-03-30use `diagnostic::on_unimplemented` insteadmejrs-2/+2
2025-03-30Delete unreacheable `#[rustc_on_unimplemented]`mejrs-8/+0
2025-03-30Simplify expansion for format_args!().Mara Bos-7/+1
Instead of calling new(), we can just use a struct expression directly. Before: Placeholder::new(…, …, …, …) After: Placeholder { position: …, flags: …, width: …, precision: …, }
2025-03-29Auto merge of #139119 - matthiaskrgr:rollup-7l2ri0f, r=matthiaskrgrbors-120/+195
Rollup of 7 pull requests Successful merges: - #137928 (stabilize const_cell) - #138431 (Fix `uclibc` LLVM target triples) - #138832 (Start using `with_native_path` in `std::sys::fs`) - #139081 (std: deduplicate `errno` accesses) - #139100 (compiletest: Support matching diagnostics on lines below) - #139105 (`BackendRepr::is_signed`: comment why this may panics) - #139106 (Mark .pp files as Rust) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-29Rollup merge of #139081 - joboet:errno_dedup, r=NoratriebMatthias Krüger-0/+9
std: deduplicate `errno` accesses By marking `__errno_location` as `#[ffi_const]` and `std::sys::os::errno` as `#[inline]`, this PR allows merging multiple calls to `io::Error::last_os_error()` into one.
2025-03-29Rollup merge of #138832 - ChrisDenton:with_native_path, r=joboetMatthias Krüger-115/+181
Start using `with_native_path` in `std::sys::fs` Ideally, each platform should use their own native path type internally. This will, for example, allow passing a `CStr` directly to `std::fs::File::open` and therefore avoid the need for allocating a new null-terminated C string. However, doing that for every function and platform all at once makes for a large PR that is way too prone to breaking. So this PR does some minimal refactoring which should help progress towards that goal. The changes are Unix-only and even then I avoided functions that require more changes so that this PR is just moving things around. r? joboet
2025-03-29Rollup merge of #137928 - RalfJung:const_cell, r=m-ou-seMatthias Krüger-5/+5
stabilize const_cell ``@rust-lang/libs-api`` ``@rust-lang/wg-const-eval`` I see no reason to wait any longer, so I propose we stabilize the use of `Cell` in `const fn` -- specifically the APIs listed here: ```rust // core::cell impl<T> Cell<T> { pub const fn replace(&self, val: T) -> T; } impl<T: Copy> Cell<T> { pub const fn get(&self) -> T; } impl<T: ?Sized> Cell<T> { pub const fn get_mut(&mut self) -> &mut T; pub const fn from_mut(t: &mut T) -> &Cell<T>; } impl<T> Cell<[T]> { pub const fn as_slice_of_cells(&self) -> &[Cell<T>]; } ``` Unfortunately, `set` cannot be made `const fn` yet as it drops the old contents. Fixes https://github.com/rust-lang/rust/issues/131283
2025-03-29Auto merge of #133572 - frank-king:feature/unique_arc, r=Amanieubors-3/+439
Implement `alloc::sync::UniqueArc` This implements the `alloc::sync::UniqueArc` part of #112566.
2025-03-29Start using with_native_path in std::sys::fsChris Denton-115/+181
2025-03-29std: make `cmath` functions safejoboet-125/+125
2025-03-29Rollup merge of #139097 - m-ou-se:pin-tests, r=WaffleLapkinMatthias Krüger-0/+11
Add more tests for pin!(). This adds the tests suggested by `@danielhenrymantilla` in this comment: https://github.com/rust-lang/rust/pull/138717#discussion_r2005433640 by
2025-03-29Rollup merge of #138988 - madsmtm:internal-weak-macro-syntax, r=ibraheemdevMatthias Krüger-80/+144
Change the syntax of the internal `weak!` macro Change the syntax to include parameter names and a trailing semicolon. Motivation: - Mirror the `syscall!` macro. - Allow rustfmt to format it (when wrapped in parentheses, and when not inside `cfg_if!`). - For better documentation (having the parameter names available in the source code is a bit nicer). - Allow a future improvement to this macro where we can sometimes use the symbol directly when it's statically known to be available (and thus need the parameter names to be available), see https://github.com/rust-lang/rust/pull/136868. r? libs
2025-03-29Rollup merge of #138757 - rust-wasi-web:wasi-thread-stack-size, r=alexcrichtonMatthias Krüger-2/+2
wasm: increase default thread stack size to 1 MB The default stack size for the [main thread is 1 MB as specified by linker options](https://github.com/rust-lang/rust/blob/38cf49dde8a5b0b284bb6dffd423d223c9f8f7a3/compiler/rustc_target/src/spec/base/wasm.rs#L14). However, the default stack size for threads was only 64 kB. This is surprisingly small and thus we increase it to 1 MB to match the main thread.
2025-03-29Promise `array::from_fn` in generated in order of increasing indicesScott McMurray-6/+27
2025-03-29Add more tests for pin!().Mara Bos-0/+11
Co-authored-by: Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>
2025-03-29Add a test for `Weak` created from `UniqueArc::downgrade`Frank King-1/+22
2025-03-28fix docs for `Peekable::next_if{_eq}`Yotam Ofek-3/+3
2025-03-28Rollup merge of #139069 - a1phyr:better_take, r=joboetMatthias Krüger-4/+4
`io::Take`: avoid new `BorrowedBuf` creation in some case If `self.limit == buf.capacity()`, doing the whole `BorrowedBuf` dance is not necessary.
2025-03-28Rollup merge of #139058 - barafael:patch-1, r=joboetMatthias Krüger-1/+1
Fix formatting nit in process.rs Minor formatting issue in `process.rs`.
2025-03-28Rollup merge of #139052 - m-ou-se:pin-macro-tests, r=joboetMatthias Krüger-14/+17
Put pin!() tests in the right file. In #138717, these tests were put in `tests/pin.rs`, but they should go in `tests/pin_macro.rs`. r? `@jdonszelmann`
2025-03-28Rollup merge of #138976 - xizheyin:issue-138969, r=RalfJungMatthias Krüger-1/+2
Explain one-past-the-end pointer in std library Closing #138969 r? libs
2025-03-28std: deduplicate `errno` accessesjoboet-0/+9
By marking `__errno_location` as `#[ffi_const]` and `std::sys::os::errno` as `#[inline]`, this PR allows merging multiple calls to `io::Error::last_os_error()` into one.
2025-03-28Add `slice::align_to_uninit_mut`Nikolai Kuklin-2/+51
2025-03-28`io::Take`: avoid new `BorrowedBuf` creation in some caseBenoît du Garreau-4/+4
2025-03-28std: Explain range follows standard half-open range in `offset`xizheyin-1/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-28Fix formatting nit in process.rsRafael Bachmann-1/+1
2025-03-28Put pin!() tests in the right file.Mara Bos-14/+17
2025-03-27Rollup merge of #139021 - joboet:pre-vista-fallback, r=ChrisDentonJacob Pratt-22/+6
std: get rid of pre-Vista fallback code We haven't had any Windows XP targets for a long while now... r? ChrisDenton
2025-03-27Trusty: Implement write_vectored for stdioThalia Archibald-38/+49
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 #136769.
2025-03-27Auto merge of #138702 - m-ou-se:spawn-in-atexit, r=Mark-Simulacrumbors-9/+14
Allow spawning threads after TLS destruction Fixes #138696
2025-03-27allow unnecessary transmutesbendn-0/+1
2025-03-27Use char::is_whitespace directly in str::trim*DaniPopes-3/+3
2025-03-27std: get rid of pre-Vista fallback codejoboet-22/+6
We haven't had any Windows XP targets for a long while now...
2025-03-26Swap usize -> ptr transmute for strict_pov APIJames Wainwright-2/+2
Removes some unsafety and reduces the number of `usize` -> `ptr` transmutes which might be helpful for CHERI-like targets in the future.
2025-03-26Pass `Alignment` for `RawVecInner::new_in`James Wainwright-4/+15
Encodes the safety constraint that `Unique`'s pointer must be non-zero into the API.
2025-03-26Expose `Unique::from<NonNull>` in const internallyJames Wainwright-1/+7
2025-03-26Use cfg_match in coreChristopher Durham-118/+53
2025-03-26mark cfg_match! semitransparentChristopher Durham-3/+4
2025-03-26Change the syntax of the internal `weak!` macroMads Marquart-80/+144
Change the syntax to include parameter names and a trailing semicolon. Motivation: - Mirror the `syscall!` macro. - Allow rustfmt to format it (when wrapped in parentheses). - For better documentation (having the parameter names available in the source code is a bit nicer). - Allow future improvements to this macro where we can sometimes use the symbol directly when it's statically known to be available.