Skip to content

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Aug 6, 2025

Fixes #144752.

The regression was introduced in #144600. Although I don't understand why it is an issue currently, this allows to bypass the failure for now until we can figure out what's wrong as it's currently blocking new bevy's release.

cc @alice-i-cecile
r? @fmease

@rustbot
Copy link
Collaborator

rustbot commented Aug 6, 2025

fmease is currently at their maximum review capacity.
They may take a while to respond.

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 6, 2025
@rustbot

This comment has been minimized.

@@ -0,0 +1,7 @@
pub struct X;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, tester.rs must exist, without it, it doesn't crash.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez GuillaumeGomez force-pushed the fix-rustdoc-scrape-examples-crash branch from d29e4f3 to ff371fe Compare August 6, 2025 15:20
@rustbot

This comment has been minimized.

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I also don't have the time to investigate the root cause, a hotfix seems fine to me.

Regarding the test, I'd rather see a test that doesn't rely on Cargo. Let me see if I can cook sth. up. But otherwise r=me if I don't reply within the next hours.

@fmease
Copy link
Member

fmease commented Aug 6, 2025

Eh, r=me once CI green

@GuillaumeGomez GuillaumeGomez force-pushed the fix-rustdoc-scrape-examples-crash branch from ff371fe to a2b1714 Compare August 6, 2025 15:26
@rustbot
Copy link
Collaborator

rustbot commented Aug 6, 2025

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@alice-i-cecile
Copy link

Thank you! We really appreciate it.

@GuillaumeGomez
Copy link
Member Author

@bors r=fmease rollup

@bors
Copy link
Collaborator

bors commented Aug 6, 2025

📌 Commit a2b1714 has been approved by fmease

It is now in the queue for this repository.

@bors bors 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 Aug 6, 2025
bors added a commit that referenced this pull request Aug 6, 2025
Rollup of 15 pull requests

Successful merges:

 - #144195 (Parser: Recover from attributes applied to types and generic args)
 - #144794 (Port `#[coroutine]` to the new attribute system)
 - #144835 (Anonymize binders in tail call sig)
 - #144861 (Stabilize `panic_payload_as_str` feature)
 - #144917 (Enforce tail call type is related to body return type in borrowck)
 - #144948 (we only merge candidates for trait and normalizes-to goals)
 - #144956 (Gate const trait syntax)
 - #144970 (rustdoc: fix caching of intra-doc links on reexports)
 - #144972 (add code example showing that file_prefix treats dotfiles as the name of a file, not an extension)
 - #144975 (`File::set_times`: Update documentation and example to support setting timestamps on directories)
 - #144977 (Fortify generic param default checks)
 - #144996 (simplifycfg: Mark as changed when start is modified in collapse goto chain)
 - #144998 (mir: Do not modify NonUse in `super_projection_elem`)
 - #145000 (Remove unneeded `stage` parameter when setting up stdlib Cargo)
 - #145008 (Fix rustdoc scrape examples crash)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d369a1f into rust-lang:master Aug 7, 2025
10 checks passed
rust-timer added a commit that referenced this pull request Aug 7, 2025
Rollup merge of #145008 - GuillaumeGomez:fix-rustdoc-scrape-examples-crash, r=fmease

Fix rustdoc scrape examples crash

Fixes #144752.

The regression was introduced in #144600. Although I don't understand why it is an issue currently, this allows to bypass the failure for now until we can figure out what's wrong as it's currently blocking new `bevy`'s release.

cc `@alice-i-cecile`
r? `@fmease`
@rustbot rustbot added this to the 1.91.0 milestone Aug 7, 2025
@GuillaumeGomez GuillaumeGomez deleted the fix-rustdoc-scrape-examples-crash branch August 7, 2025 08:58
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 2, 2025
…h-simple-test, r=GuillaumeGomez

fix rustdoc `render_call_locations`  panicking because of default span `DUMMY_SP` pointing at non local-source file

fixes rust-lang#144752
related to/builds on rust-lang#145008

bevy still crashes in the same way as rust-lang#144752 when building docs on nightly, and from what I can tell the cause seems to be the following (copied from zulip [#t-rustdoc > docs on nightly with example scrapes crash](https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/docs.20on.20nightly.20with.20example.20scrapes.20crash)):

> render_call_locations tries to [find](https://github.com/rust-lang/rust/blob/84a17470220e7adf249b18d7c0178dfbede89462/src/librustdoc/html/render/mod.rs#L2816) the source span of a call to add as an example, but the example files are never actually in the source map from what I can tell, and so it falls back to the default span, which points at the first file in the source map.
> Now, the issue that guillaume mentions [here](rust-lang#145008) adds new files to the source map in order to get them into the dep info, and that leads to some files, namely docs-rs/trait-tags.html in the case of bevy because it's added with --html-after-content, being added before any source files, so then the default span points at them, and when href_from_span tries to find the [source file](https://github.com/rust-lang/rust/blob/84a17470220e7adf249b18d7c0178dfbede89462/src/librustdoc/html/render/context.rs#L368) corresponding to the span, the file doesn't belong to local_sources, and it short circuits.
> This can be fixed by just not using DUMMY_SP as the default span and calculating, for example, the crates root source file as the span, because I'm not entirely sure what the href from that span is actually used for; it's not what links to the example in the end.
> I think the proper way of fixing this would be to make sure the example files are part of the local_sources or at least the source map, but I don't know nearly enough about rust internals to be able to figure out how to fix that.

I've included a test that's mostly copied from rust-lang#145008's test with the addition of `--html-after-content after.html` in the `RUSTDOCFLAGS`, which panics on master in conjunction with the `-Zrustdoc-scrape-examples` cargo flag.

cc `@GuillaumeGomez`
rust-timer added a commit that referenced this pull request Sep 2, 2025
Rollup merge of #146091 - janis-bhm:rustdoc-default-span-with-simple-test, r=GuillaumeGomez

fix rustdoc `render_call_locations`  panicking because of default span `DUMMY_SP` pointing at non local-source file

fixes #144752
related to/builds on #145008

bevy still crashes in the same way as #144752 when building docs on nightly, and from what I can tell the cause seems to be the following (copied from zulip [#t-rustdoc > docs on nightly with example scrapes crash](https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/docs.20on.20nightly.20with.20example.20scrapes.20crash)):

> render_call_locations tries to [find](https://github.com/rust-lang/rust/blob/84a17470220e7adf249b18d7c0178dfbede89462/src/librustdoc/html/render/mod.rs#L2816) the source span of a call to add as an example, but the example files are never actually in the source map from what I can tell, and so it falls back to the default span, which points at the first file in the source map.
> Now, the issue that guillaume mentions [here](#145008) adds new files to the source map in order to get them into the dep info, and that leads to some files, namely docs-rs/trait-tags.html in the case of bevy because it's added with --html-after-content, being added before any source files, so then the default span points at them, and when href_from_span tries to find the [source file](https://github.com/rust-lang/rust/blob/84a17470220e7adf249b18d7c0178dfbede89462/src/librustdoc/html/render/context.rs#L368) corresponding to the span, the file doesn't belong to local_sources, and it short circuits.
> This can be fixed by just not using DUMMY_SP as the default span and calculating, for example, the crates root source file as the span, because I'm not entirely sure what the href from that span is actually used for; it's not what links to the example in the end.
> I think the proper way of fixing this would be to make sure the example files are part of the local_sources or at least the source map, but I don't know nearly enough about rust internals to be able to figure out how to fix that.

I've included a test that's mostly copied from #145008's test with the addition of `--html-after-content after.html` in the `RUSTDOCFLAGS`, which panics on master in conjunction with the `-Zrustdoc-scrape-examples` cargo flag.

cc `@GuillaumeGomez`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: only local crates should have sources emitted
6 participants