windows-clang type value collisions - #4957
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Root planning can still discard constants during type exclusions and function collisions.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR preserves colliding C type/value names through RDL and Rust projection.
Changes:
- Separates type and value output-name tracking.
- Adds collision fixtures and dependency-planning tests.
- Regenerates HTTP bindings with both
HTTP_VERSIONdeclarations.
File summaries
| File | Description |
|---|---|
metadata/win32/http.rdl |
Adds the HTTP_VERSION constant. |
docs/crates/windows-clang.md |
Documents collision handling. |
crates/tests/libs/rdl/input/type_value_name_collision.rdl |
Tests type/constant collisions. |
crates/tests/libs/rdl/input/type_function_name_collision.rdl |
Tests type/function collisions. |
crates/tests/libs/clang/input/type_value_name_collision.h |
Adds the Clang fixture input. |
crates/tests/libs/clang/expected/type_value_name_collision.rdl |
Defines expected extraction output. |
crates/libs/windows/src/Windows/Win32/http/mod.rs |
Projects the Windows HTTP constant. |
crates/libs/sys/src/Windows/Win32/http/mod.rs |
Projects the windows-sys HTTP constant. |
crates/libs/clang/tests/checkpoint3.rs |
Updates dependency-collision expectations. |
crates/libs/clang/src/lib.rs |
Separates output namespaces and revises planning. |
Review details
- Files reviewed: 10/11 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🔵 Needs a closer look
Planning still rejects collisions between real types and value-emitting GUID, property-key, or class facts.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
crates/libs/clang/src/lib.rs:520
- The category split happens only after planning.
plan()still putsFactData::Guid,PropertyKey, andClassinRoots.types, so a real type with the same projected name reacheschoose_type_root_cachedas an incompatible pair and fails withambiguous type rootbefore this classification runs. For example, valid C containingstruct Shared { ... }; DEFINE_GUID(Shared, ...)should produce a struct and GUID constant. Please separate these value-emitting facts during planning as well, while continuing to reject collisions with other values, and cover this case with a fixture.
- Files reviewed: 10/11 changed files
- Comments generated: 0 new
- Review effort level: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
The new value-fact path ignores constant exclusions and can re-emit values already present in referenced metadata.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 12/13 changed files
- Comments generated: 1
- Review effort level: Balanced
Fixes #4941.
C permits a type and an object-like macro to share the same spelling.
windows-clangpreviously selected the type and discarded the constant because planning and emission treated every projected name as globally unique. Preserve both output categories while continuing to reject duplicate values and incompatible translation-unit dependency graphs explicitly.Add focused
test_clangandtest_rdlfixtures for supported type/value and type/function names. Full SDK regeneration surfaces the canonicalHTTP_VERSIONcase as both a struct and an ANSI string constant, andtool-packageprojects both declarations into the same Rust module forwindowsandwindows-sys.This PR is intentionally scoped to object-like macro constants. GUID, property-key, and coclass facts also emit values but currently participate in type-root planning and have separate exclusion and UM/KM ownership behavior. A follow-up will separate those facts throughout planning and apply metadata exclusions consistently; full generation shows that work will remove redundant UM-owned GUIDs from the additive WDK RDL while leaving the merged WinMD unchanged.
Validation:
cargo test -p windows-clang -p test_clang -p test_rdlcargo clippy -p windows-clang --all-targetscargo check -p windows --features httpcargo check -p windows-sys --features httpcargo run -p tool-roundtrip --quietcargo run -p tool-package --quietcargo run -p tool-features --quiettool-win32runs produced identical output in 470.66s and 455.12s.