Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Remove three development expect exemptions

Manav Rathie88c415fb703
diff --git a/rust/crates/ml/tests/support/ml_indexing.rs b/rust/crates/ml/tests/support/ml_indexing.rs
index 8beed80870..3c2f303b35 100644
--- a/rust/crates/ml/tests/support/ml_indexing.rs
+++ b/rust/crates/ml/tests/support/ml_indexing.rs
@@ -1,7 +1,6 @@
use std::{
collections::{BTreeSet, HashMap, HashSet},
fs,
- io::Write,
path::{Component, Path, PathBuf},
};
@@ -333,7 +332,10 @@ impl MlIndexingTestContext {
Ok(())
}
+ #[cfg(test)]
pub(crate) fn verify_corrupt_model(&self) -> Result<()> {
+ use std::io::Write;
+
let mut model = tempfile::NamedTempFile::new()?;
model.write_all(b"not an ONNX protobuf")?;
let model_path = model.path().to_string_lossy().into_owned();
@@ -351,10 +353,6 @@ impl MlIndexingTestContext {
let mut model_paths = self.model_paths.clone();
model_paths.face_detection = model_path.clone();
- #[expect(
- clippy::expect_used,
- reason = "The invalid-model fixture must fail analysis"
- )]
let error = analyze_image(AnalyzeImageRequest {
file_id: -1,
source: ImageSource::Path(image_path.to_string_lossy().into_owned()),
diff --git a/rust/tools/location-dataset/src/urban.rs b/rust/tools/location-dataset/src/urban.rs
index 7304a28fa5..2fabbb9956 100644
--- a/rust/tools/location-dataset/src/urban.rs
+++ b/rust/tools/location-dataset/src/urban.rs
@@ -385,18 +385,13 @@ fn country_alias(name: &str) -> Option<[u8; 2]> {
}
fn decode_geopackage_geometry(bytes: &[u8]) -> Result<MultiPolygon<f64>> {
- if bytes.len() < 8 || &bytes[..2] != b"GP" || bytes[2] != 0 {
+ let Some(&[b'G', b'P', 0, flags, srs @ ..]) = bytes.first_chunk::<8>() else {
return Err(invalid("invalid GHSL GeoPackage geometry header"));
- }
- let flags = bytes[3];
+ };
if flags & 1 == 0 || flags & 0x10 != 0 {
return Err(invalid("unsupported GHSL GeoPackage geometry flags"));
}
- #[expect(
- clippy::expect_used,
- reason = "The header length is checked before taking its four-byte SRS field"
- )]
- let srs = i32::from_le_bytes(bytes[4..8].try_into().expect("eight-byte header"));
+ let srs = i32::from_le_bytes(srs);
if srs != 54_009 {
return Err(invalid(format!("unexpected GHSL spatial reference {srs}")));
}
@@ -510,19 +505,13 @@ impl<'a> WkbReader<'a> {
}
fn take<const N: usize>(&mut self) -> Result<[u8; N]> {
- let end = self
- .position
- .checked_add(N)
- .ok_or_else(|| invalid("truncated GHSL WKB geometry"))?;
- #[expect(clippy::expect_used, reason = "The checked slice has exactly N bytes")]
let bytes = self
.bytes
- .get(self.position..end)
- .ok_or_else(|| invalid("truncated GHSL WKB geometry"))?
- .try_into()
- .expect("fixed-length slice");
- self.position = end;
- Ok(bytes)
+ .get(self.position..)
+ .and_then(|bytes| bytes.first_chunk::<N>())
+ .ok_or_else(|| invalid("truncated GHSL WKB geometry"))?;
+ self.position += N;
+ Ok(*bytes)
}
}