| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
|
|
Implement the accepted ACP for methods that find the index of the least
significant (lowest) and most significant (highest) set bit in an
integer for signed, unsigned, and NonZero types.
Also add unit tests for all these types.
|
|
|
|
bump bootstrap compiler to 1.90 beta
There were significantly less `cfg(bootstrap)` and `cfg(not(bootstrap))` this release. Presumably due to the fact that we change the bootstrap stage orderings to reduce the need for them and it was successful :pray:
|
|
|
|
libs-api has agreed to rename these functions to
`isolate_highest_one`/`isolate_lowest_one`
|
|
|
|
|
|
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
|
|
|
|
"Basic usage" implies there is an example that shows advanced usage
|
|
|
|
|
|
|
|
Ergonomic ref counting
This is an experimental first version of ergonomic ref counting.
This first version implements most of the RFC but doesn't implement any of the optimizations. This was left for following iterations.
RFC: https://github.com/rust-lang/rfcs/pull/3680
Tracking issue: https://github.com/rust-lang/rust/issues/132290
Project goal: https://github.com/rust-lang/rust-project-goals/issues/107
r? ```@nikomatsakis```
|
|
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the
prelude instead of importing or qualifying them.
These functions were added to all preludes in Rust 1.80.
|
|
|
|
Master bootstrap update
https://forge.rust-lang.org/release/process.html#master-bootstrap-update-tuesday
r? `@Mark-Simulacrum`
|
|
Implement feature `isolate_most_least_significant_one` for integer types
Accepted ACP - https://github.com/rust-lang/libs-team/issues/467
Tracking issue - #136909
Implement ACP for functions that isolate the most significant set bit and least significant set bit on unsigned, signed, and `NonZero` integers.
Add function `isolate_most_significant_one`
Add function `isolate_least_significant_one`
---
This PR adds the following impls
```rust
impl {u8, u16, u32, u64, u128, usize} {
const fn isolate_most_significant_one(self) -> Self;
const fn isolate_least_significant_one(self) -> Self;
}
impl {i8, i16, i32, i64, i128, isize} {
const fn isolate_most_significant_one(self) -> Self;
const fn isolate_least_significant_one(self) -> Self;
}
impl NonZeroT {
const fn isolate_most_significant_one(self) -> Self;
const fn isolate_least_significant_one(self) -> Self;
}
```
Example behavior
```rust
assert_eq!(u8::isolate_most_significant_one(0b01100100), 0b01000000);
assert_eq!(u8::isolate_least_significant_one(0b01100100), 0b00000100);
```
|
|
Implement accepted ACP for functions that isolate the most significant
set bit and least significant set bit on unsigned, signed, and NonZero
integers.
Add function `isolate_most_significant_one`
Add function `isolate_least_significant_one`
Add tests
|
|
(cherry picked from commit e4840ce59bdddb19394df008c5c26d9c493725f8)
|
|
|
|
|
|
|
|
signed type
There was a macro parameter giving signed impls access to the
corresponding unsigned type, but not the other way around.
This will allow implementing methods converting in both directions.
|
|
Add an `unchecked_div` alias to the `Div<NonZero<_>>` impls
Inspired by https://github.com/rust-lang/libs-team/issues/526, if people are looking for `unchecked_div`, point them to `u32: Div<NonZero<u32>>` and friends which do no runtime checks -- and are safe! -- rather than today's behaviour of [the intrinsic being the top result](https://doc.rust-lang.org/std/?search=unchecked_div).

|
|
|
|
Tweak language
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
|
|
|
|
This greatly reduces the number of places that actually use the `rustc_layout_scalar_valid_range_*` attributes down to just 3:
```
library/core\src\ptr\non_null.rs
68:#[rustc_layout_scalar_valid_range_start(1)]
library/core\src\num\niche_types.rs
19: #[rustc_layout_scalar_valid_range_start($low)]
20: #[rustc_layout_scalar_valid_range_end($high)]
```
Everything else -- PAL Nanoseconds, alloc's `Cap`, niched FDs, etc -- all just wrap those `niche_types` types.
|
|
|
|
r=oli-obk
Update `NonZero` and `NonNull` to not field-project (per MCP#807)
https://github.com/rust-lang/compiler-team/issues/807#issuecomment-2506098540 was accepted, so this is the first PR towards moving the library to not using field projections into `[rustc_layout_scalar_valid_range_*]` types.
`NonZero` was already using `transmute` nearly everywhere, so there are very few changes to it.
`NonNull` needed more changes, but they're mostly simple, changing `.pointer` to `.as_ptr()`.
r? libs
cc #133324, which will tidy up some of the MIR from this a bit more, but isn't a blocker.
|
|
|
|
Rollup of 4 pull requests
Successful merges:
- #133589 (Remove `hir::ArrayLen`)
- #133672 (Remove a bunch of unnecessary const stability noise)
- #133678 (Stabilize `ptr::fn_addr_eq`)
- #133727 (Update mailmap)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Stabilize unsigned and float variants of `num_midpoint` feature
This PR proposes that we stabilize the unsigned variants of the [`num_midpoint`](https://github.com/rust-lang/rust/issues/110840#issue-1684506201) feature as well as the floats variants, since they are not subject to any unresolved questions, which is equivalent to doing `(a + b) / 2` (and `(a + b) >> 1`) in a sufficiently large number.
The stabilized API surface would be:
```rust
/// Calculates the middle point of `self` and `rhs`.
///
/// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a sufficiently-large unsigned integral type.
/// This implies that the result is always rounded towards negative infinity and that no overflow will ever occur.
impl u{8,16,32,64,128,size} {
pub const fn midpoint(self, rhs: Self) -> Self;
}
impl NonZeroU{8,16,32,64,size} {
pub const fn midpoint(self, rhs: Self) -> Self;
}
impl f{32,64} {
pub const fn midpoint(self, rhs: Self) -> Self;
}
```
The signed variants `u{8,16,32,64,128,size}` would remain gated, until a decision is made about the rounding mode, in other words that the [unresolved questions](https://github.com/rust-lang/rust/issues/110840#issue-1684506201) are resolved.
cc `@rust-lang/libs-api`
cc `@scottmcm`
r? libs-api
|
|
|
|
|
|
|
|
|
|
|
|
Modify `NonZero` documentation to reference the underlying integer type
This change updates the documentation for `NonZero` integer types to explicitly reference the underlying integer type each `NonZero` variant wraps, instead of using a general "integer" term.
**Before**

**After**

|
|
This change updates the documentation for `NonZero` integer types to
explicitly reference the underlying integer type each `NonZero` variant
wraps, instead of using a general "integer" term.
|
|
Add LowerExp and UpperExp implementations to NonZero
Adds `LowerExp` and `UpperExp` trait implementations to `NonZero`, as discussed in rust-lang/libs-team#458.
I had to modify the macro to mark the new impls with a different rust version. Let me know if this is the right way to do it (first timer here!)
|
|
|
|
|
|
Stabilize `isqrt` feature
Stabilizes the `isqrt` feature. FCP is incomplete.
Closes #116226
|
|
|
|
|