about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-09-02 17:08:57 +0200
committerGitHub <noreply@github.com>2025-09-02 17:08:57 +0200
commit15cde9c505df79ce071858b67e63fbb98512f88e (patch)
tree7a6a5b9a0ebcfe57f41370b6766062782b596f26 /compiler/rustc_parse/src
parentf77a31fbfff6f3fe983ebeedd3165fbf57d655b1 (diff)
parentf67e29e5a82d5272a03028c5e4a91fbe2bbab81f (diff)
downloadrust-15cde9c505df79ce071858b67e63fbb98512f88e.tar.gz
rust-15cde9c505df79ce071858b67e63fbb98512f88e.zip
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 https://github.com/rust-lang/rust/issues/144752
related to/builds on https://github.com/rust-lang/rust/pull/145008

bevy still crashes in the same way as rust-lang/rust#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](https://github.com/rust-lang/rust/pull/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/rust#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`
Diffstat (limited to 'compiler/rustc_parse/src')
0 files changed, 0 insertions, 0 deletions