about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2024-12-31Rollup merge of #134953 - DiuDiu777:unaligned-doc, r=RalfJungMatthias Krüger-4/+0
Fix doc for read&write unaligned in zst operation ### PR Description This PR addresses an inconsistency in the Rust documentation regarding `read_unaligned ` and `write_unaligned` on zero-sized types (ZSTs). The current documentation for [pointer validity](https://doc.rust-lang.org/nightly/std/ptr/index.html#safety) states that for zero-sized types (ZSTs), null pointers are valid: > For zero-sized types (ZSTs), every pointer is valid, including the null pointer. However, there is an inconsistency in the documentation for the unaligned read operation in the function [ptr::read_unaligned](https://doc.rust-lang.org/nightly/std/ptr/fn.read_unaligned.html)(as well as `write_unaligned`), which states: > Note that even if T has size 0, the pointer must be non-null. This change is also supported by [PR #134912](https://github.com/rust-lang/rust/pull/134912) > the _unaligned method docs should be fixed.
2024-12-31Auto merge of #134620 - ChrisDenton:line-writer, r=tgross35bors-6/+21
Avoid short writes in LineWriter If the bytes written to `LineWriter` contains at least one new line but doesn't end in a new line (e.g. `"abc\ndef"`) then we: - write up to the last new line direct to the underlying `Writer`. - copy as many of the remaining bytes as will fit into our internal buffer. That last step is inefficient if the remaining bytes are larger than our buffer. It will needlessly split the bytes in two, requiring at least two writes to the underlying `Writer` (one to flush the buffer, one more to write the rest). This PR skips the extra buffering if the remaining bytes are larger than the buffer.
2024-12-31Rollup merge of #134930 - RalfJung:ptr-docs-valid-access, r=jhprattStuart Cook-2/+2
ptr docs: make it clear that we are talking only about memory accesses This should make it harder to take this sentence out of context and misunderstand it.
2024-12-31Rollup merge of #134927 - DaniPopes:const-as_flattened_mut, r=scottmcmStuart Cook-1/+2
Make slice::as_flattened_mut unstably const Tracking issue: https://github.com/rust-lang/rust/issues/95629 Unblocked by const_mut_refs being stabilized: https://github.com/rust-lang/rust/pull/129195
2024-12-31fix doc for read write unaligned in zst operationLemonJ-4/+0
2024-12-30Auto merge of #134757 - RalfJung:const_swap, r=scottmcmbors-12/+25
stabilize const_swap libs-api FCP passed in https://github.com/rust-lang/rust/issues/83163. However, I only just realized that this actually involves an intrinsic. The intrinsic could be implemented entirely with existing stable const functionality, but we choose to make it a primitive to be able to detect more UB. So nominating for `@rust-lang/lang` to make sure they are aware; I leave it up to them whether they want to FCP this. While at it I also renamed the intrinsic to make the "nonoverlapping" constraint more clear. Fixes #83163
2024-12-30ptr docs: make it clear that we are talking only about memory accessesRalf Jung-2/+2
2024-12-30Make slice::as_flattened_mut unstably constDaniPopes-1/+2
Tracking issue: https://github.com/rust-lang/rust/issues/95629 Unblocked by const_mut_refs being stabilized: https://github.com/rust-lang/rust/pull/129195
2024-12-30Remove lossy casting in `logspace`Trevor Gross-3/+10
Currently `logspace` does a lossy cast from `F::Int` to `usize`. This could be problematic in the rare cases that this is called with a step count exceeding what is representable in `usize`. Resolve this by instead adding bounds so the float's integer type itself can be iterated.
2024-12-29Set the allowed FMA ULP to 0Trevor Gross-0/+2
It is currently getting the default of 1 or 2. Since this operation should always be infinite precision, no deviation is allowed.
2024-12-30Fix ptr::from_ref documentation example commentMads Marquart-2/+2
The comment says that the expression involves no function call, but that was only true for the example above, the example here _does_ contain a function call.
2024-12-29Rollup merge of #134884 - calciumbe:patch1, r=jieyouxuMatthias Krüger-2/+2
Fix typos Hello, I fix some typos in docs and comments. Thank you very much.
2024-12-29Rollup merge of #134870 - geofft:patch-1, r=jhprattMatthias Krüger-1/+1
Fix sentence fragment in `pin` module docs Looks like this was inadvertently dropped in 8241ca60. Restore the words from before that commit.
2024-12-29fix: typoscalciumbe-2/+2
Signed-off-by: calciumbe <192480234+calciumbe@users.noreply.github.com>
2024-12-29Rollup merge of #134851 - lukas-code:alloc-ffi, r=tgross35Stuart Cook-1/+1
docs: inline `alloc::ffi::c_str` types to `alloc::ffi` like https://github.com/rust-lang/rust/pull/134791 but for `alloc` r? ``@tgross35`` ``@notriddle``
2024-12-29Fix typo and prettify commentSatoshi Tanda-5/+3
2024-12-29Don't run `push` CI on anything other than `master`Trevor Gross-1/+5
2024-12-29Use `CheckCtx` in more placesTrevor Gross-13/+17
Rather than passing names or identifiers, just pass `CheckCtx` in a few more places.
2024-12-29Move `CheckBasis` and `CheckCtx` to a new `run_cfg` moduleTrevor Gross-39/+55
These are used more places than just test traits, so this new module should be a better home. `run_cfg` will also be expanded in the near future.
2024-12-29Add `ALL`, `from_str` and `math_op` to `Identifier`Trevor Gross-5/+47
Introduce new API to iterate the function list and associate items with their `MathOp`.
2024-12-29Add new trait implementations for `Identifier` and `BaseName`Trevor Gross-2/+14
These allow for more convenient printing, as well as storage in map types.
2024-12-29Include `shared.rs` in `libm_test::op`Trevor Gross-1/+9
These types from `libm-macros` provide a way to get information about an operation at runtime, rather than only being encoded in the type system. Include the file and reexport relevant types.
2024-12-29Move the macro's input function list to a new module `shared`Trevor Gross-263/+320
This will enable us to `include!` the file to access these types in `libm-test`, rather than somehow reproducing the types as part of the macro. Ideally `libm-test` would just `use` the types from `libm-macros` but proc macro crates cannot currently export anything else. This also adjusts naming to closer match the scheme described in `libm_test::op`.
2024-12-29Add a way to plot the output from generatorsTrevor Gross-0/+262
For visualization, add a simple script for generating scatter plots and a binary (via examples) to plot the inputs given various domains.
2024-12-29Update allowed precision to account for new testsTrevor Gross-11/+9
2024-12-29Add tests for edge casesTrevor Gross-3/+101
Introduce a generator that will tests various points of interest including zeros, infinities, and NaNs.
2024-12-29Add interfaces and tests based on function domainsTrevor Gross-5/+327
Create a type representing a function's domain and a test that does a logarithmic sweep of points within the domain.
2024-12-29Introduce a float extension trait and some numerical routinesTrevor Gross-1/+461
2024-12-29Add an 8-bit float type for testing purposesTrevor Gross-0/+491
Introduce `f8`, which is an 8-bit float compliant with IEEE-754. This type is useful for testing since it is easily possible to enumerate all values.
2024-12-29Remove an `is_nan` workaround that is no longer neededbeetrees-11/+1
2024-12-29Update and slightly refactor some of the `Float` traitTrevor Gross-24/+36
Add a constant for negative pi and provide a standalone const `from_bits`, which can be combined with what we already had in `hex_float`. Also provide another default method to reduce what needs to be provided by the macro.
2024-12-29Always enable `unstable-float` in CITrevor Gross-5/+9
Since these add new API but do not affect runtime, we can enable it for all tests that run with nightly.
2024-12-29Add `f16` and `f128` configuration from `compiler-builtins`Trevor Gross-83/+208
In preparation of adding routines from these two types, duplicate the `compiler-builtins` configuration here.
2024-12-29Introduce generic `abs` and `copysign`Trevor Gross-12/+26
Add generic versions of `abs` and `copysign`, which will provide an entrypoint for adding `f16` and `f128`. Since this implementation is identical to the existing type-specific implementations, make use of it for `f32` and `f64`.
2024-12-29Change from `-latest` to named CI imagesTrevor Gross-31/+31
GitHub will be upgrading the `-latest` tags of these images in the near future. Change all images to specify the latest version.
2024-12-28Fix sentence fragment in `pin` module docsGeoffrey Thomas-1/+1
Looks like this was inadvertently dropped in 8241ca60. Restore the words from before that commit.
2024-12-28docs: inline `alloc::ffi::c_str` types to `alloc::ffi`Lukas Markeffsky-1/+1
2024-12-28Auto merge of #134547 - SUPERCILEX:unify-copy, r=thomccbors-24/+70
Unify fs::copy and io::copy on Linux Currently, `fs::copy` first tries a regular file copy (via copy_file_range) and then falls back to userspace read/write copying. We should use `io::copy` instead as it tries copy_file_range, sendfile, and splice before falling back to userspace copying. This was discovered here: https://github.com/SUPERCILEX/fuc/issues/40 Perf impact: `fs::copy` will now have two additional statx calls to decide which syscall to use. I wonder if we should get rid of the statx calls and only continue down the next fallback when the relevant syscalls say the FD isn't supported.
2024-12-28Rollup merge of #134832 - tgross35:update-builtins, r=tgross35Stuart Cook-4/+4
Update `compiler-builtins` to 0.1.140 Nothing significant here, just syncing the following small changes: - https://github.com/rust-lang/compiler-builtins/pull/727 - https://github.com/rust-lang/compiler-builtins/pull/730 - https://github.com/rust-lang/compiler-builtins/pull/736 - https://github.com/rust-lang/compiler-builtins/pull/737
2024-12-27Tidy up bigint mul methodsltdk-123/+388
2024-12-27Rollup merge of #134823 - chloefeal:fix, r=tgross35,dtolnayDavid Tolnay-2/+2
Fix typos This PR focuses on correcting typos and improving clarity in documentation files. Thank you.
2024-12-28Update library/alloc/tests/sort/tests.rschloefeal-1/+1
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2024-12-27Update `compiler-builtins` to 0.1.140Trevor Gross-4/+4
Nothing significant here, just syncing the following small changes: - https://github.com/rust-lang/compiler-builtins/pull/727 - https://github.com/rust-lang/compiler-builtins/pull/730 - https://github.com/rust-lang/compiler-builtins/pull/736 - https://github.com/rust-lang/compiler-builtins/pull/737
2024-12-27Implement `int_from_ascii` (#134821)Niklas Fiekas-89/+131
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.
2024-12-27Rollup merge of #133663 - scottmcm:carrying_mul_add, r=AmanieuMatthias Krüger-135/+326
Add a compiler intrinsic to back `bigint_helper_methods` cc https://github.com/rust-lang/rust/issues/85532 This adds a new `carrying_mul_add` intrinsic, to implement `wide_mul` and `carrying_mul`. It has fallback MIR for all types -- including `u128`, which isn't currently supported on nightly -- so that it'll continue to work on all backends, including CTFE. Then it's overridden in `cg_llvm` to use wider intermediate types, including `i256` for `u128::carrying_mul`.
2024-12-27Override `carrying_mul_add` in cg_llvmScott McMurray-2/+12
2024-12-27Move `{widening, carrying}_mul` to an intrinsic with fallback MIRScott McMurray-135/+316
Including implementing it for `u128`, so it can be defined in `uint_impl!`. This way it works for all backends, including CTFE.
2024-12-27Fix typoschloefeal-2/+2
Signed-off-by: chloefeal <188809157+chloefeal@users.noreply.github.com>
2024-12-27Auto merge of #134822 - jieyouxu:rollup-5xuaq82, r=jieyouxubors-7/+30
Rollup of 8 pull requests Successful merges: - #134606 (ptr::copy: fix docs for the overlapping case) - #134622 (Windows: Use WriteFile to write to a UTF-8 console) - #134759 (compiletest: Remove the `-test` suffix from normalize directives) - #134787 (Spruce up the docs of several queries related to the type/trait system and const eval) - #134806 (rustdoc: use shorter paths as preferred canonical paths) - #134815 (Sort triples by name in platform_support.md) - #134816 (tools: fix build failure caused by PR #134420) - #134819 (Fix mistake in windows file open) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-27Rollup merge of #134819 - ChrisDenton:trunc, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-1/+1
Fix mistake in windows file open In #134722 this should have been `c::FileAllocationInfo` not `c::FileEndOfFileInfo`. Oops.