Skip to content

fix(links): warn when ANCHOR region closed with duplicate start (#2778)#3112

Closed
leno23 wants to merge 1 commit into
rust-lang:masterfrom
leno23:fix/anchor-end-duplicate-start-warn-2778
Closed

fix(links): warn when ANCHOR region closed with duplicate start (#2778)#3112
leno23 wants to merge 1 commit into
rust-lang:masterfrom
leno23:fix/anchor-end-duplicate-start-warn-2778

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

Clarifies anchor region handling for #include / rustdoc_include:

  • Only ANCHOR_END: name closes a region opened with ANCHOR: name
  • A duplicate ANCHOR: name inside the region logs a warning (it does not close the region)
  • Added unit test showing duplicate start vs ANCHOR_END behave differently when trailing lines exist

Fixes #2778

Test plan

  • cargo test -p mdbook-driver duplicate_anchor
  • cargo test -p mdbook-driver take_anchored
  • CI

Made with Cursor

Log a warning when a region opened with `ANCHOR: name` encounters another
`ANCHOR: name` instead of `ANCHOR_END: name`, and document via test that
only ANCHOR_END closes the region (duplicate starts do not).

Fixes rust-lang#2778

Co-authored-by: Cursor <cursoragent@cursor.com>
@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label May 17, 2026
@ehuss ehuss closed this May 23, 2026
@rustbot rustbot removed the S-waiting-on-review Status: waiting on a review label May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anchor parsing ignores ANCHOR_END, making it behave the same as a starting ANCHOR tag.

3 participants