about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2025-01-31doc all differences of ptr:copy(_nonoverlapping) with memcpy and memmoveMarijn Schouten-3/+6
2025-01-31Auto merge of #134424 - 1c3t3a:null-checks, r=saethlinbors-0/+16
Insert null checks for pointer dereferences when debug assertions are enabled Similar to how the alignment is already checked, this adds a check for null pointer dereferences in debug mode. It is implemented similarly to the alignment check as a `MirPass`. This inserts checks in the same places as the `CheckAlignment` pass and additionally also inserts checks for `Borrows`, so code like ```rust let ptr: *const u32 = std::ptr::null(); let val: &u32 = unsafe { &*ptr }; ``` will have a check inserted on dereference. This is done because null references are UB. The alignment check doesn't cover these places, because in `&(*ptr).field`, the exact requirement is that the final reference must be aligned. This is something to consider further enhancements of the alignment check. For now this is implemented as a separate `MirPass`, to make it easy to disable this check if necessary. This is related to a 2025H1 project goal for better UB checks in debug mode: https://github.com/rust-lang/rust-project-goals/pull/177. r? `@saethlin`
2025-01-31Rename `EXP_MAX` to `EXP_SAT`Trevor Gross-12/+15
`EXP_MAX` sounds like it would be the maximum value representable by that float type's exponent, rather than the maximum unsigned value of its bits. Clarify this by renaming to `EXP_SAT`, the "saturated" exponent representation.
2025-01-31Add documentation for derive(CoercePointee)Alice Ryhl-1/+189
2025-01-31Insert null checks for pointer dereferences when debug assertions are enabledBastian Kersting-0/+16
Similar to how the alignment is already checked, this adds a check for null pointer dereferences in debug mode. It is implemented similarly to the alignment check as a MirPass. This is related to a 2025H1 project goal for better UB checks in debug mode: https://github.com/rust-lang/rust-project-goals/pull/177.
2025-01-31Update encode_utf16 to mention it is native endianMarijn Schouten-12/+13
2025-01-31Update fs.rsTommaso Allevi-0/+1
2025-01-31Auto merge of #136332 - jhpratt:rollup-aa69d0e, r=jhprattbors-0/+18
Rollup of 9 pull requests Successful merges: - #132156 (When encountering unexpected closure return type, point at return type/expression) - #133429 (Autodiff Upstreaming - rustc_codegen_ssa, rustc_middle) - #136281 (`rustc_hir_analysis` cleanups) - #136297 (Fix a typo in profile-guided-optimization.md) - #136300 (atomic: extend compare_and_swap migration docs) - #136310 (normalize `*.long-type.txt` paths for compare-mode tests) - #136312 (Disable `overflow_delimited_expr` in edition 2024) - #136313 (Filter out RPITITs when suggesting unconstrained assoc type on too many generics) - #136323 (Fix a typo in conventions.md) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-31Rollup merge of #136300 - RalfJung:compare-and-swap, r=joboetJacob Pratt-0/+18
atomic: extend compare_and_swap migration docs Fixes https://github.com/rust-lang/rust/issues/80486
2025-01-31Rollup merge of #136296 - RalfJung:float-min-max, r=tgross35Jacob Pratt-8/+16
float::min/max: mention the non-determinism around signed 0 Turns out this can actually produce different results on different machines [in practice](https://github.com/rust-lang/rust/issues/83984#issuecomment-2623859230); that seems worth documenting. I assume LLVM will happily const-fold these operations so so there could be different results for the same input even on the same machine, depending on whether things get const-folded or not. `@nikic` I remember there was an LLVM soundness fix regarding scalar evolution for loops that had to recognize certain operations as non-deterministic... it seems to me that pass would also have to avoid predicting the result of `llvm.{min,max}num`, for the same reason? r? `@tgross35` Cc `@rust-lang/libs-api` If this lands we should also make Miri non-deterministic here. Fixes https://github.com/rust-lang/rust/issues/83984
2025-01-31Rollup merge of #135414 - tgross35:stabilize-const_black_box, r=dtolnayJacob Pratt-2/+4
Stabilize `const_black_box` This has been unstably const since #92226, but a tracking issue was never created. Per [discussion on Zulip][zulip], there should not be any blockers to making this const-stable. The function does not provide any functionality at compile time but does allow code reuse between const- and non-const functions, so stabilize it here. [zulip]: https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/const_black_box
2025-01-31implement all min/max fns in terms of `<`/`is_lt`Waffle Lapkin-15/+9
`<` seems to be the "lucky one" for llvm
2025-01-30implement unstable `new_range` featurePeter Jaszkowiak-0/+3
for RFC 3550, tracking issue #123741
2025-01-31improve doc tests for (min/max/minmax).* functionsWaffle Lapkin-18/+128
- add tests for `a == b` where missing - try to make all the tests more similar - try to use more illustrative test values
2025-01-30std::rangePeter Jaszkowiak-0/+2
2025-01-30Specify license as just MITManish Goregaokar-1/+1
Simplify the SPDX string to the user-facing version to make it easier for users and tooling to understand. Contributions must still be `MIT OR Apache-2.0`. [ add commit body with context - Trevor ]
2025-01-30Rollup merge of #136288 - ↵Matthias Krüger-17/+40
joshtriplett:would-you-could-you-with-some-locks--would-you-could-you-in-some-docs, r=m-ou-se Improve documentation for file locking Add notes to each method stating that locks get dropped on close. Clarify the return values of the try methods: they're only defined if the lock is held via a *different* file handle/descriptor. That goes along with the documentation that calling them while holding a lock via the *same* file handle/descriptor may deadlock. Document the behavior of unlock if no lock is held. r? `@m-ou-se` (Documentation changes requested in https://github.com/rust-lang/rust/issues/130994 .)
2025-01-30Rollup merge of #136271 - Sky9x:debug-maybeuninit-footgun, r=tgross35Matthias Krüger-3/+2
Remove minor future footgun in `impl Debug for MaybeUninit` No longer breaks if `MaybeUninit` moves modules (technically it could break if `MaybeUninit` were renamed but realistically that will never happen) Debug impl originally added in #133282
2025-01-30Rollup merge of #135852 - lukas-code:asyncfn-prelude-core, r=compiler-errorsMatthias Krüger-0/+3
Add `AsyncFn*` to `core` prelude In https://github.com/rust-lang/rust/pull/132611 these got added to the `std` prelude only, which looks like an oversight. r? libs-api cc `@compiler-errors`
2025-01-30Rollup merge of #135475 - Ayush1325:uefi-absolute-path, r=jhprattMatthias Krüger-5/+158
uefi: Implement path This PR is split off from https://github.com/rust-lang/rust/pull/135368 to reduce noise. UEFI paths can be of 4 types: 1. Absolute Shell Path: Uses shell mappings 2. Absolute Device Path: this is what we want 3. Relative root: path relative to the current root. 4. Relative Absolute shell path can be identified with `:` and Absolute Device path can be identified with `/`. Relative root path will start with `\`. The algorithm is mostly taken from edk2 UEFI shell implementation and is somewhat simple. Check for the path type in order. For Absolute Shell path, use `EFI_SHELL->GetDevicePathFromMap` to get a BorrowedDevicePath for the volume. For Relative paths, we use the current working directory to construct the new path. BorrowedDevicePath abstraction is needed to interact with `EFI_SHELL->GetDevicePathFromMap` which returns a Device Path Protocol with the lifetime of UEFI shell. Absolute Shell paths cannot exist if UEFI shell is missing. cc `@nicholasbishop`
2025-01-30black_box integer-input on fmt benchesPascal S. de Kloe-7/+6
2025-01-30Auto merge of #134824 - niklasf:int_from_ascii, r=ibraheemdevbors-89/+131
Implement `int_from_ascii` (#134821) Provides unstable `T::from_ascii()` and `T::from_ascii_radix()` for integer types `T`, as drafted in tracking issue #134821. To deduplicate documentation without additional macros, implementations of `isize` and `usize` no longer delegate to equivalent integer types. After #132870 they are inlined anyway.
2025-01-30Improve instant docsMarijn Schouten-2/+8
2025-01-30atomic: extend compare_and_swap migration docsRalf Jung-0/+18
2025-01-30float::min/max: mention the non-determinism around signed 0Ralf Jung-8/+16
2025-01-30Improve documentation for file lockingJosh Triplett-17/+40
Add notes to each method stating that locks get dropped on close. Clarify the return values of the try methods: they're only defined if the lock is held via a *different* file handle/descriptor. That goes along with the documentation that calling them while holding a lock via the *same* file handle/descriptor may deadlock. Document the behavior of unlock if no lock is held.
2025-01-30Rollup merge of #136259 - hkBst:patch-30, r=thomccStuart Cook-31/+27
Cleanup docs for Allocator This is an attempt to remove ungrammatical constructions and clean up the prose. I've sometimes had to try hard to understand what was being stated, so it is possible that I've misunderstood the original meaning. In particular, I did not see a difference between: - the borrow-checker lifetime of the allocator type itself. - as long as at least one of the allocator instance and all of its clones has not been dropped.
2025-01-30Rollup merge of #136215 - btj:patch-1, r=cuviperStuart Cook-2/+2
btree/node.rs: remove incorrect comment from pop_internal_level docs
2025-01-30Rollup merge of #135847 - edwloef:slice_ptr_rotate_opt, r=scottmcmStuart Cook-152/+182
optimize slice::ptr_rotate for small rotates r? `@scottmcm` This swaps the positions and numberings of algorithms 1 and 2 in `slice::ptr_rotate`, and pulls the entire outer loop into algorithm 3 since it was redundant for the first two. Effectively, `ptr_rotate` now always does the `memcpy`+`memmove`+`memcpy` sequence if the shifts fit into the stack buffer. With this change, an `IndexMap`-style `move_index` function is optimized correctly. Assembly comparisons: - `move_index`, before: https://godbolt.org/z/Kr616KnYM - `move_index`, after: https://godbolt.org/z/1aoov6j8h - the code from `#89714`, before: https://godbolt.org/z/Y4zaPxEG6 - the code from `#89714`, after: https://godbolt.org/z/1dPx83axc related to #89714 some relevant discussion in https://internals.rust-lang.org/t/idea-shift-move-to-efficiently-move-elements-in-a-vec/22184 Behavior tests pass locally. I can't get any consistent microbenchmark results on my machine, but the assembly diffs look promising.
2025-01-29Remove minor future footgun in `impl Debug for MaybeUninit`Sky-3/+2
No longer breaks if `MaybeUninit` moves modules (technically it could break if `MaybeUninit` were renamed but realistically that will never happen)
2025-01-29Cleanup docs for AllocatorMarijn Schouten-31/+27
2025-01-29add inline attribute and codegen testedwloef-0/+4
2025-01-29split slice::ptr_rotate into three separate algorithms, to hopefully help ↵edwloef-174/+195
inlining
2025-01-29Fix usage of proc_macro2::Punct.Jacob Bramley-3254/+52
Restructure stdarch-gen-arm to use `Group`s with `Delimiter`s rather than ad-hoc `Punct`s. `Punct` should only be used to represent specific characters, and never for bracket-like characters. Recent versions of `Punct::new` check this with an assertion. Note that there doesn't appear to be a way to emit a line break for formatting reasons — `Punct::new('\n', ...)` no longer works — so this also removes all blank lines between functions in the generated files.
2025-01-29Auto merge of #136248 - matthiaskrgr:rollup-leaxgfd, r=matthiaskrgrbors-1/+1
Rollup of 8 pull requests Successful merges: - #133382 (Suggest considering casting fn item as fn pointer in more cases) - #136092 (Test pipes also when not running on Windows and Linux simultaneously) - #136190 (Remove duplicated code in RISC-V asm bad-reg test) - #136192 (ci: remove unused windows runner) - #136205 (Properly check that array length is valid type during built-in unsizing in index) - #136211 (Update mdbook to 0.4.44) - #136212 (Tweak `&mut self` suggestion span) - #136214 (Make crate AST mutation accessible for driver callback) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-29Rollup merge of #136092 - tbu-:pr_io_pipe_test, r=joboetMatthias Krüger-1/+1
Test pipes also when not running on Windows and Linux simultaneously Fixes https://github.com/rust-lang/rust/pull/135635#pullrequestreview-2574184488. Based on top of #135635 to avoid merge conflicts.
2025-01-29Auto merge of #136227 - fmease:rollup-ewpvznh, r=fmeasebors-4/+3
Rollup of 9 pull requests Successful merges: - #136121 (Deduplicate operand creation between scalars, non-scalars and string patterns) - #136134 (Fix SIMD codegen tests on LLVM 20) - #136153 (Locate asan-odr-win with other sanitizer tests) - #136161 (rustdoc: add nobuild typescript checking to our JS) - #136166 (interpret: is_alloc_live: check global allocs last) - #136168 (GCI: Don't try to eval / collect mono items inside overly generic free const items) - #136170 (Reject unsound toggling of Arm atomics-32 target feature) - #136176 (Render pattern types nicely in mir dumps) - #136186 (uefi: process: Fix args) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-28Fix off-by-one error causing driftsort to crashuellenberg-8/+22
Fixes #136103. Based on the analysis by @jonathan-gruber-jg and @orlp.
2025-01-29btree/node.rs: pop_internal_level: does not invalidate other handlesBart Jacobs-0/+3
2025-01-29Simplify Rc::as_ptr docs + typo fixMarijn Schouten-3/+3
2025-01-29Rollup merge of #136186 - Ayush1325:uefi-process-args-fix, ↵León Orell Valerian Liehr-4/+3
r=nicholasbishop,Noratrieb uefi: process: Fix args - While working on process env support, I found that args were currently broken. Not sure how I missed it in the PR, but well here is the fix. - Additionally, no point in adding space at the end of args.
2025-01-29Rollup merge of #135625 - c410-f3r:cfg-match-foo-bar-baz, r=tgross35,jhprattLeón Orell Valerian Liehr-0/+11
[cfg_match] Document the use of expressions. cc #115585 Adds documentation to this new feature introduced in #133720.
2025-01-29Util: also print the hex float format for outputsTrevor Gross-2/+9
2025-01-29Introduce a wrapper type for IEEE hex float formattingTrevor Gross-4/+181
2025-01-29Support parsing NaN and infinities from the `hf*` functionsTrevor Gross-12/+61
This isn't very useful for constants since the trait constants are available, but does enable roundtripping via hex float syntax.
2025-01-28Allow Rust to use a number of libc filesystem callsErick Tryzelaar-1/+17
This allows Rust on Fuchsia to use a number of function calls from libc: * dirfd * fdatasync * flock with LOCK_EX, LOCK_SH, LOCK_NB, LOCK_UN * fstatat
2025-01-28btree/node.rs: remove incorrect comment from pop_internal_level docsBart Jacobs-3/+0
2025-01-28Revert "Temporarily pin `indicatif` to 0.17.9"Trevor Gross-2/+1
This reverts commit 1dacdabdb6186f97144c50f8952575576deb3730.
2025-01-28Auto merge of #136203 - matthiaskrgr:rollup-1k0f44l, r=matthiaskrgrbors-8/+12
Rollup of 9 pull requests Successful merges: - #135869 (Make docs for AtomicUsize::from_mut platform-independent) - #135892 (-Znext-solver: "normalize" signature before checking it mentions self in `deduce_closure_signature`) - #136055 (Implement MIR const trait stability checks) - #136066 (Pass spans to `perform_locally_in_new_solver`) - #136071 ([Clippy] Add vec_reserve & vecdeque_reserve diagnostic items) - #136124 (Arbitrary self types v2: explain test.) - #136149 (Flip the `rustc-rayon`/`indexmap` dependency order) - #136173 (Update comments and sort target_arch in c_char_definition) - #136178 (Update username in build helper example) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-28Don't build out of line atomics support code for uefiNikita Popov-2/+3
https://github.com/llvm/llvm-project/pull/116706 added Windows support to cpu_model. Compiling for UEFI also goes through that code path, because we treat it as a windows target. However, including windows.h is not actually going to work (and the used API would not be available in an UEFI environment). Disable building of cpu_model on UEFI to fix this.