-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Highlight edition-specific keywords correctly in code blocks, accounting for code block edition modifiers #80226
Conversation
The job Click to see the possible cause of the failure (guessed by this bot)
|
Hmm, I see - the issue is that the edition is not necessarily related to the span, so even if you pass in The rustdoc side of things seems reasonable to me but I think this should have a reviewer from T-compiler. |
Also you need to fix the unit tests:
|
@jyn514 I'm not sure what you're talking about. The only time I think I can see something like |
As for code blocks, they use either the explicit edition attribute or the edition given by |
One more question - I assumed that rustdoc "compiles" separate code blocks as independent programs, creating independent compilation sessions, so each session can have its own default edition possibly depending on the block's annotations (which will be used by |
@petrochenkov I’m pretty sure this is just simple lexing for highlighting and rendering—individual sessions for each code block/doctest would probably be part of the doctest logic rather than rendering as that’d seem expensive for simple lexing. |
This comment has been minimized.
This comment has been minimized.
rustc_span: Provide a reserved identifier check for a specific edition while keeping edition evaluation lazy because it may be expensive. Needed for rust-lang#80226.
Updated, rebased, and squashed. Working again 😄 |
I used |
@bors r=jyn514,petrochenkov |
📌 Commit d14ef17 has been approved by |
…yn514,petrochenkov Highlight edition-specific keywords correctly in code blocks, accounting for code block edition modifiers Previously, edition-specific keywords (such as `async` and `await`) were not highlighted in code blocks, regardless of what edition was set. With this PR, this issue is fixed. Now, the following behavior happens: - When a code block is explicitly set to edition X, keywords from edition X are highlighted - When a code block is explicitly set to a version that does not contain those keywords from edition X (e.g. edition Y), keywords from edition X are **not** highlighted - When a code block has no explicit edition, keywords from the edition passed via `--edition` to rustdoc are highlighted For example, a project set with `edition = "2015"` in its `Cargo.toml` would not highlight `async`/`await` unless the code block was set to `edition2018`. Additionally, a project set with `edition = "2018"` in its `Cargo.toml` *would* highlight `async`/`await` unless the code block was set to a version that did not contain those keywords (e.g. `edition2015`). This PR fixes rust-lang#80004. r? `@jyn514`
…yn514,petrochenkov Highlight edition-specific keywords correctly in code blocks, accounting for code block edition modifiers Previously, edition-specific keywords (such as `async` and `await`) were not highlighted in code blocks, regardless of what edition was set. With this PR, this issue is fixed. Now, the following behavior happens: - When a code block is explicitly set to edition X, keywords from edition X are highlighted - When a code block is explicitly set to a version that does not contain those keywords from edition X (e.g. edition Y), keywords from edition X are **not** highlighted - When a code block has no explicit edition, keywords from the edition passed via `--edition` to rustdoc are highlighted For example, a project set with `edition = "2015"` in its `Cargo.toml` would not highlight `async`/`await` unless the code block was set to `edition2018`. Additionally, a project set with `edition = "2018"` in its `Cargo.toml` *would* highlight `async`/`await` unless the code block was set to a version that did not contain those keywords (e.g. `edition2015`). This PR fixes rust-lang#80004. r? ```@jyn514```
has conflicts @bors r- |
Rebased and fixed merge conflicts. |
This comment has been minimized.
This comment has been minimized.
…, accounting for code block edition modifiers This is a squash of these commits: - Highlight edition-specific keywords correctly in code blocks, accounting for code block edition modifiers - Fix unit tests - Revert changes to rustc_span::symbol to prepare for merge of #80272 - Use new Symbol::is_reserved API from #80272 - Remove unused import added by accident when merging
Fixed. |
@bors r=jyn514,petrochenkov |
📌 Commit db1451c has been approved by |
☀️ Test successful - checks-actions |
Previously, edition-specific keywords (such as
async
andawait
) were not highlighted in code blocks, regardless of what edition was set. With this PR, this issue is fixed.Now, the following behavior happens:
--edition
to rustdoc are highlightedFor example, a project set with
edition = "2015"
in itsCargo.toml
would not highlightasync
/await
unless the code block was set toedition2018
. Additionally, a project set withedition = "2018"
in itsCargo.toml
would highlightasync
/await
unless the code block was set to a version that did not contain those keywords (e.g.edition2015
).This PR fixes #80004.
r? @jyn514