| Age | Commit message (Collapse) | Author | Lines |
|
core: use `compare_bytes` for more slice element types
`bool`, `NonZero<u8>`, `Option<NonZero<u8>>` and `ascii::Char` can be compared the same way as `u8`.
|
|
Rollup of 11 pull requests
Successful merges:
- #128523 (Add release notes for 1.81.0)
- #129605 (Add missing `needs-llvm-components` directives for run-make tests that need target-specific codegen)
- #129650 (Clean up `library/profiler_builtins/build.rs`)
- #129651 (skip stage 0 target check if `BOOTSTRAP_SKIP_TARGET_SANITY` is set)
- #129684 (Enable Miri to pass pointers through FFI)
- #129762 (Update the `wasm-component-ld` binary dependency)
- #129782 (couple more crash tests)
- #129816 (tidy: say which feature gate has a stability issue mismatch)
- #129818 (make the const-unstable-in-stable error more clear)
- #129824 (Fix code examples buttons not appearing on click on mobile)
- #129826 (library: Fix typo in `core::mem`)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
|
|
This typo looks unnecessary
|
|
f32 docs: define 'arithmetic' operations
r? ````@workingjubilee````
Fixes https://github.com/rust-lang/rust/issues/129699
|
|
|
|
Two improvements to the documentation:
- Document `-` as a valid character for signed integer destinations
- Make the documentation even more clear that extra whitespace and non-digit characters is invalid. Many other
languages, e.g. c++, are very permissive in string to integer routines and simply try to consume as much as they can,
ignoring the rest. This is trying to make the transition for developers who are used to the conversion semantics in
these languages a bit easier.
|
|
|
|
|
|
|
|
Improved `checked_isqrt` and `isqrt` methods
### Improved tests of `isqrt` and `checked_isqrt` implementations
* Inputs chosen more thoroughly and systematically.
* Checks that `isqrt` and `checked_isqrt` have equivalent results for signed types, either equivalent numerically or equivalent as a panic and a `None`.
* Checks that `isqrt` has numerically-equivalent results for unsigned types and their `NonZero` counterparts.
### Added benchmarks for `isqrt` implementations
### Greatly sped up `checked_isqrt` and `isqrt` methods
* Uses a lookup table for 8-bit integers and then the Karatsuba square root algorithm for larger integers.
* Includes optimization hints that give the compiler the exact numeric range of results.
### Feature tracking issue
`isqrt` is an unstable feature tracked at #116226.
<details><summary>Benchmarked improvements</summary>
### Command used to benchmark
./x bench library/core -- int_sqrt
### Before
benchmarks:
num::int_sqrt::i128::isqrt 439591.65/iter +/- 6652.70
num::int_sqrt::i16::isqrt 5302.97/iter +/- 160.93
num::int_sqrt::i32::isqrt 62999.11/iter +/- 2022.05
num::int_sqrt::i64::isqrt 125248.81/iter +/- 1674.43
num::int_sqrt::i8::isqrt 123.56/iter +/- 1.87
num::int_sqrt::isize::isqrt 125356.56/iter +/- 1017.03
num::int_sqrt::non_zero_u128::isqrt 437443.75/iter +/- 3535.43
num::int_sqrt::non_zero_u16::isqrt 8604.58/iter +/- 94.76
num::int_sqrt::non_zero_u32::isqrt 62933.33/iter +/- 517.30
num::int_sqrt::non_zero_u64::isqrt 125076.38/iter +/- 11340.61
num::int_sqrt::non_zero_u8::isqrt 221.51/iter +/- 1.58
num::int_sqrt::non_zero_usize::isqrt 136005.21/iter +/- 2020.35
num::int_sqrt::u128::isqrt 439014.55/iter +/- 3920.45
num::int_sqrt::u16::isqrt 8575.08/iter +/- 148.06
num::int_sqrt::u32::isqrt 63008.89/iter +/- 803.67
num::int_sqrt::u64::isqrt 125088.09/iter +/- 879.29
num::int_sqrt::u8::isqrt 230.18/iter +/- 2.04
num::int_sqrt::usize::isqrt 125237.51/iter +/- 4747.83
### After
benchmarks:
num::int_sqrt::i128::isqrt 105184.89/iter +/- 1171.38
num::int_sqrt::i16::isqrt 1910.26/iter +/- 78.50
num::int_sqrt::i32::isqrt 34260.34/iter +/- 960.84
num::int_sqrt::i64::isqrt 45939.19/iter +/- 2525.65
num::int_sqrt::i8::isqrt 22.87/iter +/- 0.45
num::int_sqrt::isize::isqrt 45884.17/iter +/- 595.49
num::int_sqrt::non_zero_u128::isqrt 106344.27/iter +/- 780.99
num::int_sqrt::non_zero_u16::isqrt 2790.19/iter +/- 53.43
num::int_sqrt::non_zero_u32::isqrt 33613.99/iter +/- 362.96
num::int_sqrt::non_zero_u64::isqrt 46235.42/iter +/- 429.69
num::int_sqrt::non_zero_u8::isqrt 31.78/iter +/- 0.75
num::int_sqrt::non_zero_usize::isqrt 46208.75/iter +/- 375.27
num::int_sqrt::u128::isqrt 106385.94/iter +/- 1649.95
num::int_sqrt::u16::isqrt 2747.69/iter +/- 28.72
num::int_sqrt::u32::isqrt 33627.09/iter +/- 475.68
num::int_sqrt::u64::isqrt 46182.29/iter +/- 311.16
num::int_sqrt::u8::isqrt 33.10/iter +/- 0.30
num::int_sqrt::usize::isqrt 46165.00/iter +/- 388.41
</details>
Tracking Issue for {u8,i8,...}::isqrt #116226
try-job: test-various
|
|
Avoids the code duplication issue and results in
smaller binary size, which after all is the
purpose of the feature.
|
|
|
|
* Use a lookup table for 8-bit integers and the Karatsuba square root
algorithm for larger integers.
* Include optimization hints that give the compiler the exact numeric
range of results.
|
|
Allows disabling `fmt::Debug` derive and debug formatting.
|
|
Rollup of 11 pull requests
Successful merges:
- #129421 (add repr to the allowlist for naked functions)
- #129480 (docs: correct panic conditions for rem_euclid and similar functions)
- #129551 (ub_checks intrinsics: fall back to cfg(ub_checks))
- #129608 (const-eval: do not make UbChecks behavior depend on current crate's flags)
- #129613 (interpret: do not make const-eval query result depend on tcx.sess)
- #129641 (rustdoc: fix missing resource suffix on `crates.js`)
- #129657 (Rename `BikeshedIntrinsicFrom` to `TransmuteFrom`)
- #129666 (interpret: add missing alignment check in raw_eq)
- #129667 (Rustc driver cleanup)
- #129668 (Fix Pin::set bounds regression)
- #129686 (coverage: Rename `CodeRegion` to `SourceRegion`)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Fix Pin::set bounds regression
Fixes #129601
Fixes the regression from #129449, where changing the bounds of the impl block containing `Pin::set` changed the method resolution behavior.
```rust
struct A;
impl A {
fn set(&self) {}
}
let a: Pin<&A>;
a.set();
// before:
// - checks <impl<Ptr: DerefMut> Pin<Ptr>>::set(): `&A` doesn't impl `DerefMut`
// - autorefs -> &A: resolves to A::set()
// now:
// - checks <impl<Ptr: Deref> Pin<Ptr>>::set(): `&A` impls `Deref`! resolves to Pin::set()
// - check method bounds: `&A` doesn't impl DerefMut: error
```
r? `@dtolnay`
|
|
Rename `BikeshedIntrinsicFrom` to `TransmuteFrom`
As our implementation of MCP411 nears completion and we begin to solicit testing, it's no longer reasonable to expect testers to type or remember `BikeshedIntrinsicFrom`. The name degrades the ease-of-reading of documentation, and the overall experience of using compiler safe transmute.
Tentatively, we'll instead adopt `TransmuteFrom`.
This name seems to be the one most likely to be stabilized, after discussion on Zulip [1]. We may want to revisit the ordering of `Src` and `Dst` before stabilization, at which point we'd likely consider `TransmuteInto` or `Transmute`.
[1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20should.20.60BikeshedIntrinsicFrom.60.20be.20named.3F
Tracking Issue: https://github.com/rust-lang/rust/issues/99571
r? `@compiler-errors`
|
|
ub_checks intrinsics: fall back to cfg(ub_checks)
Not sure why the fallback body uses `debug_assertions`, probably a leftover from when `cfg!(ub_checks)` did not exist yet?
r? `@saethlin`
|
|
docs: correct panic conditions for rem_euclid and similar functions
fixes https://github.com/rust-lang/rust/issues/128857
also fixes the documentation for functions behind the `int_roundings` feature (#88581)
|
|
Tweak some attributes to improve panic_immediate_abort
This is similar to https://github.com/rust-lang/rust/pull/117332; I did the same approach as before where I build a really big project with `-Zbuild-std -Zbuild-std-features=panic_immediate_abort` and grep its symbols for things that look panic-related.
|
|
|
|
|
|
fix Pointer to reference conversion docs
The aliasing rules documented in https://github.com/rust-lang/rust/pull/128157 are wrong, this fixes them.
|
|
Fix typos in floating-point primitive type docs
Fixes a few typos. Also reflows the text of a couple of paragraphs in the source code to the standard line width to make the source easier to read (will have no effect on the rendered documentation).
|
|
As our implementation of MCP411 nears completion and we begin to
solicit testing, it's no longer reasonable to expect testers to
type or remember `BikeshedIntrinsicFrom`. The name degrades the
ease-of-reading of documentation, and the overall experience of
using compiler safe transmute.
Tentatively, we'll instead adopt `TransmuteFrom`.
This name seems to be the one most likely to be stabilized, after
discussion on Zulip [1]. We may want to revisit the ordering of
`Src` and `Dst` before stabilization, at which point we'd likely
consider `TransmuteInto` or `Transmute`.
[1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20should.20.60BikeshedIntrinsicFrom.60.20be.20named.3F
|
|
|
|
|
|
|
|
float types: document NaN bit pattern guarantees
Part of https://github.com/rust-lang/rust/issues/128288: document the guarantees we make for NaN bit patterns.
Cc ``@tgross35``
|
|
simd_shuffle intrinsic: allow argument to be passed as vector
See https://github.com/rust-lang/rust/issues/128738 for context.
I'd like to get rid of [this hack](https://github.com/rust-lang/rust/blob/6c0b89dfac65be9a5be12f938f23098ebc36c635/compiler/rustc_codegen_ssa/src/mir/block.rs#L922-L935). https://github.com/rust-lang/rust/pull/128537 almost lets us do that since constant SIMD vectors will then be passed as immediate arguments. However, simd_shuffle for some reason actually takes an *array* as argument, not a vector, so the hack is still required to ensure that the array becomes an immediate (which then later stages of codegen convert into a vector, as that's what LLVM needs).
This PR prepares simd_shuffle to also support a vector as the `idx` argument. Once this lands, stdarch can hopefully be updated to pass `idx` as a vector, and then support for arrays can be removed, which finally lets us get rid of that hack.
|
|
|
|
|
|
Document & implement the transmutation modeled by `BikeshedIntrinsicFrom`
Documents that `BikeshedIntrinsicFrom` models transmute-via-union, which is slightly more expressive than the transmute-via-cast implemented by `transmute_copy`. Additionally, we provide an implementation of transmute-via-union as a method on the `BikeshedIntrinsicFrom` trait with additional documentation on the boundary between trait invariants and caller obligations.
Whether or not transmute-via-union is the right kind of transmute to model remains up for discussion [1]. Regardless, it seems wise to document the present behavior.
[1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20'kind'.20of.20transmute.20to.20model.3F/near/426331967
Tracking Issue: https://github.com/rust-lang/rust/issues/99571
r? `@compiler-errors`
cc `@scottmcm,` `@Lokathor`
|
|
deduplicate and clarify rules for converting pointers to references
part of #124669
|
|
|
|
Remove cfg(test) from library/core
The diff here is very small with the ignore whitespace option.
`core` doesn't/can't have unit tests. All of its tests are just modules under `tests/`, so it has no use for `cfg(test)`, because the entire contents of `library/core/src` are only ever compiled with that cfg off, and the entire contents of `library/core/tests` are only ever compiled with that cfg on.
You can tell this is what's happening because we had `#[cfg(test)]` on a module declaration that has no source file.
I also deleted the extra `mod tests {` layer of nesting; there's no need to mention again in the module path that this is a module of tests. This exposes a name collision between the `u128` module of tests and `core::u128`. Fixed that by using `<u128>::MAX` like is done in the `check!` macro, which is what avoids this name ambiguity for the other types.
|
|
link to Future::poll from the Poll docs
The most important thing about Poll is that Future::poll returns it, but previously the docs didn't emphasize this.
|
|
Add implementations for `unbounded_shl`/`unbounded_shr`
Tracking Issue: https://github.com/rust-lang/rust/issues/129375
This implements `unbounded_shl` and `unbounded_shr` under the feature gate `unbounded_shifts`
|
|
|
|
|
|
|
|
quicksort module
|
|
Rollup of 9 pull requests
Successful merges:
- #129288 (Use subtyping for `UnsafeFnPointer` coercion, too)
- #129405 (Fixing span manipulation and indentation of the suggestion introduced by #126187)
- #129518 (gitignore: ignore ICE reports regardless of directory)
- #129519 (Remove redundant flags from `lower_ty_common` that can be inferred from the HIR)
- #129525 (rustdoc: clean up tuple <-> primitive conversion docs)
- #129526 (Use `FxHasher` on new solver unconditionally)
- #129544 (Removes dead code from the compiler)
- #129553 (add back test for stable-const-can-only-call-stable-const)
- #129590 (Avoid taking reference of &TyKind)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
|
|
r=GuillaumeGomez
rustdoc: clean up tuple <-> primitive conversion docs
This adds a minor missing feature to `fake_variadic`, so that it can render `impl From<(T,)> for [T; 1]` correctly.
|
|
Enable Alignment::new_unchecked precondition check
Similar to what happened with https://github.com/rust-lang/rust/pull/126556, I think this has become palatable since https://github.com/rust-lang/rust/pull/126793.
|
|
|
|
select_nth_unstable
- Stable sort uses a simple merge-sort that re-uses the existing - rather gnarly - merge function.
- Unstable sort jumps directly to the branchless heapsort fallback.
- select_nth_unstable jumps directly to the median_of_medians fallback, which is augmented with a
custom tiny smallsort and partition impl.
Some code is duplicated but de-duplication would bring it's own problems. For example `swap_if_less`
is critical for performance, if the sorting networks don't inline it perf drops drastically,
however `#[inline(always)]` is also a poor fit, if the provided comparison function is huge,
it gives the compiler an out to only instantiate `swap_if_less` once and call it. Another aspect
that would suffer when making `swap_if_less` pub, is having to cfg out dozens of functions in
in smallsort module.
|
|
The most important thing about Poll is that Future::poll returns it, but
previously the docs didn't emphasize this.
|