about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2024-09-09Rollup merge of #130067 - madsmtm:clean-up-fs-test, r=ChrisDentonMatthias Krüger-18/+0
Remove redundant check in `symlink_hard_link` test We support macOS 10.12 and above, so it now always uses `linkat`, and so the check is redundant. This was missed in #126351. ``@rustbot`` label O-macos
2024-09-09move const fn with a null check into const_ptr_is_null gateRalf Jung-3/+3
2024-09-09move some const fn out of the const_ptr_as_ref featureRalf Jung-13/+13
2024-09-09Fix slice::first_mut docsJames C. Wise-1/+1
pointer -> reference
2024-09-09Stabilize `char::MIN`okaneco-4/+1
2024-09-09fix UB in a testRalf Jung-1/+6
also add an explicit test for the fact that a Option<WidePtr> has padding when it is None
2024-09-09Add missing `#[allow(missing_docs)]` on hack functions in allocUrgau-0/+4
2024-09-09`RepeatN`: use MaybeUninitDeadbeef-15/+69
2024-09-09bootstrap `naked_asm!` for `compiler-builtins`Folkert de Vries-0/+14
in this commit, `naked_asm!` is an alias for `asm!` with one difference: `options(noreturn)` is always enabled by `naked_asm!`. That makes it future-compatible for when `naked_asm!` starts disallowing `options(noreturn)` later.
2024-09-09Rollup merge of #130115 - eduardosm:needless-returns-libs, r=workingjubileeJubilee-19/+20
Remove needless returns detected by clippy in libraries
2024-09-09Rollup merge of #130107 - RalfJung:const-ptr-is-null, r=oli-obkJubilee-20/+7
const: make ptr.is_null() stop execution on ambiguity This seems better than saying `false` -- saying `false` is in fact actively unsound if `NonNull` then uses this to permit putting this pointer inside of it, but at runtime it turns out to be null. Part of https://github.com/rust-lang/rust/issues/74939 Cc ```@rust-lang/wg-const-eval```
2024-09-09Rollup merge of #130090 - RalfJung:result-copied, r=NoratriebJubilee-6/+18
make Result::copied unstably const The corresponding `Option::copied` is unstably const, so seems reasonable to do the same here.
2024-09-09Rollup merge of #130087 - RalfJung:option-const-iter, r=workingjubileeJubilee-2/+1
remove 'const' from 'Option::iter' This is kind of pointless to be a `const fn` since you can't do anything with the iterator. It is also the only `const fn iter*` in the entire standard library. It probably got constified when `~const` traits got added everywhere, and then was forgotten to be de-constified when that was undone. The rest of the const_option feature seems like it can reasonably be stabilized, but this one IMO should not be stabilized, and it's not worth creating a new tracking issue. Cc https://github.com/rust-lang/rust/issues/67441
2024-09-09[illumos] enable SIGSEGV handler to detect stack overflowsRain-4/+11
Use the same code as Solaris. I couldn't find any tests regarding this, but I did test a stage0 build against my stack-exhaust-test binary [1]. Before: ``` running with use_stacker = No, new_thread = false, make_large_local = false zsh: segmentation fault (core dumped) cargo run ``` After: ``` running with use_stacker = No, new_thread = false, make_large_local = false thread 'main' has overflowed its stack fatal runtime error: stack overflow zsh: IOT instruction (core dumped) cargo +stage0 run ``` Fixes #128568. [1] https://github.com/sunshowers/stack-exhaust-test/
2024-09-08remove const_slice_index annotations, it never had a feature gate anywayRalf Jung-18/+0
2024-09-08add FIXME(const-hack)Ralf Jung-58/+35
2024-09-08move Option::unwrap_unchecked into const_option feature gateRalf Jung-1/+1
2024-09-08Remove needless returns detected by clippy in librariesEduardo Sánchez Muñoz-19/+20
2024-09-08const: make ptr.is_null() stop execution on ambiguityRalf Jung-20/+7
2024-09-08Option, Result: put the &mut variants of 'copied' under the same feature as ↵Ralf Jung-3/+9
the '&' variants
2024-09-08Auto merge of #130002 - orlp:better-div-floor-ceil, r=thomccbors-4/+16
better implementation of signed div_floor/ceil Tracking issue for signed `div_floor`/`div_ceil`: https://github.com/rust-lang/rust/issues/88581. This PR improves the implementation of those two functions by adding a better branchless algorithm. Side-by-side comparison of `i32::div_floor` on x86-64: ```asm div_floor_new: div_floor_old: push rax push rax test esi, esi test esi, esi je .LBB0_3 je .LBB1_6 mov eax, esi mov eax, esi not eax not eax lea ecx, [rdi - 2147483648] lea ecx, [rdi - 2147483648] or ecx, eax or ecx, eax je .LBB0_2 je .LBB1_7 mov eax, edi mov eax, edi cdq cdq idiv esi idiv esi xor esi, edi test edx, edx sar esi, 31 setg cl test edx, edx test esi, esi cmove esi, edx sets dil add eax, esi test dil, cl pop rcx jne .LBB1_4 ret test edx, edx .LBB0_3: setns cl lea rdi, [rip + .L__unnamed_1] test esi, esi call qword ptr [rip + panic...] setle dl .LBB0_2: or dl, cl lea rdi, [rip + .L__unnamed_1] jne .LBB1_5 call qword ptr [rip + panic...] .LBB1_4: dec eax .LBB1_5: pop rcx ret .LBB1_6: lea rdi, [rip + .L__unnamed_2] call qword ptr [rip + panic...] .LBB1_7: lea rdi, [rip + .L__unnamed_2] call qword ptr [rip + panic...] ``` And on Aarch64: ```asm _div_floor_new: _div_floor_old: stp x29, x30, [sp, #-16]! stp x29, x30, [sp, #-16]! mov x29, sp mov x29, sp cbz w1, LBB0_4 cbz w1, LBB1_9 mov w8, #-2147483648 mov x8, x0 cmp w0, w8 mov w9, #-2147483648 b.ne LBB0_3 cmp w0, w9 cmn w1, #1 b.ne LBB1_3 b.eq LBB0_5 cmn w1, #1 LBB0_3: b.eq LBB1_10 sdiv w8, w0, w1 LBB1_3: msub w9, w8, w1, w0 sdiv w0, w8, w1 eor w10, w1, w0 msub w8, w0, w1, w8 asr w10, w10, #31 tbz w1, #31, LBB1_5 cmp w9, #0 cmp w8, #0 csel w9, wzr, w10, eq b.gt LBB1_7 add w0, w9, w8 LBB1_5: ldp x29, x30, [sp], #16 cmp w1, #1 ret b.lt LBB1_8 LBB0_4: tbz w8, #31, LBB1_8 adrp x0, l___unnamed_1@PAGE LBB1_7: add x0, x0, l___unnamed_1@PAGEOFF sub w0, w0, #1 bl panic... LBB1_8: LBB0_5: ldp x29, x30, [sp], #16 adrp x0, l___unnamed_1@PAGE ret add x0, x0, l___unnamed_1@PAGEOFF LBB1_9: bl panic... adrp x0, l___unnamed_2@PAGE add x0, x0, l___unnamed_2@PAGEOFF bl panic... LBB1_10: adrp x0, l___unnamed_2@PAGE add x0, x0, l___unnamed_2@PAGEOFF bl panic... ```
2024-09-08Auto merge of #129019 - kromych:master, r=workingjubileebors-1/+247
Break into the debugger (if attached) on panics (Windows, Linux, macOS, FreeBSD) The developer experience for panics is to provide the backtrace and exit the program. When running under debugger, that might be improved by breaking into the debugger once the code panics thus enabling the developer to examine the program state at the exact time when the code panicked. Let the developer catch the panic in the debugger if it is attached. If the debugger is not attached, nothing changes. Providing this feature inside the standard library facilitates better debugging experience. Validated under Windows, Linux, macOS 14.6, and FreeBSD 13.3..14.1.
2024-09-08Fix linking error when compiling for 32-bit watchOSMads Marquart-14/+18
In https://github.com/rust-lang/rust/pull/124748, I mistakenly conflated "not SjLj" to mean "ARM EHABI", which isn't true, watchOS armv7k (specifically only that architecture) uses a third unwinding method called "DWARF CFI".
2024-09-08remove pointless rustc_const_unstable on trait implsRalf Jung-2/+0
2024-09-08add some FIXME(const-hack)Ralf Jung-2/+2
2024-09-07Auto merge of #130091 - matthiaskrgr:rollup-kalu1cs, r=matthiaskrgrbors-35/+39
Rollup of 10 pull requests Successful merges: - #126452 (Implement raw lifetimes and labels (`'r#ident`)) - #129555 (stabilize const_float_bits_conv) - #129594 (explain the options bootstrap passes to curl) - #129677 (Don't build by-move body when async closure is tainted) - #129847 (Do not call query to compute coroutine layout for synthetic body of async closure) - #129869 (add a few more crashtests) - #130009 (rustdoc-search: allow trailing `Foo ->` arg search) - #130046 (str: make as_mut_ptr and as_bytes_mut unstably const) - #130047 (Win: Add dbghelp to the list of import libraries) - #130059 (Remove the unused `llvm-skip-rebuild` option from x.py) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-07Rollup merge of #130047 - ChrisDenton:win-dbghelp, r=wesleywiserMatthias Krüger-0/+1
Win: Add dbghelp to the list of import libraries This is used by the backtrace crate. But we use a submodule to include backtrace in std (rather than being a real crate) so we need to add the dependency here.
2024-09-07Rollup merge of #130046 - RalfJung:const_str_as_mut, r=dtolnayMatthias Krüger-2/+4
str: make as_mut_ptr and as_bytes_mut unstably const `@rust-lang/libs-api` the corresponding non-mutable methods are already const fn, so this seems pretty trivial. I hope this is small enough that it does not need an ACP? :) I would like to get these stabilized ASAP because I want to avoid people doing `s.as_ptr().cast_mut()`, which is UB if they ever write to it, but is already const-stable. TODO: create a tracking issue.
2024-09-07Rollup merge of #129555 - RalfJung:const_float_bits_conv, r=dtolnayMatthias Krüger-33/+34
stabilize const_float_bits_conv This stabilizes `const_float_bits_conv`, and thus fixes https://github.com/rust-lang/rust/issues/72447. With https://github.com/rust-lang/rust/pull/128596 having landed, this is entirely a libs-only question now. ```rust impl f32 { pub const fn to_bits(self) -> u32; pub const fn from_bits(v: u32) -> Self; pub const fn to_be_bytes(self) -> [u8; 4]; pub const fn to_le_bytes(self) -> [u8; 4] pub const fn to_ne_bytes(self) -> [u8; 4]; pub const fn from_be_bytes(bytes: [u8; 4]) -> Self; pub const fn from_le_bytes(bytes: [u8; 4]) -> Self; pub const fn from_ne_bytes(bytes: [u8; 4]) -> Self; } impl f64 { pub const fn to_bits(self) -> u64; pub const fn from_bits(v: u64) -> Self; pub const fn to_be_bytes(self) -> [u8; 8]; pub const fn to_le_bytes(self) -> [u8; 8] pub const fn to_ne_bytes(self) -> [u8; 8]; pub const fn from_be_bytes(bytes: [u8; 8]) -> Self; pub const fn from_le_bytes(bytes: [u8; 8]) -> Self; pub const fn from_ne_bytes(bytes: [u8; 8]) -> Self; } ```` Cc `@rust-lang/wg-const-eval` `@rust-lang/libs-api`
2024-09-07Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68bors-140/+77
Bump boostrap compiler to new beta Accidentally left some comments on the update cfgs commit directly xd
2024-09-07make Result::copied unstably constRalf Jung-2/+8
2024-09-07remove 'const' from 'Option::iter'Ralf Jung-2/+1
2024-09-07str: make as_mut_ptr and as_bytes_mut unstably constRalf Jung-2/+4
2024-09-07restate GlobalAlloc method safety preconditions in terms of what the caller ↵Adam Sandberg Ericsson-15/+17
has to do for greater clarity
2024-09-07Remove now redundant check in symlink_hard_link testMads Marquart-18/+0
We support macOS 10.12 and above, so it now always uses linkat, so the check is redundant. This was missed in #126351.
2024-09-07Add `NonNull` convenience methods to `Vec`Tim (Theemathas) Chirananthavat-16/+308
2024-09-07Add `NonNull` convenience methods to `Box`Tim (Theemathas) Chirananthavat-0/+223
2024-09-06fix doc comments for Peekable::next_if(_eq)glowcoil-2/+2
Fix references to a nonexistent `consume` function in the doc comments for `Peekable::next_if` and `Peekable::next_if_eq`.
2024-09-06Remove duplicate implMatthew Giordano-88/+6
2024-09-06remove the Clone requirementMatthew Giordano-173/+170
2024-09-06Win: Add dbghelp to the list of import librariesChris Denton-0/+1
2024-09-06properly handle EOF in BufReader::peekbinarycat-4/+12
previously this would cause an infinite loop due to it being unable to read `n` bytes.
2024-09-06[library/std/src/process.rs] Remove `Eq` `derive`Samuel Marks-1/+1
2024-09-06Adjust doc comment of Condvar::wait_whileUlrik Mikaelsson-2/+6
The existing phrasing implies that a notification must be received for `wait_while` to return. The phrasing is changed to better reflect the behavior.
2024-09-06Rollup merge of #129963 - rjooske:fix/inaccurate_to_string_lossy_doc, ↵Matthias Krüger-2/+2
r=workingjubilee Inaccurate `{Path,OsStr}::to_string_lossy()` documentation The documentation of `Path::to_string_lossy()` and `OsStr::to_string_lossy()` says the following: > Any non-Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER` which didn't immediately make sense to me. ("non-Unicode sequences"?) Since both `to_string_lossy` functions eventually become just a call to `String::from_utf8_lossy`, I believe the documentation meant to say: > Any *non-UTF-8* sequences are replaced with `U+FFFD REPLACEMENT CHARACTER` This PR corrects this mistake in the documentation. For the record, a similar quote can be found in the documentation of `String::from_utf8_lossy`: > ... During this conversion, `from_utf8_lossy()` will replace any invalid UTF-8 sequences with `U+FFFD REPLACEMENT CHARACTER`, ...
2024-09-06Auto merge of #129999 - matthiaskrgr:rollup-pzr9c8p, r=matthiaskrgrbors-14/+22
Rollup of 11 pull requests Successful merges: - #128919 (Add an internal lint that warns when accessing untracked data) - #129472 (fix ICE when `asm_const` and `const_refs_to_static` are combined) - #129653 (clarify that addr_of creates read-only pointers) - #129775 (bootstrap: Try to track down why `initial_libdir` sometimes fails) - #129939 (explain why Rvalue::Len still exists) - #129942 (copy rustc rustlib artifacts from ci-rustc) - #129943 (use the bootstrapped compiler for `test-float-parse` test) - #129944 (Add compat note for trait solver change) - #129947 (Add digit separators in `Duration` examples) - #129955 (Temporarily remove fmease from the review rotation) - #129957 (forward linker option to lint-docs) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-05Break into the debugger (if attached) on panics (Windows, macOS, Linux, FreeBSD)kromych-1/+247
The developer experience for panics is to provide the backtrace and exit the program. When running under debugger, that might be improved by breaking into the debugger once the code panics thus enabling the developer to examine the program state at the exact time when the code panicked. Let the developer catch the panic in the debugger if it is attached. If the debugger is not attached, nothing changes. Providing this feature inside the standard library facilitates better debugging experience. Validated under Windows, Linux, macOS 14.6, and FreeBSD 13.3..14.1.
2024-09-05better implementation of signed div_floor/ceilOrson Peters-4/+16
2024-09-05Rollup merge of #129947 - LiterallyVoid:duration-docs-digit-separators, ↵Matthias Krüger-14/+14
r=tgross35 Add digit separators in `Duration` examples ``@rustbot`` label A-docs
2024-09-05Rollup merge of #129653 - RalfJung:addr-of-read-only, r=scottmcmMatthias Krüger-0/+8
clarify that addr_of creates read-only pointers Stacked Borrows does make this UB, but Tree Borrows does not. This is tied up with https://github.com/rust-lang/rust/issues/56604 and other UCG discussions. Also see [this collection of links](https://github.com/Rust-for-Linux/linux/pull/950#discussion_r1104759431) where rustc treats `addr_of!` as a "non-mutating use". So, let's better be careful for now.