Skip to content

rustdoc: correct doctest span for trailing semicolon after item#157740

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
pbkx:issue-157371-rustdoc-doctest-span
Jun 13, 2026
Merged

rustdoc: correct doctest span for trailing semicolon after item#157740
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
pbkx:issue-157371-rustdoc-doctest-span

Conversation

@pbkx

@pbkx pbkx commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #157371.

When a doctest contains a trailing semicolon after an item, rustdoc can map the
resulting warning to unrelated source following the documentation block rather
than to the semicolon inside the doctest.

Changes only diagnostic span reporting.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jun 11, 2026
@rust-log-analyzer

This comment has been minimized.

@pbkx pbkx force-pushed the issue-157371-rustdoc-doctest-span branch from 5b22838 to de7573b Compare June 11, 2026 06:52
@rust-log-analyzer

This comment has been minimized.

@pbkx pbkx force-pushed the issue-157371-rustdoc-doctest-span branch from de7573b to a9cf06b Compare June 11, 2026 08:13
@pbkx pbkx marked this pull request as ready for review June 11, 2026 09:35
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 11, 2026
@rustbot

rustbot commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

r? @lolbinarycat

rustbot has assigned @lolbinarycat.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 9 candidates
  • Random selection from GuillaumeGomez, camelid, lolbinarycat, notriddle

@lolbinarycat

Copy link
Copy Markdown
Contributor

Please add the case from the issue as a new test, as currently there are no testcase covering the previous worst case (diagnostic span pointing completely outside the doctest) does not appear to have a regression test.

@lolbinarycat

Copy link
Copy Markdown
Contributor

Thanks!

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 1380a58 has been approved by lolbinarycat

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 13, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 13, 2026
…span, r=lolbinarycat

rustdoc: correct doctest span for trailing semicolon after item

Fixes rust-lang#157371.

When a doctest contains a trailing semicolon after an item, rustdoc can map the
resulting warning to unrelated source following the documentation block rather
than to the semicolon inside the doctest.

Changes only diagnostic span reporting.
rust-bors Bot pushed a commit that referenced this pull request Jun 13, 2026
Rollup of 7 pull requests

Successful merges:

 - #157653 (remove AliasTerm::def_id())
 - #157773 (Remove AnonConstKind::GCA and reject generic anon consts)
 - #157740 (rustdoc: correct doctest span for trailing semicolon after item)
 - #157782 (Added `PhantomPinned` diagnostic item and prevented dead field warning on `PhantomPinned`)
 - #157802 (Ensure that optimize attributes on closures are inherited by the shim.)
 - #157812 (rustc_public: implement `ty::Alias` conversion)
 - #157833 (Update wasm-component-ld to 0.5.25)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 13, 2026
…span, r=lolbinarycat

rustdoc: correct doctest span for trailing semicolon after item

Fixes rust-lang#157371.

When a doctest contains a trailing semicolon after an item, rustdoc can map the
resulting warning to unrelated source following the documentation block rather
than to the semicolon inside the doctest.

Changes only diagnostic span reporting.
rust-bors Bot pushed a commit that referenced this pull request Jun 13, 2026
Rollup of 9 pull requests

Successful merges:

 - #157653 (remove AliasTerm::def_id())
 - #157773 (Remove AnonConstKind::GCA and reject generic anon consts)
 - #157846 (Avoid ICE in unconstrained generic parameter suggestion for enums)
 - #157514 ([tiny] Use multipart suggestion for finding ident when literal was expected in attr)
 - #157740 (rustdoc: correct doctest span for trailing semicolon after item)
 - #157782 (Added `PhantomPinned` diagnostic item and prevented dead field warning on `PhantomPinned`)
 - #157802 (Ensure that optimize attributes on closures are inherited by the shim.)
 - #157812 (rustc_public: implement `ty::Alias` conversion)
 - #157833 (Update wasm-component-ld to 0.5.25)
rust-bors Bot pushed a commit that referenced this pull request Jun 13, 2026
Rollup of 10 pull requests

Successful merges:

 - #157714 (Improve polymorphization of raw pointer formatting)
 - #157653 (remove AliasTerm::def_id())
 - #157773 (Remove AnonConstKind::GCA and reject generic anon consts)
 - #157846 (Avoid ICE in unconstrained generic parameter suggestion for enums)
 - #157594 (note which target a missing target_feature belongs to)
 - #157740 (rustdoc: correct doctest span for trailing semicolon after item)
 - #157782 (Added `PhantomPinned` diagnostic item and prevented dead field warning on `PhantomPinned`)
 - #157802 (Ensure that optimize attributes on closures are inherited by the shim.)
 - #157812 (rustc_public: implement `ty::Alias` conversion)
 - #157833 (Update wasm-component-ld to 0.5.25)
rust-bors Bot pushed a commit that referenced this pull request Jun 13, 2026
Rollup of 10 pull requests

Successful merges:

 - #157714 (Improve polymorphization of raw pointer formatting)
 - #157653 (remove AliasTerm::def_id())
 - #157773 (Remove AnonConstKind::GCA and reject generic anon consts)
 - #157846 (Avoid ICE in unconstrained generic parameter suggestion for enums)
 - #157594 (note which target a missing target_feature belongs to)
 - #157740 (rustdoc: correct doctest span for trailing semicolon after item)
 - #157782 (Added `PhantomPinned` diagnostic item and prevented dead field warning on `PhantomPinned`)
 - #157802 (Ensure that optimize attributes on closures are inherited by the shim.)
 - #157812 (rustc_public: implement `ty::Alias` conversion)
 - #157833 (Update wasm-component-ld to 0.5.25)
@rust-bors rust-bors Bot merged commit 862f780 into rust-lang:main Jun 13, 2026
12 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

librustdoc: wrong span in "the main function of this doctest won't be run" diagnostic

4 participants