refactor(rust): enforce style guide rules for pub/module visibility - #4743
Open
chet wants to merge 1 commit into
Open
refactor(rust): enforce style guide rules for pub/module visibility#4743chet wants to merge 1 commit into
chet wants to merge 1 commit into
Conversation
This enables the `unreachable-pub` lint for every Rust package, enforcing the module visibility rules introduced in NVIDIA#4522, and is the last PR following NVIDIA#4593, NVIDIA#4600, NVIDIA#4630, NVIDIA#4635, NVIDIA#4647, NVIDIA#4660, NVIDIA#4661, NVIDIA#4662, NVIDIA#4663, NVIDIA#4664, NVIDIA#4665, and NVIDIA#4682. Default-feature builds exposed a small set of declarations that all-feature builds kept reachable through test and benchmark APIs. This scopes those declarations to their callers while keeping those feature-gated APIs public only when their features are enabled. Primary callouts are: - Add `-D unreachable-pub` beside `-D warnings` in the shared Cargo compiler flags so packages outside the workspace lint table are covered. - Narrow the remaining API Core, BMC mock, Health, NVLink manager, and `carbide-lints` declarations to the visibility their callers require. - Keep the Health benchmark and NVLink test-support APIs public only when their features are enabled, without adding lint allowances. - Update the custom-lint fixture to compile under the same visibility rule it helps enforce. - Leave runtime behavior, wire contracts, and generated source unchanged. This supports NVIDIA#4558. This supports the updated Rust visibility scoping guidelines in `STYLE_GUIDE.md`, established in NVIDIA#4522. Signed-off-by: Chet Nichols III <chetn@nvidia.com>
Contributor
Summary by CodeRabbit
WalkthroughThe PR enables the workspace-wide ChangesInternal API visibility
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Contributor
Author
|
@coderabbitai full_review, thanks! |
Contributor
|
🐇🔍 ✅ Action performedFull review finished. |
chet
enabled auto-merge (squash)
August 8, 2026 06:35
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.
This enables the
unreachable-publint for every Rust package, enforcingthe module visibility rules introduced in
#4522, and is the last PR following #4593, #4600, #4630, #4635, #4647, #4660, #4661, #4662, #4663, #4664, #4665, and #4682.
Default-feature builds exposed a small set of declarations that
all-feature builds kept reachable through test and benchmark APIs. This
scopes those declarations to their callers while keeping those
feature-gated APIs public only when their features are enabled.
Primary callouts are:
-D unreachable-pubbeside-D warningsin the shared Cargocompiler flags so packages outside the workspace lint table are covered.
carbide-lintsdeclarations to the visibility their callers require.their features are enabled, without adding lint allowances.
rule it helps enforce.
Related issues
This supports #4558.
This supports the updated Rust visibility scoping guidelines in
STYLE_GUIDE.md, established in#4522.
Type of Change
Breaking Changes
Testing
Additional Notes
The workspace now contains 109 Rust packages, including 17 that do not
inherit the root workspace lint table. Configuring the compiler lint in
.cargo/config.tomlcovers those packages without adding a custom lint orchanging their manifests.
No new
allow(unreachable_pub)exceptions are introduced. The existingexceptions remain limited to the generated-code and ABI boundaries reviewed
in #4682. The Health benchmark
and NVLink test-support APIs instead use feature-specific visibility so their
public surface only exists in the configuration that exports it.
Local CodeRabbit and read-only Claude reviews completed before the final fix
round. The applicable Health default-build finding is incorporated; the final
feature-boundary changes also received a fresh read-only review.