[PR #4813] [CLOSED] Windows build: estimate_disk_space's FFI compiles again #5866

Closed
opened 2026-11-03 05:15:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4813
Author: @masa-masa-0314
Created: 10/31/2026
Status: ❌ Closed

Base: main ← Head: fix/windows-unsafe-disk-space


📝 Commits (1)

  • 27887fd Windows build: estimate_disk_space's FFI compiles again

📊 Changes

2 files changed (+5 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/lib.rs (+3 -1)
📝 crates/horizon-client/src/save.rs (+2 -0)

📄 Description

🤖 Opened by masa-masa-0314's AI agent (ZCode), not by masa-masa-0314 personally.

What and why

Since the WorldOpenFlows low-disk-space port landed, cargo check, clippy and cargo test fail on Windows with

error: usage of an `unsafe extern` block
  --> crates\horizon-client\src\save.rs:282
error: usage of an `unsafe` block
  --> crates\horizon-client\src/save.rs:293

estimate_disk_space calls GetDiskFreeSpaceExW under #[cfg(windows)], which the crate's #![forbid(unsafe_code)] rejects, and Linux CI never compiles the cfg'd block, so it went unnoticed. forbid becomes deny — which a scoped #[allow(unsafe_code)] may lift for the one FFI call, SAFETY note already present — and everything else stays forbidden. allow cannot override forbid, so the downgrade is the smallest change that keeps the guarantee everywhere else and compiles on both platforms.

Vanilla reference

none (build fix; the function follows LevelStorageAccess.estimateDiskSpace / FileStore.getUsableSpace, already ported in the commit that introduced it)

Self-check

On this Windows machine, clean upstream/main (d5c4248f6) fails cargo check -p horizon-client --lib with the two errors above; with this patch, cargo clippy -p horizon-client --lib --bins -- -D warnings passes and cargo test -p horizon-client --lib runs 868 tests, all passing. cargo fmt --all -- --check is clean.

Screenshots

Not needed.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4813 **Author:** [@masa-masa-0314](https://github.com/masa-masa-0314) **Created:** 10/31/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/windows-unsafe-disk-space` --- ### 📝 Commits (1) - [`27887fd`](https://github.com/horizon-rust/horizon/commit/27887fd7758d516d4bedacbcab46b25aa15c58cd) Windows build: estimate_disk_space's FFI compiles again ### 📊 Changes **2 files changed** (+5 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lib.rs` (+3 -1) 📝 `crates/horizon-client/src/save.rs` (+2 -0) </details> ### 📄 Description > 🤖 Opened by masa-masa-0314's AI agent (ZCode), not by masa-masa-0314 personally. ## What and why Since the `WorldOpenFlows` low-disk-space port landed, `cargo check`, `clippy` and `cargo test` fail on Windows with ``` error: usage of an `unsafe extern` block --> crates\horizon-client\src\save.rs:282 error: usage of an `unsafe` block --> crates\horizon-client\src/save.rs:293 ``` `estimate_disk_space` calls `GetDiskFreeSpaceExW` under `#[cfg(windows)]`, which the crate's `#![forbid(unsafe_code)]` rejects, and Linux CI never compiles the cfg'd block, so it went unnoticed. `forbid` becomes `deny` — which a scoped `#[allow(unsafe_code)]` may lift for the one FFI call, SAFETY note already present — and everything else stays forbidden. `allow` cannot override `forbid`, so the downgrade is the smallest change that keeps the guarantee everywhere else and compiles on both platforms. ## Vanilla reference none (build fix; the function follows `LevelStorageAccess.estimateDiskSpace` / `FileStore.getUsableSpace`, already ported in the commit that introduced it) ## Self-check On this Windows machine, clean `upstream/main` (`d5c4248f6`) fails `cargo check -p horizon-client --lib` with the two errors above; with this patch, `cargo clippy -p horizon-client --lib --bins -- -D warnings` passes and `cargo test -p horizon-client --lib` runs 868 tests, all passing. `cargo fmt --all -- --check` is clean. ## Screenshots Not needed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:32 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5866
No description provided.