style: format workspace with Rust 1.97
Docs Deploy / Build and Deploy MkDocs (push) Successful in 36s
Test / Lint (push) Failing after 2m31s
Test / Test (push) Skipped
Test / Render parity (push) Skipped

This commit is contained in:
2026-07-18 05:28:07 +04:00
parent 02b4da2e3d
commit 2da28d0495
8 changed files with 147 additions and 96 deletions
@@ -32,7 +32,14 @@ fn take_runtime_owners_in_dependency_order<Instance, Validation, Surface, Device
instance.take();
}
fn take_runtime_children_with_validation_snapshot<Surface, Device, Swapchain, Validation, Snapshot, Capture>(
fn take_runtime_children_with_validation_snapshot<
Surface,
Device,
Swapchain,
Validation,
Snapshot,
Capture,
>(
surface: &mut Option<Surface>,
device: &mut Option<Device>,
swapchain: &mut Option<Swapchain>,
+2 -4
View File
@@ -634,15 +634,13 @@ pub fn prepare_mission_assets_with_repository<R: ResourceRepository>(
root_prototype_spans: &[std::ops::Range<usize>],
prototypes: &[EffectivePrototype],
) -> Result<MissionAssets, AssetError> {
Ok(
prepare_mission_assets_profiled_with_repository(
Ok(prepare_mission_assets_profiled_with_repository(
repository,
root_prototype_spans,
prototypes,
AssetPreparationLimits::default(),
)?
.0,
)
.0)
}
/// Builds mission assets while enforcing explicit preparation limits.
+10 -2
View File
@@ -894,7 +894,11 @@ mod tests {
fs::write(root.join("WORLD/MAP/land.map"), build_nres(&[])).expect("land map");
let manifest = CorpusManifest {
kind: CorpusKind::Unknown,
files: vec![manifest_entry("WORLD/MAP/land.map", 16, sha256(b"land.map"))],
files: vec![manifest_entry(
"WORLD/MAP/land.map",
16,
sha256(b"land.map"),
)],
casefold_collisions: Vec::new(),
};
@@ -913,7 +917,11 @@ mod tests {
fs::write(root.join("WORLD/MAP/land.msh"), build_nres(&[])).expect("land msh");
let manifest = CorpusManifest {
kind: CorpusKind::Unknown,
files: vec![manifest_entry("WORLD/MAP/land.msh", 16, sha256(b"land.msh"))],
files: vec![manifest_entry(
"WORLD/MAP/land.msh",
16,
sha256(b"land.msh"),
)],
casefold_collisions: Vec::new(),
};
+22 -21
View File
@@ -137,7 +137,8 @@ pub enum LandFileKind {
///
/// Returns a string error when the archive cannot be read or decoded.
pub fn inspect_archive_file(path: &Path, sample_limit: usize) -> Result<ArchiveInspection, String> {
inspect_archive_file_diagnostic(path, sample_limit).map_err(|diagnostic| render_human(&diagnostic))
inspect_archive_file_diagnostic(path, sample_limit)
.map_err(|diagnostic| render_human(&diagnostic))
}
/// Inspects a format archive and returns a structured diagnostic on failure.
@@ -215,7 +216,9 @@ fn inspect_archive_bytes(
Arc::from(bytes.to_vec().into_boxed_slice()),
ReadProfile::Compatible,
)
.map_err(|err| archive_parse_diagnostic("S1.NRES.DECODE", source, bytes, err.to_string()))?;
.map_err(|err| {
archive_parse_diagnostic("S1.NRES.DECODE", source, bytes, err.to_string())
})?;
let mut sample = Vec::new();
for entry in document.entries().iter().take(sample_limit) {
sample.push(NresEntrySummary {
@@ -234,7 +237,9 @@ fn inspect_archive_bytes(
Arc::from(bytes.to_vec().into_boxed_slice()),
fparkan_rsli::ReadProfile::Compatible,
)
.map_err(|err| archive_parse_diagnostic("S1.RSLI.DECODE", source, bytes, err.to_string()))?;
.map_err(|err| {
archive_parse_diagnostic("S1.RSLI.DECODE", source, bytes, err.to_string())
})?;
Ok(ArchiveInspection::Rsli {
entries: document.entries().len(),
})
@@ -259,8 +264,8 @@ pub fn inspect_model_from_root(
archive: &str,
resource: &str,
) -> Result<ModelInspection, String> {
let bytes =
read_resource_bytes_diagnostic(root, archive, resource).map_err(|err| render_human(&err))?;
let bytes = read_resource_bytes_diagnostic(root, archive, resource)
.map_err(|err| render_human(&err))?;
let document = decode_nres(bytes.clone(), ReadProfile::Compatible).map_err(|err| {
render_human(&resource_parse_diagnostic(
"S1.NRES.DECODE",
@@ -293,10 +298,8 @@ pub fn load_model_from_root(
archive: &str,
resource: &str,
) -> Result<ModelAsset, String> {
let document =
load_model_document_from_root_diagnostic(root, archive, resource).map_err(|err| {
render_human(&err)
})?;
let document = load_model_document_from_root_diagnostic(root, archive, resource)
.map_err(|err| render_human(&err))?;
let msh = decode_msh(&document).map_err(|err| err.to_string())?;
validate_msh(&msh).map_err(|err| err.to_string())
}
@@ -312,8 +315,8 @@ pub fn inspect_texture_from_root(
archive: &str,
resource: &str,
) -> Result<TextureInspection, String> {
let bytes =
read_resource_bytes_diagnostic(root, archive, resource).map_err(|err| render_human(&err))?;
let bytes = read_resource_bytes_diagnostic(root, archive, resource)
.map_err(|err| render_human(&err))?;
let document = decode_texm(bytes).map_err(|err| err.to_string())?;
Ok(TextureInspection {
width: document.width(),
@@ -385,9 +388,7 @@ fn read_resource_bytes_diagnostic(
)
})?;
let resource_name = resource_name(name.as_bytes());
let archive_handle = repository
.open_archive(&archive_path)
.map_err(|err| {
let archive_handle = repository.open_archive(&archive_path).map_err(|err| {
diagnostic(DiagnosticCode("S1.RESOURCE.OPEN_ARCHIVE"), err.to_string()).with_context(
DiagnosticContext {
phase: Some(Phase::Read),
@@ -410,8 +411,7 @@ fn read_resource_bytes_diagnostic(
)
})?
else {
return Err(
diagnostic(
return Err(diagnostic(
DiagnosticCode("S1.RESOURCE.MISSING_ENTRY"),
format!(
"resource not found: {archive}/{}",
@@ -423,8 +423,7 @@ fn read_resource_bytes_diagnostic(
path: Some(archive.to_string()),
archive_entry: Some(name.to_string()),
..DiagnosticContext::default()
}),
);
}));
};
let bytes = repository.read(handle).map_err(|err| {
diagnostic(DiagnosticCode("S1.RESOURCE.READ"), err.to_string()).with_context(
@@ -514,8 +513,7 @@ mod tests {
let path = dir.join("broken.nres");
fs::write(&path, b"NRes").expect("broken nres");
let diagnostic =
inspect_archive_file_diagnostic(&path, 0).expect_err("diagnostic failure");
let diagnostic = inspect_archive_file_diagnostic(&path, 0).expect_err("diagnostic failure");
assert_eq!(diagnostic.code.0, "S1.NRES.DECODE");
let expected_path = path.display().to_string();
@@ -555,7 +553,10 @@ mod tests {
assert_eq!(diagnostic.code.0, "S1.NRES.DECODE");
assert_eq!(diagnostic.context.phase, Some(Phase::Parse));
assert_eq!(diagnostic.context.path.as_deref(), Some("models.rlb"));
assert_eq!(diagnostic.context.archive_entry.as_deref(), Some("BROKEN.MSH"));
assert_eq!(
diagnostic.context.archive_entry.as_deref(),
Some("BROKEN.MSH")
);
assert_eq!(
diagnostic.context.span,
Some(SourceSpan {
+6 -5
View File
@@ -802,10 +802,8 @@ fn parse_entries(
header: &NresHeader,
limits: DecodeLimits,
) -> Result<Vec<NresEntry>, NresError> {
let capacity = checked_allocation_len(
u64::from(header.entry_count),
u64::from(limits.max_entries),
)?;
let capacity =
checked_allocation_len(u64::from(header.entry_count), u64::from(limits.max_entries))?;
let mut entries = Vec::with_capacity(capacity);
let directory_offset =
usize::try_from(header.directory_offset).map_err(|_| DecodeError::IntegerOverflow)?;
@@ -1629,7 +1627,10 @@ mod tests {
..DecodeLimits::default()
}
),
Err(NresError::Binary(DecodeError::LimitExceeded { count: 2, limit: 1 }))
Err(NresError::Binary(DecodeError::LimitExceeded {
count: 2,
limit: 1
}))
));
}
+23 -10
View File
@@ -209,7 +209,11 @@ pub struct PrototypeGraphNode {
impl PrototypeGraphNode {
/// Creates a typed resource node.
#[must_use]
pub fn resource(kind: PrototypeGraphNodeKind, resource: ResourceKey, id: PrototypeGraphNodeId) -> Self {
pub fn resource(
kind: PrototypeGraphNodeKind,
resource: ResourceKey,
id: PrototypeGraphNodeId,
) -> Self {
Self {
id,
kind,
@@ -1656,15 +1660,24 @@ mod tests {
fn malformed_unit_dat_failure_is_classified_on_unit_edge() {
let mut vfs = MemoryVfs::default();
let dat_path = resource_archive_path(b"UNITS/AUTO/bad.dat").expect("dat path");
vfs.insert(dat_path, Arc::from([1_u8, 2, 3].to_vec().into_boxed_slice()));
vfs.insert(
dat_path,
Arc::from([1_u8, 2, 3].to_vec().into_boxed_slice()),
);
let vfs = Arc::new(vfs);
let repo = CachedResourceRepository::new(vfs.clone());
let (_graph, _resolved, report) =
build_prototype_graph_report(&repo, vfs.as_ref(), &[resource_name(b"UNITS/AUTO/bad.dat")]);
let (_graph, _resolved, report) = build_prototype_graph_report(
&repo,
vfs.as_ref(),
&[resource_name(b"UNITS/AUTO/bad.dat")],
);
assert_eq!(report.failures.len(), 1);
assert_eq!(report.failures[0].edge, PrototypeGraphEdge::MissionToUnitDat);
assert_eq!(
report.failures[0].edge,
PrototypeGraphEdge::MissionToUnitDat
);
}
#[test]
@@ -1690,7 +1703,10 @@ mod tests {
);
assert_eq!(report.failures.len(), 1);
assert_eq!(report.failures[0].edge, PrototypeGraphEdge::UnitDatToComponent);
assert_eq!(
report.failures[0].edge,
PrototypeGraphEdge::UnitDatToComponent
);
assert!(report.failures[0].message.contains("missing_component"));
}
@@ -2007,10 +2023,7 @@ mod tests {
assert_eq!(report.failures.len(), 1);
assert_eq!(report.failures[0].resource_raw, b"broken");
assert_eq!(
report.failures[0].edge,
PrototypeGraphEdge::PrototypeToMesh
);
assert_eq!(report.failures[0].edge, PrototypeGraphEdge::PrototypeToMesh);
assert!(report.failures[0].message.contains("broken"));
assert!(report.failures[0]
.message
+37 -10
View File
@@ -636,7 +636,11 @@ impl RsliDocument {
///
/// Returns [`RsliError`] when the packed payload exceeds configured
/// limits, `id` is invalid, or the payload cannot be decoded.
pub fn load_with_limits(&self, id: EntryId, limits: DecodeLimits) -> Result<Vec<u8>, RsliError> {
pub fn load_with_limits(
&self,
id: EntryId,
limits: DecodeLimits,
) -> Result<Vec<u8>, RsliError> {
let record = self.record_by_id(id)?;
let packed = self.packed_slice(id, record)?;
decode_payload(
@@ -1208,12 +1212,18 @@ fn validate_lookup_order(records: &[EntryRecord]) -> Result<(), RsliError> {
.map_err(|_| RsliError::IntegerOverflow)?;
let left = records
.get(left_original)
.ok_or(RsliError::CorruptEntryTable("sort_to_original is not a permutation"))?;
.ok_or(RsliError::CorruptEntryTable(
"sort_to_original is not a permutation",
))?;
let right = records
.get(right_original)
.ok_or(RsliError::CorruptEntryTable("sort_to_original is not a permutation"))?;
if cmp_c_string(c_name_bytes(&left.meta.name_raw), c_name_bytes(&right.meta.name_raw))
== std::cmp::Ordering::Greater
.ok_or(RsliError::CorruptEntryTable(
"sort_to_original is not a permutation",
))?;
if cmp_c_string(
c_name_bytes(&left.meta.name_raw),
c_name_bytes(&right.meta.name_raw),
) == std::cmp::Ordering::Greater
{
return Err(RsliError::CorruptEntryTable(
"presorted lookup names are not sorted",
@@ -1906,7 +1916,9 @@ mod tests {
assert!(matches!(
decode(arc(bytes.clone()), ReadProfile::Strict),
Err(RsliError::CorruptEntryTable("presorted lookup names are not sorted"))
Err(RsliError::CorruptEntryTable(
"presorted lookup names are not sorted"
))
));
let doc = decode(arc(bytes), ReadProfile::Compatible).expect("compatible fallback");
@@ -2418,14 +2430,23 @@ mod tests {
..DecodeLimits::default()
}
),
Err(RsliError::Binary(DecodeError::LimitExceeded { count: 2, limit: 1 }))
Err(RsliError::Binary(DecodeError::LimitExceeded {
count: 2,
limit: 1
}))
));
}
#[test]
fn stored_entries_require_exact_packed_size() {
let bytes = synthetic_rsli(
&[SyntheticEntry::with_payload(b"A", 0x000, 0, b"ok", b"ok!".to_vec())],
&[SyntheticEntry::with_payload(
b"A",
0x000,
0,
b"ok",
b"ok!".to_vec(),
)],
true,
0x7782,
None,
@@ -2434,7 +2455,10 @@ mod tests {
assert!(matches!(
doc.load(EntryId(0)),
Err(RsliError::OutputSizeMismatch { expected: 2, got: 3 })
Err(RsliError::OutputSizeMismatch {
expected: 2,
got: 3
})
));
}
@@ -2457,7 +2481,10 @@ mod tests {
..DecodeLimits::default()
}
),
Err(RsliError::Binary(DecodeError::LimitExceeded { count: 5, limit: 4 }))
Err(RsliError::Binary(DecodeError::LimitExceeded {
count: 5,
limit: 4
}))
));
}
+13 -17
View File
@@ -257,11 +257,7 @@ fn select_casefolded_match(
}
}
fn list_recursive(
root: &Path,
dir: &Path,
out: &mut Vec<VfsEntry>,
) -> Result<(), VfsError> {
fn list_recursive(root: &Path, dir: &Path, out: &mut Vec<VfsEntry>) -> Result<(), VfsError> {
let read_dir = fs::read_dir(dir).map_err(VfsError::Io)?;
let mut children = Vec::new();
for entry in read_dir {
@@ -286,10 +282,8 @@ fn list_recursive(
let rel_bytes = rel.as_os_str().as_bytes();
#[cfg(not(unix))]
let rel_bytes = rel.to_str().ok_or(VfsError::Path)?.as_bytes();
let path = fparkan_path::normalize_relative(
rel_bytes,
fparkan_path::PathPolicy::HostCompatible,
)
let path =
fparkan_path::normalize_relative(rel_bytes, fparkan_path::PathPolicy::HostCompatible)
.map_err(|_| VfsError::Path)?;
out.push(VfsEntry {
path,
@@ -299,10 +293,7 @@ fn list_recursive(
Ok(())
}
fn metadata_from_host_file(
path: &Path,
metadata: &fs::Metadata,
) -> Result<VfsMetadata, VfsError> {
fn metadata_from_host_file(path: &Path, metadata: &fs::Metadata) -> Result<VfsMetadata, VfsError> {
if !metadata.is_file() {
return Err(VfsError::Path);
}
@@ -659,8 +650,7 @@ mod tests {
}
let vfs = DirectoryVfs::new(&root);
let path =
normalize_relative(b"data/\xFF.bin", PathPolicy::HostCompatible).expect("path");
let path = normalize_relative(b"data/\xFF.bin", PathPolicy::HostCompatible).expect("path");
assert_eq!(vfs.read(&path).expect("read raw path").as_ref(), b"raw");
let entries = vfs
@@ -770,8 +760,14 @@ mod tests {
let entries = overlay.list(&prefix).expect("list");
assert_eq!(entries.len(), 2);
assert_eq!(entries[0].path.display_lossy(), entries[1].path.display_lossy());
assert_ne!(entries[0].path.identity_bytes(), entries[1].path.identity_bytes());
assert_eq!(
entries[0].path.display_lossy(),
entries[1].path.display_lossy()
);
assert_ne!(
entries[0].path.identity_bytes(),
entries[1].path.identity_bytes()
);
}
fn unique_test_dir(name: &str) -> PathBuf {