Commit 6596489
test: guard the generated Collection impl for camelCase record NSIDs
`cargo build` does not compile the test target, so nothing catches codegen
dropping a `Collection` impl. #345 fixed exactly that: `app.bsky.actor.
contentVisibilityDeclaration` is the first record whose NSID leaf is
camelCase, and the NSID was rebuilt from the snake_case'd file stem, so the
record never matched its own schema and got no `Collection` impl.
`KnownRecord` is keyed on schema ids, so it *did* gain the variant, leaving
downstream crates with an arm they could not satisfy.
Two assertions, neither coupled to lexicon contents:
- Naming `ContentVisibilityDeclaration::NSID` requires the `Collection`
impl to exist; comparing it against the literal requires it to carry the
NSID verbatim rather than a mangled form.
- A never-called function taking `<ContentVisibilityDeclaration as
Collection>::Record` and returning the corresponding `KnownRecord`
variant asserts at compile time that the two halves agree on the record
type. Drifting the associated type fails to build here while the NSID
assertions still pass, so this catches a case the runtime checks cannot.
Verified by reintroducing the #345 breakage against the current tree:
deleting the `Collection` impl fails the test target to compile, as does
pointing its `Record` at a different record type.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent a2e623a commit 6596489
1 file changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
0 commit comments