Uh oh!
There was an error while loading. Please reload this page.
rustdoc: Take into account edition information for keyword highlighting - #161944
Conversation
This comment has been minimized.
This comment has been minimized.
1a83eb3 to
86c5df9Compare
This comment has been minimized.
This comment has been minimized.
1e831c0 to
05a128cCompareGuillaumeGomez
commented
Aug 28, 2026
Cleaned up all my mess. Ready for review. |
There was a problem hiding this comment.
Isn't source-code-pages/ for testing the contents of source code pages *.rs.html only? Here however, we're testing how the code blocks are rendered on "API pages", aren't we?
IIRC this belongs into tests/rustdoc-html/doctest/.
| &code, | ||
| None, | ||
| None, | ||
| original_span.edition(), |
There was a problem hiding this comment.
Could you add a // NOTE: here that states that this is only "an approximation" or "best effort" since the edition of individual tokens contained in the expansion can differ from the "overarching edition" / the edition of the entire expansion (original_span.edition()).
And we can't fix that since code is just a String that was produced by rustc_ast_pretty meaning more precise edition information has been lost.
To give an example:
//@ edition: 2015#[macro_export]macro_rules! generate {($kw:ident) => {pubfn host(){let _ = $kw {};}};}//@ edition: 2024
dependency::generate!(async);Here, your PR doesn't highlight the async in the rendered expansion … let _ = async {} … since it uses the edition of the entire expansion (which is Rust 2015) but the async in the Rust 2015 expansion does actually refer to Rust 2024 keyword async and thus contains an async block, not a struct expression! That's because the keyword async originates from a Rust 2024 crate (root expansion).1
I think that's perfectly acceptable for now but a NOTE would be nice.
Footnotes
Or vice versa: The dependency is Rust 2024 and the dependent is Rust 2015. In such a case, the keyword currently gets highlighted even though it shouldn't be. ↩
05a128c to
40dc901CompareGuillaumeGomez
commented
Aug 29, 2026
Applied suggestions (and mostly took your comment for the note because I think it's more than enough hehe). |
GuillaumeGomez
commented
Aug 29, 2026
@bors r=fmease rollup |
…g, r=fmease rustdoc: Take into account edition information for keyword highlighting Fixesrust-lang#148221. The only thing that was missing was passing down an `Edition` to the highlighter (and adding tests). r? @fmease
…g, r=fmease rustdoc: Take into account edition information for keyword highlighting Fixesrust-lang#148221. The only thing that was missing was passing down an `Edition` to the highlighter (and adding tests). r? @fmease
… r=fmease Move rustdoc ui doctests into the right testsuite When working on rust-lang#161944 (comment), I realized that a lot of doctests in `rustdoc-html` testsuite were not in the correct testsuite, so moving them in the right location. Because you're the one who made me realize it, here goes @fmease (thanks!) :p r? @fmease
Rollup of 7 pull requests Successful merges: - #160941 (Enforce safety comments on `alloc`) - #161975 (Abort instead of unwinding out of an inconsistent BTreeMap::split_off) - #157968 (Preserve ambiguous glob lint for subtrait method picks) - #161514 (rework handling of doc attributes on macro calls) - #161944 (rustdoc: Take into account edition information for keyword highlighting) - #161974 (remove rustc_never_type_options attr remnants) - #161978 (Move rustdoc ui doctests into the right testsuite) Failed merges: - #161702 (Use `drop_guard` in some places in {core,alloc,std})
Uh oh!
There was an error while loading. Please reload this page.
Rollup merge of #161978 - GuillaumeGomez:cleanup-ui-doctest, r=fmease Move rustdoc ui doctests into the right testsuite When working on #161944 (comment), I realized that a lot of doctests in `rustdoc-html` testsuite were not in the correct testsuite, so moving them in the right location. Because you're the one who made me realize it, here goes @fmease (thanks!) :p r? @fmease
…ease Move more `rustdoc-html` tests using `--test` into the right folder Follow-up of rust-lang#161944. I double-checked if more `rustdoc-html` tests were in the wrong folder and... yeah. So fixing that too. I'll send a patch to prevent that in the future (in `compiletest` I guess, doesn't seem like a `tidy` thing). Oh also second commit is me realizing that some ui tests were using `compile-args` (which doesn't exist anymore) and without `@`. Anyway, fixed that too. r? @fmease
…ease Move more `rustdoc-html` tests using `--test` into the right folder Follow-up of rust-lang#161944. I double-checked if more `rustdoc-html` tests were in the wrong folder and... yeah. So fixing that too. I'll send a patch to prevent that in the future (in `compiletest` I guess, doesn't seem like a `tidy` thing). Oh also second commit is me realizing that some ui tests were using `compile-args` (which doesn't exist anymore) and without `@`. Anyway, fixed that too. r? @fmease
…ease Move more `rustdoc-html` tests using `--test` into the right folder Follow-up of rust-lang#161944. I double-checked if more `rustdoc-html` tests were in the wrong folder and... yeah. So fixing that too. I'll send a patch to prevent that in the future (in `compiletest` I guess, doesn't seem like a `tidy` thing). Oh also second commit is me realizing that some ui tests were using `compile-args` (which doesn't exist anymore) and without `@`. Anyway, fixed that too. r? @fmease
…ease Move more `rustdoc-html` tests using `--test` into the right folder Follow-up of rust-lang#161944. I double-checked if more `rustdoc-html` tests were in the wrong folder and... yeah. So fixing that too. I'll send a patch to prevent that in the future (in `compiletest` I guess, doesn't seem like a `tidy` thing). Oh also second commit is me realizing that some ui tests were using `compile-args` (which doesn't exist anymore) and without `@`. Anyway, fixed that too. r? @fmease
…ease Move more `rustdoc-html` tests using `--test` into the right folder Follow-up of rust-lang#161944. I double-checked if more `rustdoc-html` tests were in the wrong folder and... yeah. So fixing that too. I'll send a patch to prevent that in the future (in `compiletest` I guess, doesn't seem like a `tidy` thing). Oh also second commit is me realizing that some ui tests were using `compile-args` (which doesn't exist anymore) and without `@`. Anyway, fixed that too. r? @fmease
Fixes#148221.
The only thing that was missing was passing down an
Editionto the highlighter (and adding tests).r? @fmease