diff --git a/scripts/check-doc-refs.sh b/scripts/check-doc-refs.sh index b4ead89e..24894438 100755 --- a/scripts/check-doc-refs.sh +++ b/scripts/check-doc-refs.sh @@ -60,6 +60,26 @@ while IFS=: read -r file lineno match; do [ -n "${match:-}" ] || continue exempt "$file" "$lineno" && continue link="${match#](}" + # A `.rs` doc comment has a second renderer, and it does not count `../` + # the way the rest of this arm assumes. rustdoc emits the href verbatim + # onto a page at `target/doc///`, so the link resolves + # against *that* directory, not the source file's. Resolving from the + # source therefore certifies links that render broken — a false pass, not + # a miss, and worse than no check. + # + # Refused rather than resolved rustdoc-aware: the repo has zero relative + # links in `.rs` doc comments (measured on this commit), so nothing needs + # the second reader, and the backticked repo-root form the root arm above + # already gates works under both. Inferring module nesting would be + # machinery in service of a form nothing uses. + case "$file" in + *.rs) + dead=$((dead + 1)) + printf '::error file=%s,line=%s::relative markdown link in a rust doc comment renders against the rustdoc output directory, not this file; use a backticked repo-root pointer instead: %s\n' \ + "$file" "$lineno" "$link" + continue + ;; + esac # Resolved from the linking file's directory, so `../` counts the same way # the renderer counts it. `-m` keeps a link that escapes the repo root # resolvable enough to report rather than erroring out here.