Repository navigation
chore: bump MSRV to Rust 1.95 and adopt new stable features #67
Description
Summary
Bump rust-version from "1.94" to "1.95" after Rust 1.95.0 is released (April 16, 2026) and adopt newly stabilized features that benefit this crate.
Rust 1.95.0 features relevant to la-stack
core::hint::cold_path (high value)
Stabilized in rust-lang/rust#151576. This is the single most useful addition for this crate.
Where to use it:
-
det_sign_exactexact-fallback path (src/exact.rs): The Bareiss fallback in the adaptive two-stage predicate is the cold path — the fast f64 filter resolves the vast majority of calls. Addingcold_path()at the start of the exact fallback block hints the compiler to optimize the hot f64 filter path at the expense of the allocation-heavy exact path.// Stage 2: exact Bareiss fallback. core::hint::cold_path(); let det = bareiss_det(self);
-
Error paths in all
exactmethods: TheNonFinite/Singular/Overflowerror returns are cold:Err(LaError::NonFinite { col: c }) => { core::hint::cold_path(); ... }
-
Lu::factorandLdlt::factorsingular/error branches: The singularity detection paths are cold in normal usage. -
det_directfallback arm (_ => Nonefor D ≥ 5): Cold path in the common D ≤ 4 case.
cold_path() can also be used to build likely/unlikely helpers if needed for future hot-loop optimizations.
if let guards (moderate value)
Stabilized in rust-lang/rust#141295. Allows if let in match arm guards.
Where to use:
-
Potential cleanup in
det_sign_exactfast filter:// Before: if let (Some(det_f64), Some(err)) = (self.det_direct(), self.det_errbound()) { if det_f64.is_finite() { ... } } // After (within a match): match self.det_direct() { Some(det_f64) if let Some(err) = self.det_errbound() && det_f64.is_finite() => { ... } ... }
-
Not a large codebase win, but worth adopting where it improves readability.
cfg_select! macro (low value for now)
Stabilized in rust-lang/rust#149783. Replaces chains of #[cfg] / #[cfg(not(...))] with a single cfg_select! block.
Where to use:
- Currently la-stack uses
#[cfg(feature = "exact")]for the module include and re-export. If feature-gated code grows more complex,cfg_select!can replace nestedcfgblocks. Low priority for now since the current feature gating is minimal.
Compiler improvements (indirect benefit)
- MIR SSA range propagation pass may improve optimization of the arithmetic chains in
det_directand the Bareiss inner loop - Better const-generic ergonomics (incremental improvements)
Proposed Changes
- Update
Cargo.toml:rust-version = "1.95" - Update CI workflows if they pin a specific Rust version
- Add
core::hint::cold_path()to:det_sign_exactBareiss fallback- Error return paths in
validate_finite,det_exact,solve_exact, etc. Lu::factor/Ldlt::factorsingular detectiondet_directD ≥ 5 fallback arm
- Audit match patterns for
if letguard opportunities - Run benchmarks before/after to measure
cold_pathimpact on the hot path
Implementation Notes
- Wait for Rust 1.95.0 stable release (April 16, 2026)
cold_path()is a pure hint with no semantic impact — safe to add liberally- Benchmark the exact arithmetic paths (especially
det_sign_exacton well-conditioned matrices where the fast filter dominates) to verify the hint helps - Related: perf: stack-backed storage for exact arithmetic kernels #62, perf: custom f64 → BigRational conversion via mantissa/exponent decomposition #63, perf: integer-only Bareiss determinant (BigInt path) #64, refactor: unify determinant computation pipeline #65, perf: minor optimizations — clone reduction + det_sign_exact short-circuit #66 (all v0.4.0 milestone work)
Activity
acgetchell commentedon Apr 14, 2026
Blocks #86 (const-ify methods depends on MSRV 1.95 const float intrinsics).
Added: regression tests for solver and determinant overflow handling