spikes/gpui: clippy -D warnings clean on nightly (as_chunks, bounded range)
Nightly's clippy flagged the two chunks_exact(4) loops of common/src/bgra.rs (chunks_exact_to_as_chunks): both now use as_chunks::<4>() and as_chunks_mut::<4>() (stable since 1.88). Behind them, because clippy stops at the first crate that fails, it flags the raw source's `for n in 0u64..` in video/src/main.rs (for_unbounded_range): now `0..=u64::MAX`, the same loop. `cargo clippy --locked --all-targets -- -D warnings` is clean on 1.95.0 and on nightly 2026-10-24 (through shell.sh); the README and the report's clippy sentence say so. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c36aae55e
commit
24069ac170
4 files changed
+17
-10
No files matched your search
@@ -359,10 +359,13 @@ error: could not compile `gpui-pre` (lib) due to 2 previous errors
|
||||
So step 3 starts by moving `rust-toolchain.toml` to 1.95 (or the stable of
|
||||
the day) in the root workspace, a change of its own with the usual checks.
|
||||
The spikes build on 1.95.0 and on nightly 2026-10-24 and pass clippy with
|
||||
`-D warnings` on 1.95.0 at every commit; nightly's clippy has a lint 1.95
|
||||
does not (`chunks_exact_to_as_chunks`) and flags two `chunks_exact(4)`
|
||||
`--all-targets -- -D warnings` on both. Nightly's clippy has two lints
|
||||
1.95 does not: `chunks_exact_to_as_chunks` flagged two `chunks_exact(4)`
|
||||
loops in `spikes/gpui/common/src/bgra.rs` (the packed-RGBA branch and a
|
||||
test), left as they are.
|
||||
test), now `as_chunks::<4>()` (stable since 1.88); behind them, because
|
||||
clippy stops at the first crate that fails, `for_unbounded_range` flagged
|
||||
the raw source's `for n in 0u64..` in `spikes/gpui/video/src/main.rs`, now
|
||||
`0..=u64::MAX`.
|
||||
|
||||
### Dependencies
|
||||
|
||||
|
||||
@@ -25,8 +25,10 @@ of them) calls `std::hint::cold_path`, stable since 1.95.0 (E0658 on 1.94).
|
||||
The workspace says `rust-version = "1.95"`; the spikes build with 1.95.0
|
||||
(the default of `shell.sh`) and nightly 2026-10-24 (`TOOLCHAIN=nightly`,
|
||||
rustc 1.101.0-nightly of 2026-10-23), both from one pinned fenix; clippy
|
||||
is clean on 1.95.0 (nightly's adds `chunks_exact_to_as_chunks`, which
|
||||
flags two loops in `common/src/bgra.rs`). `TOOLCHAIN=1.94 spikes/gpui/shell.sh sh -c 'cd spikes/gpui &&
|
||||
with `-D warnings` is clean on both (nightly's has two lints 1.95.0's lacks,
|
||||
`chunks_exact_to_as_chunks` and `for_unbounded_range`; the code uses
|
||||
`as_chunks` in `common/src/bgra.rs` and an inclusive range in
|
||||
`video/src/main.rs`). `TOOLCHAIN=1.94 spikes/gpui/shell.sh sh -c 'cd spikes/gpui &&
|
||||
cargo build --locked --ignore-rust-version'` shows the failure.
|
||||
|
||||
## Environment (NixOS)
|
||||
|
||||
@@ -71,8 +71,10 @@ pub fn to_bgra_ref(frame: &FrameRef<'_>, out: &mut [u8], stride: usize) -> Resul
|
||||
PixelsRef::Rgba(p) => {
|
||||
for y in 0..h as usize {
|
||||
let (src, dst) = (p.row(y, row), &mut out[y * stride..y * stride + row]);
|
||||
for (d, s) in dst.chunks_exact_mut(4).zip(src.chunks_exact(4)) {
|
||||
d.copy_from_slice(&[s[2], s[1], s[0], 255]);
|
||||
// `row` is a whole number of pixels: there is no remainder.
|
||||
let (dst, src) = (dst.as_chunks_mut::<4>().0, src.as_chunks::<4>().0);
|
||||
for (d, s) in dst.iter_mut().zip(src) {
|
||||
*d = [s[2], s[1], s[0], 255];
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@@ -113,8 +115,8 @@ mod tests {
|
||||
let mut bgra = vec![0; 64 * 36 * 4];
|
||||
convert::to_rgba(frame, &mut rgba, 64 * 4).unwrap();
|
||||
to_bgra(frame, &mut bgra, 64 * 4).unwrap();
|
||||
for (r, b) in rgba.chunks_exact(4).zip(bgra.chunks_exact(4)) {
|
||||
assert_eq!([r[2], r[1], r[0], r[3]], b);
|
||||
for (r, b) in rgba.as_chunks::<4>().0.iter().zip(bgra.as_chunks::<4>().0) {
|
||||
assert_eq!([r[2], r[1], r[0], r[3]], *b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ fn start_raw(config: &Config, mut on_frame: impl FnMut(Arc<VideoFrame>) + Send +
|
||||
})
|
||||
.collect();
|
||||
let start = Instant::now();
|
||||
for n in 0u64.. {
|
||||
for n in 0..=u64::MAX {
|
||||
let due = start + Duration::from_secs(n) / fps;
|
||||
if let Some(wait) = due.checked_duration_since(Instant::now()) {
|
||||
std::thread::sleep(wait);
|
||||
|
||||
Reference in new issue
Block a user