Closed
Description
I tried this code:
/// ```rust ignore
/// fn foo(bar: &dyn Baz);
/// async fn quux() {
/// qaz.frobnify().await;
/// }
/// fn bar() {
/// let mut a = 0;
/// abstract blah; /// is a reserved keyword
/// }
/// ```
fn foo() {}
I expected to see this happen: async
and other Rust 2018+ keywords are highlighted as my project is set to edition = "2018"
in its Cargo.toml
Instead, this happened: They were not highlighted, but regular keywords (including reserved ones) were.
I believe that the reason why this is happening is this snippet in librustdoc:
rust/src/librustdoc/html/highlight.rs
Lines 292 to 305 in eb4fc71
In this case, Ident::from_str
will only create a dummy span (which isn't set to 2018 edition), so is_reserved
does not include 2018+ keywords.
I would be willing to try to work on a PR to fix this issue if it is deemed worthy.
Meta
Tested
rustc --version --verbose
:
stable:
rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0
nightly:
rustc 1.50.0-nightly (7efc097c4 2020-12-12)
binary: rustc
commit-hash: 7efc097c4fe6e97f54a44cee91c56189e9ddb41c
commit-date: 2020-12-12
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly
Backtrace is not applicable.