Repository navigation
fix(rs): gate doc output-name collisions instead of hitting them in CI #3157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Find workspace targets that would render to the same `target/doc/<dir>`. | ||
| # | ||
| # `cargo doc` writes each documented target to a directory named after the target with | ||
| # dashes folded to underscores, so two targets that differ only there collide: both | ||
| # rustdoc processes race to clean it, and the warning escalates to a hard error | ||
| # depending on which wins. | ||
| # | ||
| # Reads `cargo metadata --no-deps` and prints one line per colliding group. | ||
| [ .packages[] | ||
| | . as $pkg | ||
| # Cargo skips a binary that would land on the same directory as a library in its own | ||
| # package, documenting only the library, so such a pair never actually collides. | ||
| # Compared after folding, matching cargo: a `foo_bar` lib beside a `foo-bar` bin is | ||
| # suppressed too (verified against cargo 1.95). Only cross-package pairs collide. | ||
| | [ $pkg.targets[] | ||
| | select([.kind[]] | any(. == "lib" or . == "rlib" or . == "dylib" | ||
| or . == "cdylib" or . == "staticlib" or . == "proc-macro")) | ||
| | (.name | gsub("-"; "_")) | ||
| ] as $libs | ||
| | $pkg.targets[] | ||
| # `doc = false` in the manifest, which is how a reported pair gets resolved. | ||
| | select(.doc) | ||
| | select([.kind[]] | any(. == "lib" or . == "rlib" or . == "dylib" | ||
| or . == "cdylib" or . == "staticlib" or . == "proc-macro" or . == "bin")) | ||
|
Comment on lines
+22
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a documented binary declares AGENTS.md reference: AGENTS.md:L35-L35 Useful? React with 👍 / 👎. |
||
| | select((([.kind[]] | any(. == "bin")) and ((.name | gsub("-"; "_")) | IN($libs[]))) | not) | ||
| | { dir: (.name | gsub("-"; "_")), package: $pkg.name, target: .name, kind: .kind[0] } | ||
| ] | ||
| | group_by(.dir) | ||
| | map(select(length > 1)) | ||
| | .[] | ||
| | " target/doc/\(.[0].dir) <- " + (map("\(.package) [\(.kind)] \(.target)") | join(" and ")) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an
[[example]],[[test]], or[[bench]]target explicitly setsdoc = true, the ordinarycargo doc --workspace --no-depsinvocation schedules rustdoc for it. In scratch workspaces on Cargo 1.89, Cargo reported that the library had “the same output filename as the example target,” with integration-test and bench targets behaving identically. This filter discards all three kinds, so_doc-namespasses even though the immediately following CI doc step can hit the exact collision and cleanup race this gate is intended to prevent. Include every doc-enabled target kind that Cargo schedules, not only libraries and binaries. (Written by GPT-5.6 Sol)AGENTS.md reference: AGENTS.md:L35-L35
Useful? React with 👍 / 👎.