You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And each line gets represented with a TokenStream containing two elements: a Eq token and a Lit token. These end up in metadata, and the decoding cost is quite high. Because doc comments can be long, spanning many lines, it would be nice to join them together -- much like rustdoc's collapse-span pass does, but earlier -- to reduce the metadata decoding cost.
I wrote an experimental, not-quite-right patch that condensed to the following in the parser:
#[doc="/// aaa\n/// `bbb`\n/// ccc"]
It failed lots of rustdoc tests, but the perf results were great:
But then I get build failures -- the doc string appears to be tokenized somewhere, and it complains about the backticks not being valid tokens ("error: unknown start of token: `") due to the lack of /// after the first newline. Anyone know where that tokenization might arise from?
So, there is definitely room for improvement in the representation of doc comments, but some care will be needed to keep things working. I'd love to hear suggestions on the right way to do this.
cc @rust-lang/wg-compiler-performance
The text was updated successfully, but these errors were encountered:
Hmm, it's slightly different to how I described it above. In the current code, the /// at the start of each line is actually preserved with the doc attribute, and is only stripped when it is converted into a DocFragment::SugaredDoc by rustdoc::clean::Attributes::from_ast().
So perhaps I can join the lines like I did, keeping the /// markers in there, and then change Attributes::from_ast() to strip /// markers from the middle of the string as well as the beginning.
Imagine a doc comment like this:
This gets treated like this:
And each line gets represented with a
TokenStream
containing two elements: aEq
token and aLit
token. These end up in metadata, and the decoding cost is quite high. Because doc comments can be long, spanning many lines, it would be nice to join them together -- much like rustdoc's collapse-span pass does, but earlier -- to reduce the metadata decoding cost.I wrote an experimental, not-quite-right patch that condensed to the following in the parser:
It failed lots of rustdoc tests, but the perf results were great:
I then modified it to be more correct, like this:
But then I get build failures -- the doc string appears to be tokenized somewhere, and it complains about the backticks not being valid tokens ("error: unknown start of token: `") due to the lack of
///
after the first newline. Anyone know where that tokenization might arise from?So, there is definitely room for improvement in the representation of doc comments, but some care will be needed to keep things working. I'd love to hear suggestions on the right way to do this.
cc @rust-lang/wg-compiler-performance
The text was updated successfully, but these errors were encountered: