Skip to content

Commit

Permalink
multiple updates related to the new rust-version
Browse files Browse the repository at this point in the history
- undeprecate `home_dir`.
- use `TaskWaker::noop_waker`.
- remove `unsafe_async` feature.
- make `Mem::{*_of_val, swap}` methods *const*.
- deprecate `Float` methods: `const_[clamp|max|min|signum|copysign]`.
- make `Float` methods const: `clamp`, `max`, `min`, `signum`, `copysign`.
- improve `cswap!` macro, add arms: `mut` and `xor_unchecked`, make `tmp` arm explicit, update syntax.
- miscellaneous refactors, documentation updates, & fixes.
  • Loading branch information
joseluis committed Feb 20, 2025
1 parent 2fc3813 commit f7a2fc7
Show file tree
Hide file tree
Showing 21 changed files with 168 additions and 227 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ publish = true
bench = false


[features] # 278/300 (22 remaining), 149 visible, 129 hidden
[features] # 277/300 (23 remaining), 148 visible, 129 hidden
# ==============================================================================
# https://doc.rust-lang.org/cargo/reference/features.html

Expand Down Expand Up @@ -247,13 +247,13 @@ safe = [ # [9] forbids `unsafe` (and overrides unsafe features)
safest = [ # forbids `unsafe` also in dependencies (except for alloc, core, std)
"safe"
]
unsafe = [ # [11] enables `unsafe` (as long as it isn't forbidden for that module)
"unsafe_array", "unsafe_async", "unsafe_hint", "unsafe_layout",
unsafe = [ # [10] enables `unsafe` (as long as it isn't forbidden for that module)
"unsafe_array", "unsafe_hint", "unsafe_layout",
"unsafe_niche", "unsafe_ptr", "unsafe_slice", "unsafe_str",
"unsafe_sync", "unsafe_syscall", "unsafe_thread",
] # `unsafe··`
unsafe_array = [] # faster array initialization, UninitArray.
unsafe_async = [] # task_waker_noop, CoroRun.
# unsafe_async = [] #
unsafe_hint = [] # unreachable_unchecked, unchecked arithmetic.
unsafe_layout = [] # MemPod, DSTs in the stack, ExtAny::downcast*, Mem::*.
unsafe_niche = [] # unchecked niche constructors.
Expand Down Expand Up @@ -1215,6 +1215,6 @@ required-features = ["linux", "unsafe_syscall"]
[[example]]
name = "coro_run"
path = "examples/work/coro_run.rs"
required-features = ["unsafe_async", "alloc"]
required-features = ["alloc"]

# ==============================================================================
10 changes: 8 additions & 2 deletions DOCS/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@
- text: `crate_root`, `crate_root_string`.
- work: `future_block`, `future_pending`, `future_ready`.
- remove private variant `IoErrorKind::Uncategorized`.
- remove module `data::collections`.
- remove features: `unsafe_async`.
- remove modules: `data::collections`.
- disable optional dependencies: `ring`, `rkyv`.
- deprecate `Char::len_to_utf8`.
- deprecate:
- `Char::len_to_utf8`.
- `Float::{const_[clamp|max|min|signum|copysign]}`.

### Changed
- bump MSRV to 1.84.1.
Expand Down Expand Up @@ -105,6 +108,9 @@
- auto-enable features:
- `str`: when enabling `_str_u*`.
- make customizable: `XorShift[16|32|64]`.
- make const methods:
- `Float`: `clamp`, `max`, `min`, `signum`, `copysign`.
- `Mem`: `swap`.
- derive Copy for `Lgc16`.
- update `str!` macro docs and tests.
- make modules public:
Expand Down
4 changes: 2 additions & 2 deletions build/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ mod reflection {
pub const UNSAFE: FlagsFeatures = FlagsFeatures {
flags: &["unsafe··"],
features: &[
"unsafe", // [11]
"unsafe_array", "unsafe_async", "unsafe_hint", "unsafe_layout",
"unsafe", // [10]
"unsafe_array", "unsafe_hint", "unsafe_layout",
"unsafe_niche", "unsafe_ptr", "unsafe_slice", "unsafe_str",
"unsafe_sync", "unsafe_syscall", "unsafe_thread",
]
Expand Down
2 changes: 1 addition & 1 deletion src/code/any/ext.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// devela::code::any::ext
//
//!
//! Defines the [`ExtAny`] trait.
//
// - WAIT: (const) [type_name](https://github.com/rust-lang/rust/issues/63084)
// - WAIT: [trait_upcasting](https://github.com/rust-lang/rust/issues/65991)
Expand Down
2 changes: 1 addition & 1 deletion src/data/list/array/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ macro_rules! array_init {
unsafe { $crate::MaybeUninit::uninit().assume_init() };
for (i, e) in &mut arr[..].iter_mut().enumerate() {
#[allow(clippy::redundant_closure_call, reason = "macro arg isn't redundant")]
let _ = e.write($init(i));
let _ = e.write($init(i)); // NOTE: const since 1.85
}
// Can't use transmute for now, have to use transmute_copy:
// - WAIT: [const generics transmute](https://github.com/rust-lang/rust/issues/61956)
Expand Down
18 changes: 9 additions & 9 deletions src/data/list/stack/stack/methods/own.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ macro_rules! impl_stack {
/// ```
pub const fn own_nip_unchecked(self) -> Own<Self, ()> {
let mut arr = self.data.into_array_copy();
cswap![arr[self.len as usize - 2], arr[self.len as usize - 1]];
cswap![tmp: arr[self.len as usize - 2], arr[self.len as usize - 1]];
let mut sta = Self::from_array_copy(arr);
sta.len -= 1;
Own::empty(sta)
Expand Down Expand Up @@ -382,8 +382,8 @@ macro_rules! impl_stack {
/// ```
pub const fn own_nip2_unchecked(self) -> Own<Self, ()> {
let mut arr = self.data.into_array_copy();
cswap![arr[self.len as usize - 4], arr[self.len as usize - 2]];
cswap![arr[self.len as usize - 3], arr[self.len as usize - 1]];
cswap![tmp: arr[self.len as usize - 4], arr[self.len as usize - 2]];
cswap![tmp: arr[self.len as usize - 3], arr[self.len as usize - 1]];
let mut sta = Self::from_array_copy(arr);
sta.len -= 2;
Own::empty(sta)
Expand Down Expand Up @@ -432,7 +432,7 @@ macro_rules! impl_stack {
/// ```
pub const fn own_swap_unchecked(self) -> Own<Self, ()> {
let mut arr = self.data.into_array_copy();
cswap![arr[self.len as usize - 2], arr[self.len as usize - 1]];
cswap![tmp: arr[self.len as usize - 2], arr[self.len as usize - 1]];
Own::empty(Self::from_array_copy(arr))
}

Expand Down Expand Up @@ -477,8 +477,8 @@ macro_rules! impl_stack {
/// ```
pub const fn own_swap2_unchecked(self) -> Own<Self, ()> {
let mut arr = self.data.into_array_copy();
cswap![arr[self.len as usize - 4], arr[self.len as usize - 2]];
cswap![arr[self.len as usize - 3], arr[self.len as usize - 1]];
cswap![tmp: arr[self.len as usize - 4], arr[self.len as usize - 2]];
cswap![tmp: arr[self.len as usize - 3], arr[self.len as usize - 1]];
Own::new(Self::from_array_copy(arr), ())
}

Expand Down Expand Up @@ -921,7 +921,7 @@ macro_rules! impl_stack {
pub const fn own_tuck_unchecked(self) -> Own<Self, ()> {
let mut arr = self.data.into_array_copy();
let a = arr[self.len as usize - 1];
cswap![arr[self.len as usize - 2], arr[self.len as usize - 1]];
cswap![tmp: arr[self.len as usize - 2], arr[self.len as usize - 1]];
arr[self.len as usize] = a;
let mut sta = Self::from_array_copy(arr);
sta.len = self.len + 1;
Expand Down Expand Up @@ -971,8 +971,8 @@ macro_rules! impl_stack {
pub const fn own_tuck2_unchecked(self) -> Own<Self, ()> {
let mut arr = self.data.into_array_copy();
// swap2
cswap![arr[self.len as usize - 4], arr[self.len as usize - 2]];
cswap![arr[self.len as usize - 3], arr[self.len as usize - 1]];
cswap![tmp: arr[self.len as usize - 4], arr[self.len as usize - 2]];
cswap![tmp: arr[self.len as usize - 3], arr[self.len as usize - 1]];
// over2
let a = arr[self.len as usize - 4];
let b = arr[self.len as usize - 3];
Expand Down
12 changes: 6 additions & 6 deletions src/data/sort/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ macro_rules! impl_sort {
let mut arr = self.0;
cfor![i in 0..N => {
cfor![j in 0..N-i-1 => {
iif![arr[j] > arr[j+1]; cswap!(xor arr[j], arr[j+1])];
iif![arr[j] > arr[j+1]; cswap!(xor: arr[j], arr[j+1])];
}];
}];
arr
Expand All @@ -106,7 +106,7 @@ macro_rules! impl_sort {
cfor![i in 1..N => {
let mut j = i;
while j > 0 && arr[j-1] > arr[j] {
cswap!(xor arr[j], arr[j-1]);
cswap!(xor: arr[j], arr[j-1]);
j -= 1;
}
}];
Expand All @@ -122,7 +122,7 @@ macro_rules! impl_sort {
cfor![j in (i+1)..N => {
iif![arr[j] < arr[min_index]; min_index = j];
}];
cswap!(xor arr[min_index], arr[i]);
cswap!(xor: arr[min_index], arr[i]);
}];
arr
}
Expand All @@ -139,7 +139,7 @@ macro_rules! impl_sort {
let mut arr = self.0;
cfor![i in 0..N => {
cfor![j in 0..N-i-1 => {
iif![Compare(arr[j]).gt(arr[j+1]); cswap!(arr[j], arr[j+1])];
iif![Compare(arr[j]).gt(arr[j+1]); cswap!(tmp: arr[j], arr[j+1])];
}];
}];
arr
Expand All @@ -152,7 +152,7 @@ macro_rules! impl_sort {
cfor![i in 1..N => {
let mut j = i;
while j > 0 && Compare(arr[j-1]).gt(arr[j]) {
cswap!(arr[j], arr[j-1]);
cswap!(tmp: arr[j], arr[j-1]);
j -= 1;
}
}];
Expand All @@ -168,7 +168,7 @@ macro_rules! impl_sort {
cfor![j in (i+1)..N => {
iif![Compare(arr[j]).lt(arr[min_index]); min_index = j];
}];
cswap!(arr[min_index], arr[i]);
cswap!(tmp: arr[min_index], arr[i]);
}];
arr
}
Expand Down
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ compile_error!("You can't enable the `std` and `no_std` features at the same tim
#[cfg(all(
feature = "safe",
// In sync with Cargo.toml::unsafe & build/features.rs::UNSAFE
any(feature = "unsafe", // includes all 11 specific purposes below:
feature = "unsafe_array", feature = "unsafe_async", feature = "unsafe_hint",
feature = "unsafe_layout", feature = "unsafe_niche", feature = "unsafe_ptr",
feature = "unsafe_slice", feature = "unsafe_str", feature = "unsafe_sync",
any(feature = "unsafe", // includes all 10 specific purposes below:
feature = "unsafe_array", feature = "unsafe_hint",
feature = "unsafe_layout", feature = "unsafe_niche",
feature = "unsafe_ptr", feature = "unsafe_slice",
feature = "unsafe_str", feature = "unsafe_sync",
feature = "unsafe_syscall", feature = "unsafe_thread",
)
))]
Expand Down
Loading

0 comments on commit f7a2fc7

Please sign in to comment.