Skip to content

Enable --deny-warnings for cargo shear#21616

Merged
charliemarsh-oai merged 6 commits into
mainfrom
charlie/deny-warnings
May 8, 2026
Merged

Enable --deny-warnings for cargo shear#21616
charliemarsh-oai merged 6 commits into
mainfrom
charlie/deny-warnings

Conversation

@charliemarsh-oai

@charliemarsh-oai charliemarsh-oai commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

In #21584, we disabled doctests for crates that lack any doctests. We can enforce that property via cargo shear --deny-warnings: crates that lack doctests will be flagged if doctests are enabled, and crates with doctests will be flagged if doctests are disabled.

A few additional notes:

  • By adding --deny-warnings, cargo shear also flagged a number of modules that were not reachable at all. Some of those have been removed.
  • This PR removes a usage of windows_modules! (since cargo shear and rustfmt couldn't see through it) in favor of simple #[cfg(target_os = "windows")] macros. As a consequence, many of these files exhibit churn in this PR, since they weren't being formatted by rustfmt at all on main.
  • Again, to make the code more analyzable, this PR also removes some usages of #[path = "cwd_junction.rs"] in favor of a more standard module structure. The bin sidecar structure is still retained, but, e.g., windows-sandbox-rs/src/bin/command_runner.rs‎ was moved to windows-sandbox-rs/src/bin/command_runner/main.rs, and so on.

@charliemarsh-oai charliemarsh-oai force-pushed the charlie/deny-warnings branch from 397d504 to 36473a7 Compare May 7, 2026 23:46
with:
tool: cargo-shear
version: 1.11.2
tool: cargo-shear@1.11.2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was an oversight from a prior PR (i.e., using the wrong format here).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These previously weren't included / run at all; I added them to codex-rs/core/tests/suite/mod.rs, then fixed the test, though we could also consider dropping it entirely.

Comment thread codex-rs/windows-sandbox-rs/Cargo.toml Outdated
@@ -7,9 +7,10 @@
//! accepts stdin/terminate frames, and emits a final exit frame. The legacy restricted‑token
//! path spawns the child directly and does not use this runner.

#![cfg(target_os = "windows")]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No longer necessary because this is now gated at:

#[cfg(target_os = "windows")]
mod win;

approval_texts.is_empty(),
"did not expect permissions updates before a new user turn: {approval_texts:?}"
!rollout_path.exists(),
"did not expect a rollout before a new user turn"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These tests weren't being run or compiled at all; this attempts to fix them.

@charliemarsh-oai charliemarsh-oai marked this pull request as ready for review May 8, 2026 03:15
@charliemarsh-oai charliemarsh-oai requested a review from a team as a code owner May 8, 2026 03:15

@bolinfest bolinfest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for all this cleanup!

Comment thread codex-rs/windows-sandbox-rs/src/lib.rs Outdated
#[doc(hidden)]
pub use read_acl_mutex::ReadAclMutexGuard;
#[cfg(target_os = "windows")]
#[doc(hidden)]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's try to avoid more #[doc(hidden)] sneaking in!

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.

I recall Codex wanting to try to avoid adding these to the public API to maintain the status quo. I didn't dig into why though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(I think it's easiest to just duplicate the one shared utility function for now across the two binaries. The other alternative is a crate which feels too heavy here.)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

FYI, https://github.com/openai/codex/tree/main/codex-rs/utils is where we often put "tiny utility crates," as necessary.

#[path = "conpty/mod.rs"]
mod conpty;

#[cfg(target_os = "windows")]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I haven't looked at this in detail, but ideally we would just never try to build this crate on Windows at all and cfg(target_os = "windows") would be assumed throughout and we wouldn't need these repeated annotations at all?

@zanie-oai zanie-oai May 8, 2026

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.

In uv-windows, we use a top-level bang

https://github.com/astral-sh/uv/blob/6c963dd3cb0ea4a39cebcef686dfc1329714532a/crates/uv-windows/src/lib.rs#L6

then we gate the dependencies on it

https://github.com/astral-sh/uv/blob/6c963dd3cb0ea4a39cebcef686dfc1329714532a/crates/uv-fs/Cargo.toml#L43-L47

I'm not sure if there's a way for a crate to declare it is platform-specific beyond ensuring its empty on other platforms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll look into as a separate PR. That would be behavior-changing since we'd then omit even the non-Windows-dependent tests (etc.) on other platforms.

charliemarsh-oai and others added 5 commits May 8, 2026 11:20
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Avoid tripping clippy::duplicated_attributes when Bazel clippy builds the Windows-only sandbox modules with their include sites already cfg-gated.

Co-authored-by: Codex <noreply@openai.com>
@charliemarsh-oai charliemarsh-oai force-pushed the charlie/deny-warnings branch from 9f05258 to b347e68 Compare May 8, 2026 20:01
@charliemarsh-oai charliemarsh-oai enabled auto-merge (squash) May 8, 2026 20:15
@charliemarsh-oai charliemarsh-oai merged commit 7c9731c into main May 8, 2026
29 checks passed
@charliemarsh-oai charliemarsh-oai deleted the charlie/deny-warnings branch May 8, 2026 20:29
@github-actions github-actions Bot locked and limited conversation to collaborators May 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants