Skip to content

backend: libc 只在 Unix 使用,应移到 cfg(unix) 依赖,Windows 编译报 unused dependency #19

Closed

Description

@1lck

问题

backend/Cargo.toml:28 在通用 [dependencies] 里声明了 libc = "0.2",但全仓库只有 backend/src/project_settings.rs:378 的 #[cfg(unix)] 分支用到(options.custom_flags(libc::O_NOFOLLOW),搜索依据:grep -rn "libc::" backend crates)。

Rust 1.100 默认启用 cargo::unused_dependencies,在 Windows 目标(x86_64-pc-windows-gnu / -msvc)编译时报:

warning: unused dependency `libc`
  --> backend\Cargo.toml:28:1

代价:Windows 构建多一个无用依赖和警告;一旦 CI 对警告设 -D warnings(clippy 已经是),发版工作流的 Windows 任务会失败。

由 #16(2248d64)引入,在 #18 的 Windows 虚拟机验证中发现。(仓库没有 refactor 标签,未加标签。)

建议方案

把 libc 移到 [target.'cfg(unix)'.dependencies],Cargo.lock 不变。风险:无,Unix 行为不变。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions