chore(apple-fs): audit + fix cross-platform compile hazards (XPL-1)#4743
Merged
Conversation
9bb7beb to
bec68d8
Compare
Proactive cross-platform audit per the standing rule. Walked every file in
crates/apple-fs/ checking the three known hazard patterns:
1. #[cfg(unix)] / #[cfg(target_os = "macos")] gates - is the scope the
largest reasonable unit?
2. Imports above a cfg gate used only inside it (unused_imports on the
other platform).
3. let mut bindings mutated only inside a cfg block (unused_mut on the
other platform).
4. Rustdoc intra-doc links that fail to resolve when the referent is
re-exported through lib.rs.
Files inspected:
- crates/apple-fs/Cargo.toml
- crates/apple-fs/README.md
- crates/apple-fs/src/lib.rs
- crates/apple-fs/src/apple_double.rs
- crates/apple-fs/src/resource_fork.rs
- crates/apple-fs/tests/apple_double_round_trip.rs
The .rs sources came through the audit clean - the CCL apple-fs cleanup
already gated per-test #[cfg(unix)] / #[cfg(target_os = "macos")] correctly,
the test modules each contain at least one cross-platform test (so whole-
module gating would over-rotate), and every rustdoc link resolves through
its source module rather than the lib.rs re-export.
One hygiene fix applied: Cargo.toml declared `nix` in the unconditional
[dependencies] block. `nix` 0.31 carries `#![cfg(unix)]` so it compiles to
an empty crate on Windows, but every other crate that consumes `nix`
(core, platform) gates it through `[target.'cfg(unix)'.dependencies]`.
Moving the declaration matches that convention and makes the
cross-platform intent explicit at the manifest level.
bec68d8 to
091ccab
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Proactive cross-platform audit (XPL-1) of
crates/apple-fs/per the standing rule: audit the test tree for known cross-platform CI hazards before pushing, do not wait for CI to fail.Walked every file in the crate checking the four known hazard categories enumerated in CI history:
#[cfg(unix)]/#[cfg(target_os = \"macos\")]gate scope - if every test in a module is gated, the whole module should be gated instead.unused_importson the off-platform).let mutbindings mutated only inside a cfg block (would triggerunused_muton the off-platform).lib.rs.Files inspected
crates/apple-fs/Cargo.tomlcrates/apple-fs/README.mdcrates/apple-fs/src/lib.rscrates/apple-fs/src/apple_double.rscrates/apple-fs/src/resource_fork.rscrates/apple-fs/tests/apple_double_round_trip.rs6 files audited.
Findings
Rust sources: clean
src/lib.rs- test module mixes cross-platform tests (normalize_filename_ascii_unchanged,is_apple_double_name_*,apple_double_companion_*) with#[cfg(unix)]and#[cfg(target_os = \"macos\")]gated tests. The mixed-platform composition means per-test gating is the right unit; whole-module gating would over-rotate. Helper-importuse super::*;is exercised on every platform because at least one test on each platform consumes asuperitem.unique_pathhelper and its imports (env,fs,SystemTime,UNIX_EPOCH) are correctly#[cfg(unix)]-gated together.src/apple_double.rs- pure-data module, no cfg gates, no platform-specific surface.src/resource_fork.rs- matched#[cfg(target_os = \"macos\")]/#[cfg(not(target_os = \"macos\"))]pairs for every accessor; test module has at least one platform-specific test for each side, and the shareduse std::path::PathBuf;is consumed on both branches (dummy_pathon non-macOS,make_temp_fileon macOS), so nounused_importswindow.tests/apple_double_round_trip.rs- top-level imports (AppleDouble,EntryId) consumed by both cross-platform tests and the macOS-gated test; helper functions referenced on every platform; the macOS-only test'suse apple_fs::.../use std::io;are scoped inside the gated function so they vanish cleanly on non-macOS.lib.rsre-export - every[Type]link resolves inside its source module (io::*againstuse std::io;,EntryId/FINDER_INFO_LENas siblings of their referrers).Hygiene fix applied
crates/apple-fs/Cargo.toml:nix = { workspace = true, features = [\"fs\"] }was declared in the unconditional[dependencies]block.nix0.31 carries#![cfg(unix)]so it compiles to an empty crate on Windows, but the per-crate convention used bycore/Cargo.tomlandplatform/Cargo.tomlis to putnixunder[target.'cfg(unix)'.dependencies]. Moved the declaration to match that convention and added a short comment explaining the rationale. Makes cross-platform intent explicit at the manifest level and aligns the crate with the rest of the workspace.Cross-platform compile review (mental walkthrough)
nixstill pulled in via thecfg(unix)target spec;xattrandunicode-normalizationcontinue to flow throughcfg(target_os = \"macos\").nixstill pulled in viacfg(unix); the macOS-only deps stay absent.nixis now formally absent from the dep graph (previously inert via its own#![cfg(unix)]). Zero behaviour change, manifest is now consistent withcoreandplatform.Recommended follow-ups
None. The audit recommends no XPL-1.a / XPL-1.b follow-ups for
apple-fs. The crate is small, well-gated, and benefited from the recent CCL apple-fs cleanup (#4654 era). The remaining XPL-2 / XPL-3 / XPL-4 tasks already cover the other audit targets (kqueue_stub,transfercrate, ongoing macOS/Windows CI flakiness).Test plan