Repository navigation
test(reserved-oxide-symbols): pin the constants two hygiene fixtures depend on - #648
Merged
Merged
Conversation
…depend on
Two hygiene regressions spell KERNEL_SCOPE_LOCAL's value as a Rust
identifier: a parameter named `{KERNEL_SCOPE_LOCAL}_storage` in
cuda-macros' trybuild pass suite, and a const generic named
KERNEL_SCOPE_LOCAL in the const_generic example. Their purpose is to
collide with the bindings `#[kernel]` injects, so mixed-site hygiene and
`call_site_ident_avoiding_item`'s rename path are exercised.
Nothing tied either fixture back to the constant. Renaming it left both
suites green — 13 passing in reserved-oxide-symbols, 91 plus every
trybuild suite in cuda-macros — because once the names no longer match
there is simply nothing left to collide with, so the hygiene goes
unchecked while still reporting success. `hash_value_is_pinned` asserted
eight of the crate's ten constants and covered neither
KERNEL_SCOPE_LOCAL nor ARTIFACT_ANCHOR_PREFIX, and
all_prefixes_share_reserved_root enumerated the same eight.
Pin both missing constants and enumerate them, and add a cuda-macros test
that reads the two fixtures with include_str! and asserts they still
spell the derived names. A rename now fails in both crates and the
cuda-macros message names the exact binding each fixture needs. The
include_str! calls sit inside #[cfg(test)], so non-test builds are
unaffected.
Fixes NVIDIA#647
Signed-off-by: Vyncint Ng <[email protected]>
Collaborator
|
Confirmed the fail-open, then the fix:
Thanks for the clean, test-only fix. Closes #647. |
nihalpasham
approved these changes
Aug 4, 2026
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.
Fixes #647. Branched from
mainand touches only two files, so it does not overlap #646.What was wrong
Two hygiene regressions spell
KERNEL_SCOPE_LOCAL's value as a Rust identifier, and nothing tied either back to the constant:crates/cuda-macros/tests/pass/kernel_launch_context_api.rs:27cuda_oxide_kernel_scope_246e25db_storageSpan::mixed_site()storage binding (lib.rs:4609) survives a same-text user bindingcrates/rustc-codegen-cuda/examples/const_generic/src/main.rs:55cuda_oxide_kernel_scope_246e25dbcall_site_ident_avoiding_item(lib.rs:4547) takes its rename pathTheir whole point is to collide. Rename the constant and they become ordinary unrelated names — the hygiene goes unexercised, and everything stays green:
The contributing cause:
hash_value_is_pinned— whose doc comment says changing these "must be done deliberately" — asserted 8 of the crate's 10 constants, andall_prefixes_share_reserved_rootenumerated the same 8.KERNEL_SCOPE_LOCALandARTIFACT_ANCHOR_PREFIXwere absent.ARTIFACT_ANCHOR_PREFIXat least had an indirect backstop via the exact-output asserts inartifact_anchor_symbol_is_sanitized_and_reserved;KERNEL_SCOPE_LOCALhad none anywhere in the workspace.Worth noting the contrast inside that same fixture: lines 36–40 also spell
KERNEL_PREFIXas identifiers, but those are referenced, so a rename breaks the build. The hygiene bindings are only declared, so they fail open.What this changes
KERNEL_SCOPE_LOCALandARTIFACT_ANCHOR_PREFIXinhash_value_is_pinned, with a comment naming both fixtures so a rename says what must move with it.all_prefixes_share_reserved_root, so the test named "all prefixes" covers all ten.hygiene_fixtures_still_collide_with_the_generated_scope_namestocuda-macros, which reads both fixtures viainclude_str!and asserts they still spell theKERNEL_SCOPE_LOCAL-derived names. This makes the coupling machine-checked instead of relying on memory, and is the part that would have caught this on day one.Verification
CPU-only, no GPU.
With the constant intact:
reserved-oxide-symbols13 unit + 17 doc pass;cuda-macros92 lib (91 + the new test) plus all four trybuild suites pass.With the constant renamed to
..._deadbeef, both new checks now fail loudly:cargo clippy -p reserved-oxide-symbols -p cuda-macros --all-targets -- -D warningsandcargo fmt --all --checkare clean. No new dependencies, soCargo.lockis untouched.Two notes for review
The cross-crate
include_str!. One half of (3) readscrates/rustc-codegen-cuda/examples/const_generic/src/main.rsfromcuda-macros. It sits inside#[cfg(test)], so it is stripped from non-test builds — confirmed withcargo build -p cuda-macros— and both files are git-tracked, so they exist in any CI checkout. If you would rather not have that coupling, dropping just that assertion still leaves (1) failing on a rename and naming the example explicitly.Guard compatibility. The new literals live in
crates/reserved-oxide-symbols/, whichnaming-guardexcludes, so this is clean under both the current pattern and #646's widened one — I checked both.