CI: satisfy newer clippy lints (toolchain drift, behavior-preserving)

Local clippy (1.96) flags pre-existing code that an older toolchain accepted;
these lints fire on clean main and block `cargo xtask ci`. All rewrites are
behavior-preserving:

- core/date.rs, numfmt/render.rs, functions/math.rs, functions/stat.rs:
  `!x.is_finite() || x < a || x >= b` -> `!(a..b).contains(&x)` (Range::contains
  is false for NaN/inf, matching the existing is_finite guard).
- functions/util.rs: `!(A && !B)` -> `!A || B`.
- engine/cmd/file.rs: drop a dead `.filter(|| true)`.
- ui-egui/grid.rs: `find(|| true)` was always the first table (use `.first()`);
  `wrap || Justify || (nl && wrap)` -> `wrap || Justify`.
- ui-egui/formula_bar.rs: `tab || (enter && false)` -> `tab`.
- engine/cmd/spelling.rs: split the wasm/non-wasm dictionary init so the
  non-wasm `mut` no longer warns under wasm check.
This commit is contained in:
justinjohn0306
2026-10-09 00:53:54 +05:30
parent fb823899c5
commit d9fd1b7305
9 changed files with 22 additions and 21 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ pub fn serial_from_ymd(sys: DateSystem, year: i64, month: i64, day: i64) -> Opti
/// Date/time from a serial. `None` for negative or too-large serials.
pub fn datetime_from_serial(sys: DateSystem, serial: f64) -> Option<DateTime> {
if !serial.is_finite() || serial < 0.0 || serial >= 2_958_466.0 {
if !serial.is_finite() || !(0.0..2_958_466.0).contains(&serial) {
return None;
}
let mut day = serial.floor() as i64;
+1 -1
View File
@@ -48,7 +48,7 @@ fn open(s: &mut Session, p: &Json) -> Result<Json> {
};
let (wb, warnings) = crate::io::open_bytes(&name, &bytes)?;
let title = std::path::Path::new(&name).file_name().and_then(|n| n.to_str()).unwrap_or("Book").to_string();
let path = str_param(p, "path").map(str::to_string).filter(|p| crate::io::FileKind::from_path(p) == Some(crate::io::FileKind::Xlsx) || true);
let path = str_param(p, "path").map(str::to_string);
// Replace an untouched blank Book1 like Excel does.
if s.documents().len() == 1
&& s.active().is_some_and(|d| d.path.is_none() && !d.is_dirty() && d.undo.is_empty() && d.wb.sheets.iter().all(|sh| sh.cells.is_empty()))
+13 -7
View File
@@ -21,17 +21,23 @@ pub fn specs() -> Vec<CommandSpec> {
fn dictionary() -> &'static HashSet<String> {
static DICT: OnceLock<HashSet<String>> = OnceLock::new();
DICT.get_or_init(|| {
let mut set = HashSet::new();
#[cfg(target_arch = "wasm32")]
{
HashSet::new()
}
#[cfg(not(target_arch = "wasm32"))]
for path in ["/usr/share/dict/words", "/usr/share/dict/american-english", "/usr/share/dict/british-english"] {
if let Ok(text) = std::fs::read_to_string(path) {
for w in text.lines().take(2_000_000) {
set.insert(w.trim().to_lowercase());
{
let mut set = HashSet::new();
for path in ["/usr/share/dict/words", "/usr/share/dict/american-english", "/usr/share/dict/british-english"] {
if let Ok(text) = std::fs::read_to_string(path) {
for w in text.lines().take(2_000_000) {
set.insert(w.trim().to_lowercase());
}
break;
}
break;
}
set
}
set
})
}
+1 -1
View File
@@ -487,7 +487,7 @@ fn integer_args(a: &[Arg]) -> R<Vec<u64>> {
v.iter()
.map(|x| {
let t = x.trunc();
if t < 0.0 || t >= 9.007_199_254_740_992e15 { Err(CellError::Num) } else { Ok(t as u64) }
if !(0.0..9.007_199_254_740_992e15).contains(&t) { Err(CellError::Num) } else { Ok(t as u64) }
})
.collect()
}
+1 -1
View File
@@ -1185,7 +1185,7 @@ fn binom_dist_range(a: &[Arg], _: C) -> R<Value> {
let p = num(a, 1)?;
let s1 = num(a, 2)?.trunc();
let s2 = if has(a, 3) { num(a, 3)?.trunc() } else { s1 };
if n < 0.0 || n > 1e15 || !(0.0..=1.0).contains(&p) || s1 < 0.0 || s1 > n || s2 < s1 || s2 > n {
if !(0.0..=1e15).contains(&n) || !(0.0..=1.0).contains(&p) || s1 < 0.0 || s1 > n || s2 < s1 || s2 > n {
return Err(CellError::Num);
}
if s2 - s1 > 10_000.0 {
+1 -1
View File
@@ -51,7 +51,7 @@ pub(crate) fn arg(args: &[Arg], i: usize) -> R<&Arg> {
/// Whether argument `i` was supplied (present and not an empty literal like `F(1,)`).
pub(crate) fn has(args: &[Arg], i: usize) -> bool {
matches!(args.get(i), Some(a) if !(matches!(a.value, Value::Empty) && !a.from_ref))
matches!(args.get(i), Some(a) if !matches!(a.value, Value::Empty) || a.from_ref)
}
/// Number coercion for a scalar parameter: empty = 0, TRUE = 1, numeric text parses.
+1 -1
View File
@@ -58,7 +58,7 @@ pub(crate) fn render_general(sec: &Section, v: f64, width: usize) -> Out {
/// Renders a date/time. `None` when the serial is outside the supported range.
pub(crate) fn render_date(sec: &Section, v: f64, sys: DateSystem) -> Option<Out> {
if !v.is_finite() || v < 0.0 || v >= 2_958_466.0 {
if !v.is_finite() || !(0.0..2_958_466.0).contains(&v) {
return None;
}
let sub_digits = sec.toks.iter().filter_map(|t| if let Tok::Date(DatePart::SubSec(n)) = t { Some(*n) } else { None }).max().unwrap_or(0).min(3);
+1 -1
View File
@@ -166,7 +166,7 @@ pub fn editor_widget(app: &mut SheetApp, ui: &mut egui::Ui, id: egui::Id, font:
ed.caret_to_end = false;
ed.sync_caret = true;
}
if !ed.autocomplete.is_empty() && (tab || (enter && false)) {
if !ed.autocomplete.is_empty() && tab {
ed.accept_autocomplete();
} else if enter {
action = Some((if shift { -1 } else { 1 }, 0, false, false));
+2 -7
View File
@@ -577,7 +577,7 @@ fn paint_quadrant(
};
let indent = st.align.indent as f32 * 9.0 * z;
let pad = 2.5 * z;
if st.align.wrap || st.align.h == HAlign::Justify || text.contains('\n') && st.align.wrap {
if st.align.wrap || st.align.h == HAlign::Justify {
let wrap_w = (rect.width() - 2.0 * pad - indent).max(4.0);
let mut job = egui::text::LayoutJob::simple(text.clone(), font.clone(), color, wrap_w);
job.halign = match halign {
@@ -1651,12 +1651,7 @@ fn filter_menu(app: &mut SheetApp, ui: &mut egui::Ui, geo: &Geo) {
let Some(sh) = wb.sheet(si) else { return };
let _ = geo;
// Tables get an autofilter on demand.
let table_range = sh
.tables
.iter()
.find(|t| t.range.start.row <= at.y as u32 || true)
.filter(|t| col >= t.range.start.col && col <= t.range.end.col)
.map(|t| t.range);
let table_range = sh.tables.first().filter(|t| col >= t.range.start.col && col <= t.range.end.col).map(|t| t.range);
if sh.autofilter.is_none()
&& let Some(r) = table_range
{