about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2025-04-27fix missing doc in CString::from_raw and str::from_boxed_utf8_uncheckedLemonJ-3/+12
2025-04-27Remove `#[doc(hidden)]` from `AtomicPrimitive::AtomicInner`Pavel Grigorenko-2/+2
2025-04-27name ATOMIC_INIT without unstable aliasChristopher Durham-3/+3
2025-04-27use generic Atomic type where possibleChristopher Durham-268/+279
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-27add generic Atomic<T> type aliasChristopher Durham-0/+94
2025-04-26docs: fix incorrect stability markers on `std::{todo, matches}`Michael Howell-2/+8
This regression appeared in 916cfbcd3ed95a737b5a62103bbc4118ffe1eb2b. The change is behaving as expected (a non-glob re-export uses the stability marker on the `use` item, not the original one), but this part of the standard library didn't follow it.
2025-04-26Update example to use `CStr::to_string_lossy`Jake Goulding-2/+3
2025-04-26Rollup merge of #140325 - ↵Matthias Krüger-2/+2
ethanwu10:ethanwu10/grammar-fixes-for-bufread-has-data-left-docs, r=jhpratt Grammar fixes for BufRead::has_data_left docs Fix some grammar in the documentation for `BufRead::has_data_left`
2025-04-26moved simple test to coretests, introduced more fleshed out doctests for ↵Jonathan Gruner-4/+120
break_ok/continue_ok
2025-04-26uefi: Update r-efiAyush Singh-6/+6
- Bump up the version to 5.2.0 Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-04-25Grammar fixes for BufRead::has_data_left docsEthan Wu-2/+2
2025-04-26Rollup merge of #140216 - t5kd:master, r=tgross35Matthias Krüger-2/+6
Document that "extern blocks must be unsafe" in Rust 2024 The [documentation on `extern`](https://doc.rust-lang.org/std/keyword.extern.html) contains the following code sample: ```rust #[link(name = "my_c_library")] extern "C" { fn my_c_function(x: i32) -> bool; } ``` Due to #123743, attempting to compile such code with the 2024 edition of Rust fails: ``` error: extern blocks must be unsafe ``` This PR extends the `extern` documentation with a brief explanation of the new requirement. It also adds the missing `unsafe` keyword to the code sample, which should be compatible with rustc since v1.82. **Related docs:** - https://doc.rust-lang.org/reference/items/external-blocks.html - https://doc.rust-lang.org/edition-guide/rust-2024/unsafe-extern.html
2025-04-26Rollup merge of #139865 - m-ou-se:stabilize-proc-macro-span-location, r=tgross35Matthias Krüger-4/+4
Stabilize proc_macro::Span::{start,end,line,column}. This stabilizes part of https://github.com/rust-lang/rust/issues/54725 Specifically, the part related to getting the location of a span: ```rust impl Span { pub fn start(&self) -> Span; // Empty span at the start of this span pub fn end(&self) -> Span; // Empty span at the end of this span pub fn line(&self) -> usize; // Line where the span starts pub fn column(&self) -> usize; // Column where the span starts } ``` History of this part of the API: Originally, `start` and `end` returned a `LineColumn` struct (containing the line and column). This has been simplified/changed: - No more `LineColumn`: `Span` now directly has `.line()` and `.column()` methods. This means we can easily add `.byte_offset()` or `.byte_range()` in the future if we want to. - `Span::start()` and `Span::end()` are now the equivalent of rustc's internal `shrink_to_lo()` and `shrink_to_hi()`. This means you can do e.g. `span.end().column()`, removing the need for a `span.end_column()` or similar.
2025-04-25Update `extern` docs for Rust 2024 and add safety remarksTobias-2/+6
2025-04-25Auto merge of #140298 - matthiaskrgr:rollup-5tc1gvb, r=matthiaskrgrbors-3/+38
Rollup of 8 pull requests Successful merges: - #137683 (Add a tidy check for GCC submodule version) - #138968 (Update the index of Result to make the summary more comprehensive) - #139572 (docs(std): mention const blocks in const keyword doc page) - #140152 (Unify the format of rustc cli flags) - #140193 (fix ICE in `#[naked]` attribute validation) - #140205 (Tidying up UI tests [2/N]) - #140284 (remove expect() in `unnecessary_transmutes`) - #140290 (rustdoc: fix typo change from equivelent to equivalent) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-25Rollup merge of #139572 - ↵Matthias Krüger-1/+8
ismailarilik:docs/std/mention-const-blocks-in-const-keyword-doc-page, r=tgross35 docs(std): mention const blocks in const keyword doc page Aims to close #139549
2025-04-25Rollup merge of #138968 - Natural-selection1:update-Result-doc, r=AmanieuMatthias Krüger-2/+30
Update the index of Result to make the summary more comprehensive fix #138966 This PR and #138957 are twin PR r? `@Amanieu`
2025-04-25Auto merge of #140282 - matthiaskrgr:rollup-g6ze4jj, r=matthiaskrgrbors-1220/+996
Rollup of 8 pull requests Successful merges: - #137653 (Deprecate the unstable `concat_idents!`) - #138957 (Update the index of Option to make the summary more comprehensive) - #140006 (ensure compiler existance of tools on the dist step) - #140143 (Move `sys::pal::os::Env` into `sys::env`) - #140202 (Make #![feature(let_chains)] bootstrap conditional in compiler/) - #140236 (norm nested aliases before evaluating the parent goal) - #140257 (Some drive-by housecleaning in `rustc_borrowck`) - #140278 (Don't use item name to look up associated item from trait item) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-25Auto merge of #140273 - matthiaskrgr:rollup-rxmuvkg, r=matthiaskrgrbors-1/+4
Rollup of 8 pull requests Successful merges: - #137096 (Stabilize flags for doctest cross compilation) - #140148 (CI: use aws codebuild for job dist-arm-linux) - #140187 ([AIX] Handle AIX dynamic library extensions within c-link-to-rust-dylib run-make test) - #140196 (Improved diagnostics for non-primitive cast on non-primitive types (`Arc`, `Option`)) - #140210 (Work around cygwin issue on condvar timeout) - #140213 (mention about `x.py setup` in `INSTALL.md`) - #140229 (`DelimArgs` tweaks) - #140248 (Fix impl block items indent) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-25docs(std): mention const blocks in const keyword doc pageismailarilik-1/+8
2025-04-25Rollup merge of #140143 - thaliaarchi:move-env-pal, r=joboetMatthias Krüger-1218/+962
Move `sys::pal::os::Env` into `sys::env` Although `Env` (as `Vars`), `Args`, path functions, and OS constants are publicly exposed via `std::env`, their implementations are each self-contained. Keep them separate in `std::sys` and make a new module, `sys::env`, for `Env`. Also fix `unsafe_op_in_unsafe_fn` for Unix and update the `!DynSend` and `!DynSync` impls which had grown out of sync with the platforms (see #48005 for discussion on that). r? joboet Tracked in #117276.
2025-04-25Rollup merge of #138957 - Natural-selection1:update-Option-doc, r=AmanieuMatthias Krüger-2/+27
Update the index of Option to make the summary more comprehensive fix: #138955 This PR and #138968 are twin PR By the way, this is my first time contributing to rust, and I'm not a native English speaker, so any suggestions—whether about the wording in the docs or the contribution process itself—would be greatly appreciated!
2025-04-25Rollup merge of #137653 - tgross35:deprecate-concat_idents, r=workingjubileeMatthias Krüger-0/+7
Deprecate the unstable `concat_idents!` `concat_idents` has been around unstably for a long time, but there is now a better (but still unstable) way to join identifiers using `${concat(...)}` syntax with `macro_metavar_expr_concat`. This resolves a lot of the problems with `concat_idents` and is on a better track toward stabilization, so there is no need to keep both versions around. `concat_idents!` still has a lot of use in the ecosystem so deprecate it before removing, as discussed in [1]. Link: https://github.com/rust-lang/rust/issues/124225 [1]: https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Removing.20.60concat_idents.60
2025-04-25Solved suggestionsHegui Dai-2/+2
2025-04-25Rollup merge of #140210 - Berrysoft:cygwin-timedwait, r=joboetMatthias Krüger-1/+4
Work around cygwin issue on condvar timeout This workaround *just works*... Actually I don't quite understand why does it work in such way. With a simple test on Cygwin, it seems that the maximum value of `tv_sec` could be 12899331056917, while the maximum value of `tv_nsec` should be a value floating around 464600000. A larger `timespec` could block the syscall forever. r? `@joboet`
2025-04-24Deprecate the unstable `concat_idents!`Trevor Gross-0/+7
`concat_idents` has been around unstably for a long time, but there is now a better (but still unstable) way to join identifiers using `${concat(...)}` syntax with `macro_metavar_expr_concat`. This resolves a lot of the problems with `concat_idents` and is on a better track toward stabilization, so there is no need to keep both versions around. `concat_idents!` still has a lot of use in the ecosystem so deprecate it before removing, as discussed in [1]. Link: https://github.com/rust-lang/rust/issues/124225 [1]: https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Removing.20.60concat_idents.60
2025-04-24implement continue_ok and break_ok for ControlFlowJonathan Gruner-0/+44
2025-04-24Rollup merge of #140172 - bjoernager:const-float-algebraic, r=RalfJungMatthias Krüger-25/+45
Make algebraic functions into `const fn` items. Tracking issue: #136469 This PR makes the algebraic intrinsics and the unstable, algebraic functions of `f16`, `f32`, `f64`, and `f128` into `const fn` items: ```rust impl f16 { pub const fn algebraic_add(self, rhs: f16) -> f16; pub const fn algebraic_sub(self, rhs: f16) -> f16; pub const fn algebraic_mul(self, rhs: f16) -> f16; pub const fn algebraic_div(self, rhs: f16) -> f16; pub const fn algebraic_rem(self, rhs: f16) -> f16; } impl f32 { pub const fn algebraic_add(self, rhs: f32) -> f32; pub const fn algebraic_sub(self, rhs: f32) -> f32; pub const fn algebraic_mul(self, rhs: f32) -> f32; pub const fn algebraic_div(self, rhs: f32) -> f32; pub const fn algebraic_rem(self, rhs: f32) -> f32; } impl f64 { pub const fn algebraic_add(self, rhs: f64) -> f64; pub const fn algebraic_sub(self, rhs: f64) -> f64; pub const fn algebraic_mul(self, rhs: f64) -> f64; pub const fn algebraic_div(self, rhs: f64) -> f64; pub const fn algebraic_rem(self, rhs: f64) -> f64; } impl f128 { pub const fn algebraic_add(self, rhs: f128) -> f128; pub const fn algebraic_sub(self, rhs: f128) -> f128; pub const fn algebraic_mul(self, rhs: f128) -> f128; pub const fn algebraic_div(self, rhs: f128) -> f128; pub const fn algebraic_rem(self, rhs: f128) -> f128; } // core::intrinsics pub const fn fadd_algebraic<T: Copy>(a: T, b: T) -> T; pub const fn fsub_algebraic<T: Copy>(a: T, b: T) -> T; pub const fn fmul_algebraic<T: Copy>(a: T, b: T) -> T; pub const fn fdiv_algebraic<T: Copy>(a: T, b: T) -> T; pub const fn frem_algebraic<T: Copy>(a: T, b: T) -> T; ``` This PR does not preserve the initial behaviour of these functions yielding non-deterministic output under Miri; it is most likely desired to reimplement this behaviour at some point.
2025-04-24Rollup merge of #140150 - RalfJung:MAX_EXP, r=tgross35Matthias Krüger-24/+48
fix MAX_EXP and MIN_EXP docs As pointed out in https://github.com/rust-lang/rust/issues/88734, the docs for these constants are wrong. r? ``@tgross35``
2025-04-24Rollup merge of #140141 - thaliaarchi:env-consts/zkvm, r=joboetMatthias Krüger-9/+11
Move zkVM constants into `sys::env_consts` I missed this in #139868. Its `mod` declaration was removed, but the contents were not moved. r? joboet
2025-04-24Rollup merge of #136083 - bend-n:⃤⃤, r=lcnrMatthias Krüger-4/+18
Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etc implements #136067 Rust has helper methods for many kinds of safe transmutes, for example integer<->bytes. This is a lint against using transmute for these cases. ```rs fn bytes_at_home(x: [u8; 4]) -> u32 { transmute(x) } // other examples transmute::<[u8; 2], u16>(); transmute::<[u8; 8], f64>(); transmute::<u32, [u8; 4]>(); transmute::<char, u32>(); transmute::<u32, char>(); ``` It would be handy to suggest `u32::from_ne_bytes(x)`. This is implemented for `[u8; _]` -> `{float int}` This also implements the cases: `fXX` <-> `uXX` = `{from_bits, to_bits}` `uXX` -> `iXX` via `cast_unsigned` and `cast_signed` {`char` -> `u32`, `bool` -> `n8`} via `from` `u32` -> `char` via `from_u32_unchecked` (note: notes `from_u32().unwrap()`) (contested) `u8` -> `bool` via `==` (debatable) --- try-job: aarch64-gnu try-job: test-various
2025-04-24Auto merge of #140245 - matthiaskrgr:rollup-e0fwsfv, r=matthiaskrgrbors-9/+25
Rollup of 8 pull requests Successful merges: - #139261 (mitigate MSVC alignment issue on x86-32) - #140075 (Mention average in midpoint documentations) - #140184 (Update doc of cygwin target) - #140186 (Rename `compute_x` methods) - #140194 (minicore: Have `//@ add-core-stubs` also imply `-Cforce-unwind-tables=yes`) - #140195 (triagebot: label minicore changes w/ `A-test-infra-minicore` and ping jieyouxu on changes) - #140214 (Remove comment about handling non-global where bounds with corresponding projection) - #140228 (Revert overzealous parse recovery for single colons in paths) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-24Rollup merge of #140075 - Urgau:midpoint-average, r=tgross35Matthias Krüger-9/+25
Mention average in midpoint documentations Added a mention to "average" in midpoint documentations and as well as some `#[doc(alias = "average")]`[^1]. This is done to improve the discoverability of the function. [^1]: https://docs.rs/num-integer/latest/num_integer/trait.Average.html#tymethod.average_floor
2025-04-24stdarchbendn-0/+0
2025-04-24Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etcbendn-4/+18
2025-04-24Rollup merge of #140232 - nnethercote:rm-unnecessary-clones, r=SparrowLiiMatthias Krüger-1/+1
Remove unnecessary clones r? `@SparrowLii`
2025-04-24Rollup merge of #139450 - NobodyXu:new-api/make-fifo, r=tgross35Matthias Krüger-1/+63
Impl new API `std::os::unix::fs::mkfifo` under feature `unix_fifo` Tracking issue #139324
2025-04-24Rollup merge of #139307 - xizheyin:issue-139296, r=joboetMatthias Krüger-0/+3
std: Add performance warnings to HashMap::get_disjoint_mut Closes #139296 The `get_disjoint_mut` in `HashMap` also performs a complexity O(n^2) check. So we need to be reminded of that as well. https://github.com/rust-lang/hashbrown/blob/b5b0655a37e156f9798ac8dd7e970d4adba9bf90/src/raw/mod.rs#L1216-L1220
2025-04-24Rollup merge of #134446 - tgross35:stabilize-cell_update, r=jhprattMatthias Krüger-4/+1
Stabilize the `cell_update` feature Included API: ```rust impl<T: Copy> Cell<T> { pub fn update(&self, f: impl FnOnce(T) -> T); } ``` FCP completed once at https://github.com/rust-lang/rust/issues/50186#issuecomment-2198783432 but the signature has since changed. Closes: https://github.com/rust-lang/rust/issues/50186
2025-04-24Mention average in midpoint documentationsUrgau-9/+25
2025-04-24fix doc errorHegui Dai-2/+2
2025-04-24fix exampleHegui Dai-1/+1
2025-04-24add examples using .as_ref() for is_some_and and is_none_orHegui Dai-0/+8
2025-04-24keep the original text for is_some and is_noneHegui Dai-2/+2
2025-04-24add examples using .as_ref() for is_err_and and is_ok_andHegui Dai-0/+8
2025-04-24keep original text for is_ok and is_errHegui Dai-8/+8
2025-04-24Remove some unnecessary clones.Nicholas Nethercote-1/+1
I found these by grepping for `&[a-z_\.]*\.clone()`, i.e. expressions like `&a.b.clone()`, which are sometimes unnecessary clones, and also looking at clones nearby to cases like that.
2025-04-23std_detect: RISC-V platform guide documentationTsukasa OI-78/+126
Since there's no architectural feature detection on RISC-V (unlike `CPUID` on x86 architectures and some system registers on Arm/AArch64), runtime feature detection entirely depends on the platform-specific facility. As a result, availability of each feature heavily depends on the platform and its version. To help users make a decision for feature checking on a RISC-V system, this commit adds a platform guide with minimum supported platform versions. Note: It intentionally omits the description of the reverse implication related to *extension groups* (such like implication of `B` *from* its members: `Zba`, `Zbb` and `Zbs` extensions) because it currently does not synchronize well with the `-Ctarget-feature` compiler option (due to missing reverse implication checks using `cfg` and due to constraints of the current Rust's feature handling). Instead, it only describes forward implications (like `D` implying `F`) due to the fact that it relatively synchronizes well between Rust and `stdarch` for this kind of feature handling (not fully synchronized though). Still, an extension group is considered "supported" once the platform/version supports runtime detection of all members in it.
2025-04-23Warn on `unsafe_op_in_unsafe_fn` by defaultTrevor Gross-51/+172
Edition 2024 requires that we avoid this. There is a lot of code that will need to be adjusted, so start the process here with a warning that will show up in CI.
2025-04-23libm-macros: Allow a way to bulk match f16 and f128 functionsTrevor Gross-122/+128
These are never available in musl, so introduce easier ways to skip them rather than needing to exclude f16/f128 functions in three different places.