Skip to content

fix(stdlib): gate Unix-only format_mode behind cfg(unix) — unblocks the nightly Windows build - #684

Merged
logbie merged 1 commit into
mainfrom
warden/fix-nightly-windows-dead-code
Aug 3, 2026
Merged

fix(stdlib): gate Unix-only format_mode behind cfg(unix) — unblocks the nightly Windows build#684
logbie merged 1 commit into
mainfrom
warden/fix-nightly-windows-dead-code

Conversation

@logbie

@logbie logbie commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Why

The Nightly Build has failed three nights running (2026-07-31, 08-01, 08-02) and has published no artifacts for main since nightly-2026-07-30.

  • run 30735206598 (08-02) — Build WFL for Windows failed at step 8, Run clippy, after 75s
  • run 30686979106 (08-01) — identical failure
  • run 30608593328 (07-31) — a different, already self-resolved failure (Check formatting: Incorrect newline style in src\interpreter\error.rs); formatting has passed since.

Create or Update Nightly Release needs: the Windows job, so it has been skipped each night.

Root cause

error: function `format_mode` is never used
  --> src\stdlib\filesystem.rs:502:4
  = note: `-D dead-code` implied by `-D warnings`

format_mode landed in #676 (file modes for #666). Both of its call sites — native_file_mode (line 571) and native_set_file_mode (line 624) — sit inside #[cfg(unix)] blocks, because Windows has no mode bits and the #[cfg(not(unix))] branches return the documented read-only approximation instead. The function itself was never gated, so on Windows it compiles to dead code and -D warnings rejects it.

parse_mode is not affected — it is called at line 603, above the cfg split, so it is live on both platforms.

What changed

One attribute, one file:

+/// Unix-only: both call sites live behind `#[cfg(unix)]` ...
+#[cfg(unix)]
 fn format_mode(bits: u32) -> String {

No behaviour change on either platform. This mirrors the cfg structure of the callers rather than papering over it with #[allow(dead_code)].

Verification

  • cargo fmt --all -- --check — clean
  • cargo check --lib — clean
  • cargo clippy --lib -- -D warnings — clean (Linux/unix path: format_mode is still live and still used)
  • Windows path verified by inspection: grep -rn format_mode src/ returns exactly the definition plus the two #[cfg(unix)]-guarded call sites, so gating the definition cannot orphan a reference. A cross-target --target x86_64-pc-windows-msvc clippy run was attempted and abandoned — the sandbox ran out of disk building the Windows dependency tree.
  • The authoritative check is the nightly itselfnightly.yml is the only lane that runs clippy on Windows. A workflow_dispatch against this branch was deliberately NOT triggered: the release job has no branch guard, so it would publish a nightly-2026-08-02 release from a non-main sha. Merge this, then the next scheduled nightly (or a dispatch from main) confirms it.
  • A cross-target cargo clippy --target x86_64-pc-windows-msvc was also attempted and could not complete in the sandbox: aws-lc-sys v0.42.0 needs a Windows build toolchain its build script cannot find. Stated plainly rather than claimed.

Testing policy

Risk class R0: a cfg attribute with no behavioural surface. Per §"pure CI mechanics" in the testing policy, no manufactured failing test — the existing Windows clippy gate is the failing test, and it is red on main right now.

Standing issue this re-exposes

This is the third instance of KB #625 / #633: ci.yml runs clippy on Ubuntu only, so platform-conditional lints reach main and are caught post-merge by the nightly. A Windows clippy lane in ci.yml would have failed #676 at review time in ~4 minutes.

Posted by the WFL repo warden (automated triage pass).


Open in Devin Review

Summary by CodeRabbit

  • Bug Fixes
    • Improved cross-platform compatibility by preventing Unix-specific file mode formatting from being compiled on unsupported platforms.

`format_mode` (src/stdlib/filesystem.rs), added in #676 with the file-mode
support for issue #666, has both of its call sites inside `#[cfg(unix)]`
blocks — Windows has no mode bits to format, so the `#[cfg(not(unix))]`
branches return the documented read-only approximation instead.

The function itself was not gated, so on Windows it is dead code and
`cargo clippy --all-targets --all-features -- -D warnings` fails:

    error: function `format_mode` is never used
      --> src\stdlib\filesystem.rs:502:4
      = note: `-D dead-code` implied by `-D warnings`

That has failed the nightly Windows build on 2026-08-01 and 2026-08-02
(runs 30686979106, 30735206598), skipping the release job both nights, so
no nightly artifacts have been published for main @150c8a76.

Gating the function with `#[cfg(unix)]` matches the cfg structure of its
callers. No behaviour change on either platform.

This is the same failure class as #633 (platform-conditional dead code in
crates/wflpkg) and the same coverage gap: ci.yml runs clippy on Ubuntu
only, so Windows-only lints are caught first by the nightly.
Copilot AI review requested due to automatic review settings August 2, 2026 18:58
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

format_mode in the filesystem standard library is now compiled only on Unix platforms through a conditional compilation attribute.

Changes

Filesystem platform gating

Layer / File(s) Summary
Gate mode formatting for Unix
src/stdlib/filesystem.rs
format_mode now uses #[cfg(unix)] and is excluded from non-Unix builds.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the Unix-only configuration fix and its effect on the nightly Windows build.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch warden/fix-nightly-windows-dead-code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread src/stdlib/filesystem.rs
Comment on lines 501 to +506
/// Format a raw permission bit set as the 4-character octal string WFL uses.
///
/// Unix-only: both call sites live behind `#[cfg(unix)]`, because Windows has
/// no mode bits to format. Without this gate the function is dead code on
/// Windows and `cargo clippy -- -D warnings` fails the nightly build.
#[cfg(unix)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Windows dead-code exposure is not fully eliminated by this fix pattern

The underlying gap called out in the description — clippy runs only on Ubuntu in ci.yml — means any future helper added for the unix branch will reproduce this exact nightly failure. A Windows clippy lane (or a --target x86_64-pc-windows-msvc clippy check) would catch it at review time; worth tracking separately since this is the third recurrence.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Windows-only clippy failure by making the Unix-only format_mode helper in the filesystem stdlib compile only on Unix targets, matching its existing #[cfg(unix)]-guarded call sites and unblocking the nightly Windows build.

Changes:

  • Add #[cfg(unix)] to format_mode so it doesn’t compile as dead code on Windows.
  • Add an explanatory doc comment clarifying why the function is Unix-only and how it relates to the Windows clippy lane.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@logbie

logbie commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

@-

@logbie
logbie merged commit 91863c0 into main Aug 3, 2026
22 checks passed
@logbie
logbie deleted the warden/fix-nightly-windows-dead-code branch August 3, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants